From patchwork Sun Jul 12 08:51:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 7650 Received: (qmail 51050 invoked by alias); 12 Jul 2015 08:51:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51032 invoked by uid 89); 12 Jul 2015 08:51:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-wi0-f170.google.com Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 12 Jul 2015 08:51:46 +0000 Received: by wiwl6 with SMTP id l6so77380931wiw.0 for ; Sun, 12 Jul 2015 01:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=oKaP+XhBD6daPgnEerfr77stJ6oaoPuuoTDJePTW18w=; b=ZG6Vh1f5dg50HeC/a95laUgd1DuNDp2C/KaHrNtzRdZAlpjgdkNFBg/SABRc4WKdge Gp917N4MhqpETNzm8sh6dv0hYwLMV7oycRz30/WiiLxSv12sfMe0vKtTKgmq2aRq+C1s lfLc9cvMlwoH/NdP2VXlvA8ryJ98J26MwHFA9EWbEMPppuPXLpbTEoTJelkKjpgZg/xO PimXEn/feL/PjgVs086nA+2ib2XoozgJ2LeYtL416rcn1meUFVa1Enh/QU+m4bSyBXXe 8PQTrAB0PsvvN60xbZSsbY0qMI7tD1HK5iOze0kf53ziX5ps9yXt44vA5klW1pUZ/dY5 ym2w== X-Gm-Message-State: ALoCoQmcvYGryFJ2DApiJBlP+7ZPnwRuOyy23kZxdW/8QK7CWf3vxH9DwsvysLrACEecvqSC5Nij X-Received: by 10.180.81.106 with SMTP id z10mr12151008wix.22.1436691102827; Sun, 12 Jul 2015 01:51:42 -0700 (PDT) Received: from localhost (host81-158-4-174.range81-158.btcentralplus.com. [81.158.4.174]) by smtp.gmail.com with ESMTPSA id z9sm7623779wiv.9.2015.07.12.01.51.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2015 01:51:42 -0700 (PDT) Date: Sun, 12 Jul 2015 09:51:40 +0100 From: Andrew Burgess To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/tui: Add command completion to winheight command. Message-ID: <20150712085140.GE5485@embecosm.com> References: <1436534024-23458-1-git-send-email-andrew.burgess@embecosm.com> <559FF19E.3010208@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <559FF19E.3010208@redhat.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes * Pedro Alves [2015-07-10 17:23:58 +0100]: > On 07/10/2015 02:13 PM, Andrew Burgess wrote: > > > > -/* Complete possible window names to focus on. TEXT is the complete text > > - entered so far, WORD is the word currently being completed. */ > > +/* Generic window name completion function. Complete window name pointed > > + too by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special > > "pointed to" ? Fixed. > > + window names 'next' and 'prev' are also included in the list of possible > > + completions (if appropriate). */ > > > > static VEC (char_ptr) * > > -focus_completer (struct cmd_list_element *ignore, > > - const char *text, const char *word) > > +window_name_completer (int include_next_prev_p, > > + const char *text, const char *word) > > { > > VEC (const_char_ptr) *completion_name_vec = NULL; > > VEC (char_ptr) *matches_vec; > > - int win_type; > > > > - for (win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++) > > + if (tui_active) > > { > > ... > > > - /* If no windows are considered visible then the TUI has not yet been > > - initialized. But still "focus src" and "focus cmd" will work because > > - invoking the focus command will entail initializing the TUI which sets the > > - default layout to SRC_COMMAND. */ > > - if (VEC_length (const_char_ptr, completion_name_vec) == 0) > > + completion_name = tui_win_name (&tui_win_list [win_type]->generic); > > + gdb_assert (completion_name != NULL); > > + VEC_safe_push (const_char_ptr, completion_name_vec, completion_name); > > + } > > + } > > + else > > { > > + /* If the tui is not yet active then we should still offer up the two > > + initial windows 'src' and 'cmd'. All tui commands will > > + auto-activate the tui, which means these windows are valid for > > + use. */ > > This changed the predicate used to get here, and it doesn't look right > to me. It used to be "not initialized yet" (no window marked visible, > no matter whether the tui is active), now it's "tui active". The former > meant that because tui had not been initialized, then the current layout > once the tui is initialized the default layout contains the src and cmd > windows. But with the new predicate that is not always correct. > We should be able to enable the tui, do "layout asm", disable the tui, > and then do "focus ". This should offer the asm window, not > the src window. That works today, but I think will not work after > your patch? Thanks, I had not appreciated this. Fixed in the new patch. Andrew --- gdb/tui: Add command completion to winheight command. Share the window name completion code from the focus command with the winheight command, providing window name completion for the winheight command. gdb/ChangeLog: * tui/tui-win.c (window_name_completer): New function. (focus_completer): Call window_name_completer. All old content moved into window_name_completer. (winheight_completer): New function. (_initialize_tui_win): Rename variable. Add completer to winheight command. Update doc string on winheight. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8ab1330..8f69009 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2015-07-10 Andrew Burgess + * tui/tui-win.c (window_name_completer): New function. + (focus_completer): Call window_name_completer. All old content + moved into window_name_completer. + (winheight_completer): New function. + (_initialize_tui_win): Rename variable. Add completer to + winheight command. Update doc string on winheight. + +2015-07-10 Andrew Burgess + * tui/tui-win.c (tui_set_win_height): Use a cleanup to free the string copy. (parse_scrolling_args): Likewise. diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index cdf322b..7248f8b 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -354,12 +354,14 @@ tui_set_var_cmd (char *null_args, int from_tty, struct cmd_list_element *c) tui_rehighlight_all (); } -/* Complete possible window names to focus on. TEXT is the complete text - entered so far, WORD is the word currently being completed. */ +/* Generic window name completion function. Complete window name pointed + to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special + window names 'next' and 'prev' are also included in the list of possible + completions (if appropriate). */ static VEC (char_ptr) * -focus_completer (struct cmd_list_element *ignore, - const char *text, const char *word) +window_name_completer (int include_next_prev_p, + const char *text, const char *word) { VEC (const_char_ptr) *completion_name_vec = NULL; VEC (char_ptr) *matches_vec; @@ -389,10 +391,13 @@ focus_completer (struct cmd_list_element *ignore, VEC_safe_push (const_char_ptr, completion_name_vec, CMD_NAME); } - VEC_safe_push (const_char_ptr, completion_name_vec, "next"); - VEC_safe_push (const_char_ptr, completion_name_vec, "prev"); - VEC_safe_push (const_char_ptr, completion_name_vec, NULL); + if (include_next_prev_p) + { + VEC_safe_push (const_char_ptr, completion_name_vec, "next"); + VEC_safe_push (const_char_ptr, completion_name_vec, "prev"); + } + VEC_safe_push (const_char_ptr, completion_name_vec, NULL); matches_vec = complete_on_enum (VEC_address (const_char_ptr, completion_name_vec), text, word); @@ -402,6 +407,32 @@ focus_completer (struct cmd_list_element *ignore, return matches_vec; } +/* Complete possible window names to focus on. TEXT is the complete text + entered so far, WORD is the word currently being completed. */ + +static VEC (char_ptr) * +focus_completer (struct cmd_list_element *ignore, + const char *text, const char *word) +{ + return window_name_completer (1, text, word); +} + +/* Complete possible window names for winheight command. TEXT is the + complete text entered so far, WORD is the word currently being + completed. */ + +static VEC (char_ptr) * +winheight_completer (struct cmd_list_element *ignore, + const char *text, const char *word) +{ + /* The first word is the window name. That we can complete. Subsequent + words can't be completed. */ + if (word != text) + return NULL; + + return window_name_completer (0, text, word); +} + /* Function to initialize gdb commands, for tui window manipulation. */ @@ -413,7 +444,7 @@ _initialize_tui_win (void) { static struct cmd_list_element *tui_setlist; static struct cmd_list_element *tui_showlist; - struct cmd_list_element *focus_cmd; + struct cmd_list_element *cmd; /* Define the classes of commands. They will appear in the help list in the reverse of this order. */ @@ -431,8 +462,8 @@ _initialize_tui_win (void) add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ Set the width (in characters) of tab stops.\n\ Usage: tabset \n")); - add_com ("winheight", class_tui, tui_set_win_height_command, _("\ -Set the height of a specified window.\n\ + cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ +Set or modify the height of a specified window.\n\ Usage: winheight [+ | -] <#lines>\n\ Window names are:\n\ src : the source window\n\ @@ -440,9 +471,10 @@ cmd : the command window\n\ asm : the disassembly window\n\ regs : the register display\n")); add_com_alias ("wh", "winheight", class_tui, 0); + set_cmd_completer (cmd, winheight_completer); add_info ("win", tui_all_windows_info, _("List of all displayed windows.\n")); - focus_cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ + cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ Set focus to named window or next/prev window.\n\ Usage: focus { | next | prev}\n\ Valid Window names are:\n\ @@ -451,7 +483,7 @@ asm : the disassembly window\n\ regs : the register display\n\ cmd : the command window\n")); add_com_alias ("fs", "focus", class_tui, 0); - set_cmd_completer (focus_cmd, focus_completer); + set_cmd_completer (cmd, focus_completer); add_com ("+", class_tui, tui_scroll_forward_command, _("\ Scroll window forward.\n\ Usage: + [win] [n]\n"));