Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: gdb-patches@sources.redhat.com
Subject: Re: Improve "help all"
Date: Tue, 31 Oct 2006 12:11:00 -0000	[thread overview]
Message-ID: <ei7eff$al3$1@sea.gmane.org> (raw)
In-Reply-To: <20061028152928.GA396@nevyn.them.org>

[-- Attachment #1: Type: text/plain, Size: 1423 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: show_class.diff --]
[-- Type: text/x-diff; name="show_class.diff", Size: 2667 bytes --]

? 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);
+    }
 }
 
 /*

  parent reply	other threads:[~2006-10-31 12:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-27 19:40 Vladimir Prus
2006-10-28 11:29 ` Eli Zaretskii
2006-10-28 11:58   ` Vladimir Prus
2006-10-28 12:26     ` Eli Zaretskii
2006-10-28 15:29       ` Daniel Jacobowitz
2006-10-28 18:57         ` Eli Zaretskii
2006-10-31 12:11         ` Vladimir Prus [this message]
2006-10-31 12:30           ` Mark Kettenis
2006-10-31 22:28             ` Eli Zaretskii
2006-11-01  9:51               ` Vladimir Prus
2006-11-01 20:16                 ` Eli Zaretskii
2006-11-01 22:50                   ` Mark Kettenis
2006-11-02  4:19                     ` Eli Zaretskii
2006-10-31 12:15       ` Vladimir Prus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ei7eff$al3$1@sea.gmane.org' \
    --to=ghost@cs.msu.su \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox