]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* cli/cli-decode.c (do_cfunc, set_cmd_cfunc): New functions.
authorAndrew Cagney <cagney@redhat.com>
Tue, 5 Feb 2002 04:37:23 +0000 (04:37 +0000)
committerAndrew Cagney <cagney@redhat.com>
Tue, 5 Feb 2002 04:37:23 +0000 (04:37 +0000)
(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.

27 files changed:
gdb/ChangeLog
gdb/alpha-tdep.c
gdb/arc-tdep.c
gdb/arch-utils.c
gdb/arm-tdep.c
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/cli/cli-decode.h
gdb/cli/cli-setshow.c
gdb/command.h
gdb/corefile.c
gdb/cris-tdep.c
gdb/demangle.c
gdb/infcmd.c
gdb/infrun.c
gdb/kod.c
gdb/language.c
gdb/maint.c
gdb/mips-tdep.c
gdb/proc-api.c
gdb/remote.c
gdb/symfile.c
gdb/top.c
gdb/tracepoint.c
gdb/utils.c
gdb/valprint.c
gdb/wince.c

index 7e565509a9426c2014cb8e7147396c958bd7c1d1..7739c4b6d6cfd0aecf61bdecaf5e33a80ce3445a 100644 (file)
@@ -1,3 +1,50 @@
+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.
index 971dd632f24d37a2a5878be42267ef4087c6ea54..4ca6bcc3884fc66ebe29534eabafae0c11a0a436 100644 (file)
@@ -1686,6 +1686,6 @@ search.  The only need to set it is when debugging a stripped executable.",
                   &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 825e55bd4fc2a507dcb4166972b66007f7a3afe8..10a1bc11b6c90dd917c30b3a3289c53b24b3f989 100644 (file)
@@ -692,9 +692,9 @@ change the cpu being debugged.  It also gives one access to\n\
 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 e6cda543b6d7d9205a95cc158075bf58802a6d46..1ec5006467593622e9fcd9123bedcb5382e75a2f 100644 (file)
@@ -793,7 +793,7 @@ initialize_current_architecture (void)
                          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 @@ _initialize_gdbarch_utils (void)
                        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 f9ffa71b9010938149746842e8c3710b6ba73cea..88135e883b3966cc72721190a148f90a49fdb911 100644 (file)
@@ -2339,7 +2339,7 @@ The valid values are:\n");
                              &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 4f033a3e1f7392b5b298b6cb34924d750a40a03b..f229a701460556c7ab43b1f5993861d5bcedd955 100644 (file)
@@ -676,7 +676,7 @@ when gdb is started.", &cmdlist);
                   "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 3821fafb186f1bbb924ef5ad28de2ebb07902508..d64b2f642905e9d0838b39487354e353685e8e84 100644 (file)
@@ -40,6 +40,46 @@ static struct cmd_list_element *find_cmd (char *command,
 
 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.
@@ -85,7 +125,7 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
 
   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 @@ add_alias_cmd (char *name, char *oldname, enum command_class class,
       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 @@ add_set_cmd (char *name,
   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 @@ help_cmd (char *command, struct ui_file *stream)
      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_cmd (char *command, struct ui_file *stream)
     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_all (struct ui_file *stream)
         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 @@ help_cmd_list (struct cmd_list_element *list, enum command_class class,
     {
       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 @@ find_cmd (char *command, int len, struct cmd_list_element *clist,
   *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 @@ complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word)
   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 9e1e0944cb04532882a1c6a21cf656b42a95db0a..6c7c22b8ac7d5500f34ff46387eca737f5531825 100644 (file)
@@ -121,7 +121,13 @@ struct cmd_list_element
     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:  */
@@ -271,6 +277,16 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
                                                       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);
index 5904d33b85eddc1952cf645d2372d277bbdd3216..f967b0c3ebae30aea8df66a47dfa6d71ad573161 100644 (file)
@@ -345,7 +345,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
     }
   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);
 }
index 205fb903531636f09225b000cddae4ef751e211d..c7d7b5eeaaf8487ff4f25ab3ffbaaa253343f7f9 100644 (file)
@@ -127,7 +127,13 @@ struct cmd_list_element
     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:  */
@@ -277,6 +283,16 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
                                                       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);
index facd2dae83bfcaff7b96393cc88fdf22c03300e1..7acbd6eb5670493b2cd44174bf719b62cde975a2 100644 (file)
@@ -448,7 +448,7 @@ No arg means have no core file.  This command has been superseded by the\n\
                   "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 8f22ed61133215211c28d20699d45d4dd40eff60..5b49a4f5fe9c69fed3e40f0369a19692c71c9f73 100644 (file)
@@ -3875,19 +3875,19 @@ _initialize_cris_tdep (void)
   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 0104d8f3f6e92a53fca907913b74ee9a0dc1273c..1fd69be4c58f5c15327bc1881c7aa2ba758d66c7 100644 (file)
@@ -200,7 +200,7 @@ _initialize_demangler (void)
 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 d5e18eccafd6ef89687014e7d55b370471ae1919..222053425a95886fbe724a6c90bbc61f704282c5 100644 (file)
@@ -248,7 +248,7 @@ notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
 
 /* 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 @@ _initialize_infcmd (void)
 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 1b0eb7e3e066cbbd006a544d708cccd3c135882f..c935db86a7b978aaacaf53bd486c6f7dd266b46d 100644 (file)
@@ -4350,7 +4350,6 @@ A fork or vfork creates a new process.  follow-fork-mode can be:\n\
 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 @@ step == scheduler locked during every single-step operation.\n\
        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 eec99e5d7a7e4a0d4672dfb8ecbfb2a2a37c33dd..2641c38e0094b11cadfb5a42eae0f2be020f3cf5 100644 (file)
--- a/gdb/kod.c
+++ b/gdb/kod.c
@@ -224,6 +224,6 @@ _initialize_kod (void)
                   (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 c2db91cd301e553f4c4ab512e1c7d3ca92ccfb80..a9077a9695eec853e378716df2408b3027f1060e 100644 (file)
@@ -1555,8 +1555,8 @@ _initialize_language (void)
                     "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 @@ _initialize_language (void)
                     "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 @@ _initialize_language (void)
 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 67e7a278efb7830a67c5e619c2c62e81f15df961..59de6dc0a8188d388c480eb20dabdecf85373f7a 100644 (file)
@@ -790,7 +790,7 @@ passes without a response from the target, an error occurs.", &setlist),
                        "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 30079b58865ab03e1627f269c4be3abf02084ca2..efcc0e71c83cffbe5b865f505103499ac94b64b3 100644 (file)
@@ -4786,9 +4786,9 @@ This option can be set to one of:\n\
 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 @@ search.  The only need to set it is when debugging a stripped executable.",
                   &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 4cae8fd2e6264f5d6ff348ef2d06b30f828a478f..986691dc83ddda970895486287ef4aa299fd251f 100644 (file)
@@ -777,7 +777,7 @@ _initialize_proc_api (void)
                   "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 @@ _initialize_proc_api (void)
                   "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 deab83d28b69bfb1e1a4f75c8465f1815f9c3687..688024d7f0f64faf28b5b762a156891249737358 100644 (file)
@@ -675,7 +675,7 @@ add_packet_config_cmd (struct packet_config *config,
   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 @@ in a memory packet.\n",
                                     &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 e77c9c25d65423a3787fabb56aefc1b9093176f7..bbc237607dafa40f52c603806cdc2137972d222c 100644 (file)
@@ -3274,7 +3274,7 @@ for access from GDB.", &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.");
index 7552de7fbf75e3281895e0ff34087fe60298fa52..7a2f756d620270e89c0435a94c0b78169aa0204c 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -672,7 +672,16 @@ execute_command (char *p, int from_tty)
       /* 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_command (char *p, int from_tty)
        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 @@ init_main (void)
                       (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 @@ Without an argument, command line editing is enabled.  To edit, use\n\
 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 @@ Without an argument, saving is enabled.", &sethistlist),
                   "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 @@ ie. the number of previous commands to keep a record of.", &sethistlist);
 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 124419214276c094b3addc60748cebbf5c805548..1eb01ccb5427416c2107c70cff0223c134689889 100644 (file)
@@ -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 93989b911fcd2169d461144c7672d70e9fc2a742..34b660d9a87e08006dd051691b6969edebd32102 100644 (file)
@@ -2238,7 +2238,7 @@ initialize_utils (void)
                   "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 5f2c1762f4f83583c08a5ea99c6a37bdb44086c5..131769b67a4d64adde8598a56b21e32a9a6342f4 100644 (file)
@@ -1490,14 +1490,14 @@ _initialize_valprint (void)
                   "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 d931ddc23354eb82bd375b908c09211d3995280d..e37866c34a9578391a680eb545339194ceccc020 100644 (file)
@@ -1983,7 +1983,7 @@ _initialize_inftarg (void)
               (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