]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: include help aliases in help command completion
authorMike Frysinger <vapier@gentoo.org>
Tue, 20 Nov 2012 21:02:36 +0000 (21:02 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 20 Nov 2012 21:02:36 +0000 (21:02 +0000)
There are a bunch of aliases that get used with help, but the current
command completion logic does not include those when doing completions.

Since the framework is already mostly in place, extend complete_on_cmdlist
slightly to pass down the ignore_help_classes flag like is done with the
existing lookup command logic.

Now you can do:
(gdb) help use<tab>
and get back:
(gdb) help user-defined

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
gdb/ChangeLog
gdb/cli/cli-decode.c
gdb/command.h
gdb/completer.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/completion.exp

index 983bbdb547b37bb00c95e4e4c4286bca55d34991..05b6f66deae472f6e5c13f2bc89f8a967e851dea 100644 (file)
@@ -1,3 +1,12 @@
+2012-11-20  Mike Frysinger  <vapier@gentoo.org>
+
+       * cli/cli-decode.c (complete_on_cmdlist): Add a fourth arg and check
+       it when looking at ptr->func.
+       * command.h (complete_on_cmdlist): Add a fourth arg.
+       * completer.c (complete_line_internal): Add local ignore_help_classes,
+       and set it to 1 when reason is not handle_help.  Pass this down to
+       lookup_cmd_1 and complete_on_cmdlist.
+
 2012-11-20  Tom Tromey  <tromey@redhat.com>
 
        * completer.c (count_struct_fields): Remove.
index 6e0f0dee477ee3bf6cf50a9d378a68f777200ffa..3de01d58368087339783fd8cc23b7c4b7ae87835 100644 (file)
@@ -1726,7 +1726,8 @@ lookup_cmd_composition (char *text,
    "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
 
 VEC (char_ptr) *
-complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word)
+complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word,
+                    int ignore_help_classes)
 {
   struct cmd_list_element *ptr;
   VEC (char_ptr) *matchlist = NULL;
@@ -1743,7 +1744,7 @@ complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word)
       for (ptr = list; ptr; ptr = ptr->next)
        if (!strncmp (ptr->name, text, textlen)
            && !ptr->abbrev_flag
-           && (ptr->func
+           && (!ignore_help_classes || ptr->func
                || ptr->prefixlist))
          {
            char *match;
index b88bd8b7e8d6dfbe049ca1bd3ae082b2f2b30593..8eb86ba84b079f6f250ac7bf96c3f819d6009bf7 100644 (file)
@@ -216,7 +216,7 @@ extern struct cmd_list_element *add_info (char *,
 extern struct cmd_list_element *add_info_alias (char *, char *, int);
 
 extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
-                                           char *, char *);
+                                           char *, char *, int);
 
 extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist,
                                         char *, char *);
index 0815711fdbc2133a3753e0c5f4e1552037a760d8..4d6b0d1c7e876860a70d53166d93520543f6afa2 100644 (file)
@@ -501,6 +501,7 @@ complete_line_internal (const char *text,
 {
   VEC (char_ptr) *list = NULL;
   char *tmp_command, *p;
+  int ignore_help_classes;
   /* Pointer within tmp_command which corresponds to text.  */
   char *word;
   struct cmd_list_element *c, *result_list;
@@ -520,6 +521,9 @@ complete_line_internal (const char *text,
   tmp_command = (char *) alloca (point + 1);
   p = tmp_command;
 
+  /* The help command should complete help aliases.  */
+  ignore_help_classes = reason != handle_help;
+
   strncpy (tmp_command, line_buffer, point);
   tmp_command[point] = '\0';
   /* Since text always contains some number of characters leading up
@@ -536,7 +540,7 @@ complete_line_internal (const char *text,
     }
   else
     {
-      c = lookup_cmd_1 (&p, cmdlist, &result_list, 1);
+      c = lookup_cmd_1 (&p, cmdlist, &result_list, ignore_help_classes);
     }
 
   /* Move p up to the next interesting thing.  */
@@ -577,12 +581,13 @@ complete_line_internal (const char *text,
            {
              if (reason != handle_brkchars)
                list = complete_on_cmdlist (*result_list->prefixlist, p,
-                                           word);
+                                           word, ignore_help_classes);
            }
          else
            {
              if (reason != handle_brkchars)
-               list = complete_on_cmdlist (cmdlist, p, word);
+               list = complete_on_cmdlist (cmdlist, p, word,
+                                           ignore_help_classes);
            }
          /* Ensure that readline does the right thing with respect to
             inserting quotes.  */
@@ -608,7 +613,8 @@ complete_line_internal (const char *text,
                  /* It is a prefix command; what comes after it is
                     a subcommand (e.g. "info ").  */
                  if (reason != handle_brkchars)
-                   list = complete_on_cmdlist (*c->prefixlist, p, word);
+                   list = complete_on_cmdlist (*c->prefixlist, p, word,
+                                               ignore_help_classes);
 
                  /* Ensure that readline does the right thing
                     with respect to inserting quotes.  */
@@ -679,7 +685,8 @@ complete_line_internal (const char *text,
                }
 
              if (reason != handle_brkchars)
-               list = complete_on_cmdlist (result_list, q, word);
+               list = complete_on_cmdlist (result_list, q, word,
+                                           ignore_help_classes);
 
              /* Ensure that readline does the right thing
                 with respect to inserting quotes.  */
index 04821e64d80c47c06962024c46f16a8ff1f2de98..907bec366016892ca09503cf501d2fe988a2ba3e 100644 (file)
@@ -1,3 +1,7 @@
+2012-11-20  Mike Frysinger  <vapier@gentoo.org>
+
+       * gdb.base/completion.exp: Add test for help aliases completion.
+
 2012-11-20  Yao Qi  <yao@codesourcery.com>
 
        * gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed):
index 8b1facb1ab383374c9d7487a733a8d373ca338d4..80f703251cf6d54450d9fda3ec008ed0049c2765 100644 (file)
@@ -389,6 +389,19 @@ gdb_test_multiple "" "$test" {
     }
 }
 
+set test "complete help aliases"
+send_gdb "help user-define\t"
+gdb_test_multiple "" "$test" {
+    -re "^help user-defined $" {
+       send_gdb "\n"
+       gdb_test_multiple "" "$test" {
+           -re "$gdb_prompt $" {
+               pass "$test"
+           }
+       }
+    }
+}
+
 
 # These tests used to try completing the shorter "p b-a".
 # Unfortunately, on some systems, there are .o files in system