This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa:cli/rfc] Use cmd->func instead of cmd->cfunc/sfunc
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 02 Feb 2002 20:42:15 -0500
- Subject: [rfa:cli/rfc] Use cmd->func instead of cmd->cfunc/sfunc
Hello,
The attatched patch is the first shaky step towards changing the
signature of the CLI callback function. I'm looking to add things like
a context parameter and (possibly) replace is-tty with a ui-file
parameter. The ultimate objective here is to fix gdb/145.
Up until now the cli has used ->function.cfunc() and ->function.sfunc()
both members of the same union. This patch pushes these interfaces down
a level and introduces ->func.
The routines set_cmd_cfunc() and set_cmd_sfunc() handle the problem of
compatibility by installing versions of ->func that call the
corresponding old function.
Going through the code, I've also managed to purge most, but not all,
references to ->function.[cs]func.. Have a look at tracepoint.c for the
problem ones - that looks to need a serious thinko :-(
Ok? ``I've found no regressions.''
enjoy,
Andrew
2002-02-02 Andrew Cagney <ac131313@redhat.com>
* cli/cli-decode.c (help_cmd): Test for func not cfunc/sfunc.
(help_all, help_cmd_list): Ditto.
(find_cmd, complete_on_cmdlist): Ditto.
* cli/cli-setshow.c (do_setshow_command): Call func instead of
function.sfunc.
* top.c (execute_command): Test func instead of function.cfunc or
function.sfunc.
* infcmd.c (notice_args_read): Fix function signature.
* cli/cli-decode.c (do_cfunc, set_cmd_cfunc): New functions.
(do_sfunc, set_cmd_sfunc): New functions.
* command.h (struct cmd_list_element): Add field func.
* cli/cli-decode.h (struct cmd_list_element): Ditto.
* command.h (set_cmd_sfunc, set_cmd_cfunc): Declare.
* cli/cli-decode.h: Ditto.
* cli/cli-cmds.c (init_cli_cmds): Use set_cmd_sfunc.
* cli/cli-decode.c (add_set_cmd): Ditto.
* utils.c (initialize_utils): Ditto.
* maint.c (_initialize_maint_cmds): Ditto.
* infrun.c (_initialize_infrun): Ditto.
* demangle.c (_initialize_demangler): Ditto.
* remote.c (add_packet_config_cmd): Ditto.
* mips-tdep.c (_initialize_mips_tdep): Ditto.
* cris-tdep.c (_initialize_cris_tdep): Ditto.
* proc-api.c (_initialize_proc_api): Ditto.
* kod.c (_initialize_kod): Ditto.
* valprint.c (_initialize_valprint): Ditto.
* top.c (init_main): Ditto.
* infcmd.c (_initialize_infcmd): Ditto.
* corefile.c (_initialize_core): Ditto.
* arm-tdep.c (_initialize_arm_tdep): Ditto.
* arch-utils.c (initialize_current_architecture): Ditto.
(_initialize_gdbarch_utils): Ditto.
* alpha-tdep.c (_initialize_alpha_tdep): Ditto.
* cli/cli-decode.c (add_cmd): Use set_cmd_cfunc.
* wince.c (_initialize_inftarg): Ditto.
* symfile.c (_initialize_symfile): Ditto.
* mips-tdep.c (_initialize_mips_tdep): Ditto.
* language.c (_initialize_language): Ditto.
* arc-tdep.c (_initialize_arc_tdep): Ditto.
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.18
diff -u -r1.18 alpha-tdep.c
--- alpha-tdep.c 2002/01/20 01:33:15 1.18
+++ alpha-tdep.c 2002/02/03 01:19:59
@@ -1686,6 +1686,6 @@
&setlist);
/* We need to throw away the frame cache when we set this, since it
might change our ability to get backtraces. */
- c->function.sfunc = reinit_frame_cache_sfunc;
+ set_cmd_sfunc (c, reinit_frame_cache_sfunc);
add_show_from_set (c, &showlist);
}
Index: arc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arc-tdep.c,v
retrieving revision 1.7
diff -u -r1.7 arc-tdep.c
--- arc-tdep.c 2001/03/06 08:21:05 1.7
+++ arc-tdep.c 2002/02/03 01:20:00
@@ -692,9 +692,9 @@
cpu-type-specific registers and recognize cpu-type-specific instructions.\
",
&setlist);
- c->function.cfunc = arc_set_cpu_type_command;
+ set_cmd_cfunc (c, arc_set_cpu_type_command);
c = add_show_from_set (c, &showlist);
- c->function.cfunc = arc_show_cpu_type_command;
+ set_cmd_cfunc (c, arc_show_cpu_type_command);
/* We have to use xstrdup() here because the `set' command frees it
before setting a new value. */
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.48
diff -u -r1.48 arch-utils.c
--- arch-utils.c 2002/01/29 03:51:14 1.48
+++ arch-utils.c 2002/02/03 01:20:03
@@ -793,7 +793,7 @@
arches, &set_architecture_string,
"Set architecture of target.",
&setlist);
- c->function.sfunc = set_architecture;
+ set_cmd_sfunc (c, set_architecture);
add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
/* Don't use set_from_show - need to print both auto/manual and
current setting. */
@@ -828,7 +828,7 @@
endian_enum, &set_endian_string,
"Set endianness of target.",
&setlist);
- c->function.sfunc = set_endian;
+ set_cmd_sfunc (c, set_endian);
/* Don't use set_from_show - need to print both auto/manual and
current setting. */
add_cmd ("endian", class_support, show_endian,
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.31
diff -u -r1.31 arm-tdep.c
--- arm-tdep.c 2002/02/01 13:39:41 1.31
+++ arm-tdep.c 2002/02/03 01:20:09
@@ -2330,7 +2330,7 @@
&disassembly_flavor,
helptext,
&setlist);
- new_cmd->function.sfunc = set_disassembly_flavor_sfunc;
+ set_cmd_sfunc (new_cmd, set_disassembly_flavor_sfunc);
add_show_from_set (new_cmd, &showlist);
/* ??? Maybe this should be a boolean. */
Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.21
diff -u -r1.21 command.h
--- command.h 2002/02/02 00:56:34 1.21
+++ command.h 2002/02/03 01:20:10
@@ -127,7 +127,13 @@
enum command_class class;
/* Function definition of this command. NULL for command class
- names and for help topics that are not really commands. */
+ names and for help topics that are not really commands. NOTE:
+ cagney/2002-02-02: This function signature is evolving. For
+ the moment suggest sticking with either set_cmd_cfunc() or
+ set_cmd_sfunc(). */
+ void (*func) (struct cmd_list_element *c, char *args, int from_tty);
+ /* The command's real callback. At present func() bounces through
+ to one of the below. */
union
{
/* If type is not_set_cmd, call it like this: */
@@ -276,6 +282,16 @@
**, char *, int,
struct cmd_list_element
**);
+
+/* Set the commands corresponding callback. */
+
+extern void set_cmd_cfunc (struct cmd_list_element *cmd,
+ void (*cfunc) (char *args, int from_tty));
+
+extern void set_cmd_sfunc (struct cmd_list_element *cmd,
+ void (*sfunc) (char *args, int from_tty,
+ struct cmd_list_element * c));
+
extern struct cmd_list_element *lookup_cmd (char **,
struct cmd_list_element *, char *,
Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gdb/corefile.c,v
retrieving revision 1.16
diff -u -r1.16 corefile.c
--- corefile.c 2001/12/19 23:54:26 1.16
+++ corefile.c 2002/02/03 01:20:12
@@ -448,7 +448,7 @@
"Set the current BFD target.\n\
Use `set gnutarget auto' to specify automatic detection.",
&setlist);
- c->function.sfunc = set_gnutarget_command;
+ set_cmd_sfunc (c, set_gnutarget_command);
add_show_from_set (c, &showlist);
if (getenv ("GNUTARGET"))
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.11
diff -u -r1.11 cris-tdep.c
--- cris-tdep.c 2002/01/20 18:05:51 1.11
+++ cris-tdep.c 2002/02/03 01:20:20
@@ -3875,19 +3875,19 @@
c = add_set_cmd ("cris-version", class_support, var_integer,
(char *) &usr_cmd_cris_version,
"Set the current CRIS version.", &setlist);
- c->function.sfunc = cris_version_update;
+ set_cmd_sfunc (c, cris_version_update);
add_show_from_set (c, &showlist);
c = add_set_enum_cmd ("cris-mode", class_support, cris_mode_enums,
&usr_cmd_cris_mode,
"Set the current CRIS mode.", &setlist);
- c->function.sfunc = cris_mode_update;
+ set_cmd_sfunc (c, cris_mode_update);
add_show_from_set (c, &showlist);
c = add_set_enum_cmd ("cris-abi", class_support, cris_abi_enums,
&usr_cmd_cris_abi,
"Set the current CRIS ABI version.", &setlist);
- c->function.sfunc = cris_abi_update;
+ set_cmd_sfunc (c, cris_abi_update);
add_show_from_set (c, &showlist);
c = add_cmd ("cris-fpless-backtrace", class_support, cris_fpless_backtrace,
Index: demangle.c
===================================================================
RCS file: /cvs/src/src/gdb/demangle.c,v
retrieving revision 1.8
diff -u -r1.8 demangle.c
--- demangle.c 2001/04/16 14:36:16 1.8
+++ demangle.c 2002/02/03 01:20:20
@@ -200,7 +200,7 @@
Use `set demangle-style' without arguments for a list of demangling styles.",
&setlist);
show = add_show_from_set (set, &showlist);
- set->function.sfunc = set_demangling_command;
+ set_cmd_sfunc (set, set_demangling_command);
/* Set the default demangling style chosen at compilation time. */
set_demangling_style (DEFAULT_DEMANGLING_STYLE);
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.39
diff -u -r1.39 infcmd.c
--- infcmd.c 2002/01/29 03:08:25 1.39
+++ infcmd.c 2002/02/03 01:20:26
@@ -248,7 +248,7 @@
/* Notice when `show args' is run. */
static void
-notice_args_read (struct cmd_list_element *c)
+notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
{
/* Might compute the value. */
get_inferior_args ();
@@ -1877,9 +1877,9 @@
Follow this command with any number of args, to be passed to the program.",
&setlist);
c->completer = filename_completer;
- c->function.sfunc = notice_args_set;
+ set_cmd_sfunc (c, notice_args_set);
c = add_show_from_set (c, &showlist);
- c->pre_show_hook = notice_args_read;
+ set_cmd_sfunc (c, notice_args_read);
c = add_cmd
("environment", no_class, environment_info,
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.51
diff -u -r1.51 infrun.c
--- infrun.c 2002/02/02 03:42:58 1.51
+++ infrun.c 2002/02/03 01:20:38
@@ -4350,7 +4350,6 @@
For \"parent\" or \"child\", the unfollowed process will run free.\n\
By default, the debugger will follow the parent process.",
&setlist);
-/* c->function.sfunc = ; */
add_show_from_set (c, &showlist);
c = add_set_enum_cmd ("scheduler-locking", class_run,
@@ -4364,7 +4363,7 @@
Other threads may run while stepping over a function call ('next').",
&setlist);
- c->function.sfunc = set_schedlock_func; /* traps on target vector */
+ set_cmd_sfunc (c, set_schedlock_func); /* traps on target vector */
add_show_from_set (c, &showlist);
c = add_set_cmd ("step-mode", class_run,
Index: kod.c
===================================================================
RCS file: /cvs/src/src/gdb/kod.c,v
retrieving revision 1.4
diff -u -r1.4 kod.c
--- kod.c 2001/03/06 08:21:09 1.4
+++ kod.c 2002/02/03 01:20:39
@@ -224,6 +224,6 @@
(char *) &operating_system,
"Set operating system",
&setlist);
- c->function.sfunc = kod_set_os;
+ set_cmd_sfunc (c, kod_set_os);
add_show_from_set (c, &showlist);
}
Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.20
diff -u -r1.20 language.c
--- language.c 2002/02/02 02:28:40 1.20
+++ language.c 2002/02/03 01:20:42
@@ -1555,8 +1555,8 @@
"Set the current source language.",
&setlist);
show = add_show_from_set (set, &showlist);
- set->function.cfunc = set_language_command;
- show->function.cfunc = show_language_command;
+ set_cmd_cfunc (set, set_language_command);
+ set_cmd_cfunc (show, show_language_command);
add_prefix_cmd ("check", no_class, set_check,
"Set the status of the type/range checker",
@@ -1575,16 +1575,16 @@
"Set type checking. (on/warn/off/auto)",
&setchecklist);
show = add_show_from_set (set, &showchecklist);
- set->function.cfunc = set_type_command;
- show->function.cfunc = show_type_command;
+ set_cmd_cfunc (set, set_type_command);
+ set_cmd_cfunc (show, show_type_command);
set = add_set_cmd ("range", class_support, var_string_noescape,
(char *) &range,
"Set range checking. (on/warn/off/auto)",
&setchecklist);
show = add_show_from_set (set, &showchecklist);
- set->function.cfunc = set_range_command;
- show->function.cfunc = show_range_command;
+ set_cmd_cfunc (set, set_range_command);
+ set_cmd_cfunc (show, show_range_command);
set = add_set_cmd ("case-sensitive", class_support, var_string_noescape,
(char *) &case_sensitive,
@@ -1592,8 +1592,8 @@
For Fortran the default is off; for other languages the default is on.",
&setlist);
show = add_show_from_set (set, &showlist);
- set->function.cfunc = set_case_command;
- show->function.cfunc = show_case_command;
+ set_cmd_cfunc (set, set_case_command);
+ set_cmd_cfunc (show, show_case_command);
add_language (&unknown_language_defn);
add_language (&local_language_defn);
Index: maint.c
===================================================================
RCS file: /cvs/src/src/gdb/maint.c,v
retrieving revision 1.22
diff -u -r1.22 maint.c
--- maint.c 2002/01/01 15:17:40 1.22
+++ maint.c 2002/02/03 01:20:45
@@ -790,7 +790,7 @@
"Set internal profiling.\n\
When enabled GDB is profiled.",
&maintenance_set_cmdlist);
- tmpcmd->function.sfunc = maintenance_set_profile_cmd;
+ set_cmd_sfunc (tmpcmd, maintenance_set_profile_cmd);
add_show_from_set (tmpcmd, &maintenance_show_cmdlist);
#endif
}
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.64
diff -u -r1.64 mips-tdep.c
--- mips-tdep.c 2002/01/20 18:05:51 1.64
+++ mips-tdep.c 2002/02/03 01:20:56
@@ -4786,9 +4786,9 @@
Set this to be able to access processor-type-specific registers.\n\
",
&setlist);
- c->function.cfunc = mips_set_processor_type_command;
+ set_cmd_cfunc (c, mips_set_processor_type_command);
c = add_show_from_set (c, &showlist);
- c->function.cfunc = mips_show_processor_type_command;
+ set_cmd_cfunc (c, mips_show_processor_type_command);
tmp_mips_processor_type = xstrdup (DEFAULT_MIPS_TYPE);
mips_set_processor_type_command (xstrdup (DEFAULT_MIPS_TYPE), 0);
@@ -4807,7 +4807,7 @@
&setlist);
/* We need to throw away the frame cache when we set this, since it
might change our ability to get backtraces. */
- c->function.sfunc = reinit_frame_cache_sfunc;
+ set_cmd_sfunc (c, reinit_frame_cache_sfunc);
add_show_from_set (c, &showlist);
/* Allow the user to control whether the upper bits of 64-bit
Index: proc-api.c
===================================================================
RCS file: /cvs/src/src/gdb/proc-api.c,v
retrieving revision 1.10
diff -u -r1.10 proc-api.c
--- proc-api.c 2001/05/10 21:03:03 1.10
+++ proc-api.c 2002/02/03 01:20:59
@@ -777,7 +777,7 @@
"Set tracing for /proc api calls.\n", &setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_procfs_trace_cmd;
+ set_cmd_sfunc (c, set_procfs_trace_cmd);
c->completer = filename_completer;
c = add_set_cmd ("procfs-file", no_class, var_filename,
@@ -785,5 +785,5 @@
"Set filename for /proc tracefile.\n", &setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_procfs_file_cmd;
+ set_cmd_sfunc (c, set_procfs_file_cmd);
}
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.74
diff -u -r1.74 remote.c
--- remote.c 2002/01/19 03:32:40 1.74
+++ remote.c 2002/02/03 01:21:12
@@ -675,7 +675,7 @@
set_cmd = add_set_auto_boolean_cmd (cmd_name, class_obscure,
&config->detect, set_doc,
set_remote_list);
- set_cmd->function.sfunc = set_func;
+ set_cmd_sfunc (set_cmd, set_func);
show_cmd = add_cmd (cmd_name, class_obscure, show_func, show_doc,
show_remote_list);
/* set/show remote NAME-packet {auto,on,off} -- legacy */
@@ -6154,7 +6154,7 @@
&remote_Z_packet_detect,
"\
Set use of remote protocol `Z' packets", &remote_set_cmdlist);
- tmpcmd->function.sfunc = set_remote_protocol_Z_packet_cmd;
+ set_cmd_sfunc (tmpcmd, set_remote_protocol_Z_packet_cmd);
add_cmd ("Z-packet", class_obscure, show_remote_protocol_Z_packet_cmd,
"Show use of remote protocol `Z' packets ",
&remote_show_cmdlist);
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.51
diff -u -r1.51 symfile.c
--- symfile.c 2002/02/01 01:14:20 1.51
+++ symfile.c 2002/02/03 01:21:22
@@ -3274,7 +3274,7 @@
"Set mapping between filename extension and source language.\n\
Usage: set extension-language .foo bar",
&setlist);
- c->function.cfunc = set_ext_lang_command;
+ set_cmd_cfunc (c, set_ext_lang_command);
add_info ("extensions", info_ext_lang_command,
"All filename extensions associated with a source language.");
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.54
diff -u -r1.54 top.c
--- top.c 2002/02/02 00:56:34 1.54
+++ top.c 2002/02/03 01:21:28
@@ -672,7 +672,16 @@
/* Pass null arg rather than an empty one. */
arg = *p ? p : 0;
- /* Clear off trailing whitespace, except for set and complete command. */
+ /* FIXME: cagney/2002-02-02: The c->type test is pretty dodgy
+ while the is_complete_command(cfunc) test is just plain
+ bogus. They should both be replaced by a test of the form
+ c->strip_trailing_white_space_p. */
+ /* NOTE: cagney/2002-02-02: The function.cfunc in the below
+ can't be replaced with func. This is because it is the
+ cfunc, and not the func, that has the value that the
+ is_complete_command hack is testing for. */
+ /* Clear off trailing whitespace, except for set and complete
+ command. */
if (arg
&& c->type != set_cmd
&& !is_complete_command (c->function.cfunc))
@@ -698,12 +707,12 @@
execute_user_command (c, arg);
else if (c->type == set_cmd || c->type == show_cmd)
do_setshow_command (arg, from_tty & caution, c);
- else if (c->function.cfunc == NULL)
+ else if (c->func == NULL)
error ("That is not a command, just a help topic.");
else if (call_command_hook)
call_command_hook (c, arg, from_tty & caution);
else
- (*c->function.cfunc) (arg, from_tty & caution);
+ (*c->func) (c, arg, from_tty & caution);
/* If this command has been post-hooked, run the hook last. */
if ((c->hook_post) && (!c->hook_in))
@@ -1943,7 +1952,7 @@
(char *) &new_async_prompt, "Set gdb's prompt",
&setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_async_prompt;
+ set_cmd_sfunc (c, set_async_prompt);
}
add_show_from_set
@@ -1979,7 +1988,7 @@
EMACS-like or VI-like commands like control-P or ESC.", &setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_async_editing_command;
+ set_cmd_sfunc (c, set_async_editing_command);
}
add_show_from_set
@@ -1993,7 +2002,7 @@
"Set the size of the command history, \n\
ie. the number of previous commands to keep a record of.", &sethistlist);
add_show_from_set (c, &showhistlist);
- c->function.sfunc = set_history_size_command;
+ set_cmd_sfunc (c, set_history_size_command);
c = add_set_cmd ("filename", no_class, var_filename,
(char *) &history_filename,
@@ -2030,7 +2039,7 @@
2 == output annotated suitably for use by programs that control GDB.",
&setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_async_annotation_level;
+ set_cmd_sfunc (c, set_async_annotation_level);
}
if (event_loop_p)
{
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.31
diff -u -r1.31 tracepoint.c
--- tracepoint.c 2002/02/02 00:56:34 1.31
+++ tracepoint.c 2002/02/03 01:21:34
@@ -1,5 +1,7 @@
/* Tracing functionality for remote targets in custom GDB protocol
- Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+ Foundation, Inc.
This file is part of GDB.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.60
diff -u -r1.60 utils.c
--- utils.c 2002/02/02 15:39:33 1.60
+++ utils.c 2002/02/03 01:21:39
@@ -2238,7 +2238,7 @@
"Set number of characters gdb thinks are in a line.",
&setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_width_command;
+ set_cmd_sfunc (c, set_width_command);
add_show_from_set
(add_set_cmd ("height", class_support,
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.21
diff -u -r1.21 valprint.c
--- valprint.c 2002/01/20 18:05:51 1.21
+++ valprint.c 2002/02/03 01:21:43
@@ -1484,14 +1484,14 @@
"Set default input radix for entering numbers.",
&setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_input_radix;
+ set_cmd_sfunc (c, set_input_radix);
c = add_set_cmd ("output-radix", class_support, var_uinteger,
(char *) &output_radix,
"Set default output radix for printing of values.",
&setlist);
add_show_from_set (c, &showlist);
- c->function.sfunc = set_output_radix;
+ set_cmd_sfunc (c, set_output_radix);
/* The "set radix" and "show radix" commands are special in that they are
like normal set and show commands but allow two normally independent
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.17
diff -u -r1.17 wince.c
--- wince.c 2001/05/04 04:15:28 1.17
+++ wince.c 2002/02/03 01:21:48
@@ -1983,7 +1983,7 @@
(char *) "Set how to upload executables to remote device.\n",
&setlist);
add_show_from_set (set, &showlist);
- set->function.cfunc = set_upload_type;
+ set_cmd_cfunc (set, set_upload_type);
set_upload_type (NULL, 0);
add_show_from_set
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.13
diff -u -r1.13 cli-cmds.c
--- cli-cmds.c 2002/02/02 00:56:36 1.13
+++ cli-cmds.c 2002/02/03 01:21:51
@@ -676,7 +676,7 @@
"Set ",
&setlist),
add_show_from_set (c, &showlist);
- c->function.sfunc = set_verbose;
+ set_cmd_sfunc (c, set_verbose);
set_verbose (NULL, 0, c);
add_prefix_cmd ("history", class_support, set_history,
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.12
diff -u -r1.12 cli-decode.c
--- cli-decode.c 2002/02/02 00:56:36 1.12
+++ cli-decode.c 2002/02/03 01:21:54
@@ -40,6 +40,46 @@
static void help_all (struct ui_file *stream);
+/* Set the callback function for the specified command. For each both
+ the commands callback and func() are set. The latter set to a
+ bounce function (unless cfunc / sfunc is NULL that is). */
+
+static void
+do_cfunc (struct cmd_list_element *c, char *args, int from_tty)
+{
+ c->function.cfunc (args, from_tty); /* Ok. */
+}
+
+void
+set_cmd_cfunc (struct cmd_list_element *cmd,
+ void (*cfunc) (char *args, int from_tty))
+{
+ if (cfunc == NULL)
+ cmd->func = NULL;
+ else
+ cmd->func = do_cfunc;
+ cmd->function.cfunc = cfunc; /* Ok. */
+}
+
+static void
+do_sfunc (struct cmd_list_element *c, char *args, int from_tty)
+{
+ c->function.sfunc (args, from_tty, c); /* Ok. */
+}
+
+void
+set_cmd_sfunc (struct cmd_list_element *cmd,
+ void (*sfunc) (char *args, int from_tty,
+ struct cmd_list_element * c))
+{
+ if (sfunc == NULL)
+ cmd->func = NULL;
+ else
+ cmd->func = do_sfunc;
+ cmd->function.sfunc = sfunc; /* Ok. */
+}
+
+
/* Add element named NAME.
CLASS is the top level category into which commands are broken down
for "help" purposes.
@@ -85,7 +125,7 @@
c->name = name;
c->class = class;
- c->function.cfunc = fun;
+ set_cmd_cfunc (c, fun);
c->doc = doc;
c->flags = 0;
c->replacement = NULL;
@@ -165,7 +205,10 @@
return 0;
}
- c = add_cmd (name, class, old->function.cfunc, old->doc, list);
+ c = add_cmd (name, class, NULL, old->doc, list);
+ /* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
+ c->func = old->func;
+ c->function = old->function;
c->prefixlist = old->prefixlist;
c->prefixname = old->prefixname;
c->allow_unknown = old->allow_unknown;
@@ -244,7 +287,7 @@
c->var = var;
/* This needs to be something besides NULL so that this isn't
treated as a help class. */
- c->function.sfunc = empty_sfunc;
+ set_cmd_sfunc (c, empty_sfunc);
return c;
}
@@ -516,18 +559,18 @@
If c->prefixlist is nonzero, we have a prefix command.
Print its documentation, then list its subcommands.
- If c->function is nonzero, we really have a command.
- Print its documentation and return.
+ If c->func is non NULL, we really have a command. Print its
+ documentation and return.
- If c->function is zero, we have a class name.
- Print its documentation (as if it were a command)
- and then set class to the number of this class
- so that the commands in the class will be listed. */
+ If c->func is NULL, we have a class name. Print its
+ documentation (as if it were a command) and then set class to the
+ number of this class so that the commands in the class will be
+ listed. */
fputs_filtered (c->doc, stream);
fputs_filtered ("\n", stream);
- if (c->prefixlist == 0 && c->function.cfunc != NULL)
+ if (c->prefixlist == 0 && c->func != NULL)
return;
fprintf_filtered (stream, "\n");
@@ -536,7 +579,7 @@
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->function.cfunc == NULL)
+ if (c->func == NULL)
help_list (cmdlist, "", c->class, stream);
if (c->hook_pre || c->hook_post)
@@ -620,7 +663,7 @@
help_cmd_list (*c->prefixlist, all_commands, c->prefixname, 0, stream);
/* If this is a class name, print all of the commands in the class */
- else if (c->function.cfunc == NULL)
+ else if (c->func == NULL)
help_cmd_list (cmdlist, c->class, "", 0, stream);
}
}
@@ -681,8 +724,8 @@
{
if (c->abbrev_flag == 0 &&
(class == all_commands
- || (class == all_classes && c->function.cfunc == NULL)
- || (class == c->class && c->function.cfunc != NULL)))
+ || (class == all_classes && c->func == NULL)
+ || (class == c->class && c->func != NULL)))
{
fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
print_doc_line (stream, c->doc);
@@ -710,7 +753,7 @@
*nfound = 0;
for (c = clist; c; c = c->next)
if (!strncmp (command, c->name, len)
- && (!ignore_help_classes || c->function.cfunc))
+ && (!ignore_help_classes || c->func))
{
found = c;
(*nfound)++;
@@ -1241,7 +1284,7 @@
for (ptr = list; ptr; ptr = ptr->next)
if (!strncmp (ptr->name, text, textlen)
&& !ptr->abbrev_flag
- && (ptr->function.cfunc
+ && (ptr->func
|| ptr->prefixlist))
{
if (matches == sizeof_matchlist)
Index: cli/cli-decode.h
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.h,v
retrieving revision 1.6
diff -u -r1.6 cli-decode.h
--- cli-decode.h 2002/02/02 00:56:36 1.6
+++ cli-decode.h 2002/02/03 01:21:55
@@ -121,7 +121,13 @@
enum command_class class;
/* Function definition of this command. NULL for command class
- names and for help topics that are not really commands. */
+ names and for help topics that are not really commands. NOTE:
+ cagney/2002-02-02: This function signature is evolving. For
+ the moment suggest sticking with either set_cmd_cfunc() or
+ set_cmd_sfunc(). */
+ void (*func) (struct cmd_list_element *c, char *args, int from_tty);
+ /* The command's real callback. At present func() bounces through
+ to one of the below. */
union
{
/* If type is not_set_cmd, call it like this: */
@@ -270,6 +276,16 @@
**, char *, int,
struct cmd_list_element
**);
+
+/* Set the commands corresponding callback. */
+
+extern void set_cmd_cfunc (struct cmd_list_element *cmd,
+ void (*cfunc) (char *args, int from_tty));
+
+extern void set_cmd_sfunc (struct cmd_list_element *cmd,
+ void (*sfunc) (char *args, int from_tty,
+ struct cmd_list_element * c));
+
extern struct cmd_list_element *lookup_cmd (char **,
struct cmd_list_element *, char *,
Index: cli/cli-setshow.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-setshow.c,v
retrieving revision 1.6
diff -u -r1.6 cli-setshow.c
--- cli-setshow.c 2002/01/17 22:15:18 1.6
+++ cli-setshow.c 2002/02/03 01:21:55
@@ -345,7 +345,7 @@
}
else
error ("gdb internal error: bad cmd_type in do_setshow_command");
- (*c->function.sfunc) (NULL, from_tty, c);
+ c->func (c, NULL, from_tty);
if (c->type == set_cmd && set_hook)
set_hook (c);
}