[RFA/command] Change add_set_enum_cmd() signature

Andrew Cagney ac131313@cygnus.com
Sun May 14 17:03:00 GMT 2000


Hello,

The attached patch ``fixes'' the add_set_enum_cmd() function signature. 
Some reason (lost in the depths of time) it took a ``char *var''
parameter when it should have taken ``char **var''.

As a follow-on, it also updates the add_set_cmd() and ``struct command''
so that they use ``void *var'' instead of ``char *var''.

Ok?
	Andrew
Mon May 15 09:32:31 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* command.h (add_set_cmd): Change VAR parameter to void pointer.
	(add_set_enum_cmd): Change VAR parameter to char pointer pointer.
	(struct command): Change member VAR to void pointer.
	* command.c (add_set_cmd, add_set_enum_cmd): Update.
	
	* remote.c (add_packet_config_cmd), mips-tdep.c
 	(_initialize_mips_tdep), infrun.c (_initialize_infrun),
 	i386-tdep.c (_initialize_i386_tdep), arm-tdep.c
 	(_initialize_arm_tdep): Update VAR parameter to add_set_enum_cmd.

Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.5
diff -p -r1.5 arm-tdep.c
*** arm-tdep.c	2000/03/24 21:33:35	1.5
--- arm-tdep.c	2000/05/14 23:55:18
*************** The valid values are:\n");
*** 2083,2089 ****
    /* Add the disassembly-flavor command */
    new_cmd = add_set_enum_cmd ("disassembly-flavor", no_class,
  			      valid_flavors,
! 			      (char *) &disassembly_flavor,
  			      helptext,
  			      &setlist);
    new_cmd->function.sfunc = set_disassembly_flavor_sfunc;
--- 2083,2089 ----
    /* Add the disassembly-flavor command */
    new_cmd = add_set_enum_cmd ("disassembly-flavor", no_class,
  			      valid_flavors,
! 			      &disassembly_flavor,
  			      helptext,
  			      &setlist);
    new_cmd->function.sfunc = set_disassembly_flavor_sfunc;
Index: command.c
===================================================================
RCS file: /cvs/src/src/gdb/command.c,v
retrieving revision 1.7
diff -p -r1.7 command.c
*** command.c	2000/04/21 05:21:55	1.7
--- command.c	2000/05/14 23:55:22
*************** empty_sfunc (args, from_tty, c)
*** 285,297 ****
     DOC is the documentation string.  */
  
  struct cmd_list_element *
