diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 694 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.h | 8 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 750 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 30 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 209 | ||||
-rw-r--r-- | gdb/cli/cli-interp.c | 144 | ||||
-rw-r--r-- | gdb/cli/cli-interp.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-logging.c | 130 | ||||
-rw-r--r-- | gdb/cli/cli-option.c | 169 | ||||
-rw-r--r-- | gdb/cli/cli-option.h | 148 | ||||
-rw-r--r-- | gdb/cli/cli-script.c | 235 | ||||
-rw-r--r-- | gdb/cli/cli-script.h | 60 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 96 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.h | 6 | ||||
-rw-r--r-- | gdb/cli/cli-style.c | 202 | ||||
-rw-r--r-- | gdb/cli/cli-utils.c | 66 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 21 |
17 files changed, 1334 insertions, 1636 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 6c0d780..6f3a2b1 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -21,17 +21,17 @@ #include "arch-utils.h" #include "readline/tilde.h" #include "completer.h" -#include "target.h" /* For baud_rate, remote_debug and remote_timeout. */ -#include "gdbsupport/gdb_wait.h" /* For shell escape implementation. */ +#include "target.h" /* For baud_rate, remote_debug and remote_timeout. */ +#include "gdbsupport/gdb_wait.h" /* For shell escape implementation. */ #include "gdbcmd.h" -#include "gdbsupport/gdb_regex.h" /* Used by apropos_command. */ +#include "gdbsupport/gdb_regex.h" /* Used by apropos_command. */ #include "gdb_vfork.h" #include "linespec.h" #include "expression.h" #include "frame.h" #include "value.h" #include "language.h" -#include "filenames.h" /* For DOSish file names. */ +#include "filenames.h" /* For DOSish file names. */ #include "objfiles.h" #include "source.h" #include "disasm.h" @@ -57,7 +57,7 @@ #include "gdbsupport/gdb_tilde_expand.h" #ifdef TUI -#include "tui/tui.h" /* For tui_active et.al. */ +#include "tui/tui.h" /* For tui_active et.al. */ #endif #include <fcntl.h> @@ -74,7 +74,6 @@ static void ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals, static void filter_sals (std::vector<symtab_and_line> &); - /* See cli-cmds.h. */ unsigned int max_user_call_depth = 1024; @@ -176,22 +175,17 @@ struct cmd_list_element *showsourcelist; int source_verbose = 0; bool trace_commands = false; - + /* 'script-extension' option support. */ static const char script_ext_off[] = "off"; static const char script_ext_soft[] = "soft"; static const char script_ext_strict[] = "strict"; -static const char *const script_ext_enums[] = { - script_ext_off, - script_ext_soft, - script_ext_strict, - NULL -}; +static const char *const script_ext_enums[] + = { script_ext_off, script_ext_soft, script_ext_strict, NULL }; static const char *script_ext_mode = script_ext_soft; - /* User-controllable flag to suppress event notification on CLI. */ @@ -203,7 +197,7 @@ static bool user_wants_cli_suppress_notification = false; void error_no_arg (const char *why) { - error (_("Argument required (%s)."), why); + error (_ ("Argument required (%s)."), why); } /* This implements the "info" prefix command. Normally such commands @@ -220,29 +214,29 @@ info_command (const char *arg, int from_tty) /* See cli/cli-cmds.h. */ void -with_command_1 (const char *set_cmd_prefix, - cmd_list_element *setlist, const char *args, int from_tty) +with_command_1 (const char *set_cmd_prefix, cmd_list_element *setlist, + const char *args, int from_tty) { if (args == nullptr) - error (_("Missing arguments.")); + error (_ ("Missing arguments.")); const char *delim = strstr (args, "--"); const char *nested_cmd = nullptr; if (delim == args) - error (_("Missing setting before '--' delimiter")); + error (_ ("Missing setting before '--' delimiter")); if (delim == nullptr || *skip_spaces (&delim[2]) == '\0') nested_cmd = repeat_previous (); - cmd_list_element *set_cmd = lookup_cmd (&args, setlist, set_cmd_prefix, - nullptr, - /*allow_unknown=*/ 0, - /*ignore_help_classes=*/ 1); + cmd_list_element *set_cmd + = lookup_cmd (&args, setlist, set_cmd_prefix, nullptr, + /*allow_unknown=*/0, + /*ignore_help_classes=*/1); gdb_assert (set_cmd != nullptr); if (!set_cmd->var.has_value ()) - error (_("Cannot use this setting with the \"with\" command")); + error (_ ("Cannot use this setting with the \"with\" command")); std::string temp_value = (delim == nullptr ? args : std::string (args, delim - args)); @@ -274,7 +268,7 @@ with_command_1 (const char *set_cmd_prefix, } catch (const gdb_exception &ex2) { - warning (_("Couldn't restore setting: %s"), ex2.what ()); + warning (_ ("Couldn't restore setting: %s"), ex2.what ()); } throw; @@ -288,8 +282,7 @@ with_command_1 (const char *set_cmd_prefix, void with_command_completer_1 (const char *set_cmd_prefix, - completion_tracker &tracker, - const char *text) + completion_tracker &tracker, const char *text) { tracker.set_use_custom_word_point (true); @@ -297,9 +290,7 @@ with_command_completer_1 (const char *set_cmd_prefix, /* If we're still not past the "--" delimiter, complete the "with" command as if it was a "set" command. */ - if (delim == text - || delim == nullptr - || !isspace (delim[-1]) + if (delim == text || delim == nullptr || !isspace (delim[-1]) || !(isspace (delim[2]) || delim[2] == '\0')) { std::string new_text = std::string (set_cmd_prefix) + text; @@ -326,10 +317,10 @@ with_command (const char *args, int from_tty) static void with_command_completer (struct cmd_list_element *ignore, - completion_tracker &tracker, - const char *text, const char * /*word*/) + completion_tracker &tracker, const char *text, + const char * /*word*/) { - with_command_completer_1 ("set ", tracker, text); + with_command_completer_1 ("set ", tracker, text); } /* Look up the contents of TEXT as a command usable with default args. @@ -346,13 +337,13 @@ lookup_cmd_for_default_args (const char **text, struct cmd_list_element *lcmd; if (*text == nullptr || skip_spaces (*text) == nullptr) - error (_("ALIAS missing.")); + error (_ ("ALIAS missing.")); /* We first use lookup_cmd to verify TEXT unambiguously identifies a command. */ lcmd = lookup_cmd (text, cmdlist, "", NULL, - /*allow_unknown=*/ 0, - /*ignore_help_classes=*/ 1); + /*allow_unknown=*/0, + /*ignore_help_classes=*/1); /* Note that we accept default args for prefix commands, as a prefix command can also be a valid usable @@ -369,9 +360,8 @@ lookup_cmd_for_default_args (const char **text, has specified an alias, and find the possible prefix_cmd of cmd. */ struct cmd_list_element *alias, *cmd; - lookup_cmd_composition - (std::string (orig_text, *text - orig_text).c_str (), - &alias, prefix_cmd, &cmd); + lookup_cmd_composition (std::string (orig_text, *text - orig_text).c_str (), + &alias, prefix_cmd, &cmd); gdb_assert (cmd != nullptr); gdb_assert (cmd == lcmd); if (alias != nullptr) @@ -388,7 +378,6 @@ help_command (const char *command, int from_tty) { help_cmd (command, gdb_stdout); } - /* Note: The "complete" command is used by Emacs to implement completion. [Is that why this function writes output with *_unfiltered?] */ @@ -404,8 +393,8 @@ complete_command (const char *arg, int from_tty) be able to handle this. */ if (!current_uiout->is_mi_like_p ()) { - printf_unfiltered (_("max-completions is zero," - " completion is disabled.\n")); + printf_unfiltered (_ ("max-completions is zero," + " completion is disabled.\n")); } return; } @@ -423,15 +412,15 @@ complete_command (const char *arg, int from_tty) std::string arg_prefix (arg, word - arg); if (result.number_matches == 1) - printf_unfiltered ("%s%s\n", arg_prefix.c_str (), result.match_list[0]); + printf_unfiltered ("%s%s\n", arg_prefix.c_str (), + result.match_list[0]); else { result.sort_match_list (); for (size_t i = 0; i < result.number_matches; i++) { - printf_unfiltered ("%s%s", - arg_prefix.c_str (), + printf_unfiltered ("%s%s", arg_prefix.c_str (), result.match_list[i + 1]); if (quote_char) printf_unfiltered ("%c", quote_char); @@ -443,8 +432,7 @@ complete_command (const char *arg, int from_tty) { /* ARG_PREFIX and WORD are included in the output so that emacs will include the message in the output. */ - printf_unfiltered (_("%s%s %s\n"), - arg_prefix.c_str (), word, + printf_unfiltered (_ ("%s%s %s\n"), arg_prefix.c_str (), word, get_max_completions_reached_message ()); } } @@ -486,7 +474,7 @@ quit_command (const char *args, int from_tty) } if (!quit_confirm ()) - error (_("Not confirmed.")); + error (_ ("Not confirmed.")); try { @@ -510,23 +498,21 @@ static void pwd_command (const char *args, int from_tty) { if (args) - error (_("The \"pwd\" command does not take an argument: %s"), args); + error (_ ("The \"pwd\" command does not take an argument: %s"), args); gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0)); if (cwd == NULL) - error (_("Error finding name of working directory: %s"), + error (_ ("Error finding name of working directory: %s"), safe_strerror (errno)); if (strcmp (cwd.get (), current_directory) != 0) - gdb_printf (_("Working directory %ps\n (canonically %ps).\n"), - styled_string (file_name_style.style (), - current_directory), + gdb_printf (_ ("Working directory %ps\n (canonically %ps).\n"), + styled_string (file_name_style.style (), current_directory), styled_string (file_name_style.style (), cwd.get ())); else - gdb_printf (_("Working directory %ps.\n"), - styled_string (file_name_style.style (), - current_directory)); + gdb_printf (_ ("Working directory %ps.\n"), + styled_string (file_name_style.style (), current_directory)); } void @@ -541,8 +527,8 @@ cd_command (const char *dir, int from_tty) repeat might be useful but is more likely to be a mistake. */ dont_repeat (); - gdb::unique_xmalloc_ptr<char> dir_holder - (tilde_expand (dir != NULL ? dir : "~")); + gdb::unique_xmalloc_ptr<char> dir_holder (tilde_expand (dir != NULL ? dir + : "~")); dir = dir_holder.get (); if (chdir (dir) < 0) @@ -561,11 +547,11 @@ cd_command (const char *dir, int from_tty) { /* Remove the trailing slash unless this is a root directory (including a drive letter on non-Unix systems). */ - if (!(len == 1) /* "/" */ + if (!(len == 1) /* "/" */ #ifdef HAVE_DOS_BASED_FILE_SYSTEM && !(len == 3 && dir[1] == ':') /* "d:/" */ #endif - ) + ) len--; } @@ -578,8 +564,8 @@ cd_command (const char *dir, int from_tty) else { if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])) - current_directory = concat (current_directory, dir_holder.get (), - (char *) NULL); + current_directory + = concat (current_directory, dir_holder.get (), (char *) NULL); else current_directory = concat (current_directory, SLASH_STRING, dir_holder.get (), (char *) NULL); @@ -632,15 +618,14 @@ cd_command (const char *dir, int from_tty) if (from_tty) pwd_command ((char *) 0, 1); } - + /* Show the current value of the 'script-extension' option. */ static void show_script_ext_mode (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) + struct cmd_list_element *c, const char *value) { - gdb_printf (file, - _("Script filename extension recognition is \"%s\".\n"), + gdb_printf (file, _ ("Script filename extension recognition is \"%s\".\n"), value); } @@ -668,8 +653,8 @@ find_and_open_script (const char *script_file, int search_path) /* Search for and open 'file' on the search path used for source files. Put the full location in *FULL_PATHP. */ gdb::unique_xmalloc_ptr<char> full_path; - fd = openp (source_path.c_str (), search_flags, - file.get (), O_RDONLY, &full_path); + fd = openp (source_path.c_str (), search_flags, file.get (), O_RDONLY, + &full_path); if (fd == -1) return opened; @@ -708,8 +693,7 @@ source_script_from_stream (FILE *stream, const char *file, { if (ext_lang_present_p (extlang)) { - script_sourcer_func *sourcer - = ext_lang_script_sourcer (extlang); + script_sourcer_func *sourcer = ext_lang_script_sourcer (extlang); gdb_assert (sourcer != NULL); sourcer (extlang, stream, file_to_open); @@ -736,9 +720,8 @@ source_script_from_stream (FILE *stream, const char *file, static void source_script_with_search (const char *file, int from_tty, int search_path) { - if (file == NULL || *file == 0) - error (_("source command requires file name of file to source.")); + error (_ ("source command requires file name of file to source.")); gdb::optional<open_script> opened = find_and_open_script (file, search_path); if (!opened) @@ -831,7 +814,6 @@ source_command (const char *args, int from_tty) source_script_with_search (file, from_tty, search_path); } - static void echo_command (const char *text, int from_tty) { @@ -890,14 +872,14 @@ exit_status_set_internal_vars (int exit_status) else if (WIFSIGNALED (exit_status)) set_internalvar_integer (var_signal, WTERMSIG (exit_status)); else - warning (_("unexpected shell command exit status %d"), exit_status); + warning (_ ("unexpected shell command exit status %d"), exit_status); } static void shell_escape (const char *arg, int from_tty) { -#if defined(CANT_FORK) || \ - (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK)) +#if defined(CANT_FORK) \ + || (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK)) /* If ARG is NULL, they want an inferior shell, but `system' just reports if the shell is available when passed a NULL arg. */ int rc = system (arg ? arg : ""); @@ -916,7 +898,7 @@ shell_escape (const char *arg, int from_tty) chdir (current_directory); #endif exit_status_set_internal_vars (rc); -#else /* Can fork. */ +#else /* Can fork. */ int status, pid; if ((pid = vfork ()) == 0) @@ -941,7 +923,7 @@ shell_escape (const char *arg, int from_tty) if (pid != -1) waitpid (pid, &status, 0); else - error (_("Fork failed")); + error (_ ("Fork failed")); exit_status_set_internal_vars (status); #endif /* Can fork. */ } @@ -974,7 +956,7 @@ edit_command (const char *arg, int from_tty) if (arg == 0) { if (sal.symtab == 0) - error (_("No default source file yet.")); + error (_ ("No default source file yet.")); sal.line += get_lines_to_list () / 2; } else @@ -983,15 +965,14 @@ edit_command (const char *arg, int from_tty) /* Now should only be one argument -- decode it in SAL. */ arg1 = arg; - location_spec_up locspec = string_to_location_spec (&arg1, - current_language); + location_spec_up locspec + = string_to_location_spec (&arg1, current_language); if (*arg1) - error (_("Junk at end of line specification.")); + error (_ ("Junk at end of line specification.")); - std::vector<symtab_and_line> sals = decode_line_1 (locspec.get (), - DECODE_LINE_LIST_MODE, - NULL, NULL, 0); + std::vector<symtab_and_line> sals + = decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); filter_sals (sals); if (sals.empty ()) @@ -1001,8 +982,7 @@ edit_command (const char *arg, int from_tty) } if (sals.size () > 1) { - ambiguous_line_spec (sals, - _("Specified line is ambiguous:\n")); + ambiguous_line_spec (sals, _ ("Specified line is ambiguous:\n")); return; } @@ -1017,29 +997,25 @@ edit_command (const char *arg, int from_tty) struct gdbarch *gdbarch; if (sal.symtab == 0) - error (_("No source file for address %s."), + error (_ ("No source file for address %s."), paddress (get_current_arch (), sal.pc)); gdbarch = sal.symtab->compunit ()->objfile ()->arch (); sym = find_pc_function (sal.pc); if (sym) - gdb_printf ("%s is in %s (%s:%d).\n", - paddress (gdbarch, sal.pc), + gdb_printf ("%s is in %s (%s:%d).\n", paddress (gdbarch, sal.pc), sym->print_name (), - symtab_to_filename_for_display (sal.symtab), - sal.line); + symtab_to_filename_for_display (sal.symtab), sal.line); else - gdb_printf ("%s is at %s:%d.\n", - paddress (gdbarch, sal.pc), - symtab_to_filename_for_display (sal.symtab), - sal.line); + gdb_printf ("%s is at %s:%d.\n", paddress (gdbarch, sal.pc), + symtab_to_filename_for_display (sal.symtab), sal.line); } /* If what was given does not imply a symtab, it must be an undebuggable symbol which means no source code. */ if (sal.symtab == 0) - error (_("No line number known for %s."), arg); + error (_ ("No line number known for %s."), arg); } if ((editor = getenv ("EDITOR")) == NULL) @@ -1068,7 +1044,7 @@ static const gdb::option::option_def pipe_cmd_option_defs[] = { "d", [] (pipe_cmd_opts *opts) { return &opts->delimiter; }, nullptr, - N_("Indicates to use the specified delimiter string to separate\n\ + N_ ("Indicates to use the specified delimiter string to separate\n\ COMMAND from SHELL_COMMAND, in alternative to |. This is useful in\n\ case COMMAND contains a | character."), }, @@ -1081,7 +1057,7 @@ case COMMAND contains a | character."), static inline gdb::option::option_def_group make_pipe_cmd_options_def_group (pipe_cmd_opts *opts) { - return {{pipe_cmd_option_defs}, opts}; + return { { pipe_cmd_option_defs }, opts }; } /* Implementation of the "pipe" command. */ @@ -1092,8 +1068,8 @@ pipe_command (const char *arg, int from_tty) pipe_cmd_opts opts; auto grp = make_pipe_cmd_options_def_group (&opts); - gdb::option::process_options - (&arg, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); + gdb::option::process_options ( + &arg, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); const char *delim = "|"; if (!opts.delimiter.empty ()) @@ -1101,12 +1077,12 @@ pipe_command (const char *arg, int from_tty) const char *command = arg; if (command == nullptr) - error (_("Missing COMMAND")); + error (_ ("Missing COMMAND")); arg = strstr (arg, delim); if (arg == nullptr) - error (_("Missing delimiter before SHELL_COMMAND")); + error (_ ("Missing delimiter before SHELL_COMMAND")); std::string gdb_cmd (command, arg - command); @@ -1117,12 +1093,12 @@ pipe_command (const char *arg, int from_tty) const char *shell_command = skip_spaces (arg); if (*shell_command == '\0') - error (_("Missing SHELL_COMMAND")); + error (_ ("Missing SHELL_COMMAND")); FILE *to_shell_command = popen (shell_command, "w"); if (to_shell_command == nullptr) - error (_("Error launching \"%s\""), shell_command); + error (_ ("Error launching \"%s\""), shell_command); try { @@ -1139,7 +1115,7 @@ pipe_command (const char *arg, int from_tty) int exit_status = pclose (to_shell_command); if (exit_status < 0) - error (_("shell command \"%s\" failed: %s"), shell_command, + error (_ ("shell command \"%s\" failed: %s"), shell_command, safe_strerror (errno)); exit_status_set_internal_vars (exit_status); } @@ -1148,15 +1124,15 @@ pipe_command (const char *arg, int from_tty) static void pipe_command_completer (struct cmd_list_element *ignore, - completion_tracker &tracker, - const char *text, const char *word_ignored) + completion_tracker &tracker, const char *text, + const char *word_ignored) { pipe_cmd_opts opts; const char *org_text = text; auto grp = make_pipe_cmd_options_def_group (&opts); - if (gdb::option::complete_options - (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp)) + if (gdb::option::complete_options ( + tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp)) return; const char *delimiter = "|"; @@ -1210,8 +1186,8 @@ list_command (const char *arg, int from_tty) should list only one line, list the preceding line, instead of the exact line we've just shown after e.g., stopping for a breakpoint. */ - if (arg != NULL && arg[0] == '-' - && get_lines_to_list () == 1 && first > 1) + if (arg != NULL && arg[0] == '-' && get_lines_to_list () == 1 + && first > 1) first -= 1; print_source_lines (cursal.symtab, source_lines_range (first), 0); @@ -1219,15 +1195,15 @@ list_command (const char *arg, int from_tty) /* "l" or "l +" lists next ten lines. */ else if (arg == NULL || arg[0] == '+') - print_source_lines (cursal.symtab, - source_lines_range (cursal.line), 0); + print_source_lines (cursal.symtab, source_lines_range (cursal.line), + 0); /* "l -" lists previous ten lines, the ones before the ten just listed. */ else if (arg[0] == '-') { if (get_first_line_listed () == 1) - error (_("Already at the start of %s."), + error (_ ("Already at the start of %s."), symtab_to_filename_for_display (cursal.symtab)); source_lines_range range (get_first_line_listed (), source_lines_range::BACKWARD); @@ -1244,7 +1220,7 @@ list_command (const char *arg, int from_tty) set DUMMY_BEG or DUMMY_END to record that fact. */ if (!have_full_symbols () && !have_partial_symbols ()) - error (_("No symbol table is loaded. Use the \"file\" command.")); + error (_ ("No symbol table is loaded. Use the \"file\" command.")); std::vector<symtab_and_line> sals; symtab_and_line sal, sal_end; @@ -1263,10 +1239,10 @@ list_command (const char *arg, int from_tty) a location spec condition, and so the string_to_location_spec call stopped parsing. */ if (arg1 == arg) - error (_("Junk at end of line specification.")); + error (_ ("Junk at end of line specification.")); - sals = decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, - NULL, NULL, 0); + sals + = decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); filter_sals (sals); if (sals.empty ()) { @@ -1279,7 +1255,8 @@ list_command (const char *arg, int from_tty) /* Record whether the BEG arg is all digits. */ - for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++); + for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++) + ; linenum_beg = (p == arg1); /* Save the range of the first argument, in case we need to let the @@ -1294,9 +1271,9 @@ list_command (const char *arg, int from_tty) no_end = 0; if (sals.size () > 1) { - ambiguous_line_spec (sals, - _("Specified first line '%.*s' is ambiguous:\n"), - (int) beg_len, beg); + ambiguous_line_spec ( + sals, _ ("Specified first line '%.*s' is ambiguous:\n"), + (int) beg_len, beg); return; } arg1++; @@ -1314,23 +1291,23 @@ list_command (const char *arg, int from_tty) = string_to_location_spec (&arg1, current_language); if (*arg1) - error (_("Junk at end of line specification.")); + error (_ ("Junk at end of line specification.")); std::vector<symtab_and_line> sals_end = (dummy_beg - ? decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, - NULL, NULL, 0) - : decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, - NULL, sal.symtab, sal.line)); + ? decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, + NULL, 0) + : decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, + sal.symtab, sal.line)); filter_sals (sals_end); if (sals_end.empty ()) return; if (sals_end.size () > 1) { - ambiguous_line_spec (sals_end, - _("Specified last line '%s' is ambiguous:\n"), - end_arg); + ambiguous_line_spec ( + sals_end, _ ("Specified last line '%s' is ambiguous:\n"), + end_arg); return; } sal_end = sals_end[0]; @@ -1338,13 +1315,12 @@ list_command (const char *arg, int from_tty) } if (*arg1) - error (_("Junk at end of line specification.")); + error (_ ("Junk at end of line specification.")); - if (!no_end && !dummy_beg && !dummy_end - && sal.symtab != sal_end.symtab) - error (_("Specified first and last lines are in different files.")); + if (!no_end && !dummy_beg && !dummy_end && sal.symtab != sal_end.symtab) + error (_ ("Specified first and last lines are in different files.")); if (dummy_beg && dummy_end) - error (_("Two empty args do not say what lines to list.")); + error (_ ("Two empty args do not say what lines to list.")); /* If line was specified by address, first print exactly which line, and which file. @@ -1356,19 +1332,17 @@ list_command (const char *arg, int from_tty) struct gdbarch *gdbarch; if (sal.symtab == 0) - error (_("No source file for address %s."), + error (_ ("No source file for address %s."), paddress (get_current_arch (), sal.pc)); gdbarch = sal.symtab->compunit ()->objfile ()->arch (); sym = find_pc_function (sal.pc); if (sym) - gdb_printf ("%s is in %s (%s:%d).\n", - paddress (gdbarch, sal.pc), + gdb_printf ("%s is in %s (%s:%d).\n", paddress (gdbarch, sal.pc), sym->print_name (), symtab_to_filename_for_display (sal.symtab), sal.line); else - gdb_printf ("%s is at %s:%d.\n", - paddress (gdbarch, sal.pc), + gdb_printf ("%s is at %s:%d.\n", paddress (gdbarch, sal.pc), symtab_to_filename_for_display (sal.symtab), sal.line); } @@ -1377,7 +1351,7 @@ list_command (const char *arg, int from_tty) source code. */ if (!linenum_beg && sal.symtab == 0) - error (_("No line number known for %s."), arg); + error (_ ("No line number known for %s."), arg); /* If this command is repeated with RET, turn it into the no-arg variant. */ @@ -1386,7 +1360,7 @@ list_command (const char *arg, int from_tty) set_repeat_arguments (""); if (dummy_beg && sal_end.symtab == 0) - error (_("No default source file yet. Do \"help list\".")); + error (_ ("No default source file yet. Do \"help list\".")); if (dummy_beg) { source_lines_range range (sal_end.line + 1, @@ -1394,7 +1368,7 @@ list_command (const char *arg, int from_tty) print_source_lines (sal_end.symtab, range, 0); } else if (sal.symtab == 0) - error (_("No default source file yet. Do \"help list\".")); + error (_ ("No default source file yet. Do \"help list\".")); else if (no_end) { for (int i = 0; i < sals.size (); i++) @@ -1412,8 +1386,7 @@ list_command (const char *arg, int from_tty) print_source_lines (sal.symtab, source_lines_range (sal.line), 0); else print_source_lines (sal.symtab, - source_lines_range (sal.line, (sal_end.line + 1)), - 0); + source_lines_range (sal.line, (sal_end.line + 1)), 0); } /* Subroutine of disassemble_command to simplify it. @@ -1426,9 +1399,8 @@ list_command (const char *arg, int from_tty) MIXED is non-zero to print source with the assembler. */ static void -print_disassembly (struct gdbarch *gdbarch, const char *name, - CORE_ADDR low, CORE_ADDR high, - const struct block *block, +print_disassembly (struct gdbarch *gdbarch, const char *name, CORE_ADDR low, + CORE_ADDR high, const struct block *block, gdb_disassembly_flags flags) { #if defined(TUI) @@ -1437,14 +1409,14 @@ print_disassembly (struct gdbarch *gdbarch, const char *name, else #endif { - gdb_printf (_("Dump of assembler code ")); + gdb_printf (_ ("Dump of assembler code ")); if (name != NULL) - gdb_printf (_("for function %ps:\n"), + gdb_printf (_ ("for function %ps:\n"), styled_string (function_name_style.style (), name)); if (block == nullptr || block->is_contiguous ()) { if (name == NULL) - gdb_printf (_("from %ps to %ps:\n"), + gdb_printf (_ ("from %ps to %ps:\n"), styled_string (address_style.style (), paddress (gdbarch, low)), styled_string (address_style.style (), @@ -1460,16 +1432,16 @@ print_disassembly (struct gdbarch *gdbarch, const char *name, CORE_ADDR range_low = range.start (); CORE_ADDR range_high = range.end (); - gdb_printf (_("Address range %ps to %ps:\n"), + gdb_printf (_ ("Address range %ps to %ps:\n"), styled_string (address_style.style (), paddress (gdbarch, range_low)), styled_string (address_style.style (), paddress (gdbarch, range_high))); - gdb_disassembly (gdbarch, current_uiout, flags, -1, - range_low, range_high); + gdb_disassembly (gdbarch, current_uiout, flags, -1, range_low, + range_high); } } - gdb_printf (_("End of assembler dump.\n")); + gdb_printf (_ ("End of assembler dump.\n")); } } @@ -1485,11 +1457,11 @@ disassemble_current_function (gdb_disassembly_flags flags) const char *name; const struct block *block; - frame = get_selected_frame (_("No frame selected.")); + frame = get_selected_frame (_ ("No frame selected.")); gdbarch = get_frame_arch (frame); pc = get_frame_address_in_block (frame); if (find_pc_partial_function (pc, &name, &low, &high, &block) == 0) - error (_("No function contains program counter for selected frame.")); + error (_ ("No function contains program counter for selected frame.")); #if defined(TUI) /* NOTE: cagney/2003-02-13 The `tui_active' was previously `tui_version'. */ @@ -1550,9 +1522,9 @@ disassemble_command (const char *arg, int from_tty) ++p; if (*p == '\0') - error (_("Missing modifier.")); + error (_ ("Missing modifier.")); - while (*p && ! isspace (*p)) + while (*p && !isspace (*p)) { switch (*p++) { @@ -1569,7 +1541,7 @@ disassemble_command (const char *arg, int from_tty) flags |= DISASSEMBLY_SOURCE; break; default: - error (_("Invalid disassembly modifier.")); + error (_ ("Invalid disassembly modifier.")); } } @@ -1578,9 +1550,9 @@ disassemble_command (const char *arg, int from_tty) if ((flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE)) == (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE)) - error (_("Cannot specify both /m and /s.")); + error (_ ("Cannot specify both /m and /s.")); - if (! p || ! *p) + if (!p || !*p) { flags |= DISASSEMBLY_OMIT_FNAME; disassemble_current_function (flags); @@ -1594,7 +1566,7 @@ disassemble_command (const char *arg, int from_tty) { /* One argument. */ if (!find_pc_partial_function_sym (pc, &symbol, &low, &high, &block)) - error (_("No function contains specified address.")); + error (_ ("No function contains specified address.")); if (asm_demangle) name = symbol->print_name (); @@ -1654,7 +1626,7 @@ show_user (const char *args, int from_tty) c = lookup_cmd (&comname, cmdlist, "", NULL, 0, 1); if (!cli_user_command_p (c)) - error (_("Not a user command.")); + error (_ ("Not a user command.")); show_user_1 (c, "", args, gdb_stdout); } else @@ -1683,8 +1655,7 @@ has_user_subcmd (struct cmd_list_element *command) if (command->is_prefix ()) for (struct cmd_list_element *subcommand = *command->subcommands; - subcommand != nullptr; - subcommand = subcommand->next) + subcommand != nullptr; subcommand = subcommand->next) if (has_user_subcmd (subcommand)) return true; @@ -1694,9 +1665,8 @@ has_user_subcmd (struct cmd_list_element *command) /* Implement completer for the 'show user' command. */ static void -show_user_completer (cmd_list_element *, - completion_tracker &tracker, const char *text, - const char *word) +show_user_completer (cmd_list_element *, completion_tracker &tracker, + const char *text, const char *word) { struct cmd_list_element *cmd_group = cmdlist; @@ -1731,8 +1701,8 @@ show_user_completer (cmd_list_element *, if (has_user_subcmd (c)) { if (strncmp (c->name, word, wordlen) == 0) - tracker.add_completion - (gdb::unique_xmalloc_ptr<char> (xstrdup (c->name))); + tracker.add_completion ( + gdb::unique_xmalloc_ptr<char> (xstrdup (c->name))); } } @@ -1745,10 +1715,9 @@ apropos_command (const char *arg, int from_tty) bool verbose = arg && check_for_argument (&arg, "-v", 2); if (arg == NULL || *arg == '\0') - error (_("REGEXP string is empty")); + error (_ ("REGEXP string is empty")); - compiled_regex pattern (arg, REG_ICASE, - _("Error in regular expression")); + compiled_regex pattern (arg, REG_ICASE, _ ("Error in regular expression")); apropos_cmd (gdb_stdout, cmdlist, verbose, pattern, ""); } @@ -1766,7 +1735,7 @@ static const gdb::option::option_def alias_option_defs[] = { gdb::option::flag_option_def<alias_opts> { "a", [] (alias_opts *opts) { return &opts->abbrev_flag; }, - N_("Specify that ALIAS is an abbreviation of COMMAND.\n\ + N_ ("Specify that ALIAS is an abbreviation of COMMAND.\n\ Abbreviations are not used in command completion."), }, @@ -1778,22 +1747,22 @@ Abbreviations are not used in command completion."), static gdb::option::option_def_group make_alias_options_def_group (alias_opts *a_opts) { - return {{alias_option_defs}, a_opts}; + return { { alias_option_defs }, a_opts }; } /* Completer for the "alias_command". */ static void alias_command_completer (struct cmd_list_element *ignore, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { const auto grp = make_alias_options_def_group (nullptr); tracker.set_use_custom_word_point (true); - if (gdb::option::complete_options - (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp)) + if (gdb::option::complete_options ( + tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp)) return; const char *delim = strchr (text, '='); @@ -1801,9 +1770,7 @@ alias_command_completer (struct cmd_list_element *ignore, /* If we're past the "=" delimiter, complete the "alias ALIAS = COMMAND [DEFAULT-ARGS...]" as if the user is typing COMMAND DEFAULT-ARGS... */ - if (delim != text - && delim != nullptr - && isspace (delim[-1]) + if (delim != text && delim != nullptr && isspace (delim[-1]) && (isspace (delim[1]) || delim[1] == '\0')) { std::string new_text = std::string (delim + 1); @@ -1860,13 +1827,13 @@ validate_aliased_command (const char *command) { std::string default_args; cmd_list_element *c - = lookup_cmd_1 (& command, cmdlist, NULL, &default_args, 1); + = lookup_cmd_1 (&command, cmdlist, NULL, &default_args, 1); if (c == NULL || c == (struct cmd_list_element *) -1) - error (_("Invalid command to alias to: %s"), command); + error (_ ("Invalid command to alias to: %s"), command); if (!default_args.empty ()) - error (_("Cannot define an alias of an alias that has default args")); + error (_ ("Cannot define an alias of an alias that has default args")); return c; } @@ -1876,7 +1843,7 @@ validate_aliased_command (const char *command) static void alias_usage_error (void) { - error (_("Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]")); + error (_ ("Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]")); } /* Make an alias of an existing command. */ @@ -1887,8 +1854,9 @@ alias_command (const char *args, int from_tty) alias_opts a_opts; auto grp = make_alias_options_def_group (&a_opts); - gdb::option::process_options - (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp); + gdb::option::process_options (&args, + gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, + grp); int i, alias_argc, command_argc; const char *equals; @@ -1906,10 +1874,9 @@ alias_command (const char *args, int from_tty) struct cmd_list_element *c_command_prefix; lookup_cmd_for_default_args (&default_args, &c_command_prefix); - std::string command_argv_str (equals + 1, - default_args == nullptr - ? strlen (equals + 1) - : default_args - equals - 1); + std::string command_argv_str (equals + 1, default_args == nullptr + ? strlen (equals + 1) + : default_args - equals - 1); gdb_argv command_argv (command_argv_str.c_str ()); char **alias_argv = built_alias_argv.get (); @@ -1920,12 +1887,12 @@ alias_command (const char *args, int from_tty) for (i = 0; alias_argv[i] != NULL; ++i) { - if (! valid_user_defined_cmd_name_p (alias_argv[i])) + if (!valid_user_defined_cmd_name_p (alias_argv[i])) { if (i == 0) - error (_("Invalid command name: %s"), alias_argv[i]); + error (_ ("Invalid command name: %s"), alias_argv[i]); else - error (_("Invalid command element name: %s"), alias_argv[i]); + error (_ ("Invalid command element name: %s"), alias_argv[i]); } } @@ -1948,25 +1915,22 @@ alias_command (const char *args, int from_tty) if (lookup_cmd_composition (alias, &alias_cmd, &prefix_cmd, &cmd)) { - const char *alias_name = alias_argv[alias_argc-1]; + const char *alias_name = alias_argv[alias_argc - 1]; /* If we found an existing ALIAS_CMD, check that the prefix differ or the name differ. */ - if (alias_cmd != nullptr - && alias_cmd->prefix == prefix_cmd + if (alias_cmd != nullptr && alias_cmd->prefix == prefix_cmd && strcmp (alias_name, alias_cmd->name) == 0) - error (_("Alias already exists: %s"), alias); + error (_ ("Alias already exists: %s"), alias); /* Check ALIAS differs from the found CMD. */ - if (cmd->prefix == prefix_cmd - && strcmp (alias_name, cmd->name) == 0) - error (_("Alias %s is the name of an existing command"), alias); + if (cmd->prefix == prefix_cmd && strcmp (alias_name, cmd->name) == 0) + error (_ ("Alias %s is the name of an existing command"), alias); } } - struct cmd_list_element *alias_cmd; /* If ALIAS is one word, it is an alias for the entire COMMAND. @@ -1990,7 +1954,7 @@ alias_command (const char *args, int from_tty) struct cmd_list_element *c_alias, *c_command; if (alias_argc != command_argc) - error (_("Mismatched command length between ALIAS and COMMAND.")); + error (_ ("Mismatched command length between ALIAS and COMMAND.")); /* Create copies of ALIAS and COMMAND without the last word, and use that to verify the leading elements give the same @@ -2002,14 +1966,14 @@ alias_command (const char *args, int from_tty) alias_prefix = alias_prefix_string.c_str (); command_prefix = command_prefix_string.c_str (); - c_command = lookup_cmd_1 (& command_prefix, cmdlist, NULL, NULL, 1); + c_command = lookup_cmd_1 (&command_prefix, cmdlist, NULL, NULL, 1); /* We've already tried to look up COMMAND. */ gdb_assert (c_command != NULL && c_command != (struct cmd_list_element *) -1); gdb_assert (c_command->is_prefix ()); - c_alias = lookup_cmd_1 (& alias_prefix, cmdlist, NULL, NULL, 1); + c_alias = lookup_cmd_1 (&alias_prefix, cmdlist, NULL, NULL, 1); if (c_alias != c_command) - error (_("ALIAS and COMMAND prefixes do not match.")); + error (_ ("ALIAS and COMMAND prefixes do not match.")); /* add_cmd requires *we* allocate space for name, hence the xstrdup. */ alias_cmd = add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]), @@ -2026,7 +1990,7 @@ alias_command (const char *args, int from_tty) alias_cmd->default_args = default_args; } } - + /* Print the file / line number / symbol name of the location specified by SAL. */ @@ -2039,9 +2003,9 @@ print_sal_location (const symtab_and_line &sal) const char *sym_name = NULL; if (sal.symbol != NULL) sym_name = sal.symbol->print_name (); - gdb_printf (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"), - symtab_to_filename_for_display (sal.symtab), - sal.line, sym_name != NULL ? sym_name : "???"); + gdb_printf (_ ("file: \"%s\", line number: %d, symbol: \"%s\"\n"), + symtab_to_filename_for_display (sal.symtab), sal.line, + sym_name != NULL ? sym_name : "???"); } /* Print a list of files and line numbers which a user may choose from @@ -2108,41 +2072,42 @@ filter_sals (std::vector<symtab_and_line> &sals) { /* Remove SALs that do not match. */ auto from = std::remove_if (sals.begin (), sals.end (), - [&] (const symtab_and_line &sal) - { return (sal.pspace != current_program_space || sal.symtab == NULL); }); + [&] (const symtab_and_line &sal) { + return (sal.pspace != current_program_space || sal.symtab == NULL); + }); /* Remove dups. */ std::sort (sals.begin (), from, - [] (const symtab_and_line &sala, const symtab_and_line &salb) - { return cmp_symtabs (sala, salb) < 0; }); + [] (const symtab_and_line &sala, const symtab_and_line &salb) { + return cmp_symtabs (sala, salb) < 0; + }); from = std::unique (sals.begin (), from, [&] (const symtab_and_line &sala, - const symtab_and_line &salb) - { return cmp_symtabs (sala, salb) == 0; }); + const symtab_and_line &salb) { + return cmp_symtabs (sala, salb) == 0; + }); sals.erase (from, sals.end ()); } static void show_info_verbose (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) + struct cmd_list_element *c, const char *value) { if (info_verbose) gdb_printf (file, - _("Verbose printing of informational messages is %s.\n"), + _ ("Verbose printing of informational messages is %s.\n"), value); else - gdb_printf (file, _("Verbosity is %s.\n"), value); + gdb_printf (file, _ ("Verbosity is %s.\n"), value); } static void show_history_expansion_p (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("History expansion on command input is %s.\n"), - value); + gdb_printf (file, _ ("History expansion on command input is %s.\n"), value); } static void @@ -2150,7 +2115,7 @@ show_max_user_call_depth (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { gdb_printf (file, - _("The max call depth for user-defined commands is %s.\n"), + _ ("The max call depth for user-defined commands is %s.\n"), value); } @@ -2160,8 +2125,10 @@ static void show_suppress_cli_notifications (ui_file *file, int from_tty, cmd_list_element *c, const char *value) { - gdb_printf (file, _("Suppression of printing CLI notifications " - "is %s.\n"), value); + gdb_printf (file, + _ ("Suppression of printing CLI notifications " + "is %s.\n"), + value); } /* Implement 'set suppress-cli-notifications'. */ @@ -2172,8 +2139,7 @@ set_suppress_cli_notifications (const char *args, int from_tty, { cli_suppress_notification.user_selected_context = user_wants_cli_suppress_notification; - cli_suppress_notification.normal_stop - = user_wants_cli_suppress_notification; + cli_suppress_notification.normal_stop = user_wants_cli_suppress_notification; } /* Returns the cmd_list_element in SHOWLIST corresponding to the first @@ -2182,26 +2148,26 @@ set_suppress_cli_notifications (const char *args, int from_tty, FNNAME is used in the error message. */ static cmd_list_element * -setting_cmd (const char *fnname, struct cmd_list_element *showlist, - int argc, struct value **argv) +setting_cmd (const char *fnname, struct cmd_list_element *showlist, int argc, + struct value **argv) { if (argc == 0) - error (_("You must provide an argument to %s"), fnname); + error (_ ("You must provide an argument to %s"), fnname); if (argc != 1) - error (_("You can only provide one argument to %s"), fnname); + error (_ ("You can only provide one argument to %s"), fnname); struct type *type0 = check_typedef (value_type (argv[0])); - if (type0->code () != TYPE_CODE_ARRAY - && type0->code () != TYPE_CODE_STRING) - error (_("First argument of %s must be a string."), fnname); + if (type0->code () != TYPE_CODE_ARRAY && type0->code () != TYPE_CODE_STRING) + error (_ ("First argument of %s must be a string."), fnname); const char *a0 = (const char *) value_contents (argv[0]).data (); cmd_list_element *cmd = lookup_cmd (&a0, showlist, "", NULL, -1, 0); if (cmd == nullptr || cmd->type != show_cmd) - error (_("First argument of %s must be a " - "valid setting of the 'show' command."), fnname); + error (_ ("First argument of %s must be a " + "valid setting of the 'show' command."), + fnname); return cmd; } @@ -2217,15 +2183,13 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) case var_integer: case var_pinteger: { - LONGEST value - = (var.type () == var_uinteger - ? static_cast<LONGEST> (var.get<unsigned int> ()) - : static_cast<LONGEST> (var.get<int> ())); + LONGEST value = (var.type () == var_uinteger + ? static_cast<LONGEST> (var.get<unsigned int> ()) + : static_cast<LONGEST> (var.get<int> ())); if (var.extra_literals () != nullptr) for (const literal_def *l = var.extra_literals (); - l->literal != nullptr; - l++) + l->literal != nullptr; l++) if (value == l->use) { if (l->val.has_value ()) @@ -2236,13 +2200,12 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) } if (var.type () == var_uinteger) - return - value_from_ulongest (builtin_type (gdbarch)->builtin_unsigned_int, - static_cast<unsigned int> (value)); + return value_from_ulongest ( + builtin_type (gdbarch)->builtin_unsigned_int, + static_cast<unsigned int> (value)); else - return - value_from_longest (builtin_type (gdbarch)->builtin_int, - static_cast<int> (value)); + return value_from_longest (builtin_type (gdbarch)->builtin_int, + static_cast<int> (value)); } case var_boolean: return value_from_longest (builtin_type (gdbarch)->builtin_int, @@ -2265,8 +2228,7 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) default: gdb_assert_not_reached ("invalid var_auto_boolean"); } - return value_from_longest (builtin_type (gdbarch)->builtin_int, - val); + return value_from_longest (builtin_type (gdbarch)->builtin_int, val); } case var_string: case var_string_noescape: @@ -2292,8 +2254,7 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) return value_cstring (value, len, builtin_type (gdbarch)->builtin_char); else - return value_cstring ("", 1, - builtin_type (gdbarch)->builtin_char); + return value_cstring ("", 1, builtin_type (gdbarch)->builtin_char); } default: gdb_assert_not_reached ("bad var_type"); @@ -2304,8 +2265,8 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) static struct value * gdb_setting_internal_fn (struct gdbarch *gdbarch, - const struct language_defn *language, - void *cookie, int argc, struct value **argv) + const struct language_defn *language, void *cookie, + int argc, struct value **argv) { cmd_list_element *show_cmd = setting_cmd ("$_gdb_setting", showlist, argc, argv); @@ -2323,7 +2284,8 @@ gdb_maint_setting_internal_fn (struct gdbarch *gdbarch, void *cookie, int argc, struct value **argv) { cmd_list_element *show_cmd - = setting_cmd ("$_gdb_maint_setting", maintenance_show_cmdlist, argc, argv); + = setting_cmd ("$_gdb_maint_setting", maintenance_show_cmdlist, argc, + argv); gdb_assert (show_cmd->var.has_value ()); @@ -2377,8 +2339,7 @@ str_value_from_setting (const setting &var, struct gdbarch *gdbarch) return value_cstring (value, len, builtin_type (gdbarch)->builtin_char); else - return value_cstring ("", 1, - builtin_type (gdbarch)->builtin_char); + return value_cstring ("", 1, builtin_type (gdbarch)->builtin_char); } default: gdb_assert_not_reached ("bad var_type"); @@ -2400,7 +2361,6 @@ gdb_setting_str_internal_fn (struct gdbarch *gdbarch, return str_value_from_setting (*show_cmd->var, gdbarch); } - /* Implementation of the convenience function $_gdb_maint_setting_str. */ static struct value * @@ -2418,6 +2378,7 @@ gdb_maint_setting_str_internal_fn (struct gdbarch *gdbarch, } void _initialize_cli_cmds (); + void _initialize_cli_cmds () { @@ -2426,27 +2387,28 @@ _initialize_cli_cmds () /* Define the classes of commands. They will appear in the help list in alphabetical order. */ - add_cmd ("internals", class_maintenance, _("\ + add_cmd ("internals", class_maintenance, _ ("\ Maintenance commands.\n\ Some gdb commands are provided just for use by gdb maintainers.\n\ These commands are subject to frequent change, and may not be as\n\ well documented as user commands."), &cmdlist); - add_cmd ("obscure", class_obscure, _("Obscure features."), &cmdlist); + add_cmd ("obscure", class_obscure, _ ("Obscure features."), &cmdlist); add_cmd ("aliases", class_alias, - _("User-defined aliases of other commands."), &cmdlist); - add_cmd ("user-defined", class_user, _("\ + _ ("User-defined aliases of other commands."), &cmdlist); + add_cmd ("user-defined", class_user, _ ("\ User-defined commands.\n\ The commands in this class are those defined by the user.\n\ -Use the \"define\" command to define a command."), &cmdlist); - add_cmd ("support", class_support, _("Support facilities."), &cmdlist); - add_cmd ("status", class_info, _("Status inquiries."), &cmdlist); - add_cmd ("files", class_files, _("Specifying and examining files."), +Use the \"define\" command to define a command."), + &cmdlist); + add_cmd ("support", class_support, _ ("Support facilities."), &cmdlist); + add_cmd ("status", class_info, _ ("Status inquiries."), &cmdlist); + add_cmd ("files", class_files, _ ("Specifying and examining files."), &cmdlist); add_cmd ("breakpoints", class_breakpoint, - _("Making program stop at certain points."), &cmdlist); - add_cmd ("data", class_vars, _("Examining data."), &cmdlist); - add_cmd ("stack", class_stack, _("\ + _ ("Making program stop at certain points."), &cmdlist); + add_cmd ("data", class_vars, _ ("Examining data."), &cmdlist); + add_cmd ("stack", class_stack, _ ("\ Examining the stack.\n\ The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\ counting from zero for the innermost (currently executing) frame.\n\n\ @@ -2457,27 +2419,29 @@ The commands below can be used to select other frames by number or address."), &cmdlist); #ifdef TUI add_cmd ("text-user-interface", class_tui, - _("TUI is the GDB text based interface.\n\ + _ ("TUI is the GDB text based interface.\n\ In TUI mode, GDB can display several text windows showing\n\ -the source file, the processor registers, the program disassembly, ..."), &cmdlist); +the source file, the processor registers, the program disassembly, ..."), + &cmdlist); #endif - add_cmd ("running", class_run, _("Running the program."), &cmdlist); + add_cmd ("running", class_run, _ ("Running the program."), &cmdlist); /* Define general commands. */ - add_com ("pwd", class_files, pwd_command, _("\ + add_com ("pwd", class_files, pwd_command, _ ("\ Print working directory.\n\ This is used for your program as well.")); - c = add_cmd ("cd", class_files, cd_command, _("\ + c = add_cmd ("cd", class_files, cd_command, _ ("\ Set working directory to DIR for debugger.\n\ The debugger's current working directory specifies where scripts and other\n\ files that can be loaded by GDB are located.\n\ In order to change the inferior's current working directory, the recommended\n\ -way is to use the \"set cwd\" command."), &cmdlist); +way is to use the \"set cwd\" command."), + &cmdlist); set_cmd_completer (c, filename_completer); - add_com ("echo", class_support, echo_command, _("\ + add_com ("echo", class_support, echo_command, _ ("\ Print a constant string. Give string as argument.\n\ C escape sequences may be used in the argument.\n\ No newline is added at the end of the argument;\n\ @@ -2486,72 +2450,70 @@ Since leading and trailing whitespace are ignored in command arguments,\n\ if you want to print some you must use \"\\\" before leading whitespace\n\ to be printed or after trailing whitespace.")); - add_setshow_enum_cmd ("script-extension", class_support, - script_ext_enums, &script_ext_mode, _("\ -Set mode for script filename extension recognition."), _("\ -Show mode for script filename extension recognition."), _("\ + add_setshow_enum_cmd ("script-extension", class_support, script_ext_enums, + &script_ext_mode, _ ("\ +Set mode for script filename extension recognition."), + _ ("\ +Show mode for script filename extension recognition."), + _ ("\ off == no filename extension recognition (all sourced files are GDB scripts)\n\ soft == evaluate script according to filename extension, fallback to GDB script" - "\n\ -strict == evaluate script according to filename extension, error if not supported" - ), - NULL, - show_script_ext_mode, - &setlist, &showlist); + "\n\ +strict == evaluate script according to filename extension, error if not supported"), + NULL, show_script_ext_mode, &setlist, &showlist); cmd_list_element *quit_cmd - = add_com ("quit", class_support, quit_command, _("\ + = add_com ("quit", class_support, quit_command, _ ("\ Exit gdb.\n\ Usage: quit [EXPR] or exit [EXPR]\n\ The optional expression EXPR, if present, is evaluated and the result\n\ used as GDB's exit code. The default is zero.")); - cmd_list_element *help_cmd - = add_com ("help", class_support, help_command, - _("Print list of commands.")); + cmd_list_element *help_cmd = add_com ("help", class_support, help_command, + _ ("Print list of commands.")); set_cmd_completer (help_cmd, command_completer); add_com_alias ("q", quit_cmd, class_support, 1); add_com_alias ("exit", quit_cmd, class_support, 1); add_com_alias ("h", help_cmd, class_support, 1); - add_setshow_boolean_cmd ("verbose", class_support, &info_verbose, _("\ -Set verbosity."), _("\ -Show verbosity."), NULL, - set_verbose, - show_info_verbose, - &setlist, &showlist); - - add_setshow_prefix_cmd - ("history", class_support, - _("Generic command for setting command history parameters."), - _("Generic command for showing command history parameters."), - &sethistlist, &showhistlist, &setlist, &showlist); - - add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\ -Set history expansion on command input."), _("\ -Show history expansion on command input."), _("\ + add_setshow_boolean_cmd ("verbose", class_support, &info_verbose, _ ("\ +Set verbosity."), + _ ("\ +Show verbosity."), + NULL, set_verbose, show_info_verbose, &setlist, + &showlist); + + add_setshow_prefix_cmd ( + "history", class_support, + _ ("Generic command for setting command history parameters."), + _ ("Generic command for showing command history parameters."), + &sethistlist, &showhistlist, &setlist, &showlist); + + add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _ ("\ +Set history expansion on command input."), + _ ("\ +Show history expansion on command input."), + _ ("\ Without an argument, history expansion is enabled."), - NULL, - show_history_expansion_p, - &sethistlist, &showhistlist); + NULL, show_history_expansion_p, &sethistlist, + &showhistlist); cmd_list_element *info_cmd - = add_prefix_cmd ("info", class_info, info_command, _("\ + = add_prefix_cmd ("info", class_info, info_command, _ ("\ Generic command for showing things about the program being debugged."), &infolist, 0, &cmdlist); add_com_alias ("i", info_cmd, class_info, 1); add_com_alias ("inf", info_cmd, class_info, 1); add_com ("complete", class_obscure, complete_command, - _("List the completions for the rest of the line as a command.")); + _ ("List the completions for the rest of the line as a command.")); - c = add_show_prefix_cmd ("show", class_info, _("\ + c = add_show_prefix_cmd ("show", class_info, _ ("\ Generic command for showing things about the debugger."), &showlist, 0, &cmdlist); /* Another way to get at the same thing. */ add_alias_cmd ("set", c, class_info, 0, &infolist); - cmd_list_element *with_cmd - = add_com ("with", class_vars, with_command, _("\ + cmd_list_element *with_cmd = add_com ("with", class_vars, with_command, _ ("\ Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\ Usage: with SETTING [VALUE] [-- COMMAND]\n\ Usage: w SETTING [VALUE] [-- COMMAND]\n\ @@ -2568,7 +2530,7 @@ abbreviations for commands and/or values. E.g.:\n\ set_cmd_completer_handle_brkchars (with_cmd, with_command_completer); add_com_alias ("w", with_cmd, class_vars, 1); - add_internal_function ("_gdb_setting_str", _("\ + add_internal_function ("_gdb_setting_str", _ ("\ $_gdb_setting_str - returns the value of a GDB setting as a string.\n\ Usage: $_gdb_setting_str (setting)\n\ \n\ @@ -2578,7 +2540,7 @@ Some integer settings accept an unlimited value, returned\n\ as \"unlimited\"."), gdb_setting_str_internal_fn, NULL); - add_internal_function ("_gdb_setting", _("\ + add_internal_function ("_gdb_setting", _ ("\ $_gdb_setting - returns the value of a GDB setting.\n\ Usage: $_gdb_setting (setting)\n\ auto-boolean values are \"off\", \"on\", \"auto\".\n\ @@ -2587,7 +2549,7 @@ Some integer settings accept an unlimited value, returned\n\ as 0 or -1 depending on the setting."), gdb_setting_internal_fn, NULL); - add_internal_function ("_gdb_maint_setting_str", _("\ + add_internal_function ("_gdb_maint_setting_str", _ ("\ $_gdb_maint_setting_str - returns the value of a GDB maintenance setting as a string.\n\ Usage: $_gdb_maint_setting_str (setting)\n\ \n\ @@ -2597,7 +2559,7 @@ Some integer settings accept an unlimited value, returned\n\ as \"unlimited\"."), gdb_maint_setting_str_internal_fn, NULL); - add_internal_function ("_gdb_maint_setting", _("\ + add_internal_function ("_gdb_maint_setting", _ ("\ $_gdb_maint_setting - returns the value of a GDB maintenance setting.\n\ Usage: $_gdb_maint_setting (setting)\n\ auto-boolean values are \"off\", \"on\", \"auto\".\n\ @@ -2606,33 +2568,32 @@ Some integer settings accept an unlimited value, returned\n\ as 0 or -1 depending on the setting."), gdb_maint_setting_internal_fn, NULL); - add_cmd ("commands", no_set_class, show_commands, _("\ + add_cmd ("commands", no_set_class, show_commands, _ ("\ Show the history of commands you typed.\n\ You can supply a command number to start with, or a `+' to start after\n\ the previous command number shown."), &showlist); add_cmd ("version", no_set_class, show_version, - _("Show what version of GDB this is."), &showlist); + _ ("Show what version of GDB this is."), &showlist); add_cmd ("configuration", no_set_class, show_configuration, - _("Show how GDB was configured at build time."), &showlist); + _ ("Show how GDB was configured at build time."), &showlist); - add_setshow_prefix_cmd ("debug", no_class, - _("Generic command for setting gdb debugging flags."), - _("Generic command for showing gdb debugging flags."), - &setdebuglist, &showdebuglist, - &setlist, &showlist); + add_setshow_prefix_cmd ( + "debug", no_class, _ ("Generic command for setting gdb debugging flags."), + _ ("Generic command for showing gdb debugging flags."), &setdebuglist, + &showdebuglist, &setlist, &showlist); cmd_list_element *shell_cmd - = add_com ("shell", class_support, shell_command, _("\ + = add_com ("shell", class_support, shell_command, _ ("\ Execute the rest of the line as a shell command.\n\ With no arguments, run an inferior shell.")); set_cmd_completer (shell_cmd, filename_completer); add_com_alias ("!", shell_cmd, class_support, 0); - c = add_com ("edit", class_files, edit_command, _("\ + c = add_com ("edit", class_files, edit_command, _ ("\ Edit specified file or function.\n\ With no argument, edits file containing most recent line listed.\n\ Editing targets can be specified in these ways:\n\ @@ -2645,7 +2606,7 @@ Uses EDITOR environment variable contents as editor (or ex as default).")); c->completer = location_completer; cmd_list_element *pipe_cmd - = add_com ("pipe", class_support, pipe_command, _("\ + = add_com ("pipe", class_support, pipe_command, _ ("\ Send the output of a gdb command to a shell command.\n\ Usage: | [COMMAND] | SHELL_COMMAND\n\ Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND\n\ @@ -2664,7 +2625,7 @@ and send its output to SHELL_COMMAND.")); add_com_alias ("|", pipe_cmd, class_support, 0); cmd_list_element *list_cmd - = add_com ("list", class_files, list_command, _("\ + = add_com ("list", class_files, list_command, _ ("\ List specified function or line.\n\ With no argument, lists ten more lines after or around previous listing.\n\ \"list -\" lists the ten lines before a previous ten-line listing.\n\ @@ -2685,7 +2646,7 @@ can be shown using \"show listsize\".")); add_com_alias ("l", list_cmd, class_files, 1); - c = add_com ("disassemble", class_vars, disassemble_command, _("\ + c = add_com ("disassemble", class_vars, disassemble_command, _ ("\ Disassemble a specified section of memory.\n\ Usage: disassemble[/m|/r|/s] START [, END]\n\ Default is the function surrounding the pc of the selected frame.\n\ @@ -2713,40 +2674,40 @@ So, for example, if you want to disassemble function bar in file foo.c\n\ you must type \"disassemble 'foo.c'::bar\" and not \"disassemble foo.c:bar\".")); set_cmd_completer (c, location_completer); - c = add_com ("make", class_support, make_command, _("\ + c = add_com ("make", class_support, make_command, _ ("\ Run the ``make'' program using the rest of the line as arguments.")); set_cmd_completer (c, filename_completer); - c = add_cmd ("user", no_class, show_user, _("\ + c = add_cmd ("user", no_class, show_user, _ ("\ Show definitions of non-python/scheme user defined commands.\n\ Argument is the name of the user defined command.\n\ -With no argument, show definitions of all user defined commands."), &showlist); +With no argument, show definitions of all user defined commands."), + &showlist); set_cmd_completer (c, show_user_completer); - add_com ("apropos", class_support, apropos_command, _("\ + add_com ("apropos", class_support, apropos_command, _ ("\ Search for commands matching a REGEXP.\n\ Usage: apropos [-v] REGEXP\n\ Flag -v indicates to produce a verbose output, showing full documentation\n\ of the matching commands.")); add_setshow_uinteger_cmd ("max-user-call-depth", no_class, - &max_user_call_depth, _("\ -Set the max call depth for non-python/scheme user-defined commands."), _("\ -Show the max call depth for non-python/scheme user-defined commands."), NULL, - NULL, - show_max_user_call_depth, - &setlist, &showlist); - - add_setshow_boolean_cmd ("trace-commands", no_class, &trace_commands, _("\ -Set tracing of GDB CLI commands."), _("\ -Show state of GDB CLI command tracing."), _("\ + &max_user_call_depth, _ ("\ +Set the max call depth for non-python/scheme user-defined commands."), + _ ("\ +Show the max call depth for non-python/scheme user-defined commands."), + NULL, NULL, show_max_user_call_depth, &setlist, + &showlist); + + add_setshow_boolean_cmd ("trace-commands", no_class, &trace_commands, _ ("\ +Set tracing of GDB CLI commands."), + _ ("\ +Show state of GDB CLI command tracing."), + _ ("\ When 'on', each command is displayed as it is executed."), - NULL, - NULL, - &setlist, &showlist); + NULL, NULL, &setlist, &showlist); const auto alias_opts = make_alias_options_def_group (nullptr); - static std::string alias_help - = gdb::option::build_help (_("\ + static std::string alias_help = gdb::option::build_help (_ ("\ Define a new command that is an alias of an existing command.\n\ Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]\n\ ALIAS is the name of the alias command to create.\n\ @@ -2768,26 +2729,25 @@ Make \"btf\" an alias of \"backtrace -full -past-entry -past-main\" :\n\ alias btf = backtrace -full -past-entry -past-main\n\ Make \"wLapPeu\" an alias of 2 nested \"with\":\n\ alias wLapPeu = with language pascal -- with print elements unlimited --"), - alias_opts); + alias_opts); - c = add_com ("alias", class_support, alias_command, - alias_help.c_str ()); + c = add_com ("alias", class_support, alias_command, alias_help.c_str ()); set_cmd_completer_handle_brkchars (c, alias_command_completer); add_setshow_boolean_cmd ("suppress-cli-notifications", no_class, - &user_wants_cli_suppress_notification, - _("\ -Set whether printing notifications on CLI is suppressed."), _("\ -Show whether printing notifications on CLI is suppressed."), _("\ + &user_wants_cli_suppress_notification, _ ("\ +Set whether printing notifications on CLI is suppressed."), + _ ("\ +Show whether printing notifications on CLI is suppressed."), + _ ("\ When on, printing notifications (such as inferior/thread switch)\n\ on CLI is suppressed."), set_suppress_cli_notifications, - show_suppress_cli_notifications, - &setlist, + show_suppress_cli_notifications, &setlist, &showlist); - const char *source_help_text = xstrprintf (_("\ + const char *source_help_text = xstrprintf (_ ("\ Read commands from a file named FILE.\n\ \n\ Usage: source [-s] [-v] FILE\n\ @@ -2796,8 +2756,10 @@ Usage: source [-s] [-v] FILE\n\ -v: each command in FILE is echoed as it is executed.\n\ \n\ Note that the file \"%s\" is read automatically in this way\n\ -when GDB is started."), GDBINIT).release (); - c = add_cmd ("source", class_support, source_command, - source_help_text, &cmdlist); +when GDB is started."), + GDBINIT) + .release (); + c = add_cmd ("source", class_support, source_command, source_help_text, + &cmdlist); set_cmd_completer (c, filename_completer); } diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index 4295744..5df3278 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -179,8 +179,8 @@ struct open_script } }; -extern gdb::optional<open_script> - find_and_open_script (const char *file, int search_path); +extern gdb::optional<open_script> find_and_open_script (const char *file, + int search_path); /* Command tracing state. */ @@ -192,8 +192,8 @@ extern bool trace_commands; prefix: i.e., "set " or "maintenance set ". SETLIST is the command element for the same "set" command prefix. */ extern void with_command_1 (const char *set_cmd_prefix, - cmd_list_element *setlist, - const char *args, int from_tty); + cmd_list_element *setlist, const char *args, + int from_tty); /* Common code for the completers of the "with" and "maintenance with" commands. SET_CMD_PREFIX is the spelling of the corresponding diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 2a4f9b4..20d469c 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -30,20 +30,18 @@ static void undef_cmd_error (const char *, const char *); -static cmd_list_element::aliases_list_type delete_cmd - (const char *name, cmd_list_element **list, cmd_list_element **prehook, - cmd_list_element **prehookee, cmd_list_element **posthook, - cmd_list_element **posthookee); +static cmd_list_element::aliases_list_type +delete_cmd (const char *name, cmd_list_element **list, + cmd_list_element **prehook, cmd_list_element **prehookee, + cmd_list_element **posthook, cmd_list_element **posthookee); -static struct cmd_list_element *find_cmd (const char *command, - int len, +static struct cmd_list_element *find_cmd (const char *command, int len, struct cmd_list_element *clist, int ignore_help_classes, int *nfound); static void help_cmd_list (struct cmd_list_element *list, - enum command_class theclass, - bool recurse, + enum command_class theclass, bool recurse, struct ui_file *stream); static void help_all (struct ui_file *stream); @@ -85,9 +83,8 @@ lookup_cmd_with_subcommands (cmd_list_element **subcommands, return NULL; } -static void -print_help_for_command (const cmd_list_element &c, - bool recurse, struct ui_file *stream); +static void print_help_for_command (const cmd_list_element &c, bool recurse, + struct ui_file *stream); static void do_simple_func (const char *args, int from_tty, cmd_list_element *c) @@ -96,7 +93,8 @@ do_simple_func (const char *args, int from_tty, cmd_list_element *c) } static void -set_cmd_simple_func (struct cmd_list_element *cmd, cmd_simple_func_ftype *simple_func) +set_cmd_simple_func (struct cmd_list_element *cmd, + cmd_simple_func_ftype *simple_func) { if (simple_func == NULL) cmd->func = NULL; @@ -107,7 +105,8 @@ set_cmd_simple_func (struct cmd_list_element *cmd, cmd_simple_func_ftype *simple } int -cmd_simple_func_eq (struct cmd_list_element *cmd, cmd_simple_func_ftype *simple_func) +cmd_simple_func_eq (struct cmd_list_element *cmd, + cmd_simple_func_ftype *simple_func) { return (cmd->func == do_simple_func && cmd->function.simple_func == simple_func); @@ -178,11 +177,11 @@ cmd_list_element::command_components () const of *LIST). */ static struct cmd_list_element * -do_add_cmd (const char *name, enum command_class theclass, - const char *doc, struct cmd_list_element **list) +do_add_cmd (const char *name, enum command_class theclass, const char *doc, + struct cmd_list_element **list) { - struct cmd_list_element *c = new struct cmd_list_element (name, theclass, - doc); + struct cmd_list_element *c + = new struct cmd_list_element (name, theclass, doc); /* Turn each alias of the old command into an alias of the new command. */ @@ -225,13 +224,12 @@ do_add_cmd (const char *name, enum command_class theclass, cmd_list_element *prefixcmd = lookup_cmd_with_subcommands (list, cmdlist); c->prefix = prefixcmd; - return c; } struct cmd_list_element * -add_cmd (const char *name, enum command_class theclass, - const char *doc, struct cmd_list_element **list) +add_cmd (const char *name, enum command_class theclass, const char *doc, + struct cmd_list_element **list) { cmd_list_element *result = do_add_cmd (name, theclass, doc, list); result->func = NULL; @@ -241,8 +239,8 @@ add_cmd (const char *name, enum command_class theclass, struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, - cmd_simple_func_ftype *fun, - const char *doc, struct cmd_list_element **list) + cmd_simple_func_ftype *fun, const char *doc, + struct cmd_list_element **list) { cmd_list_element *result = do_add_cmd (name, theclass, doc, list); set_cmd_simple_func (result, fun); @@ -265,7 +263,6 @@ add_cmd_suppress_notification (const char *name, enum command_class theclass, return element; } - /* Deprecates a command CMD. REPLACEMENT is the name of the command which should be used in place of this command, or NULL if no such command exists. @@ -347,7 +344,6 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) } } - /* Like add_cmd but adds an element for a command prefix: a name that should be followed by a subcommand to be looked up in another command list. SUBCOMMANDS should be the address of the variable @@ -355,9 +351,9 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) struct cmd_list_element * add_prefix_cmd (const char *name, enum command_class theclass, - cmd_simple_func_ftype *fun, - const char *doc, struct cmd_list_element **subcommands, - int allow_unknown, struct cmd_list_element **list) + cmd_simple_func_ftype *fun, const char *doc, + struct cmd_list_element **subcommands, int allow_unknown, + struct cmd_list_element **list) { struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list); @@ -381,8 +377,8 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) while (c->is_alias ()) c = c->alias_target; - help_list (*c->subcommands, c->prefixname ().c_str (), - all_commands, gdb_stdout); + help_list (*c->subcommands, c->prefixname ().c_str (), all_commands, + gdb_stdout); } /* See command.h. */ @@ -392,9 +388,9 @@ add_basic_prefix_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { - struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, - doc, subcommands, - allow_unknown, list); + struct cmd_list_element *cmd + = add_prefix_cmd (name, theclass, nullptr, doc, subcommands, allow_unknown, + list); cmd->func = do_prefix_cmd; return cmd; } @@ -415,9 +411,9 @@ add_show_prefix_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { - struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr, - doc, subcommands, - allow_unknown, list); + struct cmd_list_element *cmd + = add_prefix_cmd (name, theclass, nullptr, doc, subcommands, allow_unknown, + list); cmd->func = do_show_prefix_cmd; return cmd; } @@ -435,11 +431,9 @@ add_setshow_prefix_cmd (const char *name, command_class theclass, set_show_commands cmds; cmds.set = add_basic_prefix_cmd (name, theclass, set_doc, - set_subcommands_list, 0, - set_list); + set_subcommands_list, 0, set_list); cmds.show = add_show_prefix_cmd (name, theclass, show_doc, - show_subcommands_list, 0, - show_list); + show_subcommands_list, 0, show_list); return cmds; } @@ -448,16 +442,14 @@ add_setshow_prefix_cmd (const char *name, command_class theclass, new command list element. */ struct cmd_list_element * -add_prefix_cmd_suppress_notification - (const char *name, enum command_class theclass, - cmd_simple_func_ftype *fun, - const char *doc, struct cmd_list_element **subcommands, - int allow_unknown, struct cmd_list_element **list, - bool *suppress_notification) +add_prefix_cmd_suppress_notification ( + const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, + const char *doc, struct cmd_list_element **subcommands, int allow_unknown, + struct cmd_list_element **list, bool *suppress_notification) { struct cmd_list_element *element - = add_prefix_cmd (name, theclass, fun, doc, subcommands, - allow_unknown, list); + = add_prefix_cmd (name, theclass, fun, doc, subcommands, allow_unknown, + list); element->suppress_notification = suppress_notification; return element; } @@ -503,13 +495,10 @@ empty_func (const char *args, int from_tty, cmd_list_element *c) DOC is the documentation string. */ static struct cmd_list_element * -add_set_or_show_cmd (const char *name, - enum cmd_types type, - enum command_class theclass, - var_types var_type, +add_set_or_show_cmd (const char *name, enum cmd_types type, + enum command_class theclass, var_types var_type, const literal_def *extra_literals, - const setting::erased_args &arg, - const char *doc, + const setting::erased_args &arg, const char *doc, struct cmd_list_element **list) { struct cmd_list_element *c = add_cmd (name, theclass, doc, list); @@ -536,17 +525,12 @@ add_set_or_show_cmd (const char *name, Return the newly created set and show commands. */ static set_show_commands -add_setshow_cmd_full_erased (const char *name, - enum command_class theclass, - var_types var_type, - const literal_def *extra_literals, - const setting::erased_args &args, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list) +add_setshow_cmd_full_erased ( + const char *name, enum command_class theclass, var_types var_type, + const literal_def *extra_literals, const setting::erased_args &args, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_func_ftype *set_func, show_value_ftype *show_func, + struct cmd_list_element **set_list, struct cmd_list_element **show_list) { struct cmd_list_element *set; struct cmd_list_element *show; @@ -563,47 +547,42 @@ add_setshow_cmd_full_erased (const char *name, full_set_doc = make_unique_xstrdup (set_doc); full_show_doc = make_unique_xstrdup (show_doc); } - set = add_set_or_show_cmd (name, set_cmd, theclass, var_type, - extra_literals, args, - full_set_doc.release (), set_list); + set = add_set_or_show_cmd (name, set_cmd, theclass, var_type, extra_literals, + args, full_set_doc.release (), set_list); set->doc_allocated = 1; if (set_func != NULL) set->func = set_func; - show = add_set_or_show_cmd (name, show_cmd, theclass, var_type, - extra_literals, args, - full_show_doc.release (), show_list); + show + = add_set_or_show_cmd (name, show_cmd, theclass, var_type, extra_literals, + args, full_show_doc.release (), show_list); show->doc_allocated = 1; show->show_value_func = show_func; /* Disable the default symbol completer. Doesn't make much sense for the "show" command to complete on anything. */ set_cmd_completer (show, nullptr); - return {set, show}; + return { set, show }; } /* Completes on integer commands that support extra literals. */ static void integer_literals_completer (struct cmd_list_element *c, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { const literal_def *extra_literals = c->var->extra_literals (); if (*text == '\0') { tracker.add_completion (make_unique_xstrdup ("NUMBER")); - for (const literal_def *l = extra_literals; - l->literal != nullptr; - l++) + for (const literal_def *l = extra_literals; l->literal != nullptr; l++) tracker.add_completion (make_unique_xstrdup (l->literal)); } else - for (const literal_def *l = extra_literals; - l->literal != nullptr; - l++) + for (const literal_def *l = extra_literals; l->literal != nullptr; l++) if (startswith (l->literal, text)) tracker.add_completion (make_unique_xstrdup (l->literal)); } @@ -624,32 +603,22 @@ integer_literals_completer (struct cmd_list_element *c, template<typename T> static set_show_commands -add_setshow_cmd_full (const char *name, - enum command_class theclass, +add_setshow_cmd_full (const char *name, enum command_class theclass, var_types var_type, T *var, - const literal_def *extra_literals, - const char *set_doc, const char *show_doc, - const char *help_doc, + const literal_def *extra_literals, const char *set_doc, + const char *show_doc, const char *help_doc, typename setting_func_types<T>::set set_setting_func, typename setting_func_types<T>::get get_setting_func, - cmd_func_ftype *set_func, - show_value_ftype *show_func, + cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { auto erased_args - = setting::erase_args (var_type, var, - set_setting_func, get_setting_func); - auto cmds = add_setshow_cmd_full_erased (name, - theclass, - var_type, extra_literals, - erased_args, - set_doc, show_doc, - help_doc, - set_func, - show_func, - set_list, - show_list); + = setting::erase_args (var_type, var, set_setting_func, get_setting_func); + auto cmds + = add_setshow_cmd_full_erased (name, theclass, var_type, extra_literals, + erased_args, set_doc, show_doc, help_doc, + set_func, show_func, set_list, show_list); if (extra_literals != nullptr) set_cmd_completer (cmds.set, integer_literals_completer); @@ -661,22 +630,19 @@ add_setshow_cmd_full (const char *name, template<typename T> static set_show_commands -add_setshow_cmd_full (const char *name, - enum command_class theclass, - var_types var_type, T *var, - const char *set_doc, const char *show_doc, - const char *help_doc, +add_setshow_cmd_full (const char *name, enum command_class theclass, + var_types var_type, T *var, const char *set_doc, + const char *show_doc, const char *help_doc, typename setting_func_types<T>::set set_setting_func, typename setting_func_types<T>::get get_setting_func, - cmd_func_ftype *set_func, - show_value_ftype *show_func, + cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - return add_setshow_cmd_full (name, theclass, var_type, var, nullptr, - set_doc, show_doc, help_doc, - set_setting_func, get_setting_func, - set_func, show_func, set_list, show_list); + return add_setshow_cmd_full (name, theclass, var_type, var, nullptr, set_doc, + show_doc, help_doc, set_setting_func, + get_setting_func, set_func, show_func, set_list, + show_list); } /* Add element named NAME to command list LIST (the list for set or @@ -685,14 +651,10 @@ add_setshow_cmd_full (const char *name, which will contain the matching string (from ENUMLIST). */ set_show_commands -add_setshow_enum_cmd (const char *name, - enum command_class theclass, - const char *const *enumlist, - const char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, +add_setshow_enum_cmd (const char *name, enum command_class theclass, + const char *const *enumlist, const char **var, + const char *set_doc, const char *show_doc, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) @@ -700,7 +662,7 @@ add_setshow_enum_cmd (const char *name, /* We require *VAR to be initialized before this call, and furthermore it must be == to one of the values in ENUMLIST. */ gdb_assert (var != nullptr && *var != nullptr); - for (int i = 0; ; ++i) + for (int i = 0;; ++i) { gdb_assert (enumlist[i] != nullptr); if (*var == enumlist[i]) @@ -708,10 +670,10 @@ add_setshow_enum_cmd (const char *name, } set_show_commands commands - = add_setshow_cmd_full<const char *> (name, theclass, var_enum, var, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, - show_func, set_list, show_list); + = add_setshow_cmd_full<const char *> (name, theclass, var_enum, var, + set_doc, show_doc, help_doc, nullptr, + nullptr, set_func, show_func, + set_list, show_list); commands.set->enums = enumlist; return commands; } @@ -725,15 +687,14 @@ add_setshow_enum_cmd (const char *name, command_class theclass, const char *show_doc, const char *help_doc, setting_func_types<const char *>::set set_func, setting_func_types<const char *>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, + show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<const char *> (name, theclass, var_enum, - nullptr, set_doc, show_doc, - help_doc, set_func, get_func, - nullptr, show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<const char *> (name, theclass, var_enum, nullptr, + set_doc, show_doc, help_doc, + set_func, get_func, nullptr, + show_func, set_list, show_list); cmds.set->enums = enumlist; @@ -741,7 +702,7 @@ add_setshow_enum_cmd (const char *name, command_class theclass, } /* See cli-decode.h. */ -const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL }; +const char *const auto_boolean_enums[] = { "on", "off", "auto", NULL }; /* Add an auto-boolean command named NAME to both the set and show command list lists. THECLASS is as in add_cmd. VAR is address of the @@ -749,21 +710,17 @@ const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL }; string. FUNC is the corresponding callback. */ set_show_commands -add_setshow_auto_boolean_cmd (const char *name, - enum command_class theclass, - enum auto_boolean *var, - const char *set_doc, const char *show_doc, - const char *help_doc, +add_setshow_auto_boolean_cmd (const char *name, enum command_class theclass, + enum auto_boolean *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - set_show_commands commands - = add_setshow_cmd_full<enum auto_boolean> (name, theclass, var_auto_boolean, - var, set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, - show_func, set_list, show_list); + set_show_commands commands = add_setshow_cmd_full<enum auto_boolean> ( + name, theclass, var_auto_boolean, var, set_doc, show_doc, help_doc, + nullptr, nullptr, set_func, show_func, set_list, show_list); commands.set->enums = auto_boolean_enums; @@ -774,22 +731,17 @@ add_setshow_auto_boolean_cmd (const char *name, to a global storage buffer. */ set_show_commands -add_setshow_auto_boolean_cmd (const char *name, command_class theclass, - const char *set_doc, const char *show_doc, - const char *help_doc, - setting_func_types<enum auto_boolean>::set set_func, - setting_func_types<enum auto_boolean>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, - cmd_list_element **show_list) -{ - auto cmds = add_setshow_cmd_full<enum auto_boolean> (name, theclass, - var_auto_boolean, - nullptr, set_doc, - show_doc, help_doc, - set_func, get_func, - nullptr, show_func, - set_list, show_list); +add_setshow_auto_boolean_cmd ( + const char *name, command_class theclass, const char *set_doc, + const char *show_doc, const char *help_doc, + setting_func_types<enum auto_boolean>::set set_func, + setting_func_types<enum auto_boolean>::get get_func, + show_value_ftype *show_func, cmd_list_element **set_list, + cmd_list_element **show_list) +{ + auto cmds = add_setshow_cmd_full<enum auto_boolean> ( + name, theclass, var_auto_boolean, nullptr, set_doc, show_doc, help_doc, + set_func, get_func, nullptr, show_func, set_list, show_list); cmds.set->enums = auto_boolean_enums; @@ -797,7 +749,7 @@ add_setshow_auto_boolean_cmd (const char *name, command_class theclass, } /* See cli-decode.h. */ -const char * const boolean_enums[] = { "on", "off", NULL }; +const char *const boolean_enums[] = { "on", "off", NULL }; /* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). THECLASS is as in @@ -806,19 +758,17 @@ const char * const boolean_enums[] = { "on", "off", NULL }; Returns the new command element. */ set_show_commands -add_setshow_boolean_cmd (const char *name, enum command_class theclass, bool *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, +add_setshow_boolean_cmd (const char *name, enum command_class theclass, + bool *var, const char *set_doc, const char *show_doc, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands - = add_setshow_cmd_full<bool> (name, theclass, var_boolean, var, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, show_func, - set_list, show_list); + = add_setshow_cmd_full<bool> (name, theclass, var_boolean, var, set_doc, + show_doc, help_doc, nullptr, nullptr, + set_func, show_func, set_list, show_list); commands.set->enums = boolean_enums; @@ -853,9 +803,8 @@ add_setshow_boolean_cmd (const char *name, command_class theclass, set_show_commands add_setshow_filename_cmd (const char *name, enum command_class theclass, - std::string *var, - const char *set_doc, const char *show_doc, - const char *help_doc, + std::string *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, @@ -863,9 +812,9 @@ add_setshow_filename_cmd (const char *name, enum command_class theclass, { set_show_commands commands = add_setshow_cmd_full<std::string> (name, theclass, var_filename, var, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, - show_func, set_list, show_list); + set_doc, show_doc, help_doc, nullptr, + nullptr, set_func, show_func, + set_list, show_list); set_cmd_completer (commands.set, filename_completer); @@ -885,11 +834,11 @@ add_setshow_filename_cmd (const char *name, command_class theclass, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<std::string> (name, theclass, var_filename, - nullptr, set_doc, show_doc, - help_doc, set_func, get_func, - nullptr, show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<std::string> (name, theclass, var_filename, nullptr, + set_doc, show_doc, help_doc, set_func, + get_func, nullptr, show_func, + set_list, show_list); set_cmd_completer (cmds.set, filename_completer); @@ -901,19 +850,17 @@ add_setshow_filename_cmd (const char *name, command_class theclass, set_show_commands add_setshow_string_cmd (const char *name, enum command_class theclass, - std::string *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, - show_value_ftype *show_func, + std::string *var, const char *set_doc, + const char *show_doc, const char *help_doc, + cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<std::string> (name, theclass, var_string, var, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, - show_func, set_list, show_list); + set_doc, show_doc, help_doc, nullptr, + nullptr, set_func, show_func, + set_list, show_list); /* Disable the default symbol completer. */ set_cmd_completer (commands.set, nullptr); @@ -934,11 +881,11 @@ add_setshow_string_cmd (const char *name, command_class theclass, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<std::string> (name, theclass, var_string, - nullptr, set_doc, show_doc, - help_doc, set_func, get_func, - nullptr, show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<std::string> (name, theclass, var_string, nullptr, + set_doc, show_doc, help_doc, set_func, + get_func, nullptr, show_func, + set_list, show_list); /* Disable the default symbol completer. */ set_cmd_completer (cmds.set, nullptr); @@ -951,9 +898,8 @@ add_setshow_string_cmd (const char *name, command_class theclass, set_show_commands add_setshow_string_noescape_cmd (const char *name, enum command_class theclass, - std::string *var, - const char *set_doc, const char *show_doc, - const char *help_doc, + std::string *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, @@ -984,12 +930,11 @@ add_setshow_string_noescape_cmd (const char *name, command_class theclass, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<std::string> (name, theclass, - var_string_noescape, nullptr, - set_doc, show_doc, help_doc, - set_func, get_func, - nullptr, show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<std::string> (name, theclass, var_string_noescape, + nullptr, set_doc, show_doc, help_doc, + set_func, get_func, nullptr, + show_func, set_list, show_list); /* Disable the default symbol completer. */ set_cmd_completer (cmds.set, nullptr); @@ -1001,14 +946,11 @@ add_setshow_string_noescape_cmd (const char *name, command_class theclass, list for set/show or some sublist thereof). */ set_show_commands -add_setshow_optional_filename_cmd (const char *name, enum command_class theclass, - std::string *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list) +add_setshow_optional_filename_cmd ( + const char *name, enum command_class theclass, std::string *var, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_func_ftype *set_func, show_value_ftype *show_func, + struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<std::string> (name, theclass, var_optional_filename, @@ -1025,20 +967,18 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class theclass to a global storage buffer. */ set_show_commands -add_setshow_optional_filename_cmd (const char *name, command_class theclass, - const char *set_doc, const char *show_doc, - const char *help_doc, - setting_func_types<std::string>::set set_func, - setting_func_types<std::string>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, - cmd_list_element **show_list) -{ - auto cmds = - add_setshow_cmd_full<std::string> (name, theclass, var_optional_filename, - nullptr, set_doc, show_doc, help_doc, - set_func, get_func, nullptr, show_func, - set_list,show_list); +add_setshow_optional_filename_cmd ( + const char *name, command_class theclass, const char *set_doc, + const char *show_doc, const char *help_doc, + setting_func_types<std::string>::set set_func, + setting_func_types<std::string>::get get_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list) +{ + auto cmds + = add_setshow_cmd_full<std::string> (name, theclass, var_optional_filename, + nullptr, set_doc, show_doc, help_doc, + set_func, get_func, nullptr, + show_func, set_list, show_list); set_cmd_completer (cmds.set, filename_completer); @@ -1055,17 +995,16 @@ set_show_commands add_setshow_integer_cmd (const char *name, enum command_class theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<int> (name, theclass, var_integer, var, - extra_literals, set_doc, show_doc, - help_doc, nullptr, nullptr, set_func, - show_func, set_list, show_list); + extra_literals, set_doc, show_doc, help_doc, + nullptr, nullptr, set_func, show_func, + set_list, show_list); return commands; } @@ -1073,15 +1012,12 @@ add_setshow_integer_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_integer_cmd (const char *name, command_class theclass, - const literal_def *extra_literals, - const char *set_doc, const char *show_doc, - const char *help_doc, - setting_func_types<int>::set set_func, - setting_func_types<int>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, - cmd_list_element **show_list) +add_setshow_integer_cmd ( + const char *name, command_class theclass, const literal_def *extra_literals, + const char *set_doc, const char *show_doc, const char *help_doc, + setting_func_types<int>::set set_func, setting_func_types<int>::get get_func, + show_value_ftype *show_func, cmd_list_element **set_list, + cmd_list_element **show_list) { auto cmds = add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr, extra_literals, set_doc, show_doc, @@ -1091,30 +1027,24 @@ add_setshow_integer_cmd (const char *name, command_class theclass, } /* Accept `unlimited' or 0, translated internally to INT_MAX. */ -const literal_def integer_unlimited_literals[] = - { - { "unlimited", INT_MAX, 0 }, - { nullptr } - }; +const literal_def integer_unlimited_literals[] + = { { "unlimited", INT_MAX, 0 }, { nullptr } }; /* Same as above but using `integer_unlimited_literals', with a pointer to a global storage buffer. */ set_show_commands add_setshow_integer_cmd (const char *name, enum command_class theclass, - int *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, + int *var, const char *set_doc, const char *show_doc, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<int> (name, theclass, var_integer, var, - integer_unlimited_literals, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, + integer_unlimited_literals, set_doc, show_doc, + help_doc, nullptr, nullptr, set_func, show_func, set_list, show_list); return commands; } @@ -1132,11 +1062,11 @@ add_setshow_integer_cmd (const char *name, command_class theclass, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr, - integer_unlimited_literals, - set_doc, show_doc, help_doc, set_func, - get_func, nullptr, show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr, + integer_unlimited_literals, set_doc, show_doc, + help_doc, set_func, get_func, nullptr, + show_func, set_list, show_list); return cmds; } @@ -1149,17 +1079,16 @@ set_show_commands add_setshow_pinteger_cmd (const char *name, enum command_class theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<int> (name, theclass, var_pinteger, var, - extra_literals, set_doc, show_doc, - help_doc, nullptr, nullptr, set_func, - show_func, set_list, show_list); + extra_literals, set_doc, show_doc, help_doc, + nullptr, nullptr, set_func, show_func, + set_list, show_list); return commands; } @@ -1167,15 +1096,12 @@ add_setshow_pinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_pinteger_cmd (const char *name, command_class theclass, - const literal_def *extra_literals, - const char *set_doc, const char *show_doc, - const char *help_doc, - setting_func_types<int>::set set_func, - setting_func_types<int>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, - cmd_list_element **show_list) +add_setshow_pinteger_cmd ( + const char *name, command_class theclass, const literal_def *extra_literals, + const char *set_doc, const char *show_doc, const char *help_doc, + setting_func_types<int>::set set_func, setting_func_types<int>::get get_func, + show_value_ftype *show_func, cmd_list_element **set_list, + cmd_list_element **show_list) { auto cmds = add_setshow_cmd_full<int> (name, theclass, var_pinteger, nullptr, extra_literals, set_doc, show_doc, @@ -1193,8 +1119,7 @@ set_show_commands add_setshow_uinteger_cmd (const char *name, enum command_class theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) @@ -1211,40 +1136,30 @@ add_setshow_uinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_uinteger_cmd (const char *name, command_class theclass, - const literal_def *extra_literals, - const char *set_doc, const char *show_doc, - const char *help_doc, - setting_func_types<unsigned int>::set set_func, - setting_func_types<unsigned int>::get get_func, - show_value_ftype *show_func, - cmd_list_element **set_list, - cmd_list_element **show_list) -{ - auto cmds = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, - nullptr, extra_literals, - set_doc, show_doc, help_doc, - set_func, get_func, nullptr, - show_func, set_list, - show_list); +add_setshow_uinteger_cmd ( + const char *name, command_class theclass, const literal_def *extra_literals, + const char *set_doc, const char *show_doc, const char *help_doc, + setting_func_types<unsigned int>::set set_func, + setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list) +{ + auto cmds = add_setshow_cmd_full<unsigned int> ( + name, theclass, var_uinteger, nullptr, extra_literals, set_doc, show_doc, + help_doc, set_func, get_func, nullptr, show_func, set_list, show_list); return cmds; } /* Accept `unlimited' or 0, translated internally to UINT_MAX. */ -const literal_def uinteger_unlimited_literals[] = - { - { "unlimited", UINT_MAX, 0 }, - { nullptr } - }; +const literal_def uinteger_unlimited_literals[] + = { { "unlimited", UINT_MAX, 0 }, { nullptr } }; /* Same as above but using `uinteger_unlimited_literals', with a pointer to a global storage buffer. */ set_show_commands add_setshow_uinteger_cmd (const char *name, enum command_class theclass, - unsigned int *var, - const char *set_doc, const char *show_doc, - const char *help_doc, + unsigned int *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, @@ -1252,10 +1167,10 @@ add_setshow_uinteger_cmd (const char *name, enum command_class theclass, { set_show_commands commands = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, var, - uinteger_unlimited_literals, - set_doc, show_doc, help_doc, nullptr, - nullptr, set_func, show_func, - set_list, show_list); + uinteger_unlimited_literals, set_doc, + show_doc, help_doc, nullptr, nullptr, + set_func, show_func, set_list, + show_list); return commands; } @@ -1272,13 +1187,12 @@ add_setshow_uinteger_cmd (const char *name, command_class theclass, cmd_list_element **set_list, cmd_list_element **show_list) { - auto cmds = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, - nullptr, - uinteger_unlimited_literals, - set_doc, show_doc, help_doc, - set_func, get_func, nullptr, - show_func, set_list, - show_list); + auto cmds + = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, + nullptr, uinteger_unlimited_literals, + set_doc, show_doc, help_doc, + set_func, get_func, nullptr, + show_func, set_list, show_list); return cmds; } @@ -1289,18 +1203,15 @@ add_setshow_uinteger_cmd (const char *name, command_class theclass, set_show_commands add_setshow_zinteger_cmd (const char *name, enum command_class theclass, - int *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, + int *var, const char *set_doc, const char *show_doc, + const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - return add_setshow_cmd_full<int> (name, theclass, var_integer, var, - set_doc, show_doc, help_doc, - nullptr, nullptr, set_func, - show_func, set_list, show_list); + return add_setshow_cmd_full<int> (name, theclass, var_integer, var, set_doc, + show_doc, help_doc, nullptr, nullptr, + set_func, show_func, set_list, show_list); } /* Same as above but using a getter and a setter function instead of a pointer @@ -1323,33 +1234,24 @@ add_setshow_zinteger_cmd (const char *name, command_class theclass, } /* Accept `unlimited' or -1, using -1 internally. */ -const literal_def pinteger_unlimited_literals[] = - { - { "unlimited", -1, -1 }, - { nullptr } - }; +const literal_def pinteger_unlimited_literals[] + = { { "unlimited", -1, -1 }, { nullptr } }; /* Same as above but using `pinteger_unlimited_literals', with a pointer to a global storage buffer. */ set_show_commands -add_setshow_zuinteger_unlimited_cmd (const char *name, - enum command_class theclass, - int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_func_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list) +add_setshow_zuinteger_unlimited_cmd ( + const char *name, enum command_class theclass, int *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, + show_value_ftype *show_func, struct cmd_list_element **set_list, + struct cmd_list_element **show_list) { set_show_commands commands = add_setshow_cmd_full<int> (name, theclass, var_pinteger, var, - pinteger_unlimited_literals, - set_doc, show_doc, help_doc, nullptr, - nullptr, set_func, show_func, set_list, - show_list); + pinteger_unlimited_literals, set_doc, + show_doc, help_doc, nullptr, nullptr, + set_func, show_func, set_list, show_list); return commands; } @@ -1368,10 +1270,9 @@ add_setshow_zuinteger_unlimited_cmd (const char *name, command_class theclass, { auto cmds = add_setshow_cmd_full<int> (name, theclass, var_pinteger, nullptr, - pinteger_unlimited_literals, - set_doc, show_doc, help_doc, set_func, - get_func, nullptr, show_func, set_list, - show_list); + pinteger_unlimited_literals, set_doc, + show_doc, help_doc, set_func, get_func, + nullptr, show_func, set_list, show_list); return cmds; } @@ -1382,16 +1283,15 @@ add_setshow_zuinteger_unlimited_cmd (const char *name, command_class theclass, set_show_commands add_setshow_zuinteger_cmd (const char *name, enum command_class theclass, - unsigned int *var, - const char *set_doc, const char *show_doc, - const char *help_doc, + unsigned int *var, const char *set_doc, + const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - return add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, - var, set_doc, show_doc, help_doc, + return add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, var, + set_doc, show_doc, help_doc, nullptr, nullptr, set_func, show_func, set_list, show_list); } @@ -1479,7 +1379,7 @@ delete_cmd (const char *name, struct cmd_list_element **list, return aliases; } - + /* Shorthands to the commands above. */ /* Add an element to the list of info subcommands. */ @@ -1502,8 +1402,7 @@ add_info_alias (const char *name, cmd_list_element *target, int abbrev_flag) struct cmd_list_element * add_com (const char *name, enum command_class theclass, - cmd_simple_func_ftype *fun, - const char *doc) + cmd_simple_func_ftype *fun, const char *doc) { return add_cmd (name, theclass, fun, doc, &cmdlist); } @@ -1527,8 +1426,8 @@ add_com_suppress_notification (const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, bool *suppress_notification) { - return add_cmd_suppress_notification (name, theclass, fun, doc, - &cmdlist, suppress_notification); + return add_cmd_suppress_notification (name, theclass, fun, doc, &cmdlist, + suppress_notification); } /* Print the prefix of C followed by name of C in title style. */ @@ -1536,11 +1435,10 @@ add_com_suppress_notification (const char *name, enum command_class theclass, static void fput_command_name_styled (const cmd_list_element &c, struct ui_file *stream) { - std::string prefixname - = c.prefix == nullptr ? "" : c.prefix->prefixname (); + std::string prefixname = c.prefix == nullptr ? "" : c.prefix->prefixname (); - fprintf_styled (stream, title_style.style (), "%s%s", - prefixname.c_str (), c.name); + fprintf_styled (stream, title_style.style (), "%s%s", prefixname.c_str (), + c.name); } /* True if ALIAS has a user-defined documentation. */ @@ -1578,8 +1476,7 @@ fput_aliases_definition_styled (const cmd_list_element &cmd, struct ui_file *stream) { for (const cmd_list_element &alias : cmd.aliases) - if (!alias.cmd_deprecated - && !user_documented_alias (alias) + if (!alias.cmd_deprecated && !user_documented_alias (alias) && !alias.default_args.empty ()) fput_alias_definition_styled (alias, stream); } @@ -1591,18 +1488,16 @@ fput_aliases_definition_styled (const cmd_list_element &cmd, */ static void -fput_command_names_styled (const cmd_list_element &c, - bool always_fput_c_name, const char *postfix, - struct ui_file *stream) +fput_command_names_styled (const cmd_list_element &c, bool always_fput_c_name, + const char *postfix, struct ui_file *stream) { /* First, check if we are going to print something. That is, either if ALWAYS_FPUT_C_NAME is true or if there exists at least one non-deprecated alias not documented specifically by the user. */ - auto print_alias = [] (const cmd_list_element &alias) - { - return !alias.cmd_deprecated && !user_documented_alias (alias); - }; + auto print_alias = [] (const cmd_list_element &alias) { + return !alias.cmd_deprecated && !user_documented_alias (alias); + }; bool print_something = always_fput_c_name; if (!print_something) @@ -1647,8 +1542,7 @@ print_doc_of_command (const cmd_list_element &c, const char *prefix, if (verbose) gdb_puts ("\n", stream); - fput_command_names_styled (c, true, - verbose ? "" : " -- ", stream); + fput_command_names_styled (c, true, verbose ? "" : " -- ", stream); if (verbose) { gdb_puts ("\n", stream); @@ -1672,15 +1566,14 @@ print_doc_of_command (const cmd_list_element &c, const char *prefix, the first line. */ void -apropos_cmd (struct ui_file *stream, - struct cmd_list_element *commandlist, +apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist, bool verbose, compiled_regex ®ex, const char *prefix) { struct cmd_list_element *c; int returnvalue; /* Walk through the commands. */ - for (c=commandlist;c;c=c->next) + for (c = commandlist; c; c = c->next) { if (c->is_alias () && !user_documented_alias (*c)) { @@ -1704,7 +1597,8 @@ apropos_cmd (struct ui_file *stream, for (const cmd_list_element &alias : c->aliases) { name_len = strlen (alias.name); - returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL); + returnvalue + = regex.search (alias.name, name_len, 0, name_len, NULL); if (returnvalue >= 0) { print_doc_of_command (*c, prefix, verbose, regex, stream); @@ -1806,24 +1700,21 @@ help_cmd (const char *command, struct ui_file *stream) /* If this is a prefix command, print it's subcommands. */ if (c->is_prefix ()) - help_list (*c->subcommands, c->prefixname ().c_str (), - all_commands, stream); + help_list (*c->subcommands, c->prefixname ().c_str (), all_commands, + stream); /* If this is a class name, print all of the commands in the class. */ if (c->is_command_class_help ()) help_list (cmdlist, "", c->theclass, stream); if (c->hook_pre || c->hook_post) - gdb_printf (stream, - "\nThis command has a hook (or hooks) defined:\n"); + gdb_printf (stream, "\nThis command has a hook (or hooks) defined:\n"); if (c->hook_pre) - gdb_printf (stream, - "\tThis command is run after : %s (pre hook)\n", + gdb_printf (stream, "\tThis command is run after : %s (pre hook)\n", c->hook_pre->name); if (c->hook_post) - gdb_printf (stream, - "\tThis command is run before : %s (post hook)\n", + gdb_printf (stream, "\tThis command is run before : %s (post hook)\n", c->hook_post->name); } @@ -1890,7 +1781,8 @@ Type \"help all\" for the list of all commands."); stream->wrap_here (0); gdb_puts ("documentation.\n", stream); gdb_puts ("Type \"apropos word\" to search " - "for commands related to \"word\".\n", stream); + "for commands related to \"word\".\n", + stream); gdb_puts ("Type \"apropos -v word\" for full documentation", stream); stream->wrap_here (0); gdb_puts (" of commands related to \"word\".\n", stream); @@ -1937,14 +1829,12 @@ help_all (struct ui_file *stream) print_help_for_command (*c, true, stream); } } - } /* See cli-decode.h. */ void -print_doc_line (struct ui_file *stream, const char *str, - bool for_value_prefix) +print_doc_line (struct ui_file *stream, const char *str, bool for_value_prefix) { static char *line_buffer = 0; static int line_size; @@ -1986,8 +1876,8 @@ print_doc_line (struct ui_file *stream, const char *str, If RECURSE is non-zero, also print one-line descriptions of all prefixed subcommands. */ static void -print_help_for_command (const cmd_list_element &c, - bool recurse, struct ui_file *stream) +print_help_for_command (const cmd_list_element &c, bool recurse, + struct ui_file *stream) { fput_command_names_styled (c, true, " -- ", stream); print_doc_line (stream, c.doc, false); @@ -1996,9 +1886,7 @@ print_help_for_command (const cmd_list_element &c, fput_alias_definition_styled (c, stream); fput_aliases_definition_styled (c, stream); - if (recurse - && c.is_prefix () - && c.abbrev_flag == 0) + if (recurse && c.is_prefix () && c.abbrev_flag == 0) /* Subcommands of a prefix command typically have 'all_commands' as class. If we pass CLASS to recursive invocation, most often we won't see anything. */ @@ -2058,15 +1946,13 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, /* If we show the class_alias and C is an alias, do not recurse, as this would show the (possibly very long) not very useful list of sub-commands of the aliased command. */ - print_help_for_command - (*c, - recurse && (theclass != class_alias || !c->is_alias ()), - stream); + print_help_for_command ( + *c, recurse && (theclass != class_alias || !c->is_alias ()), + stream); continue; } - if (recurse - && (theclass == class_user || theclass == class_alias) + if (recurse && (theclass == class_user || theclass == class_alias) && c->is_prefix ()) { /* User-defined commands or aliases may be subcommands. */ @@ -2078,7 +1964,6 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, THECLASS or because C is a help class. */ } } - /* Search the input clist for 'command'. Return the command if found (or NULL if not), and return the number of commands @@ -2194,7 +2079,6 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, /* *text and p now bracket the first command word to lookup (and it's length is len). We copy this into a local temporary. */ - command = (char *) alloca (len + 1); memcpy (command, *text, len); command[len] = '\0'; @@ -2216,7 +2100,7 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, *result_list = 0; if (default_args != nullptr) *default_args = std::string (); - return CMD_LIST_AMBIGUOUS; /* Ambiguous. */ + return CMD_LIST_AMBIGUOUS; /* Ambiguous. */ } /* We've matched something on this list. Move text pointer forward. */ @@ -2235,7 +2119,6 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, if (found->deprecated_warn_user && !lookup_for_completion_p) deprecated_cmd_warning (line, clist); - /* Return the default_args of the alias, not the default_args of the command it is pointing to. */ if (default_args != nullptr) @@ -2296,12 +2179,8 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist, static void undef_cmd_error (const char *cmdtype, const char *q) { - error (_("Undefined %scommand: \"%s\". Try \"help%s%.*s\"."), - cmdtype, - q, - *cmdtype ? " " : "", - (int) strlen (cmdtype) - 1, - cmdtype); + error (_ ("Undefined %scommand: \"%s\". Try \"help%s%.*s\"."), cmdtype, q, + *cmdtype ? " " : "", (int) strlen (cmdtype) - 1, cmdtype); } /* Look up the contents of *LINE as a command in the command list LIST. @@ -2325,9 +2204,8 @@ undef_cmd_error (const char *cmdtype, const char *q) struct cmd_list_element * lookup_cmd (const char **line, struct cmd_list_element *list, - const char *cmdtype, - std::string *default_args, - int allow_unknown, int ignore_help_classes) + const char *cmdtype, std::string *default_args, int allow_unknown, + int ignore_help_classes) { struct cmd_list_element *last_list = 0; struct cmd_list_element *c; @@ -2336,7 +2214,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, would be wrong for complete_command. Jim Kingdon */ if (!*line) - error (_("Lack of needed %scommand"), cmdtype); + error (_ ("Lack of needed %scommand"), cmdtype); c = lookup_cmd_1 (line, list, &last_list, default_args, ignore_help_classes); @@ -2359,19 +2237,19 @@ lookup_cmd (const char **line, struct cmd_list_element *list, { /* Ambigous. Local values should be off subcommands or called values. */ - int local_allow_unknown = (last_list ? last_list->allow_unknown : - allow_unknown); + int local_allow_unknown + = (last_list ? last_list->allow_unknown : allow_unknown); std::string local_cmdtype = last_list ? last_list->prefixname () : cmdtype; - struct cmd_list_element *local_list = - (last_list ? *(last_list->subcommands) : list); + struct cmd_list_element *local_list + = (last_list ? *(last_list->subcommands) : list); if (local_allow_unknown < 0) { if (last_list) - return last_list; /* Found something. */ + return last_list; /* Found something. */ else - return 0; /* Found nothing. */ + return 0; /* Found nothing. */ } else { @@ -2379,9 +2257,8 @@ lookup_cmd (const char **line, struct cmd_list_element *list, int amb_len; char ambbuf[100]; - for (amb_len = 0; - ((*line)[amb_len] && (*line)[amb_len] != ' ' - && (*line)[amb_len] != '\t'); + for (amb_len = 0; ((*line)[amb_len] && (*line)[amb_len] != ' ' + && (*line)[amb_len] != '\t'); amb_len++) ; @@ -2402,14 +2279,14 @@ lookup_cmd (const char **line, struct cmd_list_element *list, break; } } - error (_("Ambiguous %scommand \"%s\": %s."), - local_cmdtype.c_str (), *line, ambbuf); + error (_ ("Ambiguous %scommand \"%s\": %s."), local_cmdtype.c_str (), + *line, ambbuf); } } else { if (c->type == set_cmd && **line != '\0' && !isspace (**line)) - error (_("Argument must be preceded by space.")); + error (_ ("Argument must be preceded by space.")); /* We've got something. It may still not be what the caller wants (if this command *needs* a subcommand). */ @@ -2428,13 +2305,12 @@ lookup_cmd (const char **line, struct cmd_list_element *list, /* See command.h. */ struct cmd_list_element * -lookup_cmd_exact (const char *name, - struct cmd_list_element *list, +lookup_cmd_exact (const char *name, struct cmd_list_element *list, bool ignore_help_classes) { const char *tem = name; - struct cmd_list_element *cmd = lookup_cmd (&tem, list, "", NULL, -1, - ignore_help_classes); + struct cmd_list_element *cmd + = lookup_cmd (&tem, list, "", NULL, -1, ignore_help_classes); if (cmd != nullptr && strcmp (name, cmd->name) != 0) cmd = nullptr; return cmd; @@ -2504,23 +2380,21 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list) tmp_alias_str += std::string (alias->name); if (cmd->cmd_deprecated) - gdb_printf (_("Warning: command '%ps' (%ps) is deprecated.\n"), - styled_string (title_style.style (), - tmp_cmd_str.c_str ()), + gdb_printf (_ ("Warning: command '%ps' (%ps) is deprecated.\n"), + styled_string (title_style.style (), tmp_cmd_str.c_str ()), styled_string (title_style.style (), tmp_alias_str.c_str ())); else - gdb_printf (_("Warning: '%ps', an alias for the command '%ps', " - "is deprecated.\n"), + gdb_printf (_ ("Warning: '%ps', an alias for the command '%ps', " + "is deprecated.\n"), styled_string (title_style.style (), tmp_alias_str.c_str ()), styled_string (title_style.style (), tmp_cmd_str.c_str ())); } else - gdb_printf (_("Warning: command '%ps' is deprecated.\n"), - styled_string (title_style.style (), - tmp_cmd_str.c_str ())); + gdb_printf (_ ("Warning: command '%ps' is deprecated.\n"), + styled_string (title_style.style (), tmp_cmd_str.c_str ())); /* Now display a second line indicating what the user should use instead. If it is only the alias that is deprecated, we want to indicate the @@ -2531,11 +2405,10 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list) else replacement = cmd->replacement; if (replacement != nullptr) - gdb_printf (_("Use '%ps'.\n\n"), - styled_string (title_style.style (), - replacement)); + gdb_printf (_ ("Use '%ps'.\n\n"), + styled_string (title_style.style (), replacement)); else - gdb_printf (_("No alternative known.\n\n")); + gdb_printf (_ ("No alternative known.\n\n")); /* We've warned you, now we'll keep quiet. */ if (alias != nullptr) @@ -2559,8 +2432,7 @@ deprecated_cmd_warning (const char *text, struct cmd_list_element *list) */ static int -lookup_cmd_composition_1 (const char *text, - struct cmd_list_element **alias, +lookup_cmd_composition_1 (const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd, struct cmd_list_element *cur_list) @@ -2633,8 +2505,7 @@ lookup_cmd_composition_1 (const char *text, */ int -lookup_cmd_composition (const char *text, - struct cmd_list_element **alias, +lookup_cmd_composition (const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd) { @@ -2653,9 +2524,8 @@ lookup_cmd_composition (const char *text, void complete_on_cmdlist (struct cmd_list_element *list, - completion_tracker &tracker, - const char *text, const char *word, - int ignore_help_classes) + completion_tracker &tracker, const char *text, + const char *word, int ignore_help_classes) { struct cmd_list_element *ptr; int textlen = strlen (text); @@ -2671,8 +2541,7 @@ complete_on_cmdlist (struct cmd_list_element *list, bool got_matches = false; for (ptr = list; ptr; ptr = ptr->next) - if (!strncmp (ptr->name, text, textlen) - && !ptr->abbrev_flag + if (!strncmp (ptr->name, text, textlen) && !ptr->abbrev_flag && (!ignore_help_classes || !ptr->is_command_class_help () || ptr->is_prefix ())) { @@ -2685,8 +2554,8 @@ complete_on_cmdlist (struct cmd_list_element *list, } } - tracker.add_completion - (make_completion_match_str (ptr->name, text, word)); + tracker.add_completion (make_completion_match_str (ptr->name, text, + word)); got_matches = true; } @@ -2710,8 +2579,7 @@ complete_on_cmdlist (struct cmd_list_element *list, "oobar"; if WORD is "baz/foo", return "baz/foobar". */ void -complete_on_enum (completion_tracker &tracker, - const char *const *enumlist, +complete_on_enum (completion_tracker &tracker, const char *const *enumlist, const char *text, const char *word) { int textlen = strlen (text); @@ -2737,7 +2605,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) cmd->func (args, from_tty, cmd); } else - error (_("Invalid command")); + error (_ ("Invalid command")); } int diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 013ffc8..69cf9cc 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -41,7 +41,6 @@ enum cmd_types /* This structure records one command'd definition. */ - struct cmd_list_element { cmd_list_element (const char *name_, enum command_class theclass_, @@ -87,18 +86,15 @@ struct cmd_list_element std::vector<std::string> command_components () const; /* Return true if this command is an alias of another command. */ - bool is_alias () const - { return this->alias_target != nullptr; } + bool is_alias () const { return this->alias_target != nullptr; } /* Return true if this command is a prefix command. */ - bool is_prefix () const - { return this->subcommands != nullptr; } + bool is_prefix () const { return this->subcommands != nullptr; } /* Return true if this command is a "command class help" command. For instance, a "stack" dummy command is registered so that one can do "help stack" and show help for all commands of the "stack" class. */ - bool is_command_class_help () const - { return this->func == nullptr; } + bool is_command_class_help () const { return this->func == nullptr; } void set_context (void *context) { @@ -106,8 +102,7 @@ struct cmd_list_element m_context = context; } - void *context () const - { return m_context; } + void *context () const { return m_context; } /* Points to next command in this list. */ struct cmd_list_element *next = nullptr; @@ -177,14 +172,13 @@ struct cmd_list_element /* The command's real callback. At present func() bounces through to one of the below. */ union - { - /* Most commands don't need the cmd_list_element parameter passed to FUNC. + { + /* Most commands don't need the cmd_list_element parameter passed to FUNC. They therefore register a command of this type, which doesn't have the cmd_list_element parameter. do_simple_func is installed as FUNC, and acts as a shim between the two. */ - cmd_simple_func_ftype *simple_func; - } - function; + cmd_simple_func_ftype *simple_func; + } function; /* Documentation of this command (or help topic). First line is brief documentation; remaining lines form, with it, @@ -255,8 +249,7 @@ struct cmd_list_element struct cmd_list_element *alias_target = nullptr; /* Node to link aliases on an alias list. */ - using aliases_list_node_type - = intrusive_list_node<cmd_list_element>; + using aliases_list_node_type = intrusive_list_node<cmd_list_element>; aliases_list_node_type aliases_list_node; /* Linked list of all aliases of this command. */ @@ -274,6 +267,7 @@ struct cmd_list_element bool *suppress_notification = nullptr; private: + /* Local state (context) for this command. This can be anything. */ void *m_context = nullptr; }; @@ -301,10 +295,10 @@ extern void print_doc_line (struct ui_file *stream, const char *str, bool for_value_prefix); /* The enums of boolean commands. */ -extern const char * const boolean_enums[]; +extern const char *const boolean_enums[]; /* The enums of auto-boolean commands. */ -extern const char * const auto_boolean_enums[]; +extern const char *const auto_boolean_enums[]; /* Verify whether a given cmd_list_element is a user-defined command. Return 1 if it is user-defined. Return 0 otherwise. */ diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index a8811c4..8824242 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -51,7 +51,6 @@ scan_expression (const char **cmd, const char *def) } } - static gdb::unique_xmalloc_ptr<char> scan_filename (const char **cmd, const char *defname) { @@ -63,7 +62,7 @@ scan_filename (const char **cmd, const char *defname) if ((*cmd) == NULL) { if (defname == NULL) - error (_("Missing filename.")); + error (_ ("Missing filename.")); filename.reset (xstrdup (defname)); } else @@ -86,11 +85,11 @@ bfd_openr_or_error (const char *filename, const char *target) { gdb_bfd_ref_ptr ibfd (gdb_bfd_openr (filename, target)); if (ibfd == NULL) - error (_("Failed to open %s: %s."), filename, + error (_ ("Failed to open %s: %s."), filename, bfd_errmsg (bfd_get_error ())); if (!bfd_check_format (ibfd.get (), bfd_object)) - error (_("'%s' is not a recognized file format."), filename); + error (_ ("'%s' is not a recognized file format."), filename); return ibfd; } @@ -100,21 +99,21 @@ bfd_openw_or_error (const char *filename, const char *target, const char *mode) { gdb_bfd_ref_ptr obfd; - if (*mode == 'w') /* Write: create new file */ + if (*mode == 'w') /* Write: create new file */ { obfd = gdb_bfd_openw (filename, target); if (obfd == NULL) - error (_("Failed to open %s: %s."), filename, + error (_ ("Failed to open %s: %s."), filename, bfd_errmsg (bfd_get_error ())); if (!bfd_set_format (obfd.get (), bfd_object)) - error (_("bfd_openw_or_error: %s."), bfd_errmsg (bfd_get_error ())); + error (_ ("bfd_openw_or_error: %s."), bfd_errmsg (bfd_get_error ())); } - else if (*mode == 'a') /* Append to existing file. */ - { /* FIXME -- doesn't work... */ - error (_("bfd_openw does not work with append.")); + else if (*mode == 'a') /* Append to existing file. */ + { /* FIXME -- doesn't work... */ + error (_ ("bfd_openw does not work with append.")); } else - error (_("bfd_openw_or_error: unknown mode %s."), mode); + error (_ ("bfd_openw_or_error: unknown mode %s."), mode); return obfd; } @@ -129,8 +128,8 @@ static struct cmd_list_element *binary_dump_cmdlist; static struct cmd_list_element *binary_append_cmdlist; static void -dump_binary_file (const char *filename, const char *mode, - const bfd_byte *buf, ULONGEST len) +dump_binary_file (const char *filename, const char *mode, const bfd_byte *buf, + ULONGEST len) { int status; @@ -144,9 +143,8 @@ dump_binary_file (const char *filename, const char *mode, } static void -dump_bfd_file (const char *filename, const char *mode, - const char *target, CORE_ADDR vaddr, - const bfd_byte *buf, ULONGEST len) +dump_bfd_file (const char *filename, const char *mode, const char *target, + CORE_ADDR vaddr, const bfd_byte *buf, ULONGEST len) { asection *osection; @@ -158,12 +156,13 @@ dump_bfd_file (const char *filename, const char *mode, bfd_set_section_flags (osection, (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD)); osection->entsize = 0; if (!bfd_set_section_contents (obfd.get (), osection, buf, 0, len)) - warning (_("writing dump file '%s' (%s)"), filename, + warning (_ ("writing dump file '%s' (%s)"), filename, bfd_errmsg (bfd_get_error ())); } static void -dump_memory_to_file (const char *cmd, const char *mode, const char *file_format) +dump_memory_to_file (const char *cmd, const char *mode, + const char *file_format) { CORE_ADDR lo; CORE_ADDR hi; @@ -175,25 +174,25 @@ dump_memory_to_file (const char *cmd, const char *mode, const char *file_format) /* Find the low address. */ if (cmd == NULL || *cmd == '\0') - error (_("Missing start address.")); + error (_ ("Missing start address.")); gdb::unique_xmalloc_ptr<char> lo_exp = scan_expression (&cmd, NULL); /* Find the second address - rest of line. */ if (cmd == NULL || *cmd == '\0') - error (_("Missing stop address.")); + error (_ ("Missing stop address.")); hi_exp = cmd; lo = parse_and_eval_address (lo_exp.get ()); hi = parse_and_eval_address (hi_exp); if (hi <= lo) - error (_("Invalid memory address range (start >= end).")); + error (_ ("Invalid memory address range (start >= end).")); count = hi - lo; /* FIXME: Should use read_memory_partial() and a magic blocking value. */ gdb::byte_vector buf (count); read_memory (lo, buf.data (), count); - + /* Have everything. Open/write the data. */ if (file_format == NULL || strcmp (file_format, "binary") == 0) dump_binary_file (filename.get (), mode, buf.data (), count); @@ -217,10 +216,10 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) /* Find the value. */ if (cmd == NULL || *cmd == '\0') - error (_("No value to %s."), *mode == 'a' ? "append" : "dump"); + error (_ ("No value to %s."), *mode == 'a' ? "append" : "dump"); val = parse_and_eval (cmd); if (val == NULL) - error (_("Invalid expression.")); + error (_ ("Invalid expression.")); /* Have everything. Open/write the data. */ if (file_format == NULL || strcmp (file_format, "binary") == 0) @@ -237,11 +236,11 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) else { vaddr = 0; - warning (_("value is not an lval: address assumed to be zero")); + warning (_ ("value is not an lval: address assumed to be zero")); } dump_bfd_file (filename.get (), mode, file_format, vaddr, - value_contents (val).data (), + value_contents (val).data (), value_type (val)->length ()); } } @@ -348,7 +347,7 @@ add_dump_command (const char *name, struct dump_context *d; c = add_cmd (name, all_commands, descr, &dump_cmdlist); - c->completer = filename_completer; + c->completer = filename_completer; d = XNEW (struct dump_context); d->func = func; d->mode = FOPEN_WB; @@ -356,7 +355,7 @@ add_dump_command (const char *name, c->func = call_dump_func; c = add_cmd (name, all_commands, descr, &append_cmdlist); - c->completer = filename_completer; + c->completer = filename_completer; d = XNEW (struct dump_context); d->func = func; d->mode = FOPEN_AB; @@ -365,26 +364,20 @@ add_dump_command (const char *name, /* Replace "Dump " at start of docstring with "Append " (borrowed from [deleted] deprecated_add_show_from_set). */ - if ( c->doc[0] == 'W' - && c->doc[1] == 'r' - && c->doc[2] == 'i' - && c->doc[3] == 't' - && c->doc[4] == 'e' - && c->doc[5] == ' ') - c->doc = concat ("Append ", c->doc + 6, (char *)NULL); + if (c->doc[0] == 'W' && c->doc[1] == 'r' && c->doc[2] == 'i' + && c->doc[3] == 't' && c->doc[4] == 'e' && c->doc[5] == ' ') + c->doc = concat ("Append ", c->doc + 6, (char *) NULL); } /* Selectively loads the sections into memory. */ static void -restore_one_section (bfd *ibfd, asection *isec, - CORE_ADDR load_offset, - CORE_ADDR load_start, - CORE_ADDR load_end) +restore_one_section (bfd *ibfd, asection *isec, CORE_ADDR load_offset, + CORE_ADDR load_start, CORE_ADDR load_end) { - bfd_vma sec_start = bfd_section_vma (isec); + bfd_vma sec_start = bfd_section_vma (isec); bfd_size_type size = bfd_section_size (isec); - bfd_vma sec_end = sec_start + size; + bfd_vma sec_end = sec_start + size; bfd_size_type sec_offset = 0; bfd_size_type sec_load_count = size; int ret; @@ -394,12 +387,10 @@ restore_one_section (bfd *ibfd, asection *isec, return; /* Does the section overlap with the desired restore range? */ - if (sec_end <= load_start - || (load_end > 0 && sec_start >= load_end)) + if (sec_end <= load_start || (load_end > 0 && sec_start >= load_end)) { /* No, no useable data in this section. */ - gdb_printf (_("skipping section %s...\n"), - bfd_section_name (isec)); + gdb_printf (_ ("skipping section %s...\n"), bfd_section_name (isec)); return; } @@ -416,22 +407,19 @@ restore_one_section (bfd *ibfd, asection *isec, /* Get the data. */ gdb::byte_vector buf (size); if (!bfd_get_section_contents (ibfd, isec, buf.data (), 0, size)) - error (_("Failed to read bfd file %s: '%s'."), bfd_get_filename (ibfd), + error (_ ("Failed to read bfd file %s: '%s'."), bfd_get_filename (ibfd), bfd_errmsg (bfd_get_error ())); - gdb_printf ("Restoring section %s (0x%lx to 0x%lx)", - bfd_section_name (isec), - (unsigned long) sec_start, - (unsigned long) sec_end); + gdb_printf ("Restoring section %s (0x%lx to 0x%lx)", bfd_section_name (isec), + (unsigned long) sec_start, (unsigned long) sec_end); if (load_offset != 0 || load_start != 0 || load_end != 0) gdb_printf (" into memory (%s to %s)\n", - paddress (target_gdbarch (), - (unsigned long) sec_start - + sec_offset + load_offset), - paddress (target_gdbarch (), - (unsigned long) sec_start + sec_offset - + load_offset + sec_load_count)); + paddress (target_gdbarch (), (unsigned long) sec_start + + sec_offset + load_offset), + paddress (target_gdbarch (), (unsigned long) sec_start + + sec_offset + load_offset + + sec_load_count)); else gdb_puts ("\n"); @@ -439,7 +427,7 @@ restore_one_section (bfd *ibfd, asection *isec, ret = target_write_memory (sec_start + sec_offset + load_offset, &buf[sec_offset], sec_load_count); if (ret != 0) - warning (_("restore: memory write failed (%s)."), safe_strerror (ret)); + warning (_ ("restore: memory write failed (%s)."), safe_strerror (ret)); } static void @@ -451,7 +439,7 @@ restore_binary_file (const char *filename, CORE_ADDR load_offset, long len; if (file == NULL) - error (_("Failed to open %s: %s"), filename, safe_strerror (errno)); + error (_ ("Failed to open %s: %s"), filename, safe_strerror (errno)); /* Get the file size for reading. */ if (fseek (file.get (), 0, SEEK_END) == 0) @@ -464,7 +452,7 @@ restore_binary_file (const char *filename, CORE_ADDR load_offset, perror_with_name (filename); if (len <= load_start) - error (_("Start address is greater than length of binary file %s."), + error (_ ("Start address is greater than length of binary file %s."), filename); /* Chop off "len" if it exceeds the requested load_end addr. */ @@ -474,11 +462,9 @@ restore_binary_file (const char *filename, CORE_ADDR load_offset, if (load_start > 0) len -= load_start; - gdb_printf - ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", - filename, - (unsigned long) (load_start + load_offset), - (unsigned long) (load_start + load_offset + len)); + gdb_printf ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", + filename, (unsigned long) (load_start + load_offset), + (unsigned long) (load_start + load_offset + len)); /* Now set the file pos to the requested load start pos. */ if (fseek (file.get (), load_start, SEEK_SET) != 0) @@ -492,7 +478,7 @@ restore_binary_file (const char *filename, CORE_ADDR load_offset, /* Now write the buffer into target memory. */ len = target_write_memory (load_start + load_offset, buf.data (), len); if (len != 0) - warning (_("restore: memory write failed (%s)."), safe_strerror (len)); + warning (_ ("restore: memory write failed (%s)."), safe_strerror (len)); } static void @@ -504,8 +490,8 @@ restore_command (const char *args, int from_tty) noprocess (); CORE_ADDR load_offset = 0; - CORE_ADDR load_start = 0; - CORE_ADDR load_end = 0; + CORE_ADDR load_start = 0; + CORE_ADDR load_end = 0; /* Parse the input arguments. First is filename (required). */ gdb::unique_xmalloc_ptr<char> filename = scan_filename (&args, NULL); @@ -524,19 +510,19 @@ restore_command (const char *args, int from_tty) if (args != NULL && *args != '\0') load_offset = (binary_flag - ? parse_and_eval_address (scan_expression (&args, NULL).get ()) - : parse_and_eval_long (scan_expression (&args, NULL).get ())); + ? parse_and_eval_address (scan_expression (&args, NULL).get ()) + : parse_and_eval_long (scan_expression (&args, NULL).get ())); if (args != NULL && *args != '\0') { /* Parse start address (optional). */ - load_start = - parse_and_eval_long (scan_expression (&args, NULL).get ()); + load_start + = parse_and_eval_long (scan_expression (&args, NULL).get ()); if (args != NULL && *args != '\0') { /* Parse end address (optional). */ load_end = parse_and_eval_long (args); if (load_end <= load_start) - error (_("Start must be less than end.")); + error (_ ("Start must be less than end.")); } } } @@ -544,13 +530,11 @@ restore_command (const char *args, int from_tty) if (info_verbose) gdb_printf ("Restore file %s offset 0x%lx start 0x%lx end 0x%lx\n", filename.get (), (unsigned long) load_offset, - (unsigned long) load_start, - (unsigned long) load_end); + (unsigned long) load_start, (unsigned long) load_end); if (binary_flag) { - restore_binary_file (filename.get (), load_offset, load_start, - load_end); + restore_binary_file (filename.get (), load_offset, load_start, load_end); } else { @@ -565,21 +549,18 @@ restore_command (const char *args, int from_tty) } void _initialize_cli_dump (); + void _initialize_cli_dump () { struct cmd_list_element *c; add_basic_prefix_cmd ("dump", class_vars, - _("Dump target code/data to a local file."), - &dump_cmdlist, - 0/*allow-unknown*/, - &cmdlist); + _ ("Dump target code/data to a local file."), + &dump_cmdlist, 0 /*allow-unknown*/, &cmdlist); add_basic_prefix_cmd ("append", class_vars, - _("Append target code/data to a local file."), - &append_cmdlist, - 0/*allow-unknown*/, - &cmdlist); + _ ("Append target code/data to a local file."), + &append_cmdlist, 0 /*allow-unknown*/, &cmdlist); add_dump_command ("memory", dump_memory_command, "\ Write contents of memory to a raw binary file.\n\ @@ -592,114 +573,104 @@ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION to\n\ the specified FILE in raw target ordered bytes."); add_basic_prefix_cmd ("srec", all_commands, - _("Write target code/data to an srec file."), - &srec_cmdlist, - 0 /*allow-unknown*/, - &dump_cmdlist); + _ ("Write target code/data to an srec file."), + &srec_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); add_basic_prefix_cmd ("ihex", all_commands, - _("Write target code/data to an intel hex file."), - &ihex_cmdlist, - 0 /*allow-unknown*/, - &dump_cmdlist); + _ ("Write target code/data to an intel hex file."), + &ihex_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); add_basic_prefix_cmd ("verilog", all_commands, - _("Write target code/data to a verilog hex file."), - &verilog_cmdlist, - 0 /*allow-unknown*/, - &dump_cmdlist); + _ ("Write target code/data to a verilog hex file."), + &verilog_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); add_basic_prefix_cmd ("tekhex", all_commands, - _("Write target code/data to a tekhex file."), - &tekhex_cmdlist, - 0 /*allow-unknown*/, - &dump_cmdlist); + _ ("Write target code/data to a tekhex file."), + &tekhex_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); add_basic_prefix_cmd ("binary", all_commands, - _("Write target code/data to a raw binary file."), - &binary_dump_cmdlist, - 0 /*allow-unknown*/, + _ ("Write target code/data to a raw binary file."), + &binary_dump_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); add_basic_prefix_cmd ("binary", all_commands, - _("Append target code/data to a raw binary file."), - &binary_append_cmdlist, - 0 /*allow-unknown*/, + _ ("Append target code/data to a raw binary file."), + &binary_append_cmdlist, 0 /*allow-unknown*/, &append_cmdlist); - add_cmd ("memory", all_commands, dump_srec_memory, _("\ + add_cmd ("memory", all_commands, dump_srec_memory, _ ("\ Write contents of memory to an srec file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in srec format."), &srec_cmdlist); - add_cmd ("value", all_commands, dump_srec_value, _("\ + add_cmd ("value", all_commands, dump_srec_value, _ ("\ Write the value of an expression to an srec file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in srec format."), &srec_cmdlist); - add_cmd ("memory", all_commands, dump_ihex_memory, _("\ + add_cmd ("memory", all_commands, dump_ihex_memory, _ ("\ Write contents of memory to an ihex file.\n\ Arguments are FILE START STOP. Writes the contents of memory within\n\ the range [START .. STOP) to the specified FILE in intel hex format."), &ihex_cmdlist); - add_cmd ("value", all_commands, dump_ihex_value, _("\ + add_cmd ("value", all_commands, dump_ihex_value, _ ("\ Write the value of an expression to an ihex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in intel hex format."), &ihex_cmdlist); - add_cmd ("memory", all_commands, dump_verilog_memory, _("\ + add_cmd ("memory", all_commands, dump_verilog_memory, _ ("\ Write contents of memory to a verilog hex file.\n\ Arguments are FILE START STOP. Writes the contents of memory within\n\ the range [START .. STOP) to the specified FILE in verilog hex format."), &verilog_cmdlist); - add_cmd ("value", all_commands, dump_verilog_value, _("\ + add_cmd ("value", all_commands, dump_verilog_value, _ ("\ Write the value of an expression to a verilog hex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in verilog hex format."), &verilog_cmdlist); - add_cmd ("memory", all_commands, dump_tekhex_memory, _("\ + add_cmd ("memory", all_commands, dump_tekhex_memory, _ ("\ Write contents of memory to a tekhex file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in tekhex format."), &tekhex_cmdlist); - add_cmd ("value", all_commands, dump_tekhex_value, _("\ + add_cmd ("value", all_commands, dump_tekhex_value, _ ("\ Write the value of an expression to a tekhex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in tekhex format."), &tekhex_cmdlist); - add_cmd ("memory", all_commands, dump_binary_memory, _("\ + add_cmd ("memory", all_commands, dump_binary_memory, _ ("\ Write contents of memory to a raw binary file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in binary format."), &binary_dump_cmdlist); - add_cmd ("value", all_commands, dump_binary_value, _("\ + add_cmd ("value", all_commands, dump_binary_value, _ ("\ Write the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in raw target ordered bytes."), &binary_dump_cmdlist); - add_cmd ("memory", all_commands, append_binary_memory, _("\ + add_cmd ("memory", all_commands, append_binary_memory, _ ("\ Append contents of memory to a raw binary file.\n\ Arguments are FILE START STOP. Writes the contents of memory within the\n\ range [START .. STOP) to the specified FILE in raw target ordered bytes."), &binary_append_cmdlist); - add_cmd ("value", all_commands, append_binary_value, _("\ + add_cmd ("value", all_commands, append_binary_value, _ ("\ Append the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in raw target ordered bytes."), &binary_append_cmdlist); - c = add_com ("restore", class_vars, restore_command, _("\ + c = add_com ("restore", class_vars, restore_command, _ ("\ Restore the contents of FILE to target memory.\n\ Arguments are FILE OFFSET START END where all except FILE are optional.\n\ OFFSET will be added to the base address of the file (default zero).\n\ diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 9941014..ab779e1 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -23,7 +23,7 @@ #include "event-top.h" #include "ui-out.h" #include "cli-out.h" -#include "top.h" /* for "execute_command" */ +#include "top.h" /* for "execute_command" */ #include "infrun.h" #include "observable.h" #include "gdbthread.h" @@ -32,16 +32,17 @@ cli_interp_base::cli_interp_base (const char *name) : interp (name) -{} +{ +} -cli_interp_base::~cli_interp_base () -{} +cli_interp_base::~cli_interp_base () {} /* The console interpreter. */ class cli_interp final : public cli_interp_base { - public: +public: + explicit cli_interp (const char *name); ~cli_interp () = default; @@ -124,16 +125,16 @@ cli_base_on_normal_stop (struct bpstat *bs, int print_frame) return; SWITCH_THRU_ALL_UIS () - { - struct interp *interp = top_level_interpreter (); - cli_interp_base *cli = as_cli_interp_base (interp); - if (cli == nullptr) - continue; - - thread_info *thread = inferior_thread (); - if (should_print_stop_to_console (interp, thread)) - print_stop_event (cli->interp_ui_out ()); - } + { + struct interp *interp = top_level_interpreter (); + cli_interp_base *cli = as_cli_interp_base (interp); + if (cli == nullptr) + continue; + + thread_info *thread = inferior_thread (); + if (should_print_stop_to_console (interp, thread)) + print_stop_event (cli->interp_ui_out ()); + } } /* Observer for the signal_received notification. */ @@ -142,13 +143,13 @@ static void cli_base_on_signal_received (enum gdb_signal siggnal) { SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; - print_signal_received_reason (cli->interp_ui_out (), siggnal); - } + print_signal_received_reason (cli->interp_ui_out (), siggnal); + } } /* Observer for the end_stepping_range notification. */ @@ -157,13 +158,13 @@ static void cli_base_on_end_stepping_range () { SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; - print_end_stepping_range_reason (cli->interp_ui_out ()); - } + print_end_stepping_range_reason (cli->interp_ui_out ()); + } } /* Observer for the signalled notification. */ @@ -172,13 +173,13 @@ static void cli_base_on_signal_exited (enum gdb_signal siggnal) { SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; - print_signal_exited_reason (cli->interp_ui_out (), siggnal); - } + print_signal_exited_reason (cli->interp_ui_out (), siggnal); + } } /* Observer for the exited notification. */ @@ -187,13 +188,13 @@ static void cli_base_on_exited (int exitstatus) { SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; - print_exited_reason (cli->interp_ui_out (), exitstatus); - } + print_exited_reason (cli->interp_ui_out (), exitstatus); + } } /* Observer for the no_history notification. */ @@ -202,13 +203,13 @@ static void cli_base_on_no_history () { SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; - print_no_history_reason (cli->interp_ui_out ()); - } + print_no_history_reason (cli->interp_ui_out ()); + } } /* Observer for the sync_execution_done notification. */ @@ -247,18 +248,18 @@ cli_base_on_user_selected_context_changed (user_selected_what selection) thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : nullptr; SWITCH_THRU_ALL_UIS () - { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - continue; - - if (selection & USER_SELECTED_INFERIOR) - print_selected_inferior (cli->interp_ui_out ()); - - if (tp != nullptr - && ((selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))) - print_selected_thread_frame (cli->interp_ui_out (), selection); - } + { + cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); + if (cli == nullptr) + continue; + + if (selection & USER_SELECTED_INFERIOR) + print_selected_inferior (cli->interp_ui_out ()); + + if (tp != nullptr + && ((selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))) + print_selected_thread_frame (cli->interp_ui_out (), selection); + } } /* pre_command_loop implementation. */ @@ -320,11 +321,14 @@ cli_interp::exec (const char *command_str) It is important that it gets reset everytime, since the user could set gdb to use a different interpreter. */ ui_file *old_stream = m_cli_uiout->set_stream (gdb_stdout); - SCOPE_EXIT { m_cli_uiout->set_stream (old_stream); }; + SCOPE_EXIT + { + m_cli_uiout->set_stream (old_stream); + }; /* Save and override the global ``struct ui_out'' builder. */ - scoped_restore saved_uiout = make_scoped_restore (¤t_uiout, - m_cli_uiout.get ()); + scoped_restore saved_uiout + = make_scoped_restore (¤t_uiout, m_cli_uiout.get ()); try { @@ -374,16 +378,16 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, ui_file *new_stderr = logfile_p; if (!logging_redirect) { - m_saved_output->stdout_holder.reset - (new tee_file (gdb_stdout, logfile_p)); + m_saved_output->stdout_holder.reset (new tee_file (gdb_stdout, + logfile_p)); new_stdout = m_saved_output->stdout_holder.get (); - m_saved_output->stderr_holder.reset - (new tee_file (gdb_stderr, logfile_p)); + m_saved_output->stderr_holder.reset (new tee_file (gdb_stderr, + logfile_p)); new_stderr = m_saved_output->stderr_holder.get (); } - m_saved_output->stdlog_holder.reset - (new timestamped_file (debug_redirect ? logfile_p : new_stderr)); + m_saved_output->stdlog_holder.reset ( + new timestamped_file (debug_redirect ? logfile_p : new_stderr)); gdb_stdout = new_stdout; gdb_stdlog = m_saved_output->stdlog_holder.get (); @@ -414,6 +418,7 @@ cli_interp_factory (const char *name) /* Standard gdb initialization hook. */ void _initialize_cli_interp (); + void _initialize_cli_interp () { @@ -429,11 +434,12 @@ _initialize_cli_interp () gdb::observers::signal_exited.attach (cli_base_on_signal_exited, "cli-interp-base"); gdb::observers::exited.attach (cli_base_on_exited, "cli-interp-base"); - gdb::observers::no_history.attach (cli_base_on_no_history, "cli-interp-base"); + gdb::observers::no_history.attach (cli_base_on_no_history, + "cli-interp-base"); gdb::observers::sync_execution_done.attach (cli_base_on_sync_execution_done, "cli-interp-base"); gdb::observers::command_error.attach (cli_base_on_command_error, "cli-interp-base"); - gdb::observers::user_selected_context_changed.attach - (cli_base_on_user_selected_context_changed, "cli-interp-base"); + gdb::observers::user_selected_context_changed.attach ( + cli_base_on_user_selected_context_changed, "cli-interp-base"); } diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index 5ed998f..e248102 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -25,6 +25,7 @@ class cli_interp_base : public interp { public: + explicit cli_interp_base (const char *name); virtual ~cli_interp_base () = 0; @@ -34,6 +35,7 @@ public: bool supports_command_editing () override; private: + struct saved_output_files { /* Saved gdb_stdout, gdb_stderr, etc. */ diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c index a74e430..a346dc6 100644 --- a/gdb/cli/cli-logging.c +++ b/gdb/cli/cli-logging.c @@ -27,11 +27,12 @@ static std::string saved_filename; static std::string logging_filename = "gdb.txt"; + static void show_logging_filename (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - gdb_printf (file, _("The current logfile is \"%ps\".\n"), + gdb_printf (file, _ ("The current logfile is \"%ps\".\n"), styled_string (file_name_style.style (), value)); } @@ -41,13 +42,14 @@ static void maybe_warn_already_logging () { if (!saved_filename.empty ()) - warning (_("Currently logging to %s. Turn the logging off and on to " - "make the new setting effective."), saved_filename.c_str ()); + warning (_ ("Currently logging to %s. Turn the logging off and on to " + "make the new setting effective."), + saved_filename.c_str ()); } static void -set_logging_overwrite (const char *args, - int from_tty, struct cmd_list_element *c) +set_logging_overwrite (const char *args, int from_tty, + struct cmd_list_element *c) { maybe_warn_already_logging (); } @@ -57,9 +59,9 @@ show_logging_overwrite (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { if (logging_overwrite) - gdb_printf (file, _("on: Logging overwrites the log file.\n")); + gdb_printf (file, _ ("on: Logging overwrites the log file.\n")); else - gdb_printf (file, _("off: Logging appends to the log file.\n")); + gdb_printf (file, _ ("off: Logging appends to the log file.\n")); } /* Value as configured by the user. */ @@ -67,8 +69,8 @@ static bool logging_redirect; static bool debug_redirect; static void -set_logging_redirect (const char *args, - int from_tty, struct cmd_list_element *c) +set_logging_redirect (const char *args, int from_tty, + struct cmd_list_element *c) { maybe_warn_already_logging (); } @@ -78,23 +80,22 @@ show_logging_redirect (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { if (logging_redirect) - gdb_printf (file, _("on: Output will go only to the log file.\n")); + gdb_printf (file, _ ("on: Output will go only to the log file.\n")); else - gdb_printf - (file, - _("off: Output will go to both the screen and the log file.\n")); + gdb_printf ( + file, _ ("off: Output will go to both the screen and the log file.\n")); } static void show_logging_debug_redirect (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) + struct cmd_list_element *c, const char *value) { if (debug_redirect) - gdb_printf (file, _("on: Debug output will go only to the log file.\n")); + gdb_printf (file, _ ("on: Debug output will go only to the log file.\n")); else - gdb_printf - (file, - _("off: Debug output will go to both the screen and the log file.\n")); + gdb_printf ( + file, + _ ("off: Debug output will go to both the screen and the log file.\n")); } /* If we've pushed output files, close them and pop them. */ @@ -114,24 +115,21 @@ handle_redirections (int from_tty) { if (!saved_filename.empty ()) { - gdb_printf ("Already logging to %s.\n", - saved_filename.c_str ()); + gdb_printf ("Already logging to %s.\n", saved_filename.c_str ()); return; } stdio_file_up log (new no_terminal_escape_file ()); if (!log->open (logging_filename.c_str (), logging_overwrite ? "w" : "a")) - perror_with_name (_("set logging")); + perror_with_name (_ ("set logging")); /* Redirects everything to gdb_stdout while this is running. */ if (from_tty) { if (!logging_redirect) - gdb_printf ("Copying output to %s.\n", - logging_filename.c_str ()); + gdb_printf ("Copying output to %s.\n", logging_filename.c_str ()); else - gdb_printf ("Redirecting output to %s.\n", - logging_filename.c_str ()); + gdb_printf ("Redirecting output to %s.\n", logging_filename.c_str ()); if (!debug_redirect) gdb_printf ("Copying debug output to %s.\n", @@ -168,7 +166,7 @@ set_logging_on (const char *args, int from_tty) handle_redirections (from_tty); } -static void +static void set_logging_off (const char *args, int from_tty) { if (saved_filename.empty ()) @@ -176,16 +174,15 @@ set_logging_off (const char *args, int from_tty) pop_output_files (); if (from_tty) - gdb_printf ("Done logging to %s.\n", - saved_filename.c_str ()); + gdb_printf ("Done logging to %s.\n", saved_filename.c_str ()); saved_filename.clear (); } static bool logging_enabled; static void -set_logging_enabled (const char *args, - int from_tty, struct cmd_list_element *c) +set_logging_enabled (const char *args, int from_tty, + struct cmd_list_element *c) { if (logging_enabled) set_logging_on (args, from_tty); @@ -195,74 +192,77 @@ set_logging_enabled (const char *args, static void show_logging_enabled (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) + struct cmd_list_element *c, const char *value) { if (logging_enabled) - gdb_printf (file, _("on: Logging is enabled.\n")); + gdb_printf (file, _ ("on: Logging is enabled.\n")); else - gdb_printf (file, _("off: Logging is disabled.\n")); + gdb_printf (file, _ ("off: Logging is disabled.\n")); } void _initialize_cli_logging (); + void _initialize_cli_logging () { static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist; /* Set/show logging. */ - add_setshow_prefix_cmd ("logging", class_support, - _("Set logging options."), - _("Show logging options."), - &set_logging_cmdlist, &show_logging_cmdlist, - &setlist, &showlist); + add_setshow_prefix_cmd ("logging", class_support, _ ("Set logging options."), + _ ("Show logging options."), &set_logging_cmdlist, + &show_logging_cmdlist, &setlist, &showlist); /* Set/show logging overwrite. */ - add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite, _("\ -Set whether logging overwrites or appends to the log file."), _("\ -Show whether logging overwrites or appends to the log file."), _("\ + add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite, + _ ("\ +Set whether logging overwrites or appends to the log file."), + _ ("\ +Show whether logging overwrites or appends to the log file."), + _ ("\ If set, logging overwrites the log file."), - set_logging_overwrite, - show_logging_overwrite, + set_logging_overwrite, show_logging_overwrite, &set_logging_cmdlist, &show_logging_cmdlist); /* Set/show logging redirect. */ - add_setshow_boolean_cmd ("redirect", class_support, &logging_redirect, _("\ -Set the logging output mode."), _("\ -Show the logging output mode."), _("\ + add_setshow_boolean_cmd ("redirect", class_support, &logging_redirect, _ ("\ +Set the logging output mode."), + _ ("\ +Show the logging output mode."), + _ ("\ If redirect is off, output will go to both the screen and the log file.\n\ If redirect is on, output will go only to the log file."), - set_logging_redirect, - show_logging_redirect, + set_logging_redirect, show_logging_redirect, &set_logging_cmdlist, &show_logging_cmdlist); /* Set/show logging debugredirect. */ - add_setshow_boolean_cmd ("debugredirect", class_support, - &debug_redirect, _("\ -Set the logging debug output mode."), _("\ -Show the logging debug output mode."), _("\ + add_setshow_boolean_cmd ("debugredirect", class_support, &debug_redirect, + _ ("\ +Set the logging debug output mode."), + _ ("\ +Show the logging debug output mode."), + _ ("\ If debug redirect is off, debug will go to both the screen and the log file.\n\ If debug redirect is on, debug will go only to the log file."), - set_logging_redirect, - show_logging_debug_redirect, + set_logging_redirect, show_logging_debug_redirect, &set_logging_cmdlist, &show_logging_cmdlist); /* Set/show logging file. */ - add_setshow_filename_cmd ("file", class_support, &logging_filename, _("\ -Set the current logfile."), _("\ -Show the current logfile."), _("\ + add_setshow_filename_cmd ("file", class_support, &logging_filename, _ ("\ +Set the current logfile."), + _ ("\ +Show the current logfile."), + _ ("\ The logfile is used when directing GDB's output."), - NULL, - show_logging_filename, - &set_logging_cmdlist, &show_logging_cmdlist); + NULL, show_logging_filename, &set_logging_cmdlist, + &show_logging_cmdlist); /* Set/show logging enabled. */ set_show_commands setshow_logging_enabled_cmds = add_setshow_boolean_cmd ("enabled", class_support, &logging_enabled, - _("Enable logging."), - _("Show whether logging is enabled."), - _("When on, enable logging."), - set_logging_enabled, - show_logging_enabled, + _ ("Enable logging."), + _ ("Show whether logging is enabled."), + _ ("When on, enable logging."), + set_logging_enabled, show_logging_enabled, &set_logging_cmdlist, &show_logging_cmdlist); /* Set logging on, deprecated alias. */ diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 9b303b1..039dc0a 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -25,8 +25,10 @@ #include "command.h" #include <vector> -namespace gdb { -namespace option { +namespace gdb +{ +namespace option +{ /* An option's value. Which field is active depends on the option's type. */ @@ -151,16 +153,16 @@ find_end_options_delimiter (const char *args) static void complete_on_options (gdb::array_view<const option_def_group> options_group, - completion_tracker &tracker, - const char *text, const char *word) + completion_tracker &tracker, const char *text, + const char *word) { size_t textlen = strlen (text); for (const auto &grp : options_group) for (const auto &opt : grp.options) if (strncmp (opt.name, text, textlen) == 0) { - tracker.add_completion - (make_completion_match_str (opt.name, text, word)); + tracker.add_completion (make_completion_match_str (opt.name, text, + word)); } } @@ -179,8 +181,7 @@ complete_on_all_options (completion_tracker &tracker, static gdb::optional<option_def_and_value> parse_option (gdb::array_view<const option_def_group> options_group, - process_options_mode mode, - bool have_delimiter, + process_options_mode mode, bool have_delimiter, const char **args, parse_option_completion_info *completion = nullptr) { @@ -189,7 +190,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, else if (**args != '-') { if (have_delimiter) - error (_("Unrecognized option at: %s"), *args); + error (_ ("Unrecognized option at: %s"), *args); return {}; } else if (check_for_argument (args, "--")) @@ -213,13 +214,12 @@ parse_option (gdb::array_view<const option_def_group> options_group, { if (completion != nullptr && arg[len] == '\0') { - complete_on_options (options_group, - completion->tracker, + complete_on_options (options_group, completion->tracker, arg, completion->word); return {}; } - error (_("Ambiguous option at: -%s"), arg); + error (_ ("Ambiguous option at: -%s"), arg); } match = &o; @@ -235,15 +235,15 @@ parse_option (gdb::array_view<const option_def_group> options_group, if (match == nullptr) { if (have_delimiter || mode != PROCESS_OPTIONS_UNKNOWN_IS_OPERAND) - error (_("Unrecognized option at: %s"), *args); + error (_ ("Unrecognized option at: %s"), *args); return {}; } if (completion != nullptr && arg[len] == '\0') { - complete_on_options (options_group, completion->tracker, - arg, completion->word); + complete_on_options (options_group, completion->tracker, arg, + completion->word); return {}; } @@ -260,7 +260,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, { option_value val; val.boolean = true; - return option_def_and_value {*match, match_ctx, val}; + return option_def_and_value { *match, match_ctx, val }; } const char *val_str = *args; @@ -272,11 +272,11 @@ parse_option (gdb::array_view<const option_def_group> options_group, if (mode == PROCESS_OPTIONS_REQUIRE_DELIMITER) { - complete_on_enum (completion->tracker, - boolean_enums, val_str, val_str); + complete_on_enum (completion->tracker, boolean_enums, val_str, + val_str); complete_on_all_options (completion->tracker, options_group); } - return option_def_and_value {*match, match_ctx}; + return option_def_and_value { *match, match_ctx }; } else if (**args == '-') { @@ -306,20 +306,20 @@ parse_option (gdb::array_view<const option_def_group> options_group, { if (*end == '\0') { - complete_on_enum (completion->tracker, - boolean_enums, val_str, val_str); - return option_def_and_value {*match, match_ctx}; + complete_on_enum (completion->tracker, boolean_enums, + val_str, val_str); + return option_def_and_value { *match, match_ctx }; } } if (have_delimiter) - error (_("Value given for `-%s' is not a boolean: %.*s"), + error (_ ("Value given for `-%s' is not a boolean: %.*s"), match->name, (int) (end - val_str), val_str); /* The user didn't separate options from operands using "--", so treat this unrecognized value as the start of the operands. This makes "frame apply all -past-main CMD" work. */ - return option_def_and_value {*match, match_ctx}; + return option_def_and_value { *match, match_ctx }; } else if (completion != nullptr && **args == '\0') { @@ -339,11 +339,8 @@ parse_option (gdb::array_view<const option_def_group> options_group, "p -object 1[TAB]" -> "p -object 1" (i.e., nothing happens). */ static const char *const all_boolean_enums[] = { - "on", "off", - "yes", "no", - "enable", "disable", - "0", "1", - nullptr, + "on", "off", "yes", "no", "enable", + "disable", "0", "1", nullptr, }; complete_on_enum (completion->tracker, all_boolean_enums, val_str, val_str); @@ -353,7 +350,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, option_value val; val.boolean = res; - return option_def_and_value {*match, match_ctx, val}; + return option_def_and_value { *match, match_ctx, val }; } case var_uinteger: case var_integer: @@ -367,25 +364,23 @@ parse_option (gdb::array_view<const option_def_group> options_group, so that readline doesn't do a partial match. */ if (**args == '\0') { - completion->tracker.add_completion - (make_unique_xstrdup ("NUMBER")); + completion->tracker.add_completion ( + make_unique_xstrdup ("NUMBER")); for (const literal_def *l = match->extra_literals; - l->literal != nullptr; - l++) - completion->tracker.add_completion - (make_unique_xstrdup (l->literal)); + l->literal != nullptr; l++) + completion->tracker.add_completion ( + make_unique_xstrdup (l->literal)); return {}; } else { bool completions = false; for (const literal_def *l = match->extra_literals; - l->literal != nullptr; - l++) + l->literal != nullptr; l++) if (startswith (l->literal, *args)) { - completion->tracker.add_completion - (make_unique_xstrdup (l->literal)); + completion->tracker.add_completion ( + make_unique_xstrdup (l->literal)); completions = true; } if (completions) @@ -393,15 +388,14 @@ parse_option (gdb::array_view<const option_def_group> options_group, } } - LONGEST v = parse_cli_var_integer (match->type, - match->extra_literals, + LONGEST v = parse_cli_var_integer (match->type, match->extra_literals, args, false); option_value val; if (match->type == var_uinteger) val.uinteger = v; else val.integer = v; - return option_def_and_value {*match, match_ctx, val}; + return option_def_and_value { *match, match_ctx, val }; } case var_enum: { @@ -410,8 +404,8 @@ parse_option (gdb::array_view<const option_def_group> options_group, const char *after_arg = skip_to_space (*args); if (*after_arg == '\0') { - complete_on_enum (completion->tracker, - match->enums, *args, *args); + complete_on_enum (completion->tracker, match->enums, *args, + *args); if (completion->tracker.have_completions ()) return {}; @@ -432,7 +426,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, option_value val; val.enumeration = parse_cli_var_enum (args, match->enums); - return option_def_and_value {*match, match_ctx, val}; + return option_def_and_value { *match, match_ctx, val }; } case var_string: { @@ -440,17 +434,17 @@ parse_option (gdb::array_view<const option_def_group> options_group, { /* Treat e.g., "maint test-options -string --" as if there was no argument after "-string". */ - error (_("-%s requires an argument"), match->name); + error (_ ("-%s requires an argument"), match->name); } const char *arg_start = *args; std::string str = extract_string_maybe_quoted (args); if (*args == arg_start) - error (_("-%s requires an argument"), match->name); + error (_ ("-%s requires an argument"), match->name); option_value val; val.string = new std::string (std::move (str)); - return option_def_and_value {*match, match_ctx, val}; + return option_def_and_value { *match, match_ctx, val }; } default: @@ -464,8 +458,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, /* See cli-option.h. */ bool -complete_options (completion_tracker &tracker, - const char **args, +complete_options (completion_tracker &tracker, const char **args, process_options_mode mode, gdb::array_view<const option_def_group> options_group) { @@ -478,7 +471,7 @@ complete_options (completion_tracker &tracker, if (text[0] == '-' && (!have_delimiter || *delimiter == '\0')) { - parse_option_completion_info completion_info {nullptr, tracker}; + parse_option_completion_info completion_info { nullptr, tracker }; while (1) { @@ -497,16 +490,15 @@ complete_options (completion_tracker &tracker, else if (**args == '-') { gdb::optional<option_def_and_value> ov - = parse_option (options_group, mode, have_delimiter, - args, &completion_info); + = parse_option (options_group, mode, have_delimiter, args, + &completion_info); if (!ov && !tracker.have_completions ()) { tracker.advance_custom_word_point_by (*args - text); return mode == PROCESS_OPTIONS_REQUIRE_DELIMITER; } - if (ov - && ov->option.type == var_boolean + if (ov && ov->option.type == var_boolean && !ov->value.has_value ()) { /* Looked like a boolean option, but we failed to @@ -529,13 +521,10 @@ complete_options (completion_tracker &tracker, (gdb) frame apply all -limit 10[TAB] we don't try to complete on command names. */ - if (ov - && !tracker.have_completions () - && **args == '\0' + if (ov && !tracker.have_completions () && **args == '\0' && *args > text && !isspace ((*args)[-1])) { - tracker.advance_custom_word_point_by - (*args - text); + tracker.advance_custom_word_point_by (*args - text); return true; } @@ -546,16 +535,15 @@ complete_options (completion_tracker &tracker, } else { - tracker.advance_custom_word_point_by - (completion_info.word - text); + tracker.advance_custom_word_point_by (completion_info.word + - text); /* If the command requires a delimiter, but we haven't seen one, then return true, so that the caller doesn't try to complete on whatever follows options, which for these commands should only be done if there's a delimiter. */ - if (mode == PROCESS_OPTIONS_REQUIRE_DELIMITER - && !have_delimiter) + if (mode == PROCESS_OPTIONS_REQUIRE_DELIMITER && !have_delimiter) { /* If we reached the end of the input string, then offer all options, since that's all the user can @@ -570,8 +558,8 @@ complete_options (completion_tracker &tracker, if (tracker.have_completions ()) { - tracker.advance_custom_word_point_by - (completion_info.word - text); + tracker.advance_custom_word_point_by (completion_info.word + - text); return true; } } @@ -624,8 +612,7 @@ save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov) /* See cli-option.h. */ bool -process_options (const char **args, - process_options_mode mode, +process_options (const char **args, process_options_mode mode, gdb::array_view<const option_def_group> options_group) { if (*args == nullptr) @@ -681,8 +668,7 @@ get_val_type_str (const option_def &opt, std::string &buffer) buffer = "NUMBER"; if (opt.extra_literals != nullptr) for (const literal_def *l = opt.extra_literals; - l->literal != nullptr; - l++) + l->literal != nullptr; l++) { buffer += '|'; buffer += l->literal; @@ -791,8 +777,7 @@ build_help (const char *help_tmpl, /* See cli-option.h. */ void -add_setshow_cmds_for_options (command_class cmd_class, - void *data, +add_setshow_cmds_for_options (command_class cmd_class, void *data, gdb::array_view<const option_def> options, struct cmd_list_element **set_list, struct cmd_list_element **show_list) @@ -804,48 +789,39 @@ add_setshow_cmds_for_options (command_class cmd_class, add_setshow_boolean_cmd (option.name, cmd_class, option.var_address.boolean (option, data), option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, - set_list, show_list); + option.help_doc, nullptr, + option.show_cmd_cb, set_list, show_list); } else if (option.type == var_uinteger) { add_setshow_uinteger_cmd (option.name, cmd_class, option.var_address.uinteger (option, data), - option.extra_literals, - option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, - set_list, show_list); + option.extra_literals, option.set_doc, + option.show_doc, option.help_doc, nullptr, + option.show_cmd_cb, set_list, show_list); } else if (option.type == var_integer) { add_setshow_integer_cmd (option.name, cmd_class, option.var_address.integer (option, data), - option.extra_literals, - option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, - set_list, show_list); + option.extra_literals, option.set_doc, + option.show_doc, option.help_doc, nullptr, + option.show_cmd_cb, set_list, show_list); } else if (option.type == var_pinteger) { add_setshow_pinteger_cmd (option.name, cmd_class, option.var_address.integer (option, data), - option.extra_literals, - option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, - set_list, show_list); + option.extra_literals, option.set_doc, + option.show_doc, option.help_doc, nullptr, + option.show_cmd_cb, set_list, show_list); } else if (option.type == var_enum) { - add_setshow_enum_cmd (option.name, cmd_class, - option.enums, + add_setshow_enum_cmd (option.name, cmd_class, option.enums, option.var_address.enumeration (option, data), option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, + option.help_doc, nullptr, option.show_cmd_cb, set_list, show_list); } else if (option.type == var_string) @@ -853,8 +829,7 @@ add_setshow_cmds_for_options (command_class cmd_class, add_setshow_string_cmd (option.name, cmd_class, option.var_address.string (option, data), option.set_doc, option.show_doc, - option.help_doc, - nullptr, option.show_cmd_cb, + option.help_doc, nullptr, option.show_cmd_cb, set_list, show_list); } else diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 7b015b8..c67b6d2 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -26,8 +26,10 @@ #include <string> #include "command.h" -namespace gdb { -namespace option { +namespace gdb +{ +namespace option +{ /* A type-erased option definition. The actual type of the option is stored in the TYPE field. Client code cannot define objects of @@ -38,7 +40,9 @@ struct option_def { /* The ctor is protected because you're supposed to construct using one of bool_option_def, etc. below. */ + protected: + typedef void *(erased_get_var_address_ftype) (); /* Construct an option. NAME_ is the option's name. VAR_TYPE_ @@ -47,22 +51,25 @@ protected: SHOW_CMD_CB_ is a pointer to callback for the "show" command that is installed for this option. SET_DOC_, SHOW_DOC_, HELP_DOC_ are used to create the option's "set/show" commands. */ - constexpr option_def (const char *name_, - var_types var_type_, + constexpr option_def (const char *name_, var_types var_type_, const literal_def *extra_literals_, erased_get_var_address_ftype *erased_get_var_address_, - show_value_ftype *show_cmd_cb_, - const char *set_doc_, - const char *show_doc_, - const char *help_doc_) - : name (name_), type (var_type_), extra_literals (extra_literals_), + show_value_ftype *show_cmd_cb_, const char *set_doc_, + const char *show_doc_, const char *help_doc_) + : name (name_), + type (var_type_), + extra_literals (extra_literals_), erased_get_var_address (erased_get_var_address_), var_address {}, show_cmd_cb (show_cmd_cb_), - set_doc (set_doc_), show_doc (show_doc_), help_doc (help_doc_) - {} + set_doc (set_doc_), + show_doc (show_doc_), + help_doc (help_doc_) + { + } public: + /* The option's name. */ const char *name; @@ -85,14 +92,13 @@ public: object that groups the option variables from which the callback returns the address of some member. */ union - { - bool *(*boolean) (const option_def &, void *ctx); - unsigned int *(*uinteger) (const option_def &, void *ctx); - int *(*integer) (const option_def &, void *ctx); - const char **(*enumeration) (const option_def &, void *ctx); - std::string *(*string) (const option_def &, void *ctx); - } - var_address; + { + bool *(*boolean) (const option_def &, void *ctx); + unsigned int *(*uinteger) (const option_def &, void *ctx); + int *(*integer) (const option_def &, void *ctx); + const char **(*enumeration) (const option_def &, void *ctx); + std::string *(*string) (const option_def &, void *ctx); + } var_address; /* Pointer to null terminated list of enumerated values (like argv). Only used by var_enum options. */ @@ -116,10 +122,7 @@ public: /* Convenience method that returns THIS as an option_def. Useful when you're putting an option_def subclass in an option_def array_view. */ - const option_def &def () const - { - return *this; - } + const option_def &def () const { return *this; } }; namespace detail @@ -160,14 +163,12 @@ struct boolean_option_def : option_def { boolean_option_def (const char *long_option_, bool *(*get_var_address_cb_) (Context *), - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : option_def (long_option_, var_boolean, nullptr, (erased_get_var_address_ftype *) get_var_address_cb_, - show_cmd_cb_, - set_doc_, show_doc_, help_doc_) + show_cmd_cb_, set_doc_, show_doc_, help_doc_) { var_address.boolean = detail::get_var_address<bool, Context>; } @@ -181,23 +182,18 @@ template<typename Context = bool> struct flag_option_def : boolean_option_def<Context> { flag_option_def (const char *long_option_, - bool *(*var_address_cb_) (Context *), - const char *set_doc_, - const char *help_doc_ = nullptr) - : boolean_option_def<Context> (long_option_, - var_address_cb_, - NULL, + bool *(*var_address_cb_) (Context *), const char *set_doc_, + const char *help_doc_ = nullptr) + : boolean_option_def<Context> (long_option_, var_address_cb_, NULL, set_doc_, NULL, help_doc_) { this->have_argument = false; } - flag_option_def (const char *long_option_, - const char *set_doc_, - const char *help_doc_ = nullptr) + flag_option_def (const char *long_option_, const char *set_doc_, + const char *help_doc_ = nullptr) : boolean_option_def<Context> (long_option_, - gdb::option::detail::return_self, - NULL, + gdb::option::detail::return_self, NULL, set_doc_, nullptr, help_doc_) { this->have_argument = false; @@ -212,27 +208,25 @@ struct uinteger_option_def : option_def uinteger_option_def (const char *long_option_, unsigned int *(*get_var_address_cb_) (Context *), const literal_def *extra_literals_, - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : option_def (long_option_, var_uinteger, extra_literals_, (erased_get_var_address_ftype *) get_var_address_cb_, - show_cmd_cb_, - set_doc_, show_doc_, help_doc_) + show_cmd_cb_, set_doc_, show_doc_, help_doc_) { var_address.uinteger = detail::get_var_address<unsigned int, Context>; } uinteger_option_def (const char *long_option_, unsigned int *(*get_var_address_cb_) (Context *), - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : uinteger_option_def (long_option_, get_var_address_cb_, nullptr, show_cmd_cb_, set_doc_, show_doc_, help_doc_) - { /* Nothing. */ } + { /* Nothing. */ + } }; /* A var_pinteger command line option. */ @@ -243,27 +237,25 @@ struct pinteger_option_def : option_def pinteger_option_def (const char *long_option_, int *(*get_var_address_cb_) (Context *), const literal_def *extra_literals_, - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : option_def (long_option_, var_pinteger, extra_literals_, (erased_get_var_address_ftype *) get_var_address_cb_, - show_cmd_cb_, - set_doc_, show_doc_, help_doc_) + show_cmd_cb_, set_doc_, show_doc_, help_doc_) { var_address.integer = detail::get_var_address<int, Context>; } pinteger_option_def (const char *long_option_, int *(*get_var_address_cb_) (Context *), - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : pinteger_option_def (long_option_, get_var_address_cb_, nullptr, show_cmd_cb_, set_doc_, show_doc_, help_doc_) - { /* Nothing. */ } + { /* Nothing. */ + } }; /* An var_enum command line option. */ @@ -271,17 +263,14 @@ struct pinteger_option_def : option_def template<typename Context> struct enum_option_def : option_def { - enum_option_def (const char *long_option_, - const char *const *enumlist, + enum_option_def (const char *long_option_, const char *const *enumlist, const char **(*get_var_address_cb_) (Context *), - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : option_def (long_option_, var_enum, nullptr, (erased_get_var_address_ftype *) get_var_address_cb_, - show_cmd_cb_, - set_doc_, show_doc_, help_doc_) + show_cmd_cb_, set_doc_, show_doc_, help_doc_) { var_address.enumeration = detail::get_var_address<const char *, Context>; this->enums = enumlist; @@ -295,14 +284,12 @@ struct string_option_def : option_def { string_option_def (const char *long_option_, std::string *(*get_var_address_cb_) (Context *), - show_value_ftype *show_cmd_cb_, - const char *set_doc_, + show_value_ftype *show_cmd_cb_, const char *set_doc_, const char *show_doc_ = nullptr, const char *help_doc_ = nullptr) : option_def (long_option_, var_string, nullptr, (erased_get_var_address_ftype *) get_var_address_cb_, - show_cmd_cb_, - set_doc_, show_doc_, help_doc_) + show_cmd_cb_, set_doc_, show_doc_, help_doc_) { var_address.enumeration = detail::get_var_address<const char *, Context>; } @@ -341,40 +328,39 @@ enum process_options_mode if the string has been fully parsed and there are no operands to handle by the caller. Return false if options were parsed, and *ARGS now points at the first operand. */ -extern bool process_options - (const char **args, - process_options_mode mode, - gdb::array_view<const option_def_group> options_group); +extern bool +process_options (const char **args, process_options_mode mode, + gdb::array_view<const option_def_group> options_group); /* Complete ARGS on options listed by OPTIONS_GROUP. Returns true if the string has been fully parsed and there are no operands to handle by the caller. Return false if options were parsed, and *ARGS now points at the first operand. */ -extern bool complete_options - (completion_tracker &tracker, - const char **args, - process_options_mode mode, - gdb::array_view<const option_def_group> options_group); +extern bool +complete_options (completion_tracker &tracker, const char **args, + process_options_mode mode, + gdb::array_view<const option_def_group> options_group); /* Complete on all options listed by OPTIONS_GROUP. */ -extern void - complete_on_all_options (completion_tracker &tracker, - gdb::array_view<const option_def_group> options_group); +extern void complete_on_all_options ( + completion_tracker &tracker, + gdb::array_view<const option_def_group> options_group); /* Return a string with the result of replacing %OPTIONS% in HELP_TMLP with an auto-generated "help" string fragment for all the options in OPTIONS_GROUP. */ -extern std::string build_help - (const char *help_tmpl, - gdb::array_view<const option_def_group> options_group); +extern std::string +build_help (const char *help_tmpl, + gdb::array_view<const option_def_group> options_group); /* Install set/show commands for options defined in OPTIONS. DATA is a pointer to the structure that holds the data associated with the OPTIONS array. */ -extern void add_setshow_cmds_for_options (command_class cmd_class, void *data, - gdb::array_view<const option_def> options, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); +extern void +add_setshow_cmds_for_options (command_class cmd_class, void *data, + gdb::array_view<const option_def> options, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list); } /* namespace option */ } /* namespace gdb */ diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 92005ba..363657c 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -42,17 +42,15 @@ /* Prototypes for local functions. */ -static enum command_control_type -recurse_read_control_structure - (read_next_line_ftype read_next_line_func, - struct command_line *current_cmd, - gdb::function_view<void (const char *)> validator); +static enum command_control_type recurse_read_control_structure ( + read_next_line_ftype read_next_line_func, struct command_line *current_cmd, + gdb::function_view<void (const char *)> validator); static void do_define_command (const char *comname, int from_tty, const counted_command_line *commands); static void do_document_command (const char *comname, int from_tty, - const counted_command_line *commands); + const counted_command_line *commands); static const char *read_next_line (std::string &buffer); @@ -82,6 +80,7 @@ static cmd_list_element *document_cmd_element = nullptr; class user_args { public: + /* Save the command line and store the locations of arguments passed to the user defined function. */ explicit user_args (const char *line); @@ -91,11 +90,12 @@ public: std::string insert_args (const char *line) const; private: + /* Disable copy/assignment. (Since the elements of A point inside COMMAND, copying would need to reconstruct the A vector in the new copy.) */ - user_args (const user_args &) =delete; - user_args &operator= (const user_args &) =delete; + user_args (const user_args &) = delete; + user_args &operator= (const user_args &) = delete; /* It is necessary to store a copy of the command line to ensure that the arguments are not overwritten before they are used. */ @@ -122,13 +122,9 @@ struct scoped_user_args_level } /* Pop the current user arguments from the stack. */ - ~scoped_user_args_level () - { - user_args_stack.pop_back (); - } + ~scoped_user_args_level () { user_args_stack.pop_back (); } }; - /* Return non-zero if TYPE is a multi-line command (i.e., is terminated by "end"). */ @@ -161,13 +157,13 @@ build_command_line (enum command_control_type type, const char *args) if (args == NULL || *args == '\0') { if (type == if_control) - error (_("if command requires an argument.")); + error (_ ("if command requires an argument.")); else if (type == while_control) - error (_("while command requires an argument.")); + error (_ ("while command requires an argument.")); else if (type == define_control) - error (_("define command requires an argument.")); + error (_ ("define command requires an argument.")); else if (type == document_control) - error (_("document command requires an argument.")); + error (_ ("document command requires an argument.")); } gdb_assert (args != NULL); @@ -188,7 +184,7 @@ get_command_line (enum command_control_type type, const char *arg) if (recurse_read_control_structure (read_next_line, cmd.get (), 0) == invalid_control) { - warning (_("Error reading in canned sequence of commands.")); + warning (_ ("Error reading in canned sequence of commands.")); return NULL; } @@ -347,7 +343,7 @@ print_command_lines (struct ui_out *uiout, struct command_line *cmd, /* Ignore illegal command type and try next. */ list = list->next; - } /* while (list) */ + } /* while (list) */ } /* Handle pre-post hooks. */ @@ -361,10 +357,7 @@ public: { } - ~scoped_restore_hook_in () - { - m_cmd->hook_in = 0; - } + ~scoped_restore_hook_in () { m_cmd->hook_in = 0; } scoped_restore_hook_in (const scoped_restore_hook_in &) = delete; scoped_restore_hook_in &operator= (const scoped_restore_hook_in &) = delete; @@ -407,11 +400,11 @@ execute_control_commands (struct command_line *cmdlines, int from_tty) while (cmdlines) { - enum command_control_type ret = execute_control_command (cmdlines, - from_tty); + enum command_control_type ret + = execute_control_command (cmdlines, from_tty); if (ret != simple_control && ret != break_control) { - warning (_("Error executing canned sequence of commands.")); + warning (_ ("Error executing canned sequence of commands.")); break; } cmdlines = cmdlines->next; @@ -426,10 +419,8 @@ execute_control_commands_to_string (struct command_line *commands, { std::string result; - execute_fn_to_string (result, [&] () - { - execute_control_commands (commands, from_tty); - }, false); + execute_fn_to_string ( + result, [&] () { execute_control_commands (commands, from_tty); }, false); return result; } @@ -450,7 +441,7 @@ execute_user_command (struct cmd_list_element *c, const char *args) scoped_user_args_level push_user_args (args); if (user_args_stack.size () > max_user_call_depth) - error (_("Max user call depth exceeded -- command aborted.")); + error (_ ("Max user call depth exceeded -- command aborted.")); /* Set the instream to nullptr, indicating execution of a user-defined function. */ @@ -481,6 +472,7 @@ reset_command_nest_depth (void) are dealt with directly. Therefore we can use these functions to determine whether the command has been printed already or not. */ ATTRIBUTE_PRINTF (1, 2) + void print_command_trace (const char *fmt, ...) { @@ -495,7 +487,7 @@ print_command_trace (const char *fmt, ...) if (!source_verbose && !trace_commands) return; - for (i=0; i < command_nest_depth; i++) + for (i = 0; i < command_nest_depth; i++) gdb_printf ("+"); va_list args; @@ -580,7 +572,8 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) while (current) { scoped_restore save_nesting - = make_scoped_restore (&command_nest_depth, command_nest_depth + 1); + = make_scoped_restore (&command_nest_depth, + command_nest_depth + 1); ret = execute_control_command_1 (current, from_tty); /* If we got an error, or a "break" command, then stop @@ -636,7 +629,8 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) while (current) { scoped_restore save_nesting - = make_scoped_restore (&command_nest_depth, command_nest_depth + 1); + = make_scoped_restore (&command_nest_depth, + command_nest_depth + 1); ret = execute_control_command_1 (current, from_tty); /* If we got an error, get out. */ @@ -686,7 +680,7 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) } default: - warning (_("Invalid control type in canned commands structure.")); + warning (_ ("Invalid control type in canned commands structure.")); break; } @@ -718,7 +712,6 @@ execute_control_command_untraced (struct command_line *cmd) return execute_control_command (cmd); } - /* "while" command support. Executes a body of statements while the loop condition is nonzero. */ @@ -824,8 +817,7 @@ locate_arg (const char *p) { while ((p = strchr (p, '$'))) { - if (startswith (p, "$arg") - && (isdigit (p[4]) || p[4] == 'c')) + if (startswith (p, "$arg") && (isdigit (p[4]) || p[4] == 'c')) return p; p++; } @@ -874,7 +866,7 @@ user_args::insert_args (const char *line) const if ((i == 0 && tmp == p + 4) || errno != 0) line = p + 4; else if (i >= m_args.size ()) - error (_("Missing argument %ld in user function."), i); + error (_ ("Missing argument %ld in user function."), i); else { new_line.append (m_args[i].data (), m_args[i].length ()); @@ -888,7 +880,6 @@ user_args::insert_args (const char *line) const return new_line; } - /* Read next line from stdin. Passed to read_command_line_1 and recurse_read_control_structure whenever we need to read commands from stdin. */ @@ -902,11 +893,10 @@ read_next_line (std::string &buffer) int from_tty = ui->instream == ui->stdin_stream; if (control_level >= 254) - error (_("Control nesting too deep!")); + error (_ ("Control nesting too deep!")); /* Set a prompt based on the nesting of the control commands. */ - if (from_tty - || (ui->instream == 0 && deprecated_readline_hook != NULL)) + if (from_tty || (ui->instream == 0 && deprecated_readline_hook != NULL)) { for (i = 0; i < control_level; i++) control_prompt[i] = ' '; @@ -928,7 +918,7 @@ line_first_arg (const char *p) { const char *first_arg = p + find_command_name_length (p); - return skip_spaces (first_arg); + return skip_spaces (first_arg); } /* Process one input line. If the command is an "end", return such an @@ -940,8 +930,7 @@ line_first_arg (const char *p) Otherwise, only "end" is recognized. */ static enum misc_command_type -process_next_line (const char *p, command_line_up *command, - int parse_commands, +process_next_line (const char *p, command_line_up *command, int parse_commands, gdb::function_view<void (const char *)> validator) { @@ -1048,8 +1037,9 @@ process_next_line (const char *p, command_line_up *command, if (!parse_commands || not_handled) { /* A normal command. */ - *command = command_line_up (new command_line (simple_control, - savestring (p, p_end - p))); + *command + = command_line_up (new command_line (simple_control, + savestring (p, p_end - p))); } if (validator) @@ -1064,9 +1054,9 @@ process_next_line (const char *p, command_line_up *command, obtain lines of the command. */ static enum command_control_type -recurse_read_control_structure (read_next_line_ftype read_next_line_func, - struct command_line *current_cmd, - gdb::function_view<void (const char *)> validator) +recurse_read_control_structure ( + read_next_line_ftype read_next_line_func, struct command_line *current_cmd, + gdb::function_view<void (const char *)> validator) { enum misc_command_type val; enum command_control_type ret; @@ -1078,7 +1068,7 @@ recurse_read_control_structure (read_next_line_ftype read_next_line_func, /* Sanity checks. */ if (current_cmd->control_type == simple_control) - error (_("Recursed on a simple control type.")); + error (_ ("Recursed on a simple control type.")); /* Read lines from the input stream and build control structures. */ while (1) @@ -1087,11 +1077,12 @@ recurse_read_control_structure (read_next_line_ftype read_next_line_func, std::string buffer; next = nullptr; - val = process_next_line (read_next_line_func (buffer), &next, - current_cmd->control_type != python_control + val + = process_next_line (read_next_line_func (buffer), &next, + current_cmd->control_type != python_control && current_cmd->control_type != guile_control && current_cmd->control_type != compile_control, - validator); + validator); /* Just skip blanks and comments. */ if (val == nop_command) @@ -1138,8 +1129,8 @@ recurse_read_control_structure (read_next_line_ftype read_next_line_func, else { child_tail = next.get (); - *current_body = counted_command_line (next.release (), - command_lines_deleter ()); + *current_body + = counted_command_line (next.release (), command_lines_deleter ()); } /* If the latest line is another control structure, then recurse @@ -1148,8 +1139,7 @@ recurse_read_control_structure (read_next_line_ftype read_next_line_func, { control_level++; ret = recurse_read_control_structure (read_next_line_func, - child_tail, - validator); + child_tail, validator); control_level--; if (ret != simple_control) @@ -1189,19 +1179,16 @@ read_command_lines (const char *prompt_arg, int from_tty, int parse_commands, printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE); } - /* Reading commands assumes the CLI behavior, so temporarily override the current interpreter with CLI. */ counted_command_line head (nullptr, command_lines_deleter ()); if (current_interp_named_p (INTERP_CONSOLE)) - head = read_command_lines_1 (read_next_line, parse_commands, - validator); + head = read_command_lines_1 (read_next_line, parse_commands, validator); else { scoped_restore_interp interp_restorer (INTERP_CONSOLE); - head = read_command_lines_1 (read_next_line, parse_commands, - validator); + head = read_command_lines_1 (read_next_line, parse_commands, validator); } if (from_tty && current_ui->input_interactive_p () @@ -1234,8 +1221,8 @@ read_command_lines_1 (read_next_line_ftype read_next_line_func, dont_repeat (); std::string buffer; - val = process_next_line (read_next_line_func (buffer), &next, parse_commands, - validator); + val = process_next_line (read_next_line_func (buffer), &next, + parse_commands, validator); /* Ignore blank lines or comments. */ if (val == nop_command) @@ -1256,8 +1243,8 @@ read_command_lines_1 (read_next_line_ftype read_next_line_func, if (multi_line_command_p (next->control_type)) { control_level++; - ret = recurse_read_control_structure (read_next_line_func, next.get (), - validator); + ret = recurse_read_control_structure (read_next_line_func, + next.get (), validator); control_level--; if (ret == invalid_control) @@ -1273,8 +1260,8 @@ read_command_lines_1 (read_next_line_ftype read_next_line_func, else { tail = next.get (); - head = counted_command_line (next.release (), - command_lines_deleter ()); + head + = counted_command_line (next.release (), command_lines_deleter ()); } } @@ -1302,7 +1289,7 @@ free_command_lines (struct command_line **lptr) } *lptr = NULL; } - + /* Validate that *COMNAME is a valid name for a command. Return the containing command list, in case it starts with a prefix command. The prefix must already exist. *COMNAME is advanced to point after @@ -1316,7 +1303,7 @@ validate_comname (const char **comname) const char *p, *last_word; if (*comname == 0) - error_no_arg (_("name of command to define")); + error_no_arg (_ ("name of command to define")); /* Find the last word of the argument. */ p = *comname + strlen (*comname); @@ -1337,7 +1324,7 @@ validate_comname (const char **comname) c = lookup_cmd (&tem, cmdlist, "", NULL, 0, 1); if (!c->is_prefix ()) - error (_("\"%s\" is not a prefix command."), prefix.c_str ()); + error (_ ("\"%s\" is not a prefix command."), prefix.c_str ()); list = c->subcommands; *comname = last_word; @@ -1347,7 +1334,7 @@ validate_comname (const char **comname) while (*p) { if (!valid_cmd_char_p (*p)) - error (_("Junk in argument list: \"%s\""), p); + error (_ ("Junk in argument list: \"%s\""), p); p++; } @@ -1371,20 +1358,20 @@ do_define_command (const char *comname, int from_tty, const counted_command_line *commands) { enum cmd_hook_type - { - CMD_NO_HOOK = 0, - CMD_PRE_HOOK, - CMD_POST_HOOK - }; + { + CMD_NO_HOOK = 0, + CMD_PRE_HOOK, + CMD_POST_HOOK + }; struct cmd_list_element *c, *newc, *hookc = 0, **list; const char *comfull; - int hook_type = CMD_NO_HOOK; - int hook_name_size = 0; - -#define HOOK_STRING "hook-" -#define HOOK_LEN 5 + int hook_type = CMD_NO_HOOK; + int hook_name_size = 0; + +#define HOOK_STRING "hook-" +#define HOOK_LEN 5 #define HOOK_POST_STRING "hookpost-" -#define HOOK_POST_LEN 9 +#define HOOK_POST_LEN 9 comfull = comname; list = validate_comname (&comname); @@ -1402,15 +1389,16 @@ do_define_command (const char *comname, int from_tty, if ok to redefine the command. */ if (c->is_prefix ()) q = (c->user_commands.get () == nullptr - || query (_("Keeping subcommands of prefix command \"%s\".\n" - "Redefine command \"%s\"? "), c->name, c->name)); + || query (_ ("Keeping subcommands of prefix command \"%s\".\n" + "Redefine command \"%s\"? "), + c->name, c->name)); else - q = query (_("Redefine command \"%s\"? "), c->name); + q = query (_ ("Redefine command \"%s\"? "), c->name); } else - q = query (_("Really redefine built-in command \"%s\"? "), c->name); + q = query (_ ("Really redefine built-in command \"%s\"? "), c->name); if (!q) - error (_("Command \"%s\" not redefined."), c->name); + error (_ ("Command \"%s\" not redefined."), c->name); } /* If this new command is a hook, then mark the command which it @@ -1419,12 +1407,12 @@ do_define_command (const char *comname, int from_tty, if (!strncmp (comname, HOOK_STRING, HOOK_LEN)) { - hook_type = CMD_PRE_HOOK; - hook_name_size = HOOK_LEN; + hook_type = CMD_PRE_HOOK; + hook_name_size = HOOK_LEN; } else if (!strncmp (comname, HOOK_POST_STRING, HOOK_POST_LEN)) { - hook_type = CMD_POST_HOOK; + hook_type = CMD_POST_HOOK; hook_name_size = HOOK_POST_LEN; } @@ -1435,11 +1423,11 @@ do_define_command (const char *comname, int from_tty, /* ignore_help_classes = */ false); if (!hookc && commands == nullptr) { - warning (_("Your new `%s' command does not " - "hook any existing command."), + warning (_ ("Your new `%s' command does not " + "hook any existing command."), comfull); - if (!query (_("Proceed? "))) - error (_("Not confirmed.")); + if (!query (_ ("Proceed? "))) + error (_ ("Not confirmed.")); } } @@ -1461,7 +1449,9 @@ do_define_command (const char *comname, int from_tty, newc = add_cmd (comname, class_user, user_defined_command, (c != nullptr && c->theclass == class_user) - ? c->doc : xstrdup ("User-defined."), list); + ? c->doc + : xstrdup ("User-defined."), + list); newc->user_commands = std::move (cmds); /* If we define or re-define a command that was previously defined @@ -1472,7 +1462,7 @@ do_define_command (const char *comname, int from_tty, /* allow_unknown: see explanation in equivalent logic in define_prefix_command (). */ newc->allow_unknown = newc->user_commands.get () != nullptr; - } + } } /* If this new command is a hook, then mark both commands as being @@ -1482,17 +1472,17 @@ do_define_command (const char *comname, int from_tty, switch (hook_type) { case CMD_PRE_HOOK: - hookc->hook_pre = newc; /* Target gets hooked. */ + hookc->hook_pre = newc; /* Target gets hooked. */ newc->hookee_pre = hookc; /* We are marked as hooking target cmd. */ break; case CMD_POST_HOOK: - hookc->hook_post = newc; /* Target gets hooked. */ + hookc->hook_post = newc; /* Target gets hooked. */ newc->hookee_post = hookc; /* We are marked as hooking target cmd. */ break; default: /* Should never come here as hookc would be 0. */ - internal_error (_("bad switch")); + internal_error (_ ("bad switch")); } } } @@ -1509,7 +1499,7 @@ define_command (const char *comname, int from_tty) command and the commands are provided. */ static void do_document_command (const char *comname, int from_tty, - const counted_command_line *commands) + const counted_command_line *commands) { struct cmd_list_element *alias, *prefix_cmd, *c; const char *comfull; @@ -1519,15 +1509,15 @@ do_document_command (const char *comname, int from_tty, lookup_cmd_composition (comfull, &alias, &prefix_cmd, &c); if (c == nullptr) - error (_("Undefined command: \"%s\"."), comfull); + error (_ ("Undefined command: \"%s\"."), comfull); if (c->theclass != class_user && (alias == nullptr || alias->theclass != class_alias)) { if (alias == nullptr) - error (_("Command \"%s\" is built-in."), comfull); + error (_ ("Command \"%s\" is built-in."), comfull); else - error (_("Alias \"%s\" is built-in."), comfull); + error (_ ("Alias \"%s\" is built-in."), comfull); } /* If we found an alias of class_alias, the user is documenting this @@ -1540,7 +1530,7 @@ do_document_command (const char *comname, int from_tty, if (commands == nullptr) { std::string prompt - = string_printf ("Type documentation for \"%s\".", comfull); + = string_printf ("Type documentation for \"%s\".", comfull); doclines = read_command_lines (prompt.c_str (), from_tty, 0, 0); } else @@ -1592,7 +1582,7 @@ define_prefix_command (const char *comname, int from_tty) c = lookup_cmd_exact (comname, *list); if (c != nullptr && c->theclass != class_user) - error (_("Command \"%s\" is built-in."), comfull); + error (_ ("Command \"%s\" is built-in."), comfull); if (c != nullptr && c->is_prefix ()) { @@ -1610,7 +1600,7 @@ define_prefix_command (const char *comname, int from_tty) /* Allocate the c->subcommands, which marks the command as a prefix command. */ - c->subcommands = new struct cmd_list_element*; + c->subcommands = new struct cmd_list_element *; *(c->subcommands) = nullptr; /* If the prefix command C is not a command, then it must be followed by known subcommands. Otherwise, if C is also a normal command, @@ -1619,14 +1609,13 @@ define_prefix_command (const char *comname, int from_tty) c->allow_unknown = c->user_commands.get () != nullptr; } - /* Used to implement source_command. */ void script_from_file (FILE *stream, const char *file) { if (stream == NULL) - internal_error (_("called with NULL file pointer!")); + internal_error (_ ("called with NULL file pointer!")); scoped_restore restore_line_number = make_scoped_restore (&source_line_number, 0); @@ -1644,10 +1633,8 @@ script_from_file (FILE *stream, const char *file) { /* Re-throw the error, but with the file name information prepended. */ - throw_error (e.error, - _("%s:%d: Error in sourced command file:\n%s"), - source_file_name.c_str (), source_line_number, - e.what ()); + throw_error (e.error, _ ("%s:%d: Error in sourced command file:\n%s"), + source_file_name.c_str (), source_line_number, e.what ()); } } @@ -1665,8 +1652,7 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, gdb_printf (stream, "User %scommand \"", c->is_prefix () ? "prefix" : ""); - fprintf_styled (stream, title_style.style (), "%s%s", - prefix, name); + fprintf_styled (stream, title_style.style (), "%s%s", prefix, name); gdb_printf (stream, "\":\n"); if (cmdlines) { @@ -1683,10 +1669,10 @@ show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, if (c->theclass == class_user || c->is_prefix ()) show_user_1 (c, prefixname.c_str (), c->name, gdb_stdout); } - } void _initialize_cli_script (); + void _initialize_cli_script () { @@ -1695,13 +1681,13 @@ _initialize_cli_script () /* "document", "define" and "define-prefix" use command_completer, as this helps the user to either type the command name and/or its prefixes. */ - document_cmd_element = add_com ("document", class_support, document_command, - _("\ + document_cmd_element + = add_com ("document", class_support, document_command, _ ("\ Document a user-defined command or user-defined alias.\n\ Give command or alias name as argument. Give documentation on following lines.\n\ End with a line of just \"end\".")); set_cmd_completer (document_cmd_element, command_completer); - define_cmd_element = add_com ("define", class_support, define_command, _("\ + define_cmd_element = add_com ("define", class_support, define_command, _ ("\ Define a new command name. Command name is argument.\n\ Definition appears on following lines, one command per line.\n\ End with a line of just \"end\".\n\ @@ -1710,21 +1696,20 @@ Commands defined in this way may accept an unlimited number of arguments\n\ accessed via $arg0 .. $argN. $argc tells how many arguments have\n\ been passed.")); set_cmd_completer (define_cmd_element, command_completer); - c = add_com ("define-prefix", class_support, define_prefix_command, - _("\ + c = add_com ("define-prefix", class_support, define_prefix_command, _ ("\ Define or mark a command as a user-defined prefix command.\n\ User defined prefix commands can be used as prefix commands for\n\ other user defined commands.\n\ If the command already exists, it is changed to a prefix command.")); set_cmd_completer (c, command_completer); - while_cmd_element = add_com ("while", class_support, while_command, _("\ + while_cmd_element = add_com ("while", class_support, while_command, _ ("\ Execute nested commands WHILE the conditional expression is non zero.\n\ The conditional expression must follow the word `while' and must in turn be\n\ followed by a new line. The nested commands must be entered one per line,\n\ and should be terminated by the word `end'.")); - if_cmd_element = add_com ("if", class_support, if_command, _("\ + if_cmd_element = add_com ("if", class_support, if_command, _ ("\ Execute nested commands once IF the conditional expression is non zero.\n\ The conditional expression must follow the word `if' and must in turn be\n\ followed by a new line. The nested commands must be entered one per line,\n\ diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h index da7307b..547fa26 100644 --- a/gdb/cli/cli-script.h +++ b/gdb/cli/cli-script.h @@ -86,16 +86,16 @@ struct command_line struct command_line *next = nullptr; char *line; enum command_control_type control_type; + union + { + struct { - struct - { - enum compile_i_scope_types scope; - void *scope_data; - } - compile; - } - control_u; + enum compile_i_scope_types scope; + void *scope_data; + } compile; + } control_u; + /* * For composite commands, the nested lists of commands. For example, for "if" command this will contain the then branch and the else branch, if that is available. */ @@ -106,10 +106,7 @@ private: friend void free_command_lines (struct command_line **); - ~command_line () - { - xfree (line); - } + ~command_line () { xfree (line); } }; /* Prototype for a function to call to get one more input line. @@ -118,22 +115,21 @@ private: in the passed-in buffer, and return a pointer to it. Otherwise, it can simply ignore it. */ -using read_next_line_ftype = gdb::function_view<const char * (std::string &)>; - -extern counted_command_line read_command_lines - (const char *, int, int, gdb::function_view<void (const char *)>); -extern counted_command_line read_command_lines_1 - (read_next_line_ftype, int, gdb::function_view<void (const char *)>); +using read_next_line_ftype = gdb::function_view<const char *(std::string &)>; +extern counted_command_line +read_command_lines (const char *, int, int, + gdb::function_view<void (const char *)>); +extern counted_command_line +read_command_lines_1 (read_next_line_ftype, int, + gdb::function_view<void (const char *)>); /* Exported to cli/cli-cmds.c */ extern void script_from_file (FILE *stream, const char *file); -extern void show_user_1 (struct cmd_list_element *c, - const char *prefix, - const char *name, - struct ui_file *stream); +extern void show_user_1 (struct cmd_list_element *c, const char *prefix, + const char *name, struct ui_file *stream); /* Execute the commands in CMDLINES. */ @@ -144,27 +140,28 @@ extern void execute_control_commands (struct command_line *cmdlines, the returned string, do not display it to the screen. BATCH_FLAG will be temporarily set to true. */ -extern std::string execute_control_commands_to_string - (struct command_line *commands, int from_tty); +extern std::string +execute_control_commands_to_string (struct command_line *commands, + int from_tty); /* Exported to gdb/breakpoint.c */ extern enum command_control_type - execute_control_command (struct command_line *cmd, - int from_tty = 0); +execute_control_command (struct command_line *cmd, int from_tty = 0); extern enum command_control_type - execute_control_command_untraced (struct command_line *cmd); +execute_control_command_untraced (struct command_line *cmd); extern counted_command_line get_command_line (enum command_control_type, const char *); -extern void print_command_lines (struct ui_out *, - struct command_line *, unsigned int); +extern void print_command_lines (struct ui_out *, struct command_line *, + unsigned int); /* Exported to gdb/infrun.c */ -extern void execute_user_command (struct cmd_list_element *c, const char *args); +extern void execute_user_command (struct cmd_list_element *c, + const char *args); /* If we're in a user-defined command, replace any $argc/$argN reference found in LINE with the arguments that were passed to the @@ -174,8 +171,7 @@ extern std::string insert_user_defined_cmd_args (const char *line); /* Exported to top.c */ -extern void print_command_trace (const char *cmd, ...) - ATTRIBUTE_PRINTF (1, 2); +extern void print_command_trace (const char *cmd, ...) ATTRIBUTE_PRINTF (1, 2); /* Exported to event-top.c */ diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index dad3e60..cd4ffa1 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -40,7 +40,6 @@ notify_command_param_changed_p (bool param_changed, struct cmd_list_element *c) return c->theclass != class_maintenance && c->theclass != class_obscure; } - static enum auto_boolean parse_auto_binary_operation (const char *arg) { @@ -67,7 +66,7 @@ parse_auto_binary_operation (const char *arg) || (length > 1 && strncmp (arg, "-1", length) == 0)) return AUTO_BOOLEAN_AUTO; } - error (_("\"on\", \"off\" or \"auto\" expected.")); + error (_ ("\"on\", \"off\" or \"auto\" expected.")); return AUTO_BOOLEAN_AUTO; /* Pacify GCC. */ } @@ -82,8 +81,7 @@ parse_cli_boolean_value (const char **arg) /* Note that "o" is ambiguous. */ if ((length == 2 && strncmp (*arg, "on", length) == 0) - || strncmp (*arg, "1", length) == 0 - || strncmp (*arg, "yes", length) == 0 + || strncmp (*arg, "1", length) == 0 || strncmp (*arg, "yes", length) == 0 || strncmp (*arg, "enable", length) == 0) { *arg = skip_spaces (*arg + length); @@ -116,12 +114,9 @@ parse_cli_boolean_value (const char *arg) return b; } - void -deprecated_show_value_hack (struct ui_file *ignore_file, - int ignore_from_tty, - struct cmd_list_element *c, - const char *value) +deprecated_show_value_hack (struct ui_file *ignore_file, int ignore_from_tty, + struct cmd_list_element *c, const char *value) { /* If there's no command or value, don't try to print it out. */ if (c == NULL || value == NULL) @@ -164,9 +159,7 @@ get_literal_val (LONGEST &val, const literal_def *extra_literals, size_t len = p - *arg; if (len > 0 && extra_literals != nullptr) - for (const literal_def *l = extra_literals; - l->literal != nullptr; - l++) + for (const literal_def *l = extra_literals; l->literal != nullptr; l++) if (strncmp (l->literal, *arg, len) == 0) { *arg += len; @@ -179,8 +172,8 @@ get_literal_val (LONGEST &val, const literal_def *extra_literals, { const char *after = skip_spaces (*arg); if (*after != '\0') - error (_("Junk after \"%.*s\": %s"), - (int) len, unl_start, after); + error (_ ("Junk after \"%.*s\": %s"), (int) len, unl_start, + after); } val = l->use; @@ -201,14 +194,13 @@ parse_cli_var_integer (var_types var_type, const literal_def *extra_literals, if (*arg == nullptr || **arg == '\0') { if (extra_literals == nullptr) - error_no_arg (_("integer to set it to")); + error_no_arg (_ ("integer to set it to")); else { std::string buffer = ""; size_t count = 0; - for (const literal_def *l = extra_literals; - l->literal != nullptr; + for (const literal_def *l = extra_literals; l->literal != nullptr; l++, count++) { if (count != 0) @@ -216,13 +208,14 @@ parse_cli_var_integer (var_types var_type, const literal_def *extra_literals, buffer = buffer + '"' + l->literal + '"'; } if (count > 1) - error_no_arg - (string_printf (_("integer to set it to, or one of: %s"), - buffer.c_str ()).c_str ()); + error_no_arg ( + string_printf (_ ("integer to set it to, or one of: %s"), + buffer.c_str ()) + .c_str ()); else - error_no_arg - (string_printf (_("integer to set it to, or %s"), - buffer.c_str ()).c_str ()); + error_no_arg (string_printf (_ ("integer to set it to, or %s"), + buffer.c_str ()) + .c_str ()); } } @@ -236,8 +229,7 @@ parse_cli_var_integer (var_types var_type, const literal_def *extra_literals, enum tribool allowed = TRIBOOL_UNKNOWN; if (extra_literals != nullptr) { - for (const literal_def *l = extra_literals; - l->literal != nullptr; + for (const literal_def *l = extra_literals; l->literal != nullptr; l++) if (l->val.has_value () && val == *l->val) { @@ -259,7 +251,7 @@ parse_cli_var_integer (var_types var_type, const literal_def *extra_literals, allowed = TRIBOOL_FALSE; } if (allowed == TRIBOOL_FALSE) - error (_("integer %s out of range"), plongest (val)); + error (_ ("integer %s out of range"), plongest (val)); } return val; @@ -282,7 +274,7 @@ parse_cli_var_enum (const char **args, const char *const *enums) msg += ", "; msg += enums[i]; } - error (_("Requires an argument. Valid arguments are %s."), + error (_ ("Requires an argument. Valid arguments are %s."), msg.c_str ()); } @@ -308,10 +300,10 @@ parse_cli_var_enum (const char **args, const char *const *enums) } if (nmatches == 0) - error (_("Undefined item: \"%.*s\"."), (int) len, *args); + error (_ ("Undefined item: \"%.*s\"."), (int) len, *args); if (nmatches > 1) - error (_("Ambiguous item \"%.*s\"."), (int) len, *args); + error (_ ("Ambiguous item \"%.*s\"."), (int) len, *args); *args += len; return match; @@ -362,7 +354,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) break; ch = parse_escape (get_current_arch (), &p); if (ch == 0) - break; /* C loses */ + break; /* C loses */ else if (ch > 0) *q++ = ch; } @@ -385,7 +377,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) break; case var_filename: if (*arg == '\0') - error_no_arg (_("filename to set it to.")); + error_no_arg (_ ("filename to set it to.")); /* FALLTHROUGH */ case var_optional_filename: { @@ -406,8 +398,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) else val = xstrdup (""); - option_changed - = c->var->set<std::string> (std::string (val)); + option_changed = c->var->set<std::string> (std::string (val)); xfree (val); } break; @@ -416,20 +407,18 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) int val = parse_cli_boolean_value (arg); if (val < 0) - error (_("\"on\" or \"off\" expected.")); + error (_ ("\"on\" or \"off\" expected.")); option_changed = c->var->set<bool> (val); } break; case var_auto_boolean: - option_changed = c->var->set<enum auto_boolean> (parse_auto_binary_operation (arg)); + option_changed + = c->var->set<enum auto_boolean> (parse_auto_binary_operation (arg)); break; case var_uinteger: - option_changed - = c->var->set<unsigned int> (parse_cli_var_integer (c->var->type (), - c->var-> - extra_literals (), - &arg, true)); + option_changed = c->var->set<unsigned int> (parse_cli_var_integer ( + c->var->type (), c->var->extra_literals (), &arg, true)); break; case var_integer: case var_pinteger: @@ -446,13 +435,13 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) int len = end_arg - arg; const char *after = skip_spaces (end_arg); if (*after != '\0') - error (_("Junk after item \"%.*s\": %s"), len, arg, after); + error (_ ("Junk after item \"%.*s\": %s"), len, arg, after); option_changed = c->var->set<const char *> (match); } break; default: - error (_("gdb internal error: bad var_type in do_setshow_command")); + error (_ ("gdb internal error: bad var_type in do_setshow_command")); } c->func (NULL, from_tty, c); @@ -521,12 +510,12 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) case var_string_noescape: case var_filename: case var_optional_filename: - gdb::observers::command_param_changed.notify - (name, c->var->get<std::string> ().c_str ()); + gdb::observers::command_param_changed.notify ( + name, c->var->get<std::string> ().c_str ()); break; case var_enum: - gdb::observers::command_param_changed.notify - (name, c->var->get<const char *> ()); + gdb::observers::command_param_changed.notify ( + name, c->var->get<const char *> ()); break; case var_boolean: { @@ -620,13 +609,12 @@ get_setshow_command_value_string (const setting &var) bool printed = false; const LONGEST value = (var.type () == var_uinteger - ? static_cast<LONGEST> (var.get<unsigned int> ()) - : static_cast<LONGEST> (var.get<int> ())); + ? static_cast<LONGEST> (var.get<unsigned int> ()) + : static_cast<LONGEST> (var.get<int> ())); if (var.extra_literals () != nullptr) for (const literal_def *l = var.extra_literals (); - l->literal != nullptr; - l++) + l->literal != nullptr; l++) if (value == l->use) { stb.puts (l->literal); @@ -649,7 +637,6 @@ get_setshow_command_value_string (const setting &var) return stb.release (); } - /* Do a "show" command. ARG is NULL if no argument, or the text of the argument, and FROM_TTY is nonzero if this command is being entered directly by the user (i.e. these are just like any @@ -713,8 +700,9 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) { /* If we find a prefix, output it (with "show " skipped). */ std::string prefixname = list->prefix->prefixname (); - prefixname = (!list->prefix->is_prefix () ? "" - : strstr (prefixname.c_str (), "show ") + 5); + prefixname = (!list->prefix->is_prefix () + ? "" + : strstr (prefixname.c_str (), "show ") + 5); uiout->text (prefixname); } uiout->field_string ("name", list->name); @@ -726,5 +714,3 @@ cmd_show_list (struct cmd_list_element *list, int from_tty) } } } - - diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h index bc70ea6..92e4c3e 100644 --- a/gdb/cli/cli-setshow.h +++ b/gdb/cli/cli-setshow.h @@ -40,15 +40,13 @@ extern int parse_cli_boolean_value (const char **arg); would parse "-obj --" as part of the expression as well. */ extern LONGEST parse_cli_var_integer (var_types var_type, const literal_def *extra_literals, - const char **arg, - bool expression); + const char **arg, bool expression); /* Parse ARG, an option to a var_enum variable. ENUM is a null-terminated array of possible values. Either returns the parsed value on success or throws an error. ARG is advanced past the parsed value. */ -const char *parse_cli_var_enum (const char **args, - const char *const *enums); +const char *parse_cli_var_enum (const char **args, const char *const *enums); extern void do_set_command (const char *arg, int from_tty, struct cmd_list_element *c); diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index cd510b4..bf323c0 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -27,7 +27,7 @@ /* True if styling is enabled. */ -#if defined (__MSDOS__) +#if defined(__MSDOS__) bool cli_styling = false; #else bool cli_styling = true; @@ -44,27 +44,14 @@ bool source_styling = true; bool disassembler_styling = true; /* Name of colors; must correspond to ui_file_style::basic_color. */ -static const char * const cli_colors[] = { - "none", - "black", - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "white", - nullptr -}; +static const char *const cli_colors[] + = { "none", "black", "red", "green", "yellow", + "blue", "magenta", "cyan", "white", nullptr }; /* Names of intensities; must correspond to ui_file_style::intensity. */ -static const char * const cli_intensities[] = { - "normal", - "bold", - "dim", - nullptr -}; +static const char *const cli_intensities[] + = { "normal", "bold", "dim", nullptr }; /* See cli-style.h. */ @@ -199,14 +186,13 @@ cli_style_option::do_set_value (const char *ignore, int from_tty, The style for which WHAT is shown is retrieved from CMD context. */ static void -do_show (const char *what, struct ui_file *file, - struct cmd_list_element *cmd, +do_show (const char *what, struct ui_file *file, struct cmd_list_element *cmd, const char *value) { cli_style_option *cso = (cli_style_option *) cmd->context (); - gdb_puts (_("The "), file); - fprintf_styled (file, cso->style (), _("\"%s\" style"), cso->name ()); - gdb_printf (file, _(" %s is: %s\n"), what, value); + gdb_puts (_ ("The "), file); + fprintf_styled (file, cso->style (), _ ("\"%s\" style"), cso->name ()); + gdb_printf (file, _ (" %s is: %s\n"), what, value); } /* See cli-style.h. */ @@ -216,7 +202,7 @@ cli_style_option::do_show_foreground (struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value) { - do_show (_("foreground color"), file, cmd, value); + do_show (_ ("foreground color"), file, cmd, value); } /* See cli-style.h. */ @@ -226,7 +212,7 @@ cli_style_option::do_show_background (struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value) { - do_show (_("background color"), file, cmd, value); + do_show (_ ("background color"), file, cmd, value); } /* See cli-style.h. */ @@ -236,7 +222,7 @@ cli_style_option::do_show_intensity (struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value) { - do_show (_("display intensity"), file, cmd, value); + do_show (_ ("display intensity"), file, cmd, value); } /* See cli-style.h. */ @@ -254,41 +240,31 @@ cli_style_option::add_setshow_commands (enum command_class theclass, set_show_commands commands; - commands = add_setshow_enum_cmd - ("foreground", theclass, cli_colors, - &m_foreground, - _("Set the foreground color for this property."), - _("Show the foreground color for this property."), - nullptr, - do_set_value, - do_show_foreground, - &m_set_list, &m_show_list); + commands + = add_setshow_enum_cmd ("foreground", theclass, cli_colors, &m_foreground, + _ ("Set the foreground color for this property."), + _ ("Show the foreground color for this property."), + nullptr, do_set_value, do_show_foreground, + &m_set_list, &m_show_list); commands.set->set_context (this); commands.show->set_context (this); - commands = add_setshow_enum_cmd - ("background", theclass, cli_colors, - &m_background, - _("Set the background color for this property."), - _("Show the background color for this property."), - nullptr, - do_set_value, - do_show_background, - &m_set_list, &m_show_list); + commands + = add_setshow_enum_cmd ("background", theclass, cli_colors, &m_background, + _ ("Set the background color for this property."), + _ ("Show the background color for this property."), + nullptr, do_set_value, do_show_background, + &m_set_list, &m_show_list); commands.set->set_context (this); commands.show->set_context (this); if (!skip_intensity) { - commands = add_setshow_enum_cmd - ("intensity", theclass, cli_intensities, - &m_intensity, - _("Set the display intensity for this property."), - _("Show the display intensity for this property."), - nullptr, - do_set_value, - do_show_intensity, - &m_set_list, &m_show_list); + commands = add_setshow_enum_cmd ( + "intensity", theclass, cli_intensities, &m_intensity, + _ ("Set the display intensity for this property."), + _ ("Show the display intensity for this property."), nullptr, + do_set_value, do_show_intensity, &m_set_list, &m_show_list); commands.set->set_context (this); commands.show->set_context (this); } @@ -308,7 +284,7 @@ static cmd_list_element *style_disasm_set_list; static cmd_list_element *style_disasm_show_list; static void -set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c) +set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c) { g_source_cache.clear (); gdb::observers::styling_changed.notify (); @@ -319,9 +295,9 @@ show_style_enabled (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { if (cli_styling) - gdb_printf (file, _("CLI output styling is enabled.\n")); + gdb_printf (file, _ ("CLI output styling is enabled.\n")); else - gdb_printf (file, _("CLI output styling is disabled.\n")); + gdb_printf (file, _ ("CLI output styling is disabled.\n")); } static void @@ -329,9 +305,9 @@ show_style_sources (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { if (source_styling) - gdb_printf (file, _("Source code styling is enabled.\n")); + gdb_printf (file, _ ("Source code styling is enabled.\n")); else - gdb_printf (file, _("Source code styling is disabled.\n")); + gdb_printf (file, _ ("Source code styling is disabled.\n")); } /* Implement 'show style disassembler'. */ @@ -341,102 +317,107 @@ show_style_disassembler (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { if (disassembler_styling) - gdb_printf (file, _("Disassembler output styling is enabled.\n")); + gdb_printf (file, _ ("Disassembler output styling is enabled.\n")); else - gdb_printf (file, _("Disassembler output styling is disabled.\n")); + gdb_printf (file, _ ("Disassembler output styling is disabled.\n")); } void _initialize_cli_style (); + void _initialize_cli_style () { - add_setshow_prefix_cmd ("style", no_class, - _("\ + add_setshow_prefix_cmd ("style", no_class, _ ("\ Style-specific settings.\n\ Configure various style-related variables, such as colors"), - _("\ + _ ("\ Style-specific settings.\n\ Configure various style-related variables, such as colors"), - &style_set_list, &style_show_list, - &setlist, &showlist); - - add_setshow_boolean_cmd ("enabled", no_class, &cli_styling, _("\ -Set whether CLI styling is enabled."), _("\ -Show whether CLI is enabled."), _("\ + &style_set_list, &style_show_list, &setlist, + &showlist); + + add_setshow_boolean_cmd ("enabled", no_class, &cli_styling, _ ("\ +Set whether CLI styling is enabled."), + _ ("\ +Show whether CLI is enabled."), + _ ("\ If enabled, output to the terminal is styled."), set_style_enabled, show_style_enabled, &style_set_list, &style_show_list); - add_setshow_boolean_cmd ("sources", no_class, &source_styling, _("\ -Set whether source code styling is enabled."), _("\ -Show whether source code styling is enabled."), _("\ + add_setshow_boolean_cmd ( + "sources", no_class, &source_styling, _ ("\ +Set whether source code styling is enabled."), + _ ("\ +Show whether source code styling is enabled."), + _ ( + "\ If enabled, source code is styled.\n" #ifdef HAVE_SOURCE_HIGHLIGHT -"Note that source styling only works if styling in general is enabled,\n\ + "Note that source styling only works if styling in general is enabled,\n\ see \"show style enabled\"." #else -"Source highlighting may be disabled in this installation of gdb, because\n\ + "Source highlighting may be disabled in this installation of gdb, because\n\ it was not linked against GNU Source Highlight. However, it might still be\n\ available if the appropriate extension is available at runtime." #endif - ), set_style_enabled, show_style_sources, - &style_set_list, &style_show_list); + ), + set_style_enabled, show_style_sources, &style_set_list, &style_show_list); - add_setshow_prefix_cmd ("disassembler", no_class, - _("\ + add_setshow_prefix_cmd ("disassembler", no_class, _ ("\ Style-specific settings for the disassembler.\n\ Configure various disassembler style-related variables."), - _("\ + _ ("\ Style-specific settings for the disassembler.\n\ Configure various disassembler style-related variables."), &style_disasm_set_list, &style_disasm_show_list, &style_set_list, &style_show_list); - add_setshow_boolean_cmd ("enabled", no_class, &disassembler_styling, _("\ -Set whether disassembler output styling is enabled."), _("\ -Show whether disassembler output styling is enabled."), _("\ + add_setshow_boolean_cmd ("enabled", no_class, &disassembler_styling, _ ("\ +Set whether disassembler output styling is enabled."), + _ ("\ +Show whether disassembler output styling is enabled."), + _ ("\ If enabled, disassembler output is styled. Disassembler highlighting\n\ requires the Python Pygments library, if this library is not available\n\ -then disassembler highlighting will not be possible." - ), set_style_enabled, show_style_disassembler, +then disassembler highlighting will not be possible."), + set_style_enabled, show_style_disassembler, &style_disasm_set_list, &style_disasm_show_list); - file_name_style.add_setshow_commands (no_class, _("\ + file_name_style.add_setshow_commands (no_class, _ ("\ Filename display styling.\n\ Configure filename colors and display intensity."), &style_set_list, &style_show_list, false); set_show_commands function_prefix_cmds - = function_name_style.add_setshow_commands (no_class, _("\ + = function_name_style.add_setshow_commands (no_class, _ ("\ Function name display styling.\n\ Configure function name colors and display intensity"), &style_set_list, - &style_show_list, - false); + &style_show_list, false); - variable_name_style.add_setshow_commands (no_class, _("\ + variable_name_style.add_setshow_commands (no_class, _ ("\ Variable name display styling.\n\ Configure variable name colors and display intensity"), &style_set_list, &style_show_list, false); set_show_commands address_prefix_cmds - = address_style.add_setshow_commands (no_class, _("\ + = address_style.add_setshow_commands (no_class, _ ("\ Address display styling.\n\ Configure address colors and display intensity"), &style_set_list, &style_show_list, false); - title_style.add_setshow_commands (no_class, _("\ + title_style.add_setshow_commands (no_class, _ ("\ Title display styling.\n\ Configure title colors and display intensity\n\ Some commands (such as \"apropos -v REGEXP\") use the title style to improve\n\ readability."), - &style_set_list, &style_show_list, - false); + &style_set_list, &style_show_list, false); - highlight_style.add_setshow_commands (no_class, _("\ + highlight_style.add_setshow_commands (no_class, _ ("\ Highlight display styling.\n\ Configure highlight colors and display intensity\n\ Some commands use the highlight style to draw the attention to a part\n\ @@ -444,7 +425,7 @@ of their output."), &style_set_list, &style_show_list, false); - metadata_style.add_setshow_commands (no_class, _("\ + metadata_style.add_setshow_commands (no_class, _ ("\ Metadata display styling.\n\ Configure metadata colors and display intensity\n\ The \"metadata\" style is used when GDB displays information about\n\ @@ -452,7 +433,7 @@ your data, for example \"<unavailable>\""), &style_set_list, &style_show_list, false); - tui_border_style.add_setshow_commands (no_class, _("\ + tui_border_style.add_setshow_commands (no_class, _ ("\ TUI border display styling.\n\ Configure TUI border colors\n\ The \"tui-border\" style is used when GDB displays the border of a\n\ @@ -460,22 +441,21 @@ TUI window that does not have the focus."), &style_set_list, &style_show_list, true); - tui_active_border_style.add_setshow_commands (no_class, _("\ + tui_active_border_style.add_setshow_commands (no_class, _ ("\ TUI active border display styling.\n\ Configure TUI active border colors\n\ The \"tui-active-border\" style is used when GDB displays the border of a\n\ TUI window that does have the focus."), &style_set_list, - &style_show_list, - true); + &style_show_list, true); - version_style.add_setshow_commands (no_class, _("\ + version_style.add_setshow_commands (no_class, _ ("\ Version string display styling.\n\ Configure colors used to display the GDB version string."), &style_set_list, &style_show_list, false); - disasm_mnemonic_style.add_setshow_commands (no_class, _("\ + disasm_mnemonic_style.add_setshow_commands (no_class, _ ("\ Disassembler mnemonic display styling.\n\ Configure the colors and display intensity for instruction mnemonics\n\ in the disassembler output. The \"disassembler mnemonic\" style is\n\ @@ -486,10 +466,9 @@ This style will only be used for targets that support libopcodes based\n\ disassembler styling. When Python Pygments based styling is used\n\ then this style has no effect."), &style_disasm_set_list, - &style_disasm_show_list, - false); + &style_disasm_show_list, false); - disasm_register_style.add_setshow_commands (no_class, _("\ + disasm_register_style.add_setshow_commands (no_class, _ ("\ Disassembler register display styling.\n\ Configure the colors and display intensity for registers in the\n\ disassembler output.\n\ @@ -498,10 +477,9 @@ This style will only be used for targets that support libopcodes based\n\ disassembler styling. When Python Pygments based styling is used\n\ then this style has no effect."), &style_disasm_set_list, - &style_disasm_show_list, - false); + &style_disasm_show_list, false); - disasm_immediate_style.add_setshow_commands (no_class, _("\ + disasm_immediate_style.add_setshow_commands (no_class, _ ("\ Disassembler immediate display styling.\n\ Configure the colors and display intensity for immediates in the\n\ disassembler output. The \"disassembler immediate\" style is used for\n\ @@ -512,10 +490,9 @@ This style will only be used for targets that support libopcodes based\n\ disassembler styling. When Python Pygments based styling is used\n\ then this style has no effect."), &style_disasm_set_list, - &style_disasm_show_list, - false); + &style_disasm_show_list, false); - disasm_comment_style.add_setshow_commands (no_class, _("\ + disasm_comment_style.add_setshow_commands (no_class, _ ("\ Disassembler comment display styling.\n\ Configure the colors and display intensity for comments in the\n\ disassembler output. The \"disassembler comment\" style is used for\n\ @@ -527,8 +504,7 @@ This style will only be used for targets that support libopcodes based\n\ disassembler styling. When Python Pygments based styling is used\n\ then this style has no effect."), &style_disasm_set_list, - &style_disasm_show_list, - false); + &style_disasm_show_list, false); /* Setup 'disassembler address' style and 'disassembler symbol' style, these are aliases for 'address' and 'function' styles respectively. */ diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 81c3c72..98f7d2c 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -28,21 +28,21 @@ ULONGEST get_ulongest (const char **pp, int trailer) { - LONGEST retval = 0; /* default */ + LONGEST retval = 0; /* default */ const char *p = *pp; if (*p == '$') { value *val = value_from_history_ref (p, &p); - if (val != NULL) /* Value history reference */ + if (val != NULL) /* Value history reference */ { if (value_type (val)->code () == TYPE_CODE_INT) retval = value_as_long (val); else - error (_("History value must have integer type.")); + error (_ ("History value must have integer type.")); } - else /* Convenience variable */ + else /* Convenience variable */ { /* Internal variable. Make a copy of the name, so we can null-terminate it to pass to lookup_internalvar(). */ @@ -51,8 +51,8 @@ get_ulongest (const char **pp, int trailer) p++; std::string varname (start, p - start); if (!get_internalvar_integer (lookup_internalvar (varname.c_str ()), - &retval)) - error (_("Convenience variable $%s does not have integer value."), + &retval)) + error (_ ("Convenience variable $%s does not have integer value."), varname.c_str ()); } } @@ -63,13 +63,13 @@ get_ulongest (const char **pp, int trailer) if (p == end) { /* There is no number here. (e.g. "cond a == b"). */ - error (_("Expected integer at: %s"), p); + error (_ ("Expected integer at: %s"), p); } p = end; } if (!(isspace (*p) || *p == '\0' || *p == trailer)) - error (_("Trailing junk at: %s"), p); + error (_ ("Trailing junk at: %s"), p); p = skip_spaces (p); *pp = p; return retval; @@ -80,7 +80,7 @@ get_ulongest (const char **pp, int trailer) int get_number_trailer (const char **pp, int trailer) { - int retval = 0; /* default */ + int retval = 0; /* default */ const char *p = *pp; bool negative = false; @@ -94,17 +94,17 @@ get_number_trailer (const char **pp, int trailer) { struct value *val = value_from_history_ref (p, &p); - if (val) /* Value history reference */ + if (val) /* Value history reference */ { if (value_type (val)->code () == TYPE_CODE_INT) retval = value_as_long (val); else { - gdb_printf (_("History value must have integer type.\n")); + gdb_printf (_ ("History value must have integer type.\n")); retval = 0; } } - else /* Convenience variable */ + else /* Convenience variable */ { /* Internal variable. Make a copy of the name, so we can null-terminate it to pass to lookup_internalvar(). */ @@ -122,8 +122,8 @@ get_number_trailer (const char **pp, int trailer) retval = (int) longest_val; else { - gdb_printf (_("Convenience variable must " - "have integer value.\n")); + gdb_printf (_ ("Convenience variable must " + "have integer value.\n")); retval = 0; } } @@ -137,7 +137,7 @@ get_number_trailer (const char **pp, int trailer) /* There is no number here. (e.g. "cond a == b"). */ { /* Skip non-numeric token. */ - while (*p && !isspace((int) *p)) + while (*p && !isspace ((int) *p)) ++p; /* Return zero, which caller must interpret as error. */ retval = 0; @@ -185,19 +185,18 @@ report_unrecognized_option_error (const char *command, const char *args) { std::string option = extract_arg (&args); - error (_("Unrecognized option '%s' to %s command. " - "Try \"help %s\"."), option.c_str (), - command, command); + error (_ ("Unrecognized option '%s' to %s command. " + "Try \"help %s\"."), + option.c_str (), command, command); } /* See documentation in cli-utils.h. */ const char * -info_print_args_help (const char *prefix, - const char *entity_kind, +info_print_args_help (const char *prefix, const char *entity_kind, bool document_n_flag) { - return xstrprintf (_("\ + return xstrprintf (_ ("\ %sIf NAMEREGEXP is provided, only prints the %s whose name\n\ matches NAMEREGEXP.\n\ If -t TYPEREGEXP is provided, only prints the %s whose type\n\ @@ -207,9 +206,11 @@ By default, the command might produce headers and/or messages indicating\n\ why no %s can be printed.\n\ The flag -q disables the production of these headers and messages.%s"), prefix, entity_kind, entity_kind, entity_kind, - (document_n_flag ? _("\n\ + (document_n_flag ? _ ("\n\ By default, the command will include non-debug symbols in the output;\n\ -these can be excluded using the -n flag.") : "")).release (); +these can be excluded using the -n flag.") + : "")) + .release (); } /* See documentation in cli-utils.h. */ @@ -264,8 +265,7 @@ number_or_range_parser::get_number () string as well. */ if (m_cur_tok[0] == '-' && !(isspace (m_cur_tok[-1]) - && (isalpha (m_cur_tok[1]) - || m_cur_tok[1] == '-' + && (isalpha (m_cur_tok[1]) || m_cur_tok[1] == '-' || m_cur_tok[1] == '\0'))) { const char **temp; @@ -279,7 +279,7 @@ number_or_range_parser::get_number () m_end_value = ::get_number (temp); if (m_end_value < m_last_retval) { - error (_("inverted range")); + error (_ ("inverted range")); } else if (m_end_value == m_last_retval) { @@ -295,13 +295,13 @@ number_or_range_parser::get_number () else { if (isdigit (*(m_cur_tok + 1))) - error (_("negative value")); + error (_ ("negative value")); if (*(m_cur_tok + 1) == '$') { /* Convenience variable. */ m_last_retval = ::get_number (&m_cur_tok); if (m_last_retval < 0) - error (_("negative value")); + error (_ ("negative value")); } } return m_last_retval; @@ -330,8 +330,7 @@ number_or_range_parser::finished () const or we are not in a range and not in front of an integer, negative integer, convenience var or negative convenience var. */ return (m_cur_tok == NULL || *m_cur_tok == '\0' - || (!m_in_range - && !(isdigit (*m_cur_tok) || *m_cur_tok == '$') + || (!m_in_range && !(isdigit (*m_cur_tok) || *m_cur_tok == '$') && !(*m_cur_tok == '-' && (isdigit (m_cur_tok[1]) || m_cur_tok[1] == '$')))); } @@ -353,13 +352,13 @@ number_is_in_list (const char *list, int number) number_or_range_parser parser (list); if (parser.finished ()) - error (_("Arguments must be numbers or '$' variables.")); + error (_ ("Arguments must be numbers or '$' variables.")); while (!parser.finished ()) { int gotnum = parser.get_number (); if (gotnum == 0) - error (_("Arguments must be numbers or '$' variables.")); + error (_ ("Arguments must be numbers or '$' variables.")); if (gotnum == number) return 1; } @@ -436,6 +435,5 @@ void validate_flags_qcs (const char *which_command, qcs_flags *flags) { if (flags->cont && flags->silent) - error (_("%s: -c and -s are mutually exclusive"), which_command); + error (_ ("%s: -c and -s are mutually exclusive"), which_command); } - diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index 6a209ae..8d98195 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -53,14 +53,12 @@ extern ULONGEST get_ulongest (const char **pp, int trailer = '\0'); extern void report_unrecognized_option_error (const char *command, const char *args); - /* Builds the help string for a command documented by PREFIX, followed by the extract_info_print_args help for ENTITY_KIND. If DOCUMENT_N_FLAG is true then help text describing the -n flag is also included. */ -const char *info_print_args_help (const char *prefix, - const char *entity_kind, +const char *info_print_args_help (const char *prefix, const char *entity_kind, bool document_n_flag); /* Parse a number or a range. @@ -72,6 +70,7 @@ const char *info_print_args_help (const char *prefix, class number_or_range_parser { public: + /* Default construction. Must call init before calling get_next. */ number_or_range_parser () {} @@ -95,24 +94,20 @@ public: /* Setup internal state such that get_next() returns numbers in the START_VALUE to END_VALUE range. END_PTR is where the string is advanced to when get_next() returns END_VALUE. */ - void setup_range (int start_value, int end_value, - const char *end_ptr); + void setup_range (int start_value, int end_value, const char *end_ptr); /* Returns true if parsing has completed. */ bool finished () const; /* Return the string being parsed. When parsing has finished, this points past the last parsed token. */ - const char *cur_tok () const - { return m_cur_tok; } + const char *cur_tok () const { return m_cur_tok; } /* True when parsing a range. */ - bool in_range () const - { return m_in_range; } + bool in_range () const { return m_in_range; } /* When parsing a range, the final value in the range. */ - int end_value () const - { return m_end_value; } + int end_value () const { return m_end_value; } /* When parsing a range, skip past the final token in the range. */ void skip_range () @@ -123,6 +118,7 @@ public: } private: + /* No need for these. They are intentionally not defined anywhere. */ number_or_range_parser (const number_or_range_parser &); number_or_range_parser &operator= (const number_or_range_parser &); @@ -200,8 +196,7 @@ check_for_argument (const char **str, const char *arg) static inline int check_for_argument (char **str, const char *arg, int arg_len) { - return check_for_argument (const_cast<const char **> (str), - arg, arg_len); + return check_for_argument (const_cast<const char **> (str), arg, arg_len); } static inline int |