(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-decode.c (help_cmd): Test for func not cfunc/sfunc.
(help_all, help_cmd_list): Ditto.
(find_cmd, complete_on_cmdlist): Ditto.
* top.c (execute_command): Ditto.
* cli/cli-setshow.c (do_setshow_command): Call func instead of
function.sfunc.
* infcmd.c (notice_args_read): Fix function signature.
* 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.
+2002-02-04 Andrew Cagney <ac131313@redhat.com>
+
+ * 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-decode.c (help_cmd): Test for func not cfunc/sfunc.
+ (help_all, help_cmd_list): Ditto.
+ (find_cmd, complete_on_cmdlist): Ditto.
+ * top.c (execute_command): Ditto.
+
+ * cli/cli-setshow.c (do_setshow_command): Call func instead of
+ function.sfunc.
+
+ * infcmd.c (notice_args_read): Fix function signature.
+
+ * 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.
+
2002-02-04 Michael Snyder <msnyder@redhat.com>
* memattr.c (_initialize_mem): Elaborate the help for 'mem' command.
&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);
}
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. */
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. */
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,
&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. */
"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,
static void help_all (struct ui_file *stream);
\f
+/* 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.
c->name = name;
c->class = class;
- c->function.cfunc = fun;
+ set_cmd_cfunc (c, fun);
c->doc = doc;
c->flags = 0;
c->replacement = NULL;
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;
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;
}
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");
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)
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);
}
}
{
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);
*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)++;
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)
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: */
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 *,
int, int);
}
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);
}
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: */
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 *,
int, int);
"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"))
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,
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);
/* 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 ();
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,
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,
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,
(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);
}
"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",
"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,
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);
"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
}
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);
&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
"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,
"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);
}
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 */
&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);
"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.");
/* 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))
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))
(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
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
"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,
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)
{
/* 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.
"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,
"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
(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