From patchwork Sat May 27 18:28:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 70185 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DB723856961 for ; Sat, 27 May 2023 18:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DB723856961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685212104; bh=HMb4MmbgcAPgIwb/cM5Uc3j8fhZH/MZwSJJSOKmXf1s=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=XshHav6kSKtWgnopaSgRVA/U8Brl83VBBi0BHkKtFZC8UT/jxTwyT2ueibjPj82DE x08eCQt5Lq4I6aF1t3MFI/Y/qC0ZunhiFE7vDvnhp7KM4ypXGWNJl7YUMyCzdY41ba k0WXuVtzFnjNRjIwpQjF9DKHa+eJzWUghUpaAtAs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 427843858C53 for ; Sat, 27 May 2023 18:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 427843858C53 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AE00A21AED; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 9480D136AA; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id kL4uI6tLcmSeCwAAGKfGzw (envelope-from ); Sat, 27 May 2023 18:27:55 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] [gdb/tui] Add tui_default_focus_window Date: Sat, 27 May 2023 20:28:07 +0200 Message-Id: <20230527182809.20569-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230527182809.20569-1-tdevries@suse.de> References: <20230527182809.20569-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" There are two moments when TUI makes an in principle arbitrary choice about what window will get the focus: - when entering TUI, and - when changing into another layout removes the focused window. In the latter case, it picks the first window in the window list. In the former case, it picks the src window, which at that point also happens to be the first window in the window list. Introduce a new function tui_default_focus_window that formalizes this way of picking a window to focus on, and use it in both cases. To keep the function interface simple, tui_default_focus_window picks the first in the tui_windows list, which requires a minor rewrite in tui_apply_current_layout to ensure that tui_windows is updated before we call tui_default_focus_window. No functional changes. Tested on x86_64-linux. --- gdb/tui/tui-layout.c | 19 ++++++++++++++----- gdb/tui/tui-layout.h | 4 ++++ gdb/tui/tui.c | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 50c568fb7d7..ea8b4378d1e 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -66,6 +66,14 @@ std::vector tui_windows; /* See tui-layout.h. */ +struct tui_win_info * +tui_default_focus_window () +{ + return tui_windows[0]; +} + +/* See tui-layout.h. */ + void tui_apply_current_layout (bool preserve_cmd_win_size_p) { @@ -94,21 +102,22 @@ tui_apply_current_layout (bool preserve_cmd_win_size_p) std::vector new_tui_windows; applied_layout->get_windows (&new_tui_windows); + /* Replace the global list of active windows. */ + std::vector old_tui_windows = std::move (tui_windows); + tui_windows = std::move (new_tui_windows); + /* Now delete any window that was not re-applied. */ tui_win_info *focus = tui_win_with_focus (); - for (tui_win_info *win_info : tui_windows) + for (tui_win_info *win_info : old_tui_windows) { if (!win_info->is_visible ()) { if (focus == win_info) - tui_set_win_focus_to (new_tui_windows[0]); + tui_set_win_focus_to (tui_default_focus_window ()); delete win_info; } } - /* Replace the global list of active windows. */ - tui_windows = std::move (new_tui_windows); - if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr) tui_get_begin_asm_address (&gdbarch, &addr); tui_update_source_windows_with_addr (gdbarch, addr); diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index ff354fb7c2f..29f21437118 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -413,4 +413,8 @@ using known_window_names_range extern known_window_names_range all_known_window_names (); +/* Return the window to set the focus to, in case that requires a choice. */ + +extern struct tui_win_info *tui_default_focus_window (); + #endif /* TUI_TUI_LAYOUT_H */ diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 10cf811a41e..f2e4c717193 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -458,7 +458,7 @@ tui_enable (void) tui_show_frame_info (0); tui_set_initial_layout (); - tui_set_win_focus_to (TUI_SRC_WIN); + tui_set_win_focus_to (tui_default_focus_window ()); keypad (TUI_CMD_WIN->handle.get (), TRUE); wrefresh (TUI_CMD_WIN->handle.get ()); tui_finish_init = false; From patchwork Sat May 27 18:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 70184 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 281283857717 for ; Sat, 27 May 2023 18:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 281283857717 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685212104; bh=RaEtGTGJ2KqNASOpipeHy7TY35y+2ZZ0jdiI/IrOF9E=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Icup0A1VNeoSESA8PEGmd1HZs+k9emBguXTZ87F+rvRBHOIZ3olNSoxhb6MUtyac0 Qa2wqTZtJewz5ZNJC5EQ1aTX+MndDeDQS4mPsAp5m9uncsGJAlzQ/G6X7ZmBIYXgVE SNwX8qkQ8CPb11McQZmlwvQdLGGP2+pDgRKQmpyU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 457693858C66 for ; Sat, 27 May 2023 18:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 457693858C66 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C448C21AEF; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id AF05913532; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id yH2zKatLcmSeCwAAGKfGzw (envelope-from ); Sat, 27 May 2023 18:27:55 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] [gdb/tui] Add tui_get_cmd_set/show_list Date: Sat, 27 May 2023 20:28:08 +0200 Message-Id: <20230527182809.20569-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230527182809.20569-1-tdevries@suse.de> References: <20230527182809.20569-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add new functions: - tui_get_cmd_set_list, and - tui_get_cmd_show_list, similar to tui_get_cmd_list that allow introducing "set/show tui" commands in files other than tui/tui-win.c. No functional changes. No users in this patch. Tested on x86_64-linux. --- gdb/tui/tui-win.c | 50 ++++++++++++++++++++++++++++++++++++++++------- gdb/tui/tui-win.h | 6 ++++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 7abd1e225b9..c187f7c33ad 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -336,6 +336,47 @@ tui_get_cmd_list (void) return &tuilist; } +/* The "tui set" command list. */ + +static struct cmd_list_element *tui_setlist; + +/* The "tui show" command list. */ + +static struct cmd_list_element *tui_showlist; + +/* Initialize the tui_setlist and tui_showlist variables. */ + +static void +init_tui_set_show_lists () +{ + if (tui_setlist != nullptr) + return; + + add_setshow_prefix_cmd ("tui", class_tui, + _("TUI configuration variables."), + _("TUI configuration variables."), + &tui_setlist, &tui_showlist, + &setlist, &showlist); +} + +/* See tui-win.h. */ + +struct cmd_list_element ** +tui_get_cmd_set_list () +{ + init_tui_set_show_lists (); + return &tui_setlist; +} + +/* See tui-win.h. */ + +struct cmd_list_element ** +tui_get_cmd_show_list () +{ + init_tui_set_show_lists (); + return &tui_showlist; +} + /* The set_func hook of "set tui ..." commands that affect the window borders on the TUI display. */ @@ -1127,16 +1168,11 @@ void _initialize_tui_win (); void _initialize_tui_win () { - static struct cmd_list_element *tui_setlist; - static struct cmd_list_element *tui_showlist; + /* Initialize tui_setlist and tui_showlist. */ + init_tui_set_show_lists (); /* Define the classes of commands. They will appear in the help list in the reverse of this order. */ - add_setshow_prefix_cmd ("tui", class_tui, - _("TUI configuration variables."), - _("TUI configuration variables."), - &tui_setlist, &tui_showlist, - &setlist, &showlist); cmd_list_element *refresh_cmd = add_cmd ("refresh", class_tui, tui_refresh_all_command, diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index 3d35f1dfb7f..4de938fa280 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -48,6 +48,12 @@ extern void tui_update_gdb_sizes (void); /* Create or get the TUI command list. */ struct cmd_list_element **tui_get_cmd_list (void); +/* Create or get the TUI set command list. */ +extern struct cmd_list_element **tui_get_cmd_set_list (); + +/* Create or get the TUI show command list. */ +extern struct cmd_list_element **tui_get_cmd_show_list (); + /* Whether compact source display should be used. */ extern bool compact_source; From patchwork Sat May 27 18:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 70186 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17002385B534 for ; Sat, 27 May 2023 18:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17002385B534 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685212132; bh=t7G/cqq1TIxXUi6M3YyQw21JF8PzPLzCrWH8Yvjn/MI=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=fDzrxwyO720ZU6TsaHZ644u/PbF6pUUSmJiVaOIsFIWbcLPxRehEGNsH4yMEnDn+z u3xxCjYtCswCEh+TM9hBGIBsW/JBRa0n8u4jvHMAu51QNIo3JqA1EDPcQf3uPNtOVY fuRv7C5oV9cPhtigihftGxcwJ/+KXYbdAOyjp6Ww= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 426023858C50 for ; Sat, 27 May 2023 18:27:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 426023858C50 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DD49421AF0; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id C872413532; Sat, 27 May 2023 18:27:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id WHn0L6tLcmSeCwAAGKfGzw (envelope-from ); Sat, 27 May 2023 18:27:55 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/tui] Add set tui default-focus first/cmd Date: Sat, 27 May 2023 20:28:09 +0200 Message-Id: <20230527182809.20569-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230527182809.20569-1-tdevries@suse.de> References: <20230527182809.20569-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add a new command "set tui default-focus first/cmd" that set the default focus window. If set to first, it's the first window in the window list. If set to cmd, it's the command window. The default value is first, so the default behaviour is unchanged. Tested on x86_64-linux. PR tui/24137 https://sourceware.org/bugzilla/show_bug.cgi?id=24137 Reported-By: Martin Liška Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 6 ++++++ gdb/tui/tui-layout.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d1059e0cb7f..de8b42e99c7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30318,6 +30318,12 @@ The default display uses more space for line numbers; the compact display uses only as much space as is needed for the line numbers in the current file. +@item set tui default-focus @r{[}first@r{|}cmd@r{]} +@kindex set tui default-focus +The default TUI window to focus on. If set to first, it's the first +window in the window list. If set to cmd, it's the command window. +The default value is first. + @kindex set debug tui @item set debug tui @r{[}on|off@r{]} Turn on or off display of @value{GDBN} internal debug messages relating diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index ea8b4378d1e..92609e63190 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -46,6 +46,7 @@ #include "gdbsupport/gdb-safe-ctype.h" static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *); +static tui_win_info *tui_get_window_by_name (const std::string &name); /* The layouts. */ static std::vector> layouts; @@ -64,12 +65,28 @@ static tui_layout_split *asm_regs_layout; /* See tui-data.h. */ std::vector tui_windows; +/* Choices for "tui default-focus". */ +static const char *const tui_default_focus_enums[] = { + "first", + "cmd", + NULL +}; + +/* Value of "tui default-focus". */ +static const char *tui_default_focus = "first"; + /* See tui-layout.h. */ struct tui_win_info * tui_default_focus_window () { - return tui_windows[0]; + if (strcmp (tui_default_focus, "first") == 0) + return tui_windows[0]; + + if (strcmp (tui_default_focus, "cmd") == 0) + return tui_get_window_by_name ("cmd"); + + gdb_assert_not_reached (""); } /* See tui-layout.h. */ @@ -1347,6 +1364,18 @@ Each WEIGHT is an integer, which holds the relative size\n\ to be allocated to the window."), tui_get_cmd_list ()); + + add_setshow_enum_cmd ("default-focus", no_class, tui_default_focus_enums, + &tui_default_focus, _("\ +Set the default focus window"), _("\ +Show the default focus window"), _("\ +This variable controls which TUI window is focused by default:\n\ + first first window in the window list\n\ + cmd command window"), + nullptr, + nullptr, + tui_get_cmd_set_list (), tui_get_cmd_show_list ()); + initialize_layouts (); initialize_known_windows (); }