diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 29cff9e909..19893d3f1c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2005-02-20 Andrew Cagney + Use add_setshow_enum_cmd through out. + * arch-utils.c, charset.c, demangle.c, i386-tdep.c: Update. + * infrun.c, mips-tdep.c, osabi.c, serial.c, tui/tui-win.c: Update. + * mi/mi-main.c (captured_mi_execute_command): Use mi_cmd_interpreter_exec. diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 5ba08e9fdf..a8fa5caa9c 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -369,20 +369,23 @@ static const char *set_endian_string; /* Called by ``show endian''. */ static void -show_endian (char *args, int from_tty) +show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c, + const char *value) { if (target_byte_order_auto) if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) - printf_unfiltered (_("The target endianness is set automatically " - "(currently big endian)\n")); + fprintf_unfiltered (file, _("The target endianness is set automatically " + "(currently big endian)\n")); else - printf_unfiltered (_("The target endianness is set automatically " + fprintf_unfiltered (file, _("The target endianness is set automatically " "(currently little endian)\n")); else if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) - printf_unfiltered (_("The target is assumed to be big endian\n")); - else - printf_unfiltered (_("The target is assumed to be little endian\n")); + fprintf_unfiltered (file, + _("The target is assumed to be big endian\n")); + else + fprintf_unfiltered (file, + _("The target is assumed to be little endian\n")); } static void @@ -413,7 +416,7 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c) else internal_error (__FILE__, __LINE__, _("set_endian: bad value")); - show_endian (NULL, from_tty); + show_endian (gdb_stdout, from_tty, NULL, NULL); } /* Functions to manipulate the architecture of the target */ @@ -437,14 +440,17 @@ selected_architecture_name (void) argument. */ static void -show_architecture (char *args, int from_tty) +show_architecture (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) { const char *arch; arch = TARGET_ARCHITECTURE->printable_name; if (target_architecture_auto) - printf_filtered (_("The target architecture is set automatically (currently %s)\n"), arch); + fprintf_filtered (file, _("\ +The target architecture is set automatically (currently %s)\n"), arch); else - printf_filtered (_("The target architecture is assumed to be %s\n"), arch); + fprintf_filtered (file, _("\ +The target architecture is assumed to be %s\n"), arch); } @@ -472,7 +478,7 @@ set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c) printf_unfiltered (_("Architecture `%s' not recognized.\n"), set_architecture_string); } - show_architecture (NULL, from_tty); + show_architecture (gdb_stdout, from_tty, NULL, NULL); } /* Try to select a global architecture that matches "info". Return @@ -642,21 +648,13 @@ initialize_current_architecture (void) arches = xrealloc (arches, sizeof (char*) * (nr + 2)); arches[nr + 0] = "auto"; arches[nr + 1] = NULL; - /* FIXME: add_set_enum_cmd() uses an array of ``char *'' instead - of ``const char *''. We just happen to know that the casts are - safe. */ - c = add_set_enum_cmd ("architecture", class_support, - arches, &set_architecture_string, - _("Set architecture of target."), - &setlist); - set_cmd_sfunc (c, set_architecture); + add_setshow_enum_cmd ("architecture", class_support, + arches, &set_architecture_string, _("\ +Set architecture of target."), _("\ +Show architecture of target."), NULL, + set_architecture, show_architecture, + &setlist, &showlist); add_alias_cmd ("processor", "architecture", class_support, 1, &setlist); - /* Don't use set_from_show - need to print both auto/manual and - current setting. */ - /* FIXME: i18n: add_setshow_enum_cmd uses a print function so - fancy printing is possible. */ - add_cmd ("architecture", class_support, show_architecture, - _("Show the current target architecture"), &showlist); } } @@ -731,15 +729,10 @@ void _initialize_gdbarch_utils (void) { struct cmd_list_element *c; - c = add_set_enum_cmd ("endian", class_support, - endian_enum, &set_endian_string, - _("Set endianness of target."), - &setlist); - set_cmd_sfunc (c, set_endian); - /* Don't use set_from_show - need to print both auto/manual and - current setting. */ - /* FIXME: i18n: add_setshow_enum_cmd uses a print function so - fancy printing is possible. */ - add_cmd ("endian", class_support, show_endian, - _("Show the current byte-order"), &showlist); + add_setshow_enum_cmd ("endian", class_support, + endian_enum, &set_endian_string, _("\ +Set endianness of target."), _("\ +Show endianness of target."), NULL, + set_endian, show_endian, + &setlist, &showlist); } diff --git a/gdb/charset.c b/gdb/charset.c index 8e724a1512..53f9cabcce 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -1075,19 +1075,19 @@ set_target_charset_sfunc (char *charset, int from_tty, /* sfunc for the 'show charset' command. */ static void -show_charset (char *arg, int from_tty) +show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c, + const char *name) { if (current_host_charset == current_target_charset) - { - printf_filtered (_("The current host and target character set is `%s'.\n"), - host_charset ()); - } + fprintf_filtered (file, + _("The current host and target character set is `%s'.\n"), + host_charset ()); else { - printf_filtered (_("The current host character set is `%s'.\n"), - host_charset ()); - printf_filtered (_("The current target character set is `%s'.\n"), - target_charset ()); + fprintf_filtered (file, _("The current host character set is `%s'.\n"), + host_charset ()); + fprintf_filtered (file, _("The current target character set is `%s'.\n"), + target_charset ()); } } @@ -1218,60 +1218,43 @@ _initialize_charset (void) set_host_charset (host_charset_name); set_target_charset (target_charset_name); - new_cmd = add_set_enum_cmd ("charset", - class_support, - host_charset_enum, - &host_charset_name, - _("Set the host and target character sets.\n\ + add_setshow_enum_cmd ("charset", class_support, + host_charset_enum, &host_charset_name, _("\ +Set the host and target character sets."), _("\ +Show the host and target character sets."), _("\ The `host character set' is the one used by the system GDB is running on.\n\ The `target character set' is the one used by the program being debugged.\n\ You may only use supersets of ASCII for your host character set; GDB does\n\ not support any others.\n\ To see a list of the character sets GDB supports, type `set charset '."), - &setlist); + /* Note that the sfunc below needs to set + target_charset_name, because the 'set + charset' command sets two variables. */ + set_charset_sfunc, + show_charset, + &setlist, &showlist); - /* Note that the sfunc below needs to set target_charset_name, because - the 'set charset' command sets two variables. */ - set_cmd_sfunc (new_cmd, set_charset_sfunc); - /* Don't use set_from_show - need to print some extra info. */ - add_cmd ("charset", class_support, show_charset, - _("Show the host and target character sets.\n\ -The `host character set' is the one used by the system GDB is running on.\n\ -The `target character set' is the one used by the program being debugged.\n\ -You may only use supersets of ASCII for your host character set; GDB does\n\ -not support any others.\n\ -To see a list of the character sets GDB supports, type `set charset '."), - &showlist); - - - new_cmd = add_set_enum_cmd ("host-charset", - class_support, - host_charset_enum, - &host_charset_name, - _("Set the host character set.\n\ + add_setshow_enum_cmd ("host-charset", class_support, + host_charset_enum, &host_charset_name, _("\ +Set the host character set."), _("\ +Show the host character set."), _("\ The `host character set' is the one used by the system GDB is running on.\n\ You may only use supersets of ASCII for your host character set; GDB does\n\ not support any others.\n\ To see a list of the character sets GDB supports, type `set host-charset '."), - &setlist); + set_host_charset_sfunc, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); - set_cmd_sfunc (new_cmd, set_host_charset_sfunc); - - deprecated_add_show_from_set (new_cmd, &showlist); - - - - new_cmd = add_set_enum_cmd ("target-charset", - class_support, - target_charset_enum, - &target_charset_name, - _("Set the target character set.\n\ + add_setshow_enum_cmd ("target-charset", class_support, + target_charset_enum, &target_charset_name, _("\ +Set the target character set."), _("\ +Show the target character set."), _("\ The `target character set' is the one used by the program being debugged.\n\ GDB translates characters and strings between the host and target\n\ character sets as needed.\n\ To see a list of the character sets GDB supports, type `set target-charset'"), - &setlist); - - set_cmd_sfunc (new_cmd, set_target_charset_sfunc); - deprecated_add_show_from_set (new_cmd, &showlist); + set_target_charset_sfunc, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); } diff --git a/gdb/demangle.c b/gdb/demangle.c index 2e5df287ae..a95227b5a5 100644 --- a/gdb/demangle.c +++ b/gdb/demangle.c @@ -189,14 +189,19 @@ _initialize_demangler (void) demangling_style_names[i] = xstrdup (libiberty_demanglers[i].demangling_style_name); - set = add_set_enum_cmd ("demangle-style", class_support, - demangling_style_names, - (const char **) ¤t_demangling_style_string, - "Set the current C++ demangling style.\n\ -Use `set demangle-style' without arguments for a list of demangling styles.", - &setlist); - show = deprecated_add_show_from_set (set, &showlist); - set_cmd_sfunc (set, set_demangling_command); + /* FIXME: cagney/2005-02-20: The code implementing this variable are + malloc-ing and free-ing current_demangling_style_string when it + should instead just point to an element of + demangling_style_names. */ + add_setshow_enum_cmd ("demangle-style", class_support, + demangling_style_names, + (const char **) ¤t_demangling_style_string, _("\ +Set the current C++ demangling style."), _("\ +Show the current C++ demangling style."), _("\ +Use `set demangle-style' without arguments for a list of demangling styles."), + set_demangling_command, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); /* Set the default demangling style chosen at compilation time. */ set_demangling_style (DEFAULT_DEMANGLING_STYLE); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index fd0f5cfa55..240a8b5890 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2275,32 +2275,26 @@ _initialize_i386_tdep (void) register_gdbarch_init (bfd_arch_i386, i386_gdbarch_init); /* Add the variable that controls the disassembly flavor. */ - { - struct cmd_list_element *new_cmd; - - 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); - deprecated_add_show_from_set (new_cmd, &showlist); - } + add_setshow_enum_cmd ("disassembly-flavor", no_class, valid_flavors, + &disassembly_flavor, _("\ +Set the disassembly flavor."), _("\ +Show the disassembly flavor."), _("\ +The valid values are \"att\" and \"intel\", and the default value is \"att\"."), + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); /* Add the variable that controls the convention for returning structs. */ - { - struct cmd_list_element *new_cmd; - - new_cmd = add_set_enum_cmd ("struct-convention", no_class, - valid_conventions, - &struct_convention, "\ -Set the convention for returning small structs, valid values \ -are \"default\", \"pcc\" and \"reg\", and the default value is \"default\".", - &setlist); - deprecated_add_show_from_set (new_cmd, &showlist); - } + add_setshow_enum_cmd ("struct-convention", no_class, valid_conventions, + &struct_convention, _("\ +Set the convention for returning small structs."), _("\ +Show the convention for returning small structs."), _("\ +Valid values are \"default\", \"pcc\" and \"reg\", and the default value\n\ +is \"default\"."), + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, i386_coff_osabi_sniffer); diff --git a/gdb/infrun.c b/gdb/infrun.c index eb5fa1502a..4e0ca9d656 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3908,31 +3908,32 @@ to the user would be loading/unloading of a new library."), &setlist, &showlist); #endif - c = add_set_enum_cmd ("follow-fork-mode", - class_run, - follow_fork_mode_kind_names, &follow_fork_mode_string, - "Set debugger response to a program call of fork \ -or vfork.\n\ + add_setshow_enum_cmd ("follow-fork-mode", class_run, + follow_fork_mode_kind_names, + &follow_fork_mode_string, _("\ +Set debugger response to a program call of fork or vfork."), _("\ +Show debugger response to a program call of fork or vfork."), _("\ A fork or vfork creates a new process. follow-fork-mode can be:\n\ parent - the original process is debugged after a fork\n\ child - the new process is debugged after a fork\n\ The unfollowed process will continue to run.\n\ -By default, the debugger will follow the parent process.", &setlist); - deprecated_add_show_from_set (c, &showlist); +By default, the debugger will follow the parent process."), + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); - 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\ + add_setshow_enum_cmd ("scheduler-locking", class_run, + scheduler_enums, &scheduler_mode, _("\ +Set mode for locking scheduler during execution."), _("\ +Show mode for locking scheduler during execution."), _("\ off == no locking (threads may preempt at any time)\n\ on == full locking (no thread except the current thread may run)\n\ step == scheduler locked during every single-step operation.\n\ In this mode, no other thread may run during a step command.\n\ - Other threads may run while stepping over a function call ('next').", - &setlist); - - set_cmd_sfunc (c, set_schedlock_func); /* traps on target vector */ - deprecated_add_show_from_set (c, &showlist); + Other threads may run while stepping over a function call ('next')."), + set_schedlock_func, /* traps on target vector */ + NULL, /* FIXME: i18n: */ + &setlist, &showlist); add_setshow_boolean_cmd ("step-mode", class_run, &step_stop_if_no_debug, _("\ Set mode of the step operation."), _("\ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index a98c2315e4..c109ed2882 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -5210,16 +5210,21 @@ This option can be set to one of:\n\ &setmipscmdlist, &showmipscmdlist); /* Allow the user to override the ABI. */ - c = add_set_enum_cmd - ("abi", class_obscure, mips_abi_strings, &mips_abi_string, - "Set the ABI used by this program.\n" - "This option can be set to one of:\n" - " auto - the default ABI associated with the current binary\n" - " o32\n" - " o64\n" " n32\n" " n64\n" " eabi32\n" " eabi64", &setmipscmdlist); - set_cmd_sfunc (c, mips_abi_update); - add_cmd ("abi", class_obscure, show_mips_abi, - _("Show ABI in use by MIPS target"), &showmipscmdlist); + add_setshow_enum_cmd ("abi", class_obscure, mips_abi_strings, + &mips_abi_string, _("\ +Set the MIPS ABI used by this program."), _("\ +Show the MIPS ABI used by this program."), _("\ +This option can be set to one of:\n\ + auto - the default ABI associated with the current binary\n\ + o32\n\ + o64\n\ + n32\n\ + n64\n\ + eabi32\n\ + eabi64"), + mips_abi_update, + show_mips_abi, + &setmipscmdlist, &showmipscmdlist); /* Let the user turn off floating point and set the fence post for heuristic_proc_start. */ diff --git a/gdb/osabi.c b/gdb/osabi.c index 3c4cff00d7..698e941c0c 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -597,18 +597,20 @@ set_osabi (char *args, int from_tty, struct cmd_list_element *c) } static void -show_osabi (char *args, int from_tty) +show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c, + const char *value) { if (user_osabi_state == osabi_auto) - printf_filtered (_("The current OS ABI is \"auto\" (currently \"%s\").\n"), - gdbarch_osabi_name (gdbarch_osabi (current_gdbarch))); + fprintf_filtered (file, + _("The current OS ABI is \"auto\" (currently \"%s\").\n"), + gdbarch_osabi_name (gdbarch_osabi (current_gdbarch))); else - printf_filtered (_("The current OS ABI is \"%s\".\n"), - gdbarch_osabi_name (user_selected_osabi)); + fprintf_filtered (file, _("The current OS ABI is \"%s\".\n"), + gdbarch_osabi_name (user_selected_osabi)); if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN) - printf_filtered (_("The default OS ABI is \"%s\".\n"), - gdbarch_osabi_name (GDB_OSABI_DEFAULT)); + fprintf_filtered (file, _("The default OS ABI is \"%s\".\n"), + gdbarch_osabi_name (GDB_OSABI_DEFAULT)); } extern initialize_file_ftype _initialize_gdb_osabi; /* -Wmissing-prototype */ @@ -629,11 +631,12 @@ _initialize_gdb_osabi (void) generic_elf_osabi_sniffer); /* Register the "set osabi" command. */ - c = add_set_enum_cmd ("osabi", class_support, gdb_osabi_available_names, - &set_osabi_string, "Set OS ABI of target.", &setlist); - - set_cmd_sfunc (c, set_osabi); - add_cmd ("osabi", class_support, show_osabi, _("Show OS/ABI of target."), - &showlist); + add_setshow_enum_cmd ("osabi", class_support, gdb_osabi_available_names, + &set_osabi_string, _("\ +Set OS ABI of target."), _("\ +Show OS ABI of target."), NULL, + set_osabi, + show_osabi, + &setlist, &showlist); user_osabi_state = osabi_auto; } diff --git a/gdb/serial.c b/gdb/serial.c index cb8d88d5be..3ad08caef6 100644 --- a/gdb/serial.c +++ b/gdb/serial.c @@ -695,12 +695,13 @@ by gdbserver."), NULL, /* FIXME: i18n: */ &setlist, &showlist); - deprecated_add_show_from_set - (add_set_enum_cmd ("remotelogbase", no_class, - logbase_enums, &serial_logbase, - "Set numerical base for remote session logging", - &setlist), - &showlist); + add_setshow_enum_cmd ("remotelogbase", no_class, logbase_enums, + &serial_logbase, _("\ +Set numerical base for remote session logging"), _("\ +Show numerical base for remote session logging"), NULL, + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); add_setshow_zinteger_cmd ("serial", class_maintenance, &global_serial_debug_p, _("\ diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index b171893863..d65e685498 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -374,46 +374,49 @@ XDB compatibility command for setting the height of a command window.\n\ Usage: w <#lines>\n")); /* Define the tui control variables. */ - c = add_set_enum_cmd - ("border-kind", no_class, - tui_border_kind_enums, &tui_border_kind, - "Set the kind of border for TUI windows.\n" - "This variable controls the border of TUI windows:\n" - "space use a white space\n" - "ascii use ascii characters + - | for the border\n" - "acs use the Alternate Character Set\n", - &tui_setlist); - deprecated_add_show_from_set (c, &tui_showlist); + add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums, + &tui_border_kind, _("\ +Set the kind of border for TUI windows."), _("\ +Show the kind of border for TUI windows."), _("\ +This variable controls the border of TUI windows:\n\ +space use a white space\n\ +ascii use ascii characters + - | for the border\n\ +acs use the Alternate Character Set"), + NULL, + NULL, /* FIXME: i18n: */ + &tui_setlist, &tui_showlist); - c = add_set_enum_cmd - ("border-mode", no_class, - tui_border_mode_enums, &tui_border_mode, - "Set the attribute mode to use for the TUI window borders.\n" - "This variable controls the attributes to use for the window borders:\n" - "normal normal display\n" - "standout use highlight mode of terminal\n" - "reverse use reverse video mode\n" - "half use half bright\n" - "half-standout use half bright and standout mode\n" - "bold use extra bright or bold\n" - "bold-standout use extra bright or bold with standout mode\n", - &tui_setlist); - deprecated_add_show_from_set (c, &tui_showlist); + add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums, + &tui_border_mode, _("\ +Set the attribute mode to use for the TUI window borders."), _("\ +Show the attribute mode to use for the TUI window borders."), _("\ +This variable controls the attributes to use for the window borders:\n\ +normal normal display\n\ +standout use highlight mode of terminal\n\ +reverse use reverse video mode\n\ +half use half bright\n\ +half-standout use half bright and standout mode\n\ +bold use extra bright or bold\n\ +bold-standout use extra bright or bold with standout mode"), + NULL, + NULL, /* FIXME: i18n: */ + &tui_setlist, &tui_showlist); - c = add_set_enum_cmd - ("active-border-mode", no_class, - tui_border_mode_enums, &tui_active_border_mode, - "Set the attribute mode to use for the active TUI window border.\n" - "This variable controls the attributes to use for the active window border:\n" - "normal normal display\n" - "standout use highlight mode of terminal\n" - "reverse use reverse video mode\n" - "half use half bright\n" - "half-standout use half bright and standout mode\n" - "bold use extra bright or bold\n" - "bold-standout use extra bright or bold with standout mode\n", - &tui_setlist); - deprecated_add_show_from_set (c, &tui_showlist); + add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums, + &tui_active_border_mode, _("\ +Set the attribute mode to use for the active TUI window border."), _("\ +Show the attribute mode to use for the active TUI window border."), _("\ +This variable controls the attributes to use for the active window border:\n\ +normal normal display\n\ +standout use highlight mode of terminal\n\ +reverse use reverse video mode\n\ +half use half bright\n\ +half-standout use half bright and standout mode\n\ +bold use extra bright or bold\n\ +bold-standout use extra bright or bold with standout mode"), + NULL, + NULL, /* FIXME: i18n: */ + &tui_setlist, &tui_showlist); } /* Update gdb's knowledge of the terminal size. */