! add_set_cmd (name, class, var_type, var, doc, list)
!      char *name;
!      enum command_class class;
!      var_types var_type;
!      char *var;
!      char *doc;
!      struct cmd_list_element **list;
  {
    struct cmd_list_element *c
    = add_cmd (name, class, NO_FUNCTION, doc, list);
--- 285,296 ----
     DOC is the documentation string.  */
  
  struct cmd_list_element *
! add_set_cmd (char *name,
! 	     enum command_class class,
! 	     var_types var_type,
! 	     void *var,
! 	     char *doc,
! 	     struct cmd_list_element **list)
  {
    struct cmd_list_element *c
    = add_cmd (name, class, NO_FUNCTION, doc, list);
*************** add_set_cmd (name, class, var_type, var,
*** 314,326 ****
     DOC is the documentation string.  */
  
  struct cmd_list_element *
! add_set_enum_cmd (name, class, enumlist, var, doc, list)
!      char *name;
!      enum command_class class;
!      char *enumlist[];
!      char *var;
!      char *doc;
!      struct cmd_list_element **list;
  {
    struct cmd_list_element *c
    = add_set_cmd (name, class, var_enum, var, doc, list);
--- 313,324 ----
     DOC is the documentation string.  */
  
  struct cmd_list_element *
! add_set_enum_cmd (char *name,
! 		  enum command_class class,
! 		  char *enumlist[],
! 		  char **var,
! 		  char *doc,
! 		  struct cmd_list_element **list)
  {
    struct cmd_list_element *c
    = add_set_cmd (name, class, var_enum, var, doc, list);
Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.6
diff -p -r1.6 command.h
*** command.h	2000/04/21 05:21:55	1.6
--- command.h	2000/05/14 23:55:22
*************** struct cmd_list_element
*** 194,200 ****
  
      /* Pointer to variable affected by "set" and "show".  Doesn't matter
         if type is not_set.  */
!     char *var;
  
      /* What kind of variable is *VAR?  */
      var_types var_type;
--- 194,200 ----
  
      /* Pointer to variable affected by "set" and "show".  Doesn't matter
         if type is not_set.  */
!     void *var;
  
      /* What kind of variable is *VAR?  */
      var_types var_type;
*************** extern void help_list (struct cmd_list_e
*** 284,296 ****
  extern void help_cmd_list (struct cmd_list_element *, enum command_class,
  			   char *, int, struct ui_file *);
  
! extern struct cmd_list_element *
!   add_set_cmd PARAMS ((char *, enum command_class, var_types, char *, char *,
! 		       struct cmd_list_element **));
! 
! extern struct cmd_list_element *
!   add_set_enum_cmd PARAMS ((char *name, enum command_class, char *list[],
! 		       char *var, char *doc, struct cmd_list_element ** c));
  
  extern struct cmd_list_element *
    add_show_from_set PARAMS ((struct cmd_list_element *,
--- 284,301 ----
  extern void help_cmd_list (struct cmd_list_element *, enum command_class,
  			   char *, int, struct ui_file *);
  
! extern struct cmd_list_element *add_set_cmd (char *name, enum
! 					     command_class class,
! 					     var_types var_type, void *var,
! 					     char *doc,
! 					     struct cmd_list_element **list);
! 
! extern struct cmd_list_element *add_set_enum_cmd (char *name,
! 						  enum command_class class,
! 						  char *enumlist[],
! 						  char **var,
! 						  char *doc,
! 						  struct cmd_list_element **list);
  
  extern struct cmd_list_element *
    add_show_from_set PARAMS ((struct cmd_list_element *,
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.9
diff -p -r1.9 i386-tdep.c
*** i386-tdep.c	2000/03/26 21:21:50	1.9
--- i386-tdep.c	2000/05/14 23:55:25
*************** _initialize_i386_tdep ()
*** 938,944 ****
  
      new_cmd = add_set_enum_cmd ("disassembly-flavor", no_class,
  				valid_flavors,
! 				(char *) &disassembly_flavor,
  				"Set the disassembly flavor, the valid values are \"att\" and \"intel\", \
  and the default value is \"att\".",
  				&setlist);
--- 938,944 ----
  
      new_cmd = add_set_enum_cmd ("disassembly-flavor", no_class,
  				valid_flavors,
! 				&disassembly_flavor,
  				"Set the disassembly flavor, the valid values are \"att\" and \"intel\", \
  and the default value is \"att\".",
  				&setlist);
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.12
diff -p -r1.12 infrun.c
*** infrun.c	2000/05/04 17:32:49	1.12
--- infrun.c	2000/05/14 23:55:36
*************** to the user would be loading/unloading o
*** 4267,4273 ****
    c = add_set_enum_cmd ("follow-fork-mode",
  			class_run,
  			follow_fork_mode_kind_names,
! 			(char *) &follow_fork_mode_string,
  /* ??rehrauer:  The "both" option is broken, by what may be a 10.20
     kernel problem.  It's also not terribly useful without a GUI to
     help the user drive two debuggers.  So for now, I'm disabling
--- 4267,4273 ----
    c = add_set_enum_cmd ("follow-fork-mode",
  			class_run,
  			follow_fork_mode_kind_names,
! 			&follow_fork_mode_string,
  /* ??rehrauer:  The "both" option is broken, by what may be a 10.20
     kernel problem.  It's also not terribly useful without a GUI to
     help the user drive two debuggers.  So for now, I'm disabling
*************** By default, the debugger will follow the
*** 4302,4308 ****
  
    c = add_set_enum_cmd ("scheduler-locking", class_run,
  			scheduler_enums,	/* array of string names */
! 			(char *) &scheduler_mode,	/* current mode  */
  			"Set mode for locking scheduler during execution.\n\
  off  == no locking (threads may preempt at any time)\n\
  on   == full locking (no thread except the current thread may run)\n\
--- 4302,4308 ----
  
    c = add_set_enum_cmd ("scheduler-locking", class_run,
  			scheduler_enums,	/* array of string names */
! 			&scheduler_mode,	/* current mode  */
  			"Set mode for locking scheduler during execution.\n\
  off  == no locking (threads may preempt at any time)\n\
  on   == full locking (no thread except the current thread may run)\n\
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.9
diff -p -r1.9 mips-tdep.c
*** mips-tdep.c	2000/05/12 09:21:30	1.9
--- mips-tdep.c	2000/05/14 23:55:45
*************** _initialize_mips_tdep ()
*** 4153,4161 ****
  
    /* Allow the user to override the saved register size. */
    add_show_from_set (add_set_enum_cmd ("saved-gpreg-size",
! 				  class_obscure,
! 			          size_enums,
! 				  (char *) &mips_saved_regsize_string, "\
  Set size of general purpose registers saved on the stack.\n\
  This option can be set to one of:\n\
    32    - Force GDB to treat saved GP registers as 32-bit\n\
--- 4153,4161 ----
  
    /* Allow the user to override the saved register size. */
    add_show_from_set (add_set_enum_cmd ("saved-gpreg-size",
! 				       class_obscure,
! 				       size_enums,
! 				       &mips_saved_regsize_string, "\
  Set size of general purpose registers saved on the stack.\n\
  This option can be set to one of:\n\
    32    - Force GDB to treat saved GP registers as 32-bit\n\
*************** This option can be set to one of:\n\
*** 4163,4176 ****
    auto  - Allow GDB to use the target's default setting or autodetect the\n\
            saved GP register size from information contained in the executable.\n\
            (default: auto)",
! 				  &setmipscmdlist),
  		     &showmipscmdlist);
  
    /* Allow the user to override the argument stack size. */
    add_show_from_set (add_set_enum_cmd ("stack-arg-size",
  				       class_obscure,
  				       size_enums,
! 				       (char *) &mips_stack_argsize_string, "\
  Set the amount of stack space reserved for each argument.\n\
  This option can be set to one of:\n\
    32    - Force GDB to allocate 32-bit chunks per argument\n\
--- 4163,4176 ----
    auto  - Allow GDB to use the target's default setting or autodetect the\n\
            saved GP register size from information contained in the executable.\n\
            (default: auto)",
! 				       &setmipscmdlist),
  		     &showmipscmdlist);
  
    /* Allow the user to override the argument stack size. */
    add_show_from_set (add_set_enum_cmd ("stack-arg-size",
  				       class_obscure,
  				       size_enums,
! 				       &mips_stack_argsize_string, "\
  Set the amount of stack space reserved for each argument.\n\
  This option can be set to one of:\n\
    32    - Force GDB to allocate 32-bit chunks per argument\n\
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.9
diff -p -r1.9 remote.c
*** remote.c	2000/05/04 16:52:34	1.9
--- remote.c	2000/05/14 23:55:56
*************** add_packet_config_cmd (config, name, tit
*** 624,630 ****
    asprintf (&full_name, "%s-packet", name);
    c = add_set_enum_cmd (full_name,
  			class_obscure, packet_support_enums,
! 			(char *) &config->state,
  			set_doc, setlist);
    c->function.sfunc = set_func;
    add_cmd (full_name, class_obscure, show_func, show_doc, showlist);
--- 624,630 ----
    asprintf (&full_name, "%s-packet", name);
    c = add_set_enum_cmd (full_name,
  			class_obscure, packet_support_enums,
! 			&config->state,
  			set_doc, setlist);
    c->function.sfunc = set_func;
    add_cmd (full_name, class_obscure, show_func, show_doc, showlist);
Index: serial.c
===================================================================
RCS file: /cvs/src/src/gdb/serial.c,v
retrieving revision 1.2
diff -p -r1.2 serial.c
*** serial.c	2000/03/28 02:25:14	1.2
--- serial.c	2000/05/14 23:55:58
*************** by gdbserver.",
*** 667,673 ****
  
    add_show_from_set
      (add_set_enum_cmd ("remotelogbase", no_class,
! 		       logbase_enums, (char *) &serial_logbase,
  		       "Set numerical base for remote session logging",
  		       &setlist),
       &showlist);
--- 667,673 ----
  
    add_show_from_set
      (add_set_enum_cmd ("remotelogbase", no_class,
! 		       logbase_enums, &serial_logbase,
  		       "Set numerical base for remote session logging",
  		       &setlist),
       &showlist);


More information about the Gdb-patches mailing list