[PATCH] Fix PR gdb/17035: "show user" doesn't list user-defined commands that have empty bodies.

Gabriel Krisman Bertazi gabriel@krisman.be
Sun Aug 31 18:35:00 GMT 2014


Hello Pedro,

I appreciate your comments,

>> I don't see that as a problem, because python/scheme are also user
>> commands (or, at least, are part of class_user class).  Considering that
>> "help user-defined" also shows python/scheme commands, I believe it
>> would be more practical to just list them on "show user" (should we
>> update the doc string, as well).
>
> I think we'll need to track down the original discussion, and
> ask whoever was involved.  Otherwise, we'd just be going in
> circles.  :-)
>
> E.g., that commit changed the online help and the manual to
> try to make that clear.
>
> (gdb) help show user
> Show definitions of non-python/scheme user defined commands.
> Argument is the name of the user defined command.
> With no argument, show definitions of all user defined commands.
>

Reviewing the original discussion, (for the record,
<https://sourceware.org/ml/gdb-patches/2012-02/msg00246.html>), Doug has
made a pretty good point on not showing python/scheme commands here.

Since this is a simple bug fix, I'd rather not modify the behavior
here, so I rewrote the patch to not show python/scheme commands.  It got
a little simpler, since I don't have to touch a lot of testcases
anymore.

Now we use the fact that the c->function union is NULL when we have a
python/scheme command (they both use c->func directly).

I also added two testcases to make sure we are not printing scheme or
python commands, as you suggested.

>> Using the verification for cfunc/sfunc above, also avoids
>> printing the "user-defined" line.
>
> Hmm, but what is that "user-defined" command ?

user-defined is a null command.  It does nothing.  It is defined as
follows:

  add_cmd ("user-defined", class_user, NULL, _("\
User-defined commands.\n\
The commands in this class are those defined by the user.\n\
Use the \"define\" command to define a command."), &cmdlist);

I guess it's only purpose is at help user-defined.

Do you think it is acceptable now?

gdb/
2014-08-20  Gabriel Krisman Bertazi  <gabriel@krisman.be>

	* cli/cli-cmds.c (show_user): Verify if c->function is NULL to
	  decide whether c is a python/scheme command.
	* cli/cli-script.c (show_user_1): Only verify cmdlines after
	  printing command name.

gdb/testsuite/
2014-08-20  Gabriel Krisman Bertazi  <gabriel@krisman.be>

	* gdb.base/commands.exp: Include tests to verify user-defined
	  commands with empty bodies.
	* gdb.python/py-cmd.exp: Don't show user-defined python commands
	  in `show user command`
	* gdb.python/scm-cmd.exp: Don't show user-defined scheme commands
	  in `show user command`

-------------- next part --------------
A non-text attachment was scrubbed...
Name: show_user_v2.patch
Type: text/x-patch
Size: 4960 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20140831/997827d5/attachment.bin>
-------------- next part --------------


-- 
Gabriel Krisman Bertazi


More information about the Gdb-patches mailing list