* RFA: add_setshow_cmd_full
@ 2002-06-25 13:40 Tom Tromey
2002-06-25 19:35 ` Andrew Cagney
2002-06-25 22:05 ` Eli Zaretskii
0 siblings, 2 replies; 10+ messages in thread
From: Tom Tromey @ 2002-06-25 13:40 UTC (permalink / raw)
To: gdb-patches
In some situations we need to get both the set and show command
structure back when creating a set/show pair. I propose a new
add_setshow_cmd_full function that returns both.
This patch includes my previous patch to make add_setshow_cmd public.
Ok? Or is there another way you'd prefer I approach this problem?
I've converted all the add_show_from_set calls to use add_setshow_cmd.
This patch or something like it has to go in before I can completely
finish that patch. At this point I'm going to stop working on
gettextization until the patch backlog clears up a bit. It gets hard
to manage the patches when many files have already been touched.
Tom
2002-06-25 Tom Tromey <tromey@redhat.com>
* cli/cli-decode.c (add_setshow_cmd_full): New function.
(add_setshow_cmd): Use it.
* command.h (add_setshow_cmd_full): Declare.
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.25
diff -u -r1.25 cli-decode.c
--- cli/cli-decode.c 25 Jun 2002 05:39:18 -0000 1.25
+++ cli/cli-decode.c 25 Jun 2002 20:37:04 -0000
@@ -331,14 +331,16 @@
command. SET_FUNC and SHOW_FUNC are the callback functions (if
non-NULL). SET_DOC and SHOW_DOC are the documentation strings. */
-static struct cmd_list_element *
-add_setshow_cmd (char *name,
- enum command_class class,
- var_types var_type, void *var,
- char *set_doc, char *show_doc,
- cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func,
- struct cmd_list_element **set_list,
- struct cmd_list_element **show_list)
+void
+add_setshow_cmd_full (char *name,
+ enum command_class class,
+ var_types var_type, void *var,
+ char *set_doc, char *show_doc,
+ cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func,
+ struct cmd_list_element **set_list,
+ struct cmd_list_element **show_list,
+ struct cmd_list_element **set_result,
+ struct cmd_list_element **show_result)
{
struct cmd_list_element *set;
struct cmd_list_element *show;
@@ -350,9 +352,35 @@
show_doc, show_list);
if (show_func != NULL)
set_cmd_sfunc (show, show_func);
+
+ if (set_result != NULL)
+ *set_result = set;
+ if (show_result != NULL)
+ *show_result = show;
+}
+
+/* Add element named NAME to both the command SET_LIST and SHOW_LIST.
+ CLASS is as in add_cmd. VAR_TYPE is the kind of thing we are
+ setting. VAR is address of the variable being controlled by this
+ command. SET_FUNC and SHOW_FUNC are the callback functions (if
+ non-NULL). SET_DOC and SHOW_DOC are the documentation strings. */
+
+struct cmd_list_element *
+add_setshow_cmd (char *name,
+ enum command_class class,
+ var_types var_type, void *var,
+ char *set_doc, char *show_doc,
+ cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func,
+ struct cmd_list_element **set_list,
+ struct cmd_list_element **show_list)
+{
+ cmd_list_element *result;
/* The caller often wants to modify set to include info like an
enumeration. */
- return set;
+ add_setshow_cmd_full (name, class, var_type, var, set_doc, show_doc,
+ set_func, show_func, set_list, show_list,
+ &result, NULL);
+ return result;
}
struct cmd_list_element *
Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.33
diff -u -r1.33 command.h
--- command.h 15 Jun 2002 22:05:32 -0000 1.33
+++ command.h 25 Jun 2002 20:37:04 -0000
@@ -210,6 +210,28 @@
extern void help_cmd_list (struct cmd_list_element *, enum command_class,
char *, int, struct ui_file *);
+extern struct cmd_list_element *add_setshow_cmd (char *name,
+ enum command_class class,
+ var_types var_type, void *var,
+ char *set_doc, char *show_doc,
+ cmd_sfunc_ftype *set_func,
+ cmd_sfunc_ftype *show_func,
+ struct cmd_list_element **set_list,
+ struct cmd_list_element **show_list);
+
+extern struct cmd_list_element *add_setshow_cmd_full (char *name,
+ enum command_class class,
+ var_types var_type,
+ void *var,
+ char *set_doc,
+ char *show_doc,
+ cmd_sfunc_ftype *set_func,
+ cmd_sfunc_ftype *show_func,
+ struct cmd_list_element **set_list,
+ struct cmd_list_element **show_list,
+ struct cmd_list_element **set_result,
+ struct cmd_list_element **show_result);
+
extern struct cmd_list_element *add_set_cmd (char *name, enum
command_class class,
var_types var_type, void *var,
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: RFA: add_setshow_cmd_full 2002-06-25 13:40 RFA: add_setshow_cmd_full Tom Tromey @ 2002-06-25 19:35 ` Andrew Cagney 2002-06-25 22:12 ` Tom Tromey 2002-06-25 22:05 ` Eli Zaretskii 1 sibling, 1 reply; 10+ messages in thread From: Andrew Cagney @ 2002-06-25 19:35 UTC (permalink / raw) To: tromey; +Cc: gdb-patches [fernando asked me to pick up a bit of this] > 2002-06-25 Tom Tromey <tromey@redhat.com> > > * cli/cli-decode.c (add_setshow_cmd_full): New function. > (add_setshow_cmd): Use it. > * command.h (add_setshow_cmd_full): Declare. Please be careful to configure GDB with --enable-gdb-build-warnings=,-Werror so that it is compiled with the -Werror flag. Anyway, this is wrong ... > +extern struct cmd_list_element *add_setshow_cmd_full (char *name, > + enum command_class class, But this is approved .... > +void > +add_setshow_cmd_full (char *name, > + enum command_class class, > + var_types var_type, void *var, > + char *set_doc, char *show_doc, > + cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, > + struct cmd_list_element **set_list, > + struct cmd_list_element **show_list, > + struct cmd_list_element **set_result, > + struct cmd_list_element **show_result) Don't forget to remove they stray declaration: > +extern struct cmd_list_element *add_setshow_cmd (char *name, > + enum command_class class, > + var_types var_type, void *var, > + char *set_doc, char *show_doc, from the change. Andrew ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-25 19:35 ` Andrew Cagney @ 2002-06-25 22:12 ` Tom Tromey 2002-06-26 7:40 ` Andrew Cagney 0 siblings, 1 reply; 10+ messages in thread From: Tom Tromey @ 2002-06-25 22:12 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches >>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes: Andrew> Please be careful to configure GDB with Andrew> --enable-gdb-build-warnings=,-Werror so that it is compiled Andrew> with the -Werror flag. Thanks for catching this. I'm rebuilding with that right now; I wired it into my standard build script so I won't make this mistake again. Andrew> Don't forget to remove they stray declaration: >> +extern struct cmd_list_element *add_setshow_cmd (char *name, >> + enum command_class class, >> + var_types var_type, void *var, >> + char *set_doc, char *show_doc, Andrew> from the change. That declaration is part of the change, since I wanted to make add_setshow_cmd public, and add add_setshow_cmd_full as well. The latter is only used in a few places. Would you prefer I use add_setshow_cmd_full everywhere, and just have 90% of the calls have `NULL, NULL' at the end? I can do that... Tom ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-25 22:12 ` Tom Tromey @ 2002-06-26 7:40 ` Andrew Cagney 2002-06-26 10:56 ` Tom Tromey 0 siblings, 1 reply; 10+ messages in thread From: Andrew Cagney @ 2002-06-26 7:40 UTC (permalink / raw) To: tromey; +Cc: gdb-patches > That declaration is part of the change, since I wanted to make > add_setshow_cmd public, and add add_setshow_cmd_full as well. The > latter is only used in a few places. > > Would you prefer I use add_setshow_cmd_full everywhere, and just have > 90% of the calls have `NULL, NULL' at the end? I can do that... No, I was looking at them separatly. If I understand right, with the above applied, a new add_setshow_cmd(..), that returns void, can be implemented using add_setshow_cmd_full(). Andrew ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-26 7:40 ` Andrew Cagney @ 2002-06-26 10:56 ` Tom Tromey 2002-06-26 12:54 ` Andrew Cagney 0 siblings, 1 reply; 10+ messages in thread From: Tom Tromey @ 2002-06-26 10:56 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches >>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes: Andrew> If I understand right, with the above applied, a new Andrew> add_setshow_cmd(..), that returns void, can be implemented using Andrew> add_setshow_cmd_full(). Yes. I went ahead and made that change. The new patch is appended. It subsumes the last two add_setshow_cmd() patches. This time built with -Werror :-). Ok to commit? After this I'll submit my jumbo "use add_setshow_cmd instead of add_show_from_set" patch. Tom 2002-06-26 Tom Tromey <tromey@redhat.com> * command.h (add_setshow_cmd): Declare. (add_setshow_cmd_full): Declare. * cli/cli-decode.c (add_setshow_cmd): No longer static. Now returns void. Use add_setshow_cmd_full. (add_setshow_cmd_full): New function. (add_setshow_auto_boolean_cmd): Use add_setshow_cmd_full. (add_setshow_boolean_cmd): Likewise. Index: command.h =================================================================== RCS file: /cvs/src/src/gdb/command.h,v retrieving revision 1.33 diff -u -r1.33 command.h --- command.h 15 Jun 2002 22:05:32 -0000 1.33 +++ command.h 26 Jun 2002 17:54:08 -0000 @@ -210,6 +210,26 @@ extern void help_cmd_list (struct cmd_list_element *, enum command_class, char *, int, struct ui_file *); +extern void add_setshow_cmd (char *name, + enum command_class class, + var_types var_type, void *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, + cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list); + +extern void add_setshow_cmd_full (char *name, + enum command_class class, + var_types var_type, void *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, + cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list, + struct cmd_list_element **set_result, + struct cmd_list_element **show_result); + extern struct cmd_list_element *add_set_cmd (char *name, enum command_class class, var_types var_type, void *var, Index: cli/cli-decode.c =================================================================== RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v retrieving revision 1.25 diff -u -r1.25 cli-decode.c --- cli/cli-decode.c 25 Jun 2002 05:39:18 -0000 1.25 +++ cli/cli-decode.c 26 Jun 2002 17:54:11 -0000 @@ -331,14 +331,16 @@ command. SET_FUNC and SHOW_FUNC are the callback functions (if non-NULL). SET_DOC and SHOW_DOC are the documentation strings. */ -static struct cmd_list_element * -add_setshow_cmd (char *name, - enum command_class class, - var_types var_type, void *var, - char *set_doc, char *show_doc, - cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list) +void +add_setshow_cmd_full (char *name, + enum command_class class, + var_types var_type, void *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list, + struct cmd_list_element **set_result, + struct cmd_list_element **show_result) { struct cmd_list_element *set; struct cmd_list_element *show; @@ -350,9 +352,31 @@ show_doc, show_list); if (show_func != NULL) set_cmd_sfunc (show, show_func); - /* The caller often wants to modify set to include info like an - enumeration. */ - return set; + + if (set_result != NULL) + *set_result = set; + if (show_result != NULL) + *show_result = show; +} + +/* Add element named NAME to both the command SET_LIST and SHOW_LIST. + CLASS is as in add_cmd. VAR_TYPE is the kind of thing we are + setting. VAR is address of the variable being controlled by this + command. SET_FUNC and SHOW_FUNC are the callback functions (if + non-NULL). SET_DOC and SHOW_DOC are the documentation strings. */ + +void +add_setshow_cmd (char *name, + enum command_class class, + var_types var_type, void *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list) +{ + add_setshow_cmd_full (name, class, var_type, var, set_doc, show_doc, + set_func, show_func, set_list, show_list, + NULL, NULL); } struct cmd_list_element * @@ -405,9 +429,10 @@ { static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL }; struct cmd_list_element *c; - c = add_setshow_cmd (name, class, var_auto_boolean, var, - set_doc, show_doc, set_func, show_func, - set_list, show_list); + add_setshow_cmd_full (name, class, var_auto_boolean, var, + set_doc, show_doc, set_func, show_func, + set_list, show_list, + &c, NULL); c->enums = auto_boolean_enums; } @@ -426,10 +451,11 @@ { static const char *boolean_enums[] = { "on", "off", NULL }; struct cmd_list_element *c; - c = add_setshow_cmd (name, class, var_boolean, var, - set_doc, show_doc, - set_func, show_func, - set_list, show_list); + add_setshow_cmd_full (name, class, var_boolean, var, + set_doc, show_doc, + set_func, show_func, + set_list, show_list, + &c, NULL); c->enums = boolean_enums; } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-26 10:56 ` Tom Tromey @ 2002-06-26 12:54 ` Andrew Cagney 0 siblings, 0 replies; 10+ messages in thread From: Andrew Cagney @ 2002-06-26 12:54 UTC (permalink / raw) To: tromey; +Cc: Andrew Cagney, gdb-patches [heads up, my e-mail address is changing] > +extern void add_setshow_cmd (char *name, > + enum command_class class, > + var_types var_type, void *var, > + char *set_doc, char *show_doc, > + cmd_sfunc_ftype *set_func, > + cmd_sfunc_ftype *show_func, > + struct cmd_list_element **set_list, > + struct cmd_list_element **show_list); > + > +extern void add_setshow_cmd_full (char *name, > + enum command_class class, > + var_types var_type, void *var, > + char *set_doc, char *show_doc, > + cmd_sfunc_ftype *set_func, > + cmd_sfunc_ftype *show_func, > + struct cmd_list_element **set_list, > + struct cmd_list_element **show_list, > + struct cmd_list_element **set_result, > + struct cmd_list_element **show_result); > + Yep, fine. Andrew ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-25 13:40 RFA: add_setshow_cmd_full Tom Tromey 2002-06-25 19:35 ` Andrew Cagney @ 2002-06-25 22:05 ` Eli Zaretskii 2002-06-25 22:13 ` Tom Tromey 2002-06-26 11:23 ` Tom Tromey 1 sibling, 2 replies; 10+ messages in thread From: Eli Zaretskii @ 2002-06-25 22:05 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches On 25 Jun 2002, Tom Tromey wrote: > This patch includes my previous patch to make add_setshow_cmd public. Sounds good, but could you please add this function to gdbint.texinfo? TIA ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-25 22:05 ` Eli Zaretskii @ 2002-06-25 22:13 ` Tom Tromey 2002-06-26 11:23 ` Tom Tromey 1 sibling, 0 replies; 10+ messages in thread From: Tom Tromey @ 2002-06-25 22:13 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches >>>>> "Eli" == Eli Zaretskii <eliz@is.elta.co.il> writes: >> This patch includes my previous patch to make add_setshow_cmd public. Eli> Sounds good, but could you please add this function to Eli> gdbint.texinfo? Will do. Thanks. Tom ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-25 22:05 ` Eli Zaretskii 2002-06-25 22:13 ` Tom Tromey @ 2002-06-26 11:23 ` Tom Tromey 2002-06-26 11:46 ` Eli Zaretskii 1 sibling, 1 reply; 10+ messages in thread From: Tom Tromey @ 2002-06-26 11:23 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches >>>>> "Eli" == Eli Zaretskii <eliz@is.elta.co.il> writes: Eli> Sounds good, but could you please add this function to Eli> gdbint.texinfo? Assuming Andrew approves my most recent patch in this area, what do you think of the appended documentation patch? I didn't list the arguments as the other entries don't seem to, and anyway they are documented in the source. In Java it is standard to extract special comments in the source and use those to construct API documentation. I know a long time ago gdb did this, but it was abandoned. Anyway, wouldn't it be simpler to keep the docs up to date with something like this in place? Tom Index: ChangeLog from Tom Tromey <tromey@redhat.com> * gdbint.texinfo (User Interface): Mention add_setshow_cmd and add_setshow_cmd_full. Index: gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.91 diff -u -r1.91 gdbint.texinfo --- gdbint.texinfo 9 Jun 2002 17:15:40 -0000 1.91 +++ gdbint.texinfo 26 Jun 2002 18:13:36 -0000 @@ -50,7 +50,7 @@ @end tex @vskip 0pt plus 1filll -Copyright @copyright{} 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001 +Copyright @copyright{} 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001, 2002 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document @@ -721,6 +721,14 @@ the main command list, and should be used for those commands. The usual place to add commands is in the @code{_initialize_@var{xyz}} routines at the ends of most source files. + +@findex add_setshow_cmd +@findex add_setshow_cmd_full +To add paired @samp{set} and @samp{show} commands, use +@code{add_setshow_cmd} or @code{add_setshow_cmd_full}. The former is +a slightly simpler interface which is useful when you don't need to +further modify the new command structures, while the latter returns +the new command structures for manipulation. @cindex deprecating commands @findex deprecate_cmd ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: RFA: add_setshow_cmd_full 2002-06-26 11:23 ` Tom Tromey @ 2002-06-26 11:46 ` Eli Zaretskii 0 siblings, 0 replies; 10+ messages in thread From: Eli Zaretskii @ 2002-06-26 11:46 UTC (permalink / raw) To: tromey; +Cc: gdb-patches > From: Tom Tromey <tromey@redhat.com> > Date: 26 Jun 2002 12:36:13 -0600 > > Assuming Andrew approves my most recent patch in this area, what do > you think of the appended documentation patch? It's okay, please commit it with the source patches. > In Java it is standard to extract special comments in the source and > use those to construct API documentation. I know a long time ago gdb > did this, but it was abandoned. Anyway, wouldn't it be simpler to > keep the docs up to date with something like this in place? I don't mind going back to keeping the docs with the sources. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2002-06-26 19:54 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-06-25 13:40 RFA: add_setshow_cmd_full Tom Tromey 2002-06-25 19:35 ` Andrew Cagney 2002-06-25 22:12 ` Tom Tromey 2002-06-26 7:40 ` Andrew Cagney 2002-06-26 10:56 ` Tom Tromey 2002-06-26 12:54 ` Andrew Cagney 2002-06-25 22:05 ` Eli Zaretskii 2002-06-25 22:13 ` Tom Tromey 2002-06-26 11:23 ` Tom Tromey 2002-06-26 11:46 ` Eli Zaretskii
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox