This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Improve "help all"


Daniel Jacobowitz wrote:

> On Sat, Oct 28, 2006 at 02:26:19PM +0200, Eli Zaretskii wrote:
>> > From: Vladimir Prus <vladimir@codesourcery.com>
>> > Date: Sat, 28 Oct 2006 15:57:57 +0400
>> > Cc: gdb-patches@sources.redhat.com
>> > 
>> > Archived output is attached.
>> 
>> Thanks.  It looks fine to me.
>> 
>> Perhaps we should assign classes to the 3 unclassified commands that
>> appear near the end.  I think they all should go where `set' is, since
>> that's where their corresponding `set' commands are.
> 
> Perhaps a strategic assertion when adding commands?
> 
> Here's a couple of other things we noticed during the discussion that
> prompted this patch - lesser improvements than mentioning "apropos"
> prominently, I think:
> 
>   - The help output doesn't mention which class a command is in; this
>     might be useful, for finding related commands.


The attached patch implements it. The output I get is:

  (gdb) help step
  Step program until it reaches a different source line.
  Argument N means do this N times (or till program stops for another
reason).

  Run "help running" for the list of all commands in this class.

This patch would require changing "breakpoint" command that already suggests
to use "help breakpoints" in its own help string -- I'll do this later if
this patch is approved.

OK?

- Volodya

        * cli/cli-decode.c (help_cmd): Find and mention the class
        of commands.

? a.c
? help.diff
? show_class.diff
Index: cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.59
diff -u -r1.59 cli-decode.c
--- cli-decode.c	31 Oct 2006 11:45:41 -0000	1.59
+++ cli-decode.c	31 Oct 2006 12:09:05 -0000
@@ -731,6 +731,7 @@
 help_cmd (char *command, struct ui_file *stream)
 {
   struct cmd_list_element *c;
+  struct cmd_list_element *c2;
   extern struct cmd_list_element *cmdlist;
 
   if (!command)
@@ -765,30 +766,47 @@
   fputs_filtered (c->doc, stream);
   fputs_filtered ("\n", stream);
 
-  if (c->prefixlist == 0 && c->func != NULL)
-    return;
-  fprintf_filtered (stream, "\n");
-
-  /* If this is a prefix command, print it's subcommands */
-  if (c->prefixlist)
-    help_list (*c->prefixlist, c->prefixname, all_commands, stream);
-
-  /* If this is a class name, print all of the commands in the class */
-  if (c->func == NULL)
-    help_list (cmdlist, "", c->class, stream);
+  if (c->prefixlist != 0 || c->func == NULL)
+    {
+      /* This is either prefix command or class. */
+      fprintf_filtered (stream, "\n");
 
+      /* If this is a prefix command, print it's subcommands */
+      if (c->prefixlist)
+	help_list (*c->prefixlist, c->prefixname, all_commands, stream);
+      
+      /* If this is a class name, print all of the commands in the class */
+      if (c->func == NULL)
+	help_list (cmdlist, "", c->class, stream);
+    }
+      
   if (c->hook_pre || c->hook_post)
     fprintf_filtered (stream,
-                      "\nThis command has a hook (or hooks) defined:\n");
-
+		      "\nThis command has a hook (or hooks) defined:\n");
+  
   if (c->hook_pre)
     fprintf_filtered (stream, 
-                      "\tThis command is run after  : %s (pre hook)\n",
-                    c->hook_pre->name);
+		      "\tThis command is run after  : %s (pre hook)\n",
+		      c->hook_pre->name);
   if (c->hook_post)
     fprintf_filtered (stream, 
-                      "\tThis command is run before : %s (post hook)\n",
-                    c->hook_post->name);
+		      "\tThis command is run before : %s (post hook)\n",
+		      c->hook_post->name);
+  
+  if (c->func != NULL)
+    {
+      /* This is either ordinary command or prefix command, but not
+	 a command class.  Find the name of the class it belongs
+	 too.  */
+      for (c2 = cmdlist;;c2 = c2->next)
+	if (c2->class == c->class && c2->func == NULL && c2->prefixlist == 0)
+	  break;
+      
+      if (c2)
+	fprintf_filtered (stream, 
+			  "\nRun \"help %s\" for the list of all "
+			  "commands in this class.\n", c2->name);
+    }
 }
 
 /*

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]