diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/mi | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | fsf-binutils-gdb-users/simark/clang-format.zip fsf-binutils-gdb-users/simark/clang-format.tar.gz fsf-binutils-gdb-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-cmd-break.c | 183 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-catch.c | 149 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-disas.c | 86 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-env.c | 45 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-file.c | 35 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-info.c | 9 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-stack.c | 256 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-target.c | 22 | ||||
-rw-r--r-- | gdb/mi/mi-cmd-var.c | 125 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.c | 42 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.h | 18 | ||||
-rw-r--r-- | gdb/mi/mi-common.c | 44 | ||||
-rw-r--r-- | gdb/mi/mi-console.c | 3 | ||||
-rw-r--r-- | gdb/mi/mi-console.h | 2 | ||||
-rw-r--r-- | gdb/mi/mi-getopt.c | 22 | ||||
-rw-r--r-- | gdb/mi/mi-getopt.h | 16 | ||||
-rw-r--r-- | gdb/mi/mi-interp.c | 758 | ||||
-rw-r--r-- | gdb/mi/mi-interp.h | 4 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 511 | ||||
-rw-r--r-- | gdb/mi/mi-main.h | 3 | ||||
-rw-r--r-- | gdb/mi/mi-out.c | 26 | ||||
-rw-r--r-- | gdb/mi/mi-out.h | 39 | ||||
-rw-r--r-- | gdb/mi/mi-parse.c | 109 | ||||
-rw-r--r-- | gdb/mi/mi-parse.h | 53 | ||||
-rw-r--r-- | gdb/mi/mi-symbol-cmds.c | 115 |
25 files changed, 1273 insertions, 1402 deletions
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 8b04838..6573ff5 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -35,9 +35,9 @@ #include "tracepoint.h" enum - { - FROM_TTY = 0 - }; +{ + FROM_TTY = 0 +}; /* True if MI breakpoint observers have been registered. */ @@ -66,11 +66,11 @@ breakpoint_notify (struct breakpoint *b) } enum bp_type - { - REG_BP, - HW_BP, - REGEXP_BP - }; +{ + REG_BP, + HW_BP, + REGEXP_BP +}; /* Arrange for all new breakpoints and catchpoints to be reported to CURRENT_UIOUT until the destructor of the returned scoped_restore @@ -82,7 +82,7 @@ enum bp_type scoped_restore_tmpl<int> setup_breakpoint_reporting (void) { - if (! mi_breakpoint_observers_installed) + if (!mi_breakpoint_observers_installed) { gdb::observers::breakpoint_created.attach (breakpoint_notify, "mi-cmd-break"); @@ -92,7 +92,6 @@ setup_breakpoint_reporting (void) return make_scoped_restore (&mi_can_breakpoint_notify, 1); } - /* Convert arguments in ARGV to the string in "format",argv,argv... and return it. */ @@ -182,39 +181,44 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) location_spec_up locspec; const struct breakpoint_ops *ops; int is_explicit = 0; - std::unique_ptr<explicit_location_spec> explicit_loc - (new explicit_location_spec ()); + std::unique_ptr<explicit_location_spec> explicit_loc ( + new explicit_location_spec ()); std::string extra_string; bool force_condition = false; enum opt - { - HARDWARE_OPT, TEMP_OPT, CONDITION_OPT, - IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT, - TRACEPOINT_OPT, - FORCE_CONDITION_OPT, - QUALIFIED_OPT, - EXPLICIT_SOURCE_OPT, EXPLICIT_FUNC_OPT, - EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT - }; - static const struct mi_opt opts[] = { - {"h", HARDWARE_OPT, 0}, - {"t", TEMP_OPT, 0}, - {"c", CONDITION_OPT, 1}, - {"i", IGNORE_COUNT_OPT, 1}, - {"p", THREAD_OPT, 1}, - {"f", PENDING_OPT, 0}, - {"d", DISABLE_OPT, 0}, - {"a", TRACEPOINT_OPT, 0}, - {"-force-condition", FORCE_CONDITION_OPT, 0}, - {"-qualified", QUALIFIED_OPT, 0}, - {"-source" , EXPLICIT_SOURCE_OPT, 1}, - {"-function", EXPLICIT_FUNC_OPT, 1}, - {"-label", EXPLICIT_LABEL_OPT, 1}, - {"-line", EXPLICIT_LINE_OPT, 1}, - { 0, 0, 0 } + HARDWARE_OPT, + TEMP_OPT, + CONDITION_OPT, + IGNORE_COUNT_OPT, + THREAD_OPT, + PENDING_OPT, + DISABLE_OPT, + TRACEPOINT_OPT, + FORCE_CONDITION_OPT, + QUALIFIED_OPT, + EXPLICIT_SOURCE_OPT, + EXPLICIT_FUNC_OPT, + EXPLICIT_LABEL_OPT, + EXPLICIT_LINE_OPT }; + static const struct mi_opt opts[] + = { { "h", HARDWARE_OPT, 0 }, + { "t", TEMP_OPT, 0 }, + { "c", CONDITION_OPT, 1 }, + { "i", IGNORE_COUNT_OPT, 1 }, + { "p", THREAD_OPT, 1 }, + { "f", PENDING_OPT, 0 }, + { "d", DISABLE_OPT, 0 }, + { "a", TRACEPOINT_OPT, 0 }, + { "-force-condition", FORCE_CONDITION_OPT, 0 }, + { "-qualified", QUALIFIED_OPT, 0 }, + { "-source", EXPLICIT_SOURCE_OPT, 1 }, + { "-function", EXPLICIT_FUNC_OPT, 1 }, + { "-label", EXPLICIT_LABEL_OPT, 1 }, + { "-line", EXPLICIT_LINE_OPT, 1 }, + { 0, 0, 0 } }; /* Parse arguments. It could be -r or -h or -t, <location> or ``--'' to denote the end of the option list. */ @@ -223,8 +227,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) while (1) { - int opt = mi_getopt ("-break-insert", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-break-insert", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -279,16 +282,16 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) } if (oind >= argc && !is_explicit) - error (_("-%s-insert: Missing <location>"), + error (_ ("-%s-insert: Missing <location>"), dprintf ? "dprintf" : "break"); if (dprintf) { int format_num = is_explicit ? oind : oind + 1; if (hardware || tracepoint) - error (_("-dprintf-insert: does not support -h or -a")); + error (_ ("-dprintf-insert: does not support -h or -a")); if (format_num >= argc) - error (_("-dprintf-insert: Missing <format>")); + error (_ ("-dprintf-insert: Missing <format>")); extra_string = mi_argv_to_format (argv + format_num, argc - format_num); address = argv[oind]; @@ -298,12 +301,12 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) if (is_explicit) { if (oind < argc) - error (_("-break-insert: Garbage following explicit location")); + error (_ ("-break-insert: Garbage following explicit location")); } else { if (oind < argc - 1) - error (_("-break-insert: Garbage following <location>")); + error (_ ("-break-insert: Garbage following <location>")); address = argv[oind]; } } @@ -342,8 +345,9 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) && explicit_loc->function_name == NULL && explicit_loc->label_name == NULL && explicit_loc->line_offset.sign == LINE_OFFSET_UNKNOWN) - error (_("-%s-insert: --source option requires --function, --label," - " or --line"), dprintf ? "dprintf" : "break"); + error (_ ("-%s-insert: --source option requires --function, --label," + " or --line"), + dprintf ? "dprintf" : "break"); explicit_loc->func_name_match_type = match_type; @@ -354,17 +358,15 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) locspec = string_to_location_spec_basic (&address, current_language, match_type); if (*address) - error (_("Garbage '%s' at end of location"), address); + error (_ ("Garbage '%s' at end of location"), address); } create_breakpoint (get_current_arch (), locspec.get (), condition, thread, - extra_string.c_str (), - force_condition, - 0 /* condition and thread are valid. */, - temp_p, type_wanted, - ignore_count, - pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE, - ops, 0, enabled, 0, 0); + extra_string.c_str (), force_condition, + 0 /* condition and thread are valid. */, temp_p, + type_wanted, ignore_count, + pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE, ops, 0, + enabled, 0, 0); } /* Implements the -break-insert command. @@ -392,16 +394,13 @@ void mi_cmd_break_condition (const char *command, char **argv, int argc) { enum option - { - FORCE_CONDITION_OPT, - }; - - static const struct mi_opt opts[] = { - {"-force", FORCE_CONDITION_OPT, 0}, - { 0, 0, 0 } + FORCE_CONDITION_OPT, }; + static const struct mi_opt opts[] + = { { "-force", FORCE_CONDITION_OPT, 0 }, { 0, 0, 0 } }; + /* Parse arguments. */ int oind = 0; char *oarg; @@ -409,8 +408,7 @@ mi_cmd_break_condition (const char *command, char **argv, int argc) while (true) { - int opt = mi_getopt ("-break-condition", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-break-condition", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -424,7 +422,7 @@ mi_cmd_break_condition (const char *command, char **argv, int argc) /* There must be at least one more arg: a bpnum. */ if (oind >= argc) - error (_("-break-condition: Missing the <number> argument")); + error (_ ("-break-condition: Missing the <number> argument")); int bpnum = atoi (argv[oind]); @@ -456,7 +454,7 @@ mi_cmd_break_passcount (const char *command, char **argv, int argc) struct tracepoint *t; if (argc != 2) - error (_("Usage: tracepoint-number passcount")); + error (_ ("Usage: tracepoint-number passcount")); n = atoi (argv[0]); p = atoi (argv[1]); @@ -469,7 +467,7 @@ mi_cmd_break_passcount (const char *command, char **argv, int argc) } else { - error (_("Could not find tracepoint %d"), n); + error (_ ("Could not find tracepoint %d"), n); } } @@ -484,16 +482,14 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) { char *expr = NULL; enum wp_type type = REG_WP; + enum opt - { - READ_OPT, ACCESS_OPT - }; - static const struct mi_opt opts[] = { - {"r", READ_OPT, 0}, - {"a", ACCESS_OPT, 0}, - { 0, 0, 0 } + READ_OPT, + ACCESS_OPT }; + static const struct mi_opt opts[] + = { { "r", READ_OPT, 0 }, { "a", ACCESS_OPT, 0 }, { 0, 0, 0 } }; /* Parse arguments. */ int oind = 0; @@ -501,8 +497,7 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) while (1) { - int opt = mi_getopt ("-break-watch", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-break-watch", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -517,9 +512,9 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) } } if (oind >= argc) - error (_("-break-watch: Missing <expression>")); + error (_ ("-break-watch: Missing <expression>")); if (oind < argc - 1) - error (_("-break-watch: Garbage following <expression>")); + error (_ ("-break-watch: Garbage following <expression>")); expr = argv[oind]; /* Now we have what we need, let's insert the watchpoint! */ @@ -535,7 +530,7 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) awatch_command_wrapper (expr, FROM_TTY, false); break; default: - error (_("-break-watch: Unknown watchpoint type.")); + error (_ ("-break-watch: Unknown watchpoint type.")); } } @@ -548,39 +543,33 @@ mi_cmd_break_commands (const char *command, char **argv, int argc) struct breakpoint *b; if (argc < 1) - error (_("USAGE: %s <BKPT> [<COMMAND> [<COMMAND>...]]"), command); + error (_ ("USAGE: %s <BKPT> [<COMMAND> [<COMMAND>...]]"), command); bnum = strtol (argv[0], &endptr, 0); if (endptr == argv[0]) - error (_("breakpoint number argument \"%s\" is not a number."), - argv[0]); + error (_ ("breakpoint number argument \"%s\" is not a number."), argv[0]); else if (*endptr != '\0') - error (_("junk at the end of breakpoint number argument \"%s\"."), + error (_ ("junk at the end of breakpoint number argument \"%s\"."), argv[0]); b = get_breakpoint (bnum); if (b == NULL) - error (_("breakpoint %d not found."), bnum); + error (_ ("breakpoint %d not found."), bnum); int count = 1; - auto reader - = [&] (std::string &buffer) - { - const char *result = nullptr; - if (count < argc) - result = argv[count++]; - return result; - }; + auto reader = [&] (std::string &buffer) { + const char *result = nullptr; + if (count < argc) + result = argv[count++]; + return result; + }; if (is_tracepoint (b)) - break_command = read_command_lines_1 (reader, 1, - [=] (const char *line) - { - validate_actionline (line, b); - }); + break_command = read_command_lines_1 (reader, 1, [=] (const char *line) { + validate_actionline (line, b); + }); else break_command = read_command_lines_1 (reader, 1, 0); breakpoint_set_commands (b, std::move (break_command)); } - diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c index 0827037..6538898 100644 --- a/gdb/mi/mi-cmd-catch.c +++ b/gdb/mi/mi-cmd-catch.c @@ -31,7 +31,7 @@ void mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) { - struct gdbarch *gdbarch = get_current_arch(); + struct gdbarch *gdbarch = get_current_arch (); std::string condition; int enabled = 1; int temp = 0; @@ -40,21 +40,19 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) char *oarg; enum opt - { - OPT_CONDITION, OPT_DISABLED, OPT_TEMP, - }; - static const struct mi_opt opts[] = - { - { "c", OPT_CONDITION, 1}, - { "d", OPT_DISABLED, 0 }, - { "t", OPT_TEMP, 0 }, - { 0, 0, 0 } - }; + { + OPT_CONDITION, + OPT_DISABLED, + OPT_TEMP, + }; + static const struct mi_opt opts[] = { { "c", OPT_CONDITION, 1 }, + { "d", OPT_DISABLED, 0 }, + { "t", OPT_TEMP, 0 }, + { 0, 0, 0 } }; for (;;) { - int opt = mi_getopt ("-catch-assert", argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt ("-catch-assert", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -76,7 +74,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) /* This command does not accept any argument. Make sure the user did not provide any. */ if (oind != argc) - error (_("Invalid argument: %s"), argv[oind]); + error (_ ("Invalid argument: %s"), argv[oind]); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); create_ada_exception_catchpoint (gdbarch, ada_catch_assert, std::string (), @@ -88,7 +86,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) void mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) { - struct gdbarch *gdbarch = get_current_arch(); + struct gdbarch *gdbarch = get_current_arch (); std::string condition; int enabled = 1; std::string exception_name; @@ -99,24 +97,21 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) char *oarg; enum opt - { - OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP, - OPT_UNHANDLED, - }; - static const struct mi_opt opts[] = - { - { "c", OPT_CONDITION, 1}, - { "d", OPT_DISABLED, 0 }, - { "e", OPT_EXCEPTION_NAME, 1 }, - { "t", OPT_TEMP, 0 }, - { "u", OPT_UNHANDLED, 0}, - { 0, 0, 0 } - }; + { + OPT_CONDITION, + OPT_DISABLED, + OPT_EXCEPTION_NAME, + OPT_TEMP, + OPT_UNHANDLED, + }; + static const struct mi_opt opts[] + = { { "c", OPT_CONDITION, 1 }, { "d", OPT_DISABLED, 0 }, + { "e", OPT_EXCEPTION_NAME, 1 }, { "t", OPT_TEMP, 0 }, + { "u", OPT_UNHANDLED, 0 }, { 0, 0, 0 } }; for (;;) { - int opt = mi_getopt ("-catch-exception", argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt ("-catch-exception", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -144,17 +139,16 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) /* This command does not accept any argument. Make sure the user did not provide any. */ if (oind != argc) - error (_("Invalid argument: %s"), argv[oind]); + error (_ ("Invalid argument: %s"), argv[oind]); /* Specifying an exception name does not make sense when requesting an unhandled exception breakpoint. */ if (ex_kind == ada_catch_exception_unhandled && !exception_name.empty ()) - error (_("\"-e\" and \"-u\" are mutually exclusive")); + error (_ ("\"-e\" and \"-u\" are mutually exclusive")); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); - create_ada_exception_catchpoint (gdbarch, ex_kind, - exception_name, - condition, temp, enabled, 0); + create_ada_exception_catchpoint (gdbarch, ex_kind, exception_name, condition, + temp, enabled, 0); } /* Handler for the -catch-handlers command. */ @@ -172,22 +166,21 @@ mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) char *oarg; enum opt - { - OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP - }; - static const struct mi_opt opts[] = - { - { "c", OPT_CONDITION, 1}, - { "d", OPT_DISABLED, 0 }, - { "e", OPT_EXCEPTION_NAME, 1 }, - { "t", OPT_TEMP, 0 }, - { 0, 0, 0 } - }; + { + OPT_CONDITION, + OPT_DISABLED, + OPT_EXCEPTION_NAME, + OPT_TEMP + }; + static const struct mi_opt opts[] = { { "c", OPT_CONDITION, 1 }, + { "d", OPT_DISABLED, 0 }, + { "e", OPT_EXCEPTION_NAME, 1 }, + { "t", OPT_TEMP, 0 }, + { 0, 0, 0 } }; for (;;) { - int opt = mi_getopt ("-catch-handlers", argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt ("-catch-handlers", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -212,12 +205,10 @@ mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) /* This command does not accept any argument. Make sure the user did not provide any. */ if (oind != argc) - error (_("Invalid argument: %s"), argv[oind]); + error (_ ("Invalid argument: %s"), argv[oind]); - scoped_restore restore_breakpoint_reporting - = setup_breakpoint_reporting (); - create_ada_exception_catchpoint (gdbarch, ada_catch_handlers, - exception_name, + scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); + create_ada_exception_catchpoint (gdbarch, ada_catch_handlers, exception_name, condition, temp, enabled, 0); } @@ -231,22 +222,18 @@ mi_catch_load_unload (int load, char *argv[], int argc) int enabled = 1; int oind = 0; char *oarg; + enum opt - { - OPT_TEMP, - OPT_DISABLED, - }; - static const struct mi_opt opts[] = - { - { "t", OPT_TEMP, 0 }, - { "d", OPT_DISABLED, 0 }, - { 0, 0, 0 } - }; + { + OPT_TEMP, + OPT_DISABLED, + }; + static const struct mi_opt opts[] + = { { "t", OPT_TEMP, 0 }, { "d", OPT_DISABLED, 0 }, { 0, 0, 0 } }; for (;;) { - int opt = mi_getopt (actual_cmd, argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt (actual_cmd, argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -263,9 +250,9 @@ mi_catch_load_unload (int load, char *argv[], int argc) } if (oind >= argc) - error (_("-catch-load/unload: Missing <library name>")); - if (oind < argc -1) - error (_("-catch-load/unload: Garbage following the <library name>")); + error (_ ("-catch-load/unload: Missing <library name>")); + if (oind < argc - 1) + error (_ ("-catch-load/unload: Garbage following the <library name>")); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); add_solib_catchpoint (argv[oind], load, temp, enabled); @@ -279,7 +266,6 @@ mi_cmd_catch_load (const char *cmd, char *argv[], int argc) mi_catch_load_unload (1, argv, argc); } - /* Handler for the -catch-unload. */ void @@ -293,29 +279,25 @@ mi_cmd_catch_unload (const char *cmd, char *argv[], int argc) pass KIND through to GDB's core to select the correct event type. */ static void -mi_cmd_catch_exception_event (enum exception_event_kind kind, - const char *cmd, char *argv[], int argc) +mi_cmd_catch_exception_event (enum exception_event_kind kind, const char *cmd, + char *argv[], int argc) { char *regex = NULL; bool temp = false; int oind = 0; char *oarg; + enum opt - { - OPT_TEMP, - OPT_REGEX, - }; - static const struct mi_opt opts[] = - { - { "t", OPT_TEMP, 0 }, - { "r", OPT_REGEX, 1 }, - { 0, 0, 0 } - }; + { + OPT_TEMP, + OPT_REGEX, + }; + static const struct mi_opt opts[] + = { { "t", OPT_TEMP, 0 }, { "r", OPT_REGEX, 1 }, { 0, 0, 0 } }; for (;;) { - int opt = mi_getopt (cmd, argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt (cmd, argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -358,4 +340,3 @@ mi_cmd_catch_catch (const char *cmd, char *argv[], int argc) { mi_cmd_catch_exception_event (EX_EVENT_CATCH, cmd, argv, argc); } - diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c index fcda4a0..bbe0168 100644 --- a/gdb/mi/mi-cmd-disas.c +++ b/gdb/mi/mi-cmd-disas.c @@ -82,7 +82,10 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) /* Flags to handle the --opcodes option. */ enum opcodes_mode { - OPCODES_DEFAULT, OPCODES_NONE, OPCODES_DISPLAY, OPCODES_BYTES + OPCODES_DEFAULT, + OPCODES_NONE, + OPCODES_DISPLAY, + OPCODES_BYTES }; enum opcodes_mode opcodes_mode = OPCODES_DEFAULT; @@ -92,30 +95,34 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) /* Options processing stuff. */ int oind = 0; char *oarg; + enum opt { - FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT, ADDR_OPT, OPCODES_OPT, + FILE_OPT, + LINE_OPT, + NUM_OPT, + START_OPT, + END_OPT, + ADDR_OPT, + OPCODES_OPT, SHOW_SRC_OPT }; - static const struct mi_opt opts[] = - { - {"f", FILE_OPT, 1}, - {"l", LINE_OPT, 1}, - {"n", NUM_OPT, 1}, - {"s", START_OPT, 1}, - {"e", END_OPT, 1}, - {"a", ADDR_OPT, 1}, - {"-opcodes", OPCODES_OPT, 1}, - {"-source", SHOW_SRC_OPT, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "f", FILE_OPT, 1 }, + { "l", LINE_OPT, 1 }, + { "n", NUM_OPT, 1 }, + { "s", START_OPT, 1 }, + { "e", END_OPT, 1 }, + { "a", ADDR_OPT, 1 }, + { "-opcodes", OPCODES_OPT, 1 }, + { "-source", SHOW_SRC_OPT, 0 }, + { 0, 0, 0 } }; /* Get the options with their arguments. Keep track of what we encountered. */ while (1) { - int opt = mi_getopt ("-data-disassemble", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-data-disassemble", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -153,7 +160,8 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) else if (strcmp (oarg, "bytes") == 0) opcodes_mode = OPCODES_BYTES; else - error (_("-data-disassemble: unknown value for -opcodes argument")); + error ( + _ ("-data-disassemble: unknown value for -opcodes argument")); break; case SHOW_SRC_OPT: source_seen = true; @@ -167,36 +175,36 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) /* Allow only filename + linenum (with how_many which is not required) OR start_addr + end_addr OR addr. */ - if (!( - ( line_seen && file_seen && !start_seen && !end_seen - && !addr_seen) + if (!((line_seen && file_seen && !start_seen && !end_seen && !addr_seen) - || (!line_seen && !file_seen && !num_seen && start_seen && end_seen - && !addr_seen) + || (!line_seen && !file_seen && !num_seen && start_seen && end_seen + && !addr_seen) - || (!line_seen && !file_seen && !num_seen && !start_seen && !end_seen - && addr_seen)) + || (!line_seen && !file_seen && !num_seen && !start_seen && !end_seen + && addr_seen)) || argc > 1) - error (_("-data-disassemble: Usage: " - "( -f filename -l linenum [-n howmany] |" - " -s startaddr -e endaddr | -a addr ) " - "[ --opcodes mode ] [ --source ] [ [--] mode ].")); + error (_ ("-data-disassemble: Usage: " + "( -f filename -l linenum [-n howmany] |" + " -s startaddr -e endaddr | -a addr ) " + "[ --opcodes mode ] [ --source ] [ [--] mode ].")); if (argc == 1) { mode = atoi (argv[0]); if (mode < 0 || mode > 5) - error (_("-data-disassemble: Mode argument must be in the range 0-5.")); + error ( + _ ("-data-disassemble: Mode argument must be in the range 0-5.")); } else mode = 0; if (mode != 0 && (source_seen || opcodes_seen)) - error (_("-data-disassemble: --opcodes and --source can only be used with mode 0")); + error (_ ("-data-disassemble: --opcodes and --source can only be used " + "with mode 0")); /* Convert the mode into a set of disassembly flags. */ - disasm_flags = 0; /* Initialize here for -Wall. */ + disasm_flags = 0; /* Initialize here for -Wall. */ switch (mode) { case 0: @@ -248,21 +256,19 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) { s = lookup_symtab (file_string); if (s == NULL) - error (_("-data-disassemble: Invalid filename.")); + error (_ ("-data-disassemble: Invalid filename.")); if (!find_line_pc (s, line_num, &start)) - error (_("-data-disassemble: Invalid line number")); + error (_ ("-data-disassemble: Invalid line number")); if (find_pc_partial_function (start, NULL, &low, &high) == 0) - error (_("-data-disassemble: " - "No function contains specified address")); + error (_ ("-data-disassemble: " + "No function contains specified address")); } else if (addr_seen) { if (find_pc_partial_function (addr, NULL, &low, &high) == 0) - error (_("-data-disassemble: " - "No function contains specified address")); + error (_ ("-data-disassemble: " + "No function contains specified address")); } - gdb_disassembly (gdbarch, uiout, - disasm_flags, - how_many, low, high); + gdb_disassembly (gdbarch, uiout, disasm_flags, how_many, low, high); } diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c index 454f895..d4ad634 100644 --- a/gdb/mi/mi-cmd-env.c +++ b/gdb/mi/mi-cmd-env.c @@ -51,7 +51,7 @@ env_execute_cli_command (const char *cmd, const char *args) run = xstrprintf ("%s %s", cmd, args); else run.reset (xstrdup (cmd)); - execute_command ( /*ui */ run.get (), 0 /*from_tty */ ); + execute_command (/*ui */ run.get (), 0 /*from_tty */); } } @@ -63,11 +63,11 @@ mi_cmd_env_pwd (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (argc > 0) - error (_("-environment-pwd: No arguments allowed")); - + error (_ ("-environment-pwd: No arguments allowed")); + gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0)); if (cwd == NULL) - error (_("-environment-pwd: error finding name of working directory: %s"), + error (_ ("-environment-pwd: error finding name of working directory: %s"), safe_strerror (errno)); uiout->field_string ("cwd", cwd.get ()); @@ -79,8 +79,8 @@ void mi_cmd_env_cd (const char *command, char **argv, int argc) { if (argc == 0 || argc > 1) - error (_("-environment-cd: Usage DIRECTORY")); - + error (_ ("-environment-cd: Usage DIRECTORY")); + env_execute_cli_command ("cd", argv[0]); } @@ -106,22 +106,19 @@ mi_cmd_env_path (const char *command, char **argv, int argc) int oind = 0; int i; char *oarg; + enum opt - { - RESET_OPT - }; - static const struct mi_opt opts[] = { - {"r", RESET_OPT, 0}, - { 0, 0, 0 } + RESET_OPT }; + static const struct mi_opt opts[] = { { "r", RESET_OPT, 0 }, { 0, 0, 0 } }; dont_repeat (); while (1) { - int opt = mi_getopt ("-environment-path", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-environment-path", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -171,22 +168,19 @@ mi_cmd_env_dir (const char *command, char **argv, int argc) int oind = 0; int reset = 0; char *oarg; + enum opt - { - RESET_OPT - }; - static const struct mi_opt opts[] = { - {"r", RESET_OPT, 0}, - { 0, 0, 0 } + RESET_OPT }; + static const struct mi_opt opts[] = { { "r", RESET_OPT, 0 }, { 0, 0, 0 } }; dont_repeat (); while (1) { - int opt = mi_getopt ("-environment-directory", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-environment-directory", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -229,8 +223,8 @@ mi_cmd_inferior_tty_set (const char *command, char **argv, int argc) void mi_cmd_inferior_tty_show (const char *command, char **argv, int argc) { - if ( !mi_valid_noargs ("-inferior-tty-show", argc, argv)) - error (_("-inferior-tty-show: Usage: No args")); + if (!mi_valid_noargs ("-inferior-tty-show", argc, argv)) + error (_ ("-inferior-tty-show: Usage: No args")); const std::string &inferior_tty = current_inferior ()->tty (); if (!inferior_tty.empty ()) @@ -238,7 +232,8 @@ mi_cmd_inferior_tty_show (const char *command, char **argv, int argc) } void _initialize_mi_cmd_env (); -void + +void _initialize_mi_cmd_env () { const char *env; diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index 70c0a78..3601b0c 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -38,9 +38,9 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc) { struct symtab_and_line st; struct ui_out *uiout = current_uiout; - + if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv)) - error (_("-file-list-exec-source-file: Usage: No args")); + error (_ ("-file-list-exec-source-file: Usage: No args")); /* Set the default file and line, also get them. */ set_default_source_symtab_and_line (); @@ -50,7 +50,7 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc) need to be tested for NULL. The documentation in symtab.h suggests it will always be correct. */ if (!st.symtab) - error (_("-file-list-exec-source-file: No symtab")); + error (_ ("-file-list-exec-source-file: No symtab")); /* Print to the user the line, filename and fullname. */ uiout->field_signed ("line", st.line); @@ -68,18 +68,16 @@ void mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) { enum opt - { - GROUP_BY_OBJFILE_OPT, - MATCH_BASENAME_OPT, - MATCH_DIRNAME_OPT - }; - static const struct mi_opt opts[] = { - {"-group-by-objfile", GROUP_BY_OBJFILE_OPT, 0}, - {"-basename", MATCH_BASENAME_OPT, 0}, - {"-dirname", MATCH_DIRNAME_OPT, 0}, - { 0, 0, 0 } + GROUP_BY_OBJFILE_OPT, + MATCH_BASENAME_OPT, + MATCH_DIRNAME_OPT }; + static const struct mi_opt opts[] + = { { "-group-by-objfile", GROUP_BY_OBJFILE_OPT, 0 }, + { "-basename", MATCH_BASENAME_OPT, 0 }, + { "-dirname", MATCH_DIRNAME_OPT, 0 }, + { 0, 0, 0 } }; /* Parse arguments. */ int oind = 0; @@ -91,8 +89,8 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) while (1) { - int opt = mi_getopt ("-file-list-exec-source-files", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-file-list-exec-source-files", argc, argv, opts, + &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -110,7 +108,8 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) } if ((argc - oind > 1) || (match_on_basename && match_on_dirname)) - error (_("-file-list-exec-source-files: Usage: [--group-by-objfile] [--basename | --dirname] [--] REGEXP")); + error (_ ("-file-list-exec-source-files: Usage: [--group-by-objfile] " + "[--basename | --dirname] [--] REGEXP")); const char *regexp = nullptr; if (argc - oind == 1) @@ -145,7 +144,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) pattern = argv[0]; break; default: - error (_("Usage: -file-list-shared-libraries [REGEXP]")); + error (_ ("Usage: -file-list-shared-libraries [REGEXP]")); } if (pattern != NULL) @@ -153,7 +152,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) const char *re_err = re_comp (pattern); if (re_err != NULL) - error (_("Invalid regexp: %s"), re_err); + error (_ ("Invalid regexp: %s"), re_err); } update_solib_list (1); diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c index 2ddf2df..07f51c0 100644 --- a/gdb/mi/mi-cmd-info.c +++ b/gdb/mi/mi-cmd-info.c @@ -40,14 +40,13 @@ mi_cmd_info_ada_exceptions (const char *command, char **argv, int argc) regexp = argv[0]; break; default: - error (_("Usage: -info-ada-exceptions [REGEXP]")); + error (_ ("Usage: -info-ada-exceptions [REGEXP]")); break; } std::vector<ada_exc_info> exceptions = ada_exceptions_list (regexp); - ui_out_emit_table table_emitter (uiout, 2, - exceptions.size (), + ui_out_emit_table table_emitter (uiout, 2, exceptions.size (), "ada-exceptions"); uiout->table_header (1, ui_left, "name", "Name"); uiout->table_header (1, ui_left, "address", "Address"); @@ -72,7 +71,7 @@ mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc) /* This command takes exactly one argument. */ if (argc != 1) - error (_("Usage: -info-gdb-mi-command MI_COMMAND_NAME")); + error (_ ("Usage: -info-gdb-mi-command MI_COMMAND_NAME")); cmd_name = argv[0]; /* Normally, the command name (aka the "operation" in the GDB/MI @@ -100,7 +99,7 @@ mi_cmd_info_os (const char *command, char **argv, int argc) info_osdata (argv[0]); break; default: - error (_("Usage: -info-os [INFOTYPE]")); + error (_ ("Usage: -info-os [INFOTYPE]")); break; } } diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 4666808..a1107a3 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -39,12 +39,16 @@ #include "inferior.h" #include "observable.h" -enum what_to_list { locals, arguments, all }; +enum what_to_list +{ + locals, + arguments, + all +}; static void list_args_or_locals (const frame_print_options &fp_opts, enum what_to_list what, - enum print_values values, - frame_info_ptr fi, + enum print_values values, frame_info_ptr fi, int skip_unavailable); /* True if we want to allow Python-based frame filters. */ @@ -54,25 +58,23 @@ void mi_cmd_enable_frame_filters (const char *command, char **argv, int argc) { if (argc != 0) - error (_("-enable-frame-filters: no arguments allowed")); + error (_ ("-enable-frame-filters: no arguments allowed")); frame_filters = 1; } /* Like apply_ext_lang_frame_filter, but take a print_values */ static enum ext_lang_bt_status -mi_apply_ext_lang_frame_filter (frame_info_ptr frame, - frame_filter_flags flags, +mi_apply_ext_lang_frame_filter (frame_info_ptr frame, frame_filter_flags flags, enum print_values print_values, - struct ui_out *out, - int frame_low, int frame_high) + struct ui_out *out, int frame_low, + int frame_high) { /* ext_lang_frame_args's MI options are compatible with MI print values. */ return apply_ext_lang_frame_filter (frame, flags, (enum ext_lang_frame_args) print_values, - out, - frame_low, frame_high); + out, frame_low, frame_high); } /* Print a list of the stack frames. Args can be none, in which case @@ -91,23 +93,21 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) enum ext_lang_bt_status result = EXT_LANG_BT_ERROR; int raw_arg = 0; int oind = 0; + enum opt - { - NO_FRAME_FILTERS - }; - static const struct mi_opt opts[] = - { - {"-no-frame-filters", NO_FRAME_FILTERS, 0}, - { 0, 0, 0 } - }; + { + NO_FRAME_FILTERS + }; + static const struct mi_opt opts[] + = { { "-no-frame-filters", NO_FRAME_FILTERS, 0 }, { 0, 0, 0 } }; /* Parse arguments. In this instance we are just looking for --no-frame-filters. */ while (1) { char *oarg; - int opt = mi_getopt ("-stack-list-frames", argc, argv, - opts, &oind, &oarg); + int opt + = mi_getopt ("-stack-list-frames", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -121,7 +121,8 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) /* After the last option is parsed, there should either be low - high range, or no further arguments. */ if ((argc - oind != 0) && (argc - oind != 2)) - error (_("-stack-list-frames: Usage: [--no-frame-filters] [FRAME_LOW FRAME_HIGH]")); + error (_ ("-stack-list-frames: Usage: [--no-frame-filters] [FRAME_LOW " + "FRAME_HIGH]")); /* If there is a range, set it. */ if (argc - oind == 2) @@ -140,16 +141,16 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) /* Let's position fi on the frame at which to start the display. Could be the innermost frame if the whole stack needs displaying, or if frame_low is 0. */ - for (i = 0, fi = get_current_frame (); - fi && i < frame_low; - i++, fi = get_prev_frame (fi)); + for (i = 0, fi = get_current_frame (); fi && i < frame_low; + i++, fi = get_prev_frame (fi)) + ; if (fi == NULL) - error (_("-stack-list-frames: Not enough frames in stack.")); + error (_ ("-stack-list-frames: Not enough frames in stack.")); ui_out_emit_list list_emitter (current_uiout, "stack"); - if (! raw_arg && frame_filters) + if (!raw_arg && frame_filters) { frame_filter_flags flags = PRINT_LEVEL | PRINT_FRAME_INFO; int py_frame_low = frame_low; @@ -161,25 +162,24 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) py_frame_low++; result = apply_ext_lang_frame_filter (get_current_frame (), flags, - NO_VALUES, current_uiout, + NO_VALUES, current_uiout, py_frame_low, frame_high); } /* Run the inbuilt backtrace if there are no filters registered, or if "--no-frame-filters" has been specified from the command. */ - if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) + if (!frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) { /* Now let's print the frames up to frame_high, or until there are frames in the stack. */ - for (; - fi && (i <= frame_high || frame_high == -1); + for (; fi && (i <= frame_high || frame_high == -1); i++, fi = get_prev_frame (fi)) { QUIT; /* Print the location and the address always, even for level 0. If args is 0, don't print the arguments. */ - print_frame_info (user_frame_print_options, - fi, 1, LOC_AND_ADDRESS, 0 /* args */, 0); + print_frame_info (user_frame_print_options, fi, 1, LOC_AND_ADDRESS, + 0 /* args */, 0); } } } @@ -192,7 +192,7 @@ mi_cmd_stack_info_depth (const char *command, char **argv, int argc) frame_info_ptr fi; if (argc > 1) - error (_("-stack-info-depth: Usage: [MAX_DEPTH]")); + error (_ ("-stack-info-depth: Usage: [MAX_DEPTH]")); if (argc == 1) frame_high = atoi (argv[0]); @@ -230,19 +230,17 @@ mi_cmd_stack_list_locals (const char *command, char **argv, int argc) NO_FRAME_FILTERS, SKIP_UNAVAILABLE, }; - static const struct mi_opt opts[] = - { - {"-no-frame-filters", NO_FRAME_FILTERS, 0}, - {"-skip-unavailable", SKIP_UNAVAILABLE, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "-no-frame-filters", NO_FRAME_FILTERS, 0 }, + { "-skip-unavailable", SKIP_UNAVAILABLE, 0 }, + { 0, 0, 0 } }; while (1) { char *oarg; /* Don't parse 'print-values' as an option. */ - int opt = mi_getopt ("-stack-list-locals", argc - 1, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-stack-list-locals", argc - 1, argv, opts, + &oind, &oarg); if (opt < 0) break; @@ -261,28 +259,27 @@ mi_cmd_stack_list_locals (const char *command, char **argv, int argc) /* After the last option is parsed, there should be only 'print-values'. */ if (argc - oind != 1) - error (_("-stack-list-locals: Usage: [--no-frame-filters] " - "[--skip-unavailable] PRINT_VALUES")); + error (_ ("-stack-list-locals: Usage: [--no-frame-filters] " + "[--skip-unavailable] PRINT_VALUES")); frame = get_selected_frame (NULL); print_value = mi_parse_print_values (argv[oind]); - if (! raw_arg && frame_filters) - { - frame_filter_flags flags = PRINT_LEVEL | PRINT_LOCALS; + if (!raw_arg && frame_filters) + { + frame_filter_flags flags = PRINT_LEVEL | PRINT_LOCALS; - result = mi_apply_ext_lang_frame_filter (frame, flags, print_value, - current_uiout, 0, 0); - } + result = mi_apply_ext_lang_frame_filter (frame, flags, print_value, + current_uiout, 0, 0); + } - /* Run the inbuilt backtrace if there are no filters registered, or + /* Run the inbuilt backtrace if there are no filters registered, or if "--no-frame-filters" has been specified from the command. */ - if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) - { - list_args_or_locals (user_frame_print_options, - locals, print_value, frame, - skip_unavailable); - } + if (!frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) + { + list_args_or_locals (user_frame_print_options, locals, print_value, + frame, skip_unavailable); + } } /* Print a list of the arguments for the current frame. With argument @@ -302,23 +299,22 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) int oind = 0; int skip_unavailable = 0; enum ext_lang_bt_status result = EXT_LANG_BT_ERROR; + enum opt { NO_FRAME_FILTERS, SKIP_UNAVAILABLE, }; - static const struct mi_opt opts[] = - { - {"-no-frame-filters", NO_FRAME_FILTERS, 0}, - {"-skip-unavailable", SKIP_UNAVAILABLE, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "-no-frame-filters", NO_FRAME_FILTERS, 0 }, + { "-skip-unavailable", SKIP_UNAVAILABLE, 0 }, + { 0, 0, 0 } }; while (1) { char *oarg; - int opt = mi_getopt_allow_unknown ("-stack-list-args", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt_allow_unknown ("-stack-list-args", argc, argv, opts, + &oind, &oarg); if (opt < 0) break; @@ -334,9 +330,9 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) } if (argc - oind != 1 && argc - oind != 3) - error (_("-stack-list-arguments: Usage: " \ - "[--no-frame-filters] [--skip-unavailable] " - "PRINT_VALUES [FRAME_LOW FRAME_HIGH]")); + error (_ ("-stack-list-arguments: Usage: " + "[--no-frame-filters] [--skip-unavailable] " + "PRINT_VALUES [FRAME_LOW FRAME_HIGH]")); if (argc - oind == 3) { @@ -356,16 +352,16 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) /* Let's position fi on the frame at which to start the display. Could be the innermost frame if the whole stack needs displaying, or if frame_low is 0. */ - for (i = 0, fi = get_current_frame (); - fi && i < frame_low; - i++, fi = get_prev_frame (fi)); + for (i = 0, fi = get_current_frame (); fi && i < frame_low; + i++, fi = get_prev_frame (fi)) + ; if (fi == NULL) - error (_("-stack-list-arguments: Not enough frames in stack.")); + error (_ ("-stack-list-arguments: Not enough frames in stack.")); ui_out_emit_list list_emitter (uiout, "stack-args"); - if (! raw_arg && frame_filters) + if (!raw_arg && frame_filters) { frame_filter_flags flags = PRINT_LEVEL | PRINT_ARGS; int py_frame_low = frame_low; @@ -381,21 +377,20 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) py_frame_low, frame_high); } - /* Run the inbuilt backtrace if there are no filters registered, or + /* Run the inbuilt backtrace if there are no filters registered, or if "--no-frame-filters" has been specified from the command. */ - if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) - { + if (!frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) + { /* Now let's print the frames up to frame_high, or until there are frames in the stack. */ - for (; - fi && (i <= frame_high || frame_high == -1); + for (; fi && (i <= frame_high || frame_high == -1); i++, fi = get_prev_frame (fi)) { QUIT; ui_out_emit_tuple tuple_emitter (uiout, "frame"); uiout->field_signed ("level", i); - list_args_or_locals (user_frame_print_options, - arguments, print_values, fi, skip_unavailable); + list_args_or_locals (user_frame_print_options, arguments, + print_values, fi, skip_unavailable); } } } @@ -422,19 +417,17 @@ mi_cmd_stack_list_variables (const char *command, char **argv, int argc) NO_FRAME_FILTERS, SKIP_UNAVAILABLE, }; - static const struct mi_opt opts[] = - { - {"-no-frame-filters", NO_FRAME_FILTERS, 0}, - {"-skip-unavailable", SKIP_UNAVAILABLE, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "-no-frame-filters", NO_FRAME_FILTERS, 0 }, + { "-skip-unavailable", SKIP_UNAVAILABLE, 0 }, + { 0, 0, 0 } }; while (1) { char *oarg; /* Don't parse 'print-values' as an option. */ - int opt = mi_getopt ("-stack-list-variables", argc - 1, - argv, opts, &oind, &oarg); + int opt = mi_getopt ("-stack-list-variables", argc - 1, argv, opts, + &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -452,29 +445,27 @@ mi_cmd_stack_list_variables (const char *command, char **argv, int argc) /* After the last option is parsed, there should be only 'print-values'. */ if (argc - oind != 1) - error (_("-stack-list-variables: Usage: [--no-frame-filters] " \ - "[--skip-unavailable] PRINT_VALUES")); + error (_ ("-stack-list-variables: Usage: [--no-frame-filters] " + "[--skip-unavailable] PRINT_VALUES")); - frame = get_selected_frame (NULL); - print_value = mi_parse_print_values (argv[oind]); + frame = get_selected_frame (NULL); + print_value = mi_parse_print_values (argv[oind]); - if (! raw_arg && frame_filters) - { - frame_filter_flags flags = PRINT_LEVEL | PRINT_ARGS | PRINT_LOCALS; + if (!raw_arg && frame_filters) + { + frame_filter_flags flags = PRINT_LEVEL | PRINT_ARGS | PRINT_LOCALS; - result = mi_apply_ext_lang_frame_filter (frame, flags, - print_value, - current_uiout, 0, 0); - } + result = mi_apply_ext_lang_frame_filter (frame, flags, print_value, + current_uiout, 0, 0); + } - /* Run the inbuilt backtrace if there are no filters registered, or + /* Run the inbuilt backtrace if there are no filters registered, or if "--no-frame-filters" has been specified from the command. */ - if (! frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) - { - list_args_or_locals (user_frame_print_options, - all, print_value, frame, - skip_unavailable); - } + if (!frame_filters || raw_arg || result == EXT_LANG_BT_NO_FILTERS) + { + list_args_or_locals (user_frame_print_options, all, print_value, frame, + skip_unavailable); + } } /* Print single local or argument. ARG must be already read in. For @@ -535,7 +526,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, if (arg->val || arg->error) { if (arg->error) - stb.printf (_("<error reading variable: %s>"), arg->error.get ()); + stb.printf (_ ("<error reading variable: %s>"), arg->error.get ()); else { try @@ -549,8 +540,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, } catch (const gdb_exception_error &except) { - stb.printf (_("<error reading variable: %s>"), - except.what ()); + stb.printf (_ ("<error reading variable: %s>"), except.what ()); } } uiout->field_stream ("value", stb); @@ -602,24 +592,24 @@ list_args_or_locals (const frame_print_options &fp_opts, switch (sym->aclass ()) { default: - case LOC_UNDEF: /* catches errors */ - case LOC_CONST: /* constant */ - case LOC_TYPEDEF: /* local typedef */ - case LOC_LABEL: /* local label */ - case LOC_BLOCK: /* local function */ - case LOC_CONST_BYTES: /* loc. byte seq. */ - case LOC_UNRESOLVED: /* unresolved static */ - case LOC_OPTIMIZED_OUT: /* optimized out */ + case LOC_UNDEF: /* catches errors */ + case LOC_CONST: /* constant */ + case LOC_TYPEDEF: /* local typedef */ + case LOC_LABEL: /* local label */ + case LOC_BLOCK: /* local function */ + case LOC_CONST_BYTES: /* loc. byte seq. */ + case LOC_UNRESOLVED: /* unresolved static */ + case LOC_OPTIMIZED_OUT: /* optimized out */ print_me = 0; break; - case LOC_ARG: /* argument */ - case LOC_REF_ARG: /* reference arg */ - case LOC_REGPARM_ADDR: /* indirect register arg */ - case LOC_LOCAL: /* stack local */ - case LOC_STATIC: /* static */ - case LOC_REGISTER: /* register */ - case LOC_COMPUTED: /* computed location */ + case LOC_ARG: /* argument */ + case LOC_REF_ARG: /* reference arg */ + case LOC_REGPARM_ADDR: /* indirect register arg */ + case LOC_LOCAL: /* stack local */ + case LOC_STATIC: /* static */ + case LOC_REGISTER: /* register */ + case LOC_COMPUTED: /* computed location */ if (what == all) print_me = 1; else if (what == locals) @@ -634,8 +624,9 @@ list_args_or_locals (const frame_print_options &fp_opts, struct frame_arg arg, entryarg; if (sym->is_argument ()) - sym2 = lookup_symbol_search_name (sym->search_name (), - block, VAR_DOMAIN).symbol; + sym2 = lookup_symbol_search_name (sym->search_name (), block, + VAR_DOMAIN) + .symbol; else sym2 = sym; gdb_assert (sym2 != NULL); @@ -726,9 +717,7 @@ parse_frame_specification (const char *frame_exp) what (s)he gets. Still, give the highest one that matches. (NOTE: cagney/2004-10-29: Why highest, or outer-most, I don't know). */ - for (fid = get_current_frame (); - fid != NULL; - fid = get_prev_frame (fid)) + for (fid = get_current_frame (); fid != NULL; fid = get_prev_frame (fid)) { if (id == get_frame_id (fid)) { @@ -737,8 +726,7 @@ parse_frame_specification (const char *frame_exp) while (1) { prev_frame = get_prev_frame (fid); - if (!prev_frame - || id != get_frame_id (prev_frame)) + if (!prev_frame || id != get_frame_id (prev_frame)) break; fid = prev_frame; } @@ -757,7 +745,7 @@ void mi_cmd_stack_select_frame (const char *command, char **argv, int argc) { if (argc == 0 || argc > 1) - error (_("-stack-select-frame: Usage: FRAME_SPEC")); + error (_ ("-stack-select-frame: Usage: FRAME_SPEC")); select_frame (parse_frame_specification (argv[0])); } @@ -765,8 +753,8 @@ void mi_cmd_stack_info_frame (const char *command, char **argv, int argc) { if (argc > 0) - error (_("-stack-info-frame: No arguments allowed")); + error (_ ("-stack-info-frame: No arguments allowed")); - print_frame_info (user_frame_print_options, - get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0, 1); + print_frame_info (user_frame_print_options, get_selected_frame (NULL), 1, + LOC_AND_ADDRESS, 0, 1); } diff --git a/gdb/mi/mi-cmd-target.c b/gdb/mi/mi-cmd-target.c index d0d2ba5..b7385d1 100644 --- a/gdb/mi/mi-cmd-target.c +++ b/gdb/mi/mi-cmd-target.c @@ -29,15 +29,12 @@ mi_cmd_target_file_get (const char *command, char **argv, int argc) int oind = 0; char *oarg; const char *remote_file, *local_file; - static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { 0, 0, 0 } }; static const char prefix[] = "-target-file-get"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 || oind != argc - 2) - error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE")); + error (_ ("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE")); remote_file = argv[oind]; local_file = argv[oind + 1]; @@ -53,15 +50,12 @@ mi_cmd_target_file_put (const char *command, char **argv, int argc) int oind = 0; char *oarg; const char *remote_file, *local_file; - static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { 0, 0, 0 } }; static const char prefix[] = "-target-file-put"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 || oind != argc - 2) - error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE")); + error (_ ("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE")); local_file = argv[oind]; remote_file = argv[oind + 1]; @@ -77,18 +71,14 @@ mi_cmd_target_file_delete (const char *command, char **argv, int argc) int oind = 0; char *oarg; const char *remote_file; - static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { 0, 0, 0 } }; static const char prefix[] = "-target-file-delete"; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 || oind != argc - 1) - error (_("-target-file-delete: Usage: REMOTE_FILE")); + error (_ ("-target-file-delete: Usage: REMOTE_FILE")); remote_file = argv[oind]; remote_file_delete (remote_file, 0); } - diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 1cf6d3c..1381048 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -44,7 +44,7 @@ static int mi_print_value_p (struct varobj *var, if the value should be printed. The PRINT_EXPRESSION parameter controls if the expression should be printed. */ -static void +static void print_varobj (struct varobj *var, enum print_values print_values, int print_expression) { @@ -59,7 +59,7 @@ print_varobj (struct varobj *var, enum print_values print_values, uiout->field_string ("exp", exp); } uiout->field_signed ("numchild", varobj_get_num_children (var)); - + if (mi_print_value_p (var, print_values)) { std::string val = varobj_get_value (var); @@ -99,7 +99,7 @@ mi_cmd_var_create (const char *command, char **argv, int argc) enum varobj_type var_type; if (argc != 3) - error (_("-var-create: Usage: NAME FRAME EXPRESSION.")); + error (_ ("-var-create: Usage: NAME FRAME EXPRESSION.")); frame = argv[1]; expr = argv[2]; @@ -112,12 +112,12 @@ mi_cmd_var_create (const char *command, char **argv, int argc) name = gen_name.c_str (); } else if (!isalpha (name[0])) - error (_("-var-create: name of object must begin with a letter")); + error (_ ("-var-create: name of object must begin with a letter")); if (strcmp (frame, "*") == 0) var_type = USE_CURRENT_FRAME; else if (strcmp (frame, "@") == 0) - var_type = USE_SELECTED_FRAME; + var_type = USE_SELECTED_FRAME; else { var_type = USE_SPECIFIED_FRAME; @@ -126,13 +126,13 @@ mi_cmd_var_create (const char *command, char **argv, int argc) if (varobjdebug) gdb_printf (gdb_stdlog, - "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n", - name, frame, hex_string (frameaddr), expr); + "Name=\"%s\", Frame=\"%s\" (%s), Expression=\"%s\"\n", name, + frame, hex_string (frameaddr), expr); var = varobj_create (name, expr, frameaddr, var_type); if (var == NULL) - error (_("-var-create: unable to create variable object")); + error (_ ("-var-create: unable to create variable object")); print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */); @@ -149,7 +149,7 @@ mi_cmd_var_delete (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (argc < 1 || argc > 2) - error (_("-var-delete: Usage: [-c] EXPRESSION.")); + error (_ ("-var-delete: Usage: [-c] EXPRESSION.")); name = argv[0]; @@ -158,10 +158,10 @@ mi_cmd_var_delete (const char *command, char **argv, int argc) if (argc == 1) { if (strcmp (name, "-c") == 0) - error (_("-var-delete: Missing required " - "argument after '-c': variable object name")); + error (_ ("-var-delete: Missing required " + "argument after '-c': variable object name")); if (*name == '-') - error (_("-var-delete: Illegal variable object name")); + error (_ ("-var-delete: Illegal variable object name")); } /* If we have 2 arguments they must be '-c' followed by a string @@ -169,7 +169,7 @@ mi_cmd_var_delete (const char *command, char **argv, int argc) if (argc == 2) { if (strcmp (name, "-c") != 0) - error (_("-var-delete: Invalid option.")); + error (_ ("-var-delete: Invalid option.")); children_only_p = 1; name = argv[1]; } @@ -209,8 +209,9 @@ mi_parse_format (const char *arg) return FORMAT_ZHEXADECIMAL; } - error (_("Must specify the format as: \"natural\", " - "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zero-hexadecimal\"")); + error (_ ("Must specify the format as: \"natural\", " + "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or " + "\"zero-hexadecimal\"")); } void @@ -221,19 +222,19 @@ mi_cmd_var_set_format (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (argc != 2) - error (_("-var-set-format: Usage: NAME FORMAT.")); + error (_ ("-var-set-format: Usage: NAME FORMAT.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); format = mi_parse_format (argv[1]); - + /* Set the format of VAR to the given format. */ varobj_set_display_format (var, format); /* Report the new current format. */ uiout->field_string ("format", varobj_format_string[(int) format]); - + /* Report the value in the new format. */ std::string val = varobj_get_value (var); uiout->field_string ("value", val); @@ -245,12 +246,12 @@ mi_cmd_var_set_visualizer (const char *command, char **argv, int argc) struct varobj *var; if (argc != 2) - error (_("Usage: NAME VISUALIZER_FUNCTION.")); + error (_ ("Usage: NAME VISUALIZER_FUNCTION.")); var = varobj_get_handle (argv[0]); if (var == NULL) - error (_("Variable object not found")); + error (_ ("Variable object not found")); varobj_set_visualizer (var, argv[1]); } @@ -262,7 +263,7 @@ mi_cmd_var_set_frozen (const char *command, char **argv, int argc) bool frozen; if (argc != 2) - error (_("-var-set-format: Usage: NAME FROZEN_FLAG.")); + error (_ ("-var-set-format: Usage: NAME FROZEN_FLAG.")); var = varobj_get_handle (argv[0]); @@ -271,7 +272,7 @@ mi_cmd_var_set_frozen (const char *command, char **argv, int argc) else if (strcmp (argv[1], "1") == 0) frozen = true; else - error (_("Invalid flag value")); + error (_ ("Invalid flag value")); varobj_set_frozen (var, frozen); @@ -288,7 +289,7 @@ mi_cmd_var_show_format (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("-var-show-format: Usage: NAME.")); + error (_ ("-var-show-format: Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); @@ -306,7 +307,7 @@ mi_cmd_var_info_num_children (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("-var-info-num-children: Usage: NAME.")); + error (_ ("-var-info-num-children: Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); @@ -350,13 +351,13 @@ void mi_cmd_var_list_children (const char *command, char **argv, int argc) { struct ui_out *uiout = current_uiout; - struct varobj *var; + struct varobj *var; enum print_values print_values; int from, to; if (argc < 1 || argc > 4) - error (_("-var-list-children: Usage: " - "[PRINT_VALUES] NAME [FROM TO]")); + error (_ ("-var-list-children: Usage: " + "[PRINT_VALUES] NAME [FROM TO]")); /* Get varobj handle, if a valid var obj name was specified. */ if (argc == 1 || argc == 3) @@ -409,7 +410,7 @@ mi_cmd_var_info_type (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("-var-info-type: Usage: NAME.")); + error (_ ("-var-info-type: Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); @@ -425,11 +426,11 @@ mi_cmd_var_info_path_expression (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("Usage: NAME.")); + error (_ ("Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); - + const char *path_expr = varobj_get_path_expr (var); uiout->field_string ("path_expr", path_expr); @@ -443,7 +444,7 @@ mi_cmd_var_info_expression (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("-var-info-expression: Usage: NAME.")); + error (_ ("-var-info-expression: Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); @@ -465,7 +466,7 @@ mi_cmd_var_show_attributes (const char *command, char **argv, int argc) struct varobj *var; if (argc != 1) - error (_("-var-show-attributes: Usage: NAME.")); + error (_ ("-var-show-attributes: Usage: NAME.")); /* Get varobj handle, if a valid var obj name was specified */ var = varobj_get_handle (argv[0]); @@ -490,16 +491,12 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) int formatFound; int oind; char *oarg; - + enum opt { OP_FORMAT }; - static const struct mi_opt opts[] = - { - {"f", OP_FORMAT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "f", OP_FORMAT, 1 }, { 0, 0, 0 } }; /* Parse arguments. */ format = FORMAT_NATURAL; @@ -507,8 +504,8 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) oind = 0; while (1) { - int opt = mi_getopt ("-var-evaluate-expression", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-var-evaluate-expression", argc, argv, opts, &oind, + &oarg); if (opt < 0) break; @@ -516,8 +513,8 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) { case OP_FORMAT: if (formatFound) - error (_("Cannot specify format more than once")); - + error (_ ("Cannot specify format more than once")); + format = mi_parse_format (oarg); formatFound = 1; break; @@ -525,14 +522,14 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) } if (oind >= argc) - error (_("Usage: [-f FORMAT] NAME")); - + error (_ ("Usage: [-f FORMAT] NAME")); + if (oind < argc - 1) - error (_("Garbage at end of command")); - + error (_ ("Garbage at end of command")); + /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[oind]); - + if (formatFound) { std::string val = varobj_get_formatted_value (var, format); @@ -554,13 +551,13 @@ mi_cmd_var_assign (const char *command, char **argv, int argc) struct varobj *var; if (argc != 2) - error (_("-var-assign: Usage: NAME EXPRESSION.")); + error (_ ("-var-assign: Usage: NAME EXPRESSION.")); /* Get varobj handle, if a valid var obj name was specified. */ var = varobj_get_handle (argv[0]); if (!varobj_editable_p (var)) - error (_("-var-assign: Variable object is not editable")); + error (_ ("-var-assign: Variable object is not editable")); const char *expression = argv[1]; @@ -570,8 +567,8 @@ mi_cmd_var_assign (const char *command, char **argv, int argc) = make_scoped_restore (&mi_suppress_notification.memory, 1); if (!varobj_set_value (var, expression)) - error (_("-var-assign: Could not assign " - "expression to variable object")); + error (_ ("-var-assign: Could not assign " + "expression to variable object")); std::string val = varobj_get_value (var); uiout->field_string ("value", val); @@ -596,12 +593,10 @@ mi_cmd_var_update_iter (struct varobj *var, bool only_floating, { thread_info *tp = find_thread_global_id (thread_id); - thread_stopped = (tp == NULL - || tp->state == THREAD_STOPPED); + thread_stopped = (tp == NULL || tp->state == THREAD_STOPPED); } - if (thread_stopped - && (!only_floating || varobj_floating_p (var))) + if (thread_stopped && (!only_floating || varobj_floating_p (var))) varobj_update_one (var, print_values, false /* implicit */); } @@ -613,7 +608,7 @@ mi_cmd_var_update (const char *command, char **argv, int argc) enum print_values print_values; if (argc != 1 && argc != 2) - error (_("-var-update: Usage: [PRINT_VALUES] NAME.")); + error (_ ("-var-update: Usage: [PRINT_VALUES] NAME.")); if (argc == 1) name = argv[0]; @@ -636,10 +631,9 @@ mi_cmd_var_update (const char *command, char **argv, int argc) VAROBJ. Therefore update each VAROBJ only once by iterating only the root VAROBJs. */ - all_root_varobjs ([=] (varobj *var) - { - mi_cmd_var_update_iter (var, *name == '0', print_values); - }); + all_root_varobjs ([=] (varobj *var) { + mi_cmd_var_update_iter (var, *name == '0', print_values); + }); } else { @@ -658,8 +652,9 @@ varobj_update_one (struct varobj *var, enum print_values print_values, { struct ui_out *uiout = current_uiout; - std::vector<varobj_update_result> changes = varobj_update (&var, is_explicit); - + std::vector<varobj_update_result> changes + = varobj_update (&var, is_explicit); + for (const varobj_update_result &r : changes) { int from, to; @@ -733,7 +728,7 @@ void mi_cmd_enable_pretty_printing (const char *command, char **argv, int argc) { if (argc != 0) - error (_("-enable-pretty-printing: no arguments allowed")); + error (_ ("-enable-pretty-printing: no arguments allowed")); varobj_enable_pretty_printing (); } @@ -745,8 +740,8 @@ mi_cmd_var_set_update_range (const char *command, char **argv, int argc) int from, to; if (argc != 3) - error (_("-var-set-update-range: Usage: VAROBJ FROM TO")); - + error (_ ("-var-set-update-range: Usage: VAROBJ FROM TO")); + var = varobj_get_handle (argv[0]); from = atoi (argv[1]); to = atoi (argv[2]); diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index aa0f38a..64dbd75 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -38,7 +38,7 @@ struct mi_command_mi : public mi_command constructor, FUNC is the function called from do_invoke, which implements this MI command. */ mi_command_mi (const char *name, mi_cmd_argv_ftype func, - int *suppress_notification) + int *suppress_notification) : mi_command (name, suppress_notification), m_argv_function (func) { @@ -52,7 +52,7 @@ struct mi_command_mi : public mi_command mi_parse_argv (parse->args, parse); if (parse->argv == nullptr) - error (_("Problem parsing arguments: %s %s"), parse->command, + error (_ ("Problem parsing arguments: %s %s"), parse->command, parse->args); this->m_argv_function (parse->command, parse->argv, parse->argc); @@ -75,11 +75,12 @@ struct mi_command_cli : public mi_command forwarded to CLI_NAME as its argument string, otherwise, if ARGS_P is false, nullptr is send to CLI_NAME as its argument string. */ mi_command_cli (const char *name, const char *cli_name, bool args_p, - int *suppress_notification) + int *suppress_notification) : mi_command (name, suppress_notification), m_cli_name (cli_name), m_args_p (args_p) - { /* Nothing. */ } + { /* Nothing. */ + } /* Called when this MI command has been invoked, calls the m_cli_name CLI function. In m_args_p is true then the argument string from @@ -133,7 +134,7 @@ remove_mi_cmd_entry (const std::string &name) void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback) { - for (auto it = mi_cmd_table.cbegin (); it != mi_cmd_table.cend (); ) + for (auto it = mi_cmd_table.cbegin (); it != mi_cmd_table.cend ();) { if (callback (it->second.get ())) it = mi_cmd_table.erase (it); @@ -201,8 +202,8 @@ add_builtin_mi_commands () add_mi_cmd_mi ("add-inferior", mi_cmd_add_inferior); add_mi_cmd_cli ("break-after", "ignore", 1, &mi_suppress_notification.breakpoint); - add_mi_cmd_mi ("break-condition",mi_cmd_break_condition, - &mi_suppress_notification.breakpoint); + add_mi_cmd_mi ("break-condition", mi_cmd_break_condition, + &mi_suppress_notification.breakpoint); add_mi_cmd_mi ("break-commands", mi_cmd_break_commands, &mi_suppress_notification.breakpoint); add_mi_cmd_cli ("break-delete", "delete breakpoint", 1, @@ -232,12 +233,12 @@ add_builtin_mi_commands () add_mi_cmd_mi ("catch-unload", mi_cmd_catch_unload, &mi_suppress_notification.breakpoint); add_mi_cmd_mi ("catch-throw", mi_cmd_catch_throw, - &mi_suppress_notification.breakpoint), - add_mi_cmd_mi ("catch-rethrow", mi_cmd_catch_rethrow, - &mi_suppress_notification.breakpoint), - add_mi_cmd_mi ("catch-catch", mi_cmd_catch_catch, - &mi_suppress_notification.breakpoint), - add_mi_cmd_mi ("complete", mi_cmd_complete); + &mi_suppress_notification.breakpoint), + add_mi_cmd_mi ("catch-rethrow", mi_cmd_catch_rethrow, + &mi_suppress_notification.breakpoint), + add_mi_cmd_mi ("catch-catch", mi_cmd_catch_catch, + &mi_suppress_notification.breakpoint), + add_mi_cmd_mi ("complete", mi_cmd_complete); add_mi_cmd_mi ("data-disassemble", mi_cmd_disassemble); add_mi_cmd_mi ("data-evaluate-expression", mi_cmd_data_evaluate_expression); add_mi_cmd_mi ("data-list-changed-registers", @@ -280,13 +281,13 @@ add_builtin_mi_commands () add_mi_cmd_mi ("file-list-exec-source-files", mi_cmd_file_list_exec_source_files); add_mi_cmd_mi ("file-list-shared-libraries", - mi_cmd_file_list_shared_libraries), - add_mi_cmd_cli ("file-symbol-file", "symbol-file", 1); + mi_cmd_file_list_shared_libraries), + add_mi_cmd_cli ("file-symbol-file", "symbol-file", 1); add_mi_cmd_mi ("fix-breakpoint-script-output", mi_cmd_fix_breakpoint_script_output), - add_mi_cmd_mi ("fix-multi-location-breakpoint-output", - mi_cmd_fix_multi_location_breakpoint_output), - add_mi_cmd_mi ("gdb-exit", mi_cmd_gdb_exit); + add_mi_cmd_mi ("fix-multi-location-breakpoint-output", + mi_cmd_fix_multi_location_breakpoint_output), + add_mi_cmd_mi ("gdb-exit", mi_cmd_gdb_exit); add_mi_cmd_cli ("gdb-set", "set", 1, &mi_suppress_notification.cmd_param_changed); add_mi_cmd_cli ("gdb-show", "show", 1); @@ -315,9 +316,9 @@ add_builtin_mi_commands () add_mi_cmd_mi ("symbol-info-types", mi_cmd_symbol_info_types); add_mi_cmd_mi ("symbol-info-modules", mi_cmd_symbol_info_modules); add_mi_cmd_mi ("symbol-info-module-functions", - mi_cmd_symbol_info_module_functions); + mi_cmd_symbol_info_module_functions); add_mi_cmd_mi ("symbol-info-module-variables", - mi_cmd_symbol_info_module_variables); + mi_cmd_symbol_info_module_variables); add_mi_cmd_cli ("target-attach", "attach", 1); add_mi_cmd_mi ("target-detach", mi_cmd_target_detach); add_mi_cmd_cli ("target-disconnect", "disconnect", 0); @@ -372,6 +373,7 @@ mi_cmd_lookup (const char *command) } void _initialize_mi_cmds (); + void _initialize_mi_cmds () { diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 490f504..f55c0c0 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -26,10 +26,11 @@ #include "gdbsupport/gdb_optional.h" #include "mi/mi-main.h" -enum print_values { - PRINT_NO_VALUES, - PRINT_ALL_VALUES, - PRINT_SIMPLE_VALUES +enum print_values +{ + PRINT_NO_VALUES, + PRINT_ALL_VALUES, + PRINT_SIMPLE_VALUES }; typedef void (mi_cmd_argv_ftype) (const char *command, char **argv, int argc); @@ -158,8 +159,7 @@ struct mi_command /* Return the name of this command. This is the command that the user will actually type in, without any arguments, and without the leading dash. */ - const char *name () const - { return m_name; } + const char *name () const { return m_name; } /* Execute the MI command. this needs to be overridden in each base class. PARSE is the parsed command line from the user. @@ -174,7 +174,8 @@ struct mi_command user context, then it should not emit change notifications. Therefore if command does not suppress user context change notifications, then it should preserve the context. */ - return m_suppress_notification != &mi_suppress_notification.user_selected_context; + return m_suppress_notification + != &mi_suppress_notification.user_selected_context; } /* If this command was created with a suppress notifications pointer, @@ -222,8 +223,7 @@ extern bool remove_mi_cmd_entry (const std::string &name); /* Call CALLBACK for each registered MI command. Remove commands for which CALLBACK returns true. */ -using remove_mi_cmd_entries_ftype - = gdb::function_view<bool (mi_command *)>; +using remove_mi_cmd_entries_ftype = gdb::function_view<bool (mi_command *)>; extern void remove_mi_cmd_entries (remove_mi_cmd_entries_ftype callback); #endif /* MI_MI_CMDS_H */ diff --git a/gdb/mi/mi-common.c b/gdb/mi/mi-common.c index ce70d11..1cf273c 100644 --- a/gdb/mi/mi-common.c +++ b/gdb/mi/mi-common.c @@ -19,29 +19,27 @@ #include "defs.h" #include "mi-common.h" -static const char * const async_reason_string_lookup[] = -{ - "breakpoint-hit", - "watchpoint-trigger", - "read-watchpoint-trigger", - "access-watchpoint-trigger", - "function-finished", - "location-reached", - "watchpoint-scope", - "end-stepping-range", - "exited-signalled", - "exited", - "exited-normally", - "signal-received", - "solib-event", - "fork", - "vfork", - "syscall-entry", - "syscall-return", - "exec", - "no-history", - NULL -}; +static const char *const async_reason_string_lookup[] + = { "breakpoint-hit", + "watchpoint-trigger", + "read-watchpoint-trigger", + "access-watchpoint-trigger", + "function-finished", + "location-reached", + "watchpoint-scope", + "end-stepping-range", + "exited-signalled", + "exited", + "exited-normally", + "signal-received", + "solib-event", + "fork", + "vfork", + "syscall-entry", + "syscall-return", + "exec", + "no-history", + NULL }; gdb_static_assert (ARRAY_SIZE (async_reason_string_lookup) == EXEC_ASYNC_LAST + 1); diff --git a/gdb/mi/mi-console.c b/gdb/mi/mi-console.c index e0b5648..8c9adea 100644 --- a/gdb/mi/mi-console.c +++ b/gdb/mi/mi-console.c @@ -34,7 +34,8 @@ mi_console_file::mi_console_file (ui_file *raw, const char *prefix, char quote) : m_raw (raw), m_prefix (prefix), m_quote (quote) -{} +{ +} void mi_console_file::write (const char *buf, long length_buf) diff --git a/gdb/mi/mi-console.h b/gdb/mi/mi-console.h index 522053e..164b18f 100644 --- a/gdb/mi/mi-console.h +++ b/gdb/mi/mi-console.h @@ -26,6 +26,7 @@ class mi_console_file : public ui_file { public: + /* Create a console that wraps the given output stream RAW with the string PREFIX and quoting it with QUOTE. */ mi_console_file (ui_file *raw, const char *prefix, char quote); @@ -42,6 +43,7 @@ public: void write_async_safe (const char *buf, long length_buf) override; private: + /* The wrapped raw output stream. */ ui_file *m_raw; diff --git a/gdb/mi/mi-getopt.c b/gdb/mi/mi-getopt.c index 2fc2648..a9496a5 100644 --- a/gdb/mi/mi-getopt.c +++ b/gdb/mi/mi-getopt.c @@ -19,6 +19,7 @@ #include "defs.h" #include "mi-getopt.h" + /* See comments about mi_getopt and mi_getopt_silent in mi-getopt.h. When there is an unknown option, if ERROR_ON_UNKNOWN is true, throw an error, otherwise return -1. */ @@ -33,7 +34,7 @@ mi_getopt_1 (const char *prefix, int argc, char **argv, /* We assume that argv/argc are ok. */ if (*oind > argc || *oind < 0) - internal_error (_("mi_getopt_long: oind out of bounds")); + internal_error (_ ("mi_getopt_long: oind out of bounds")); if (*oind == argc) return -1; arg = argv[*oind]; @@ -59,7 +60,7 @@ mi_getopt_1 (const char *prefix, int argc, char **argv, { /* A non-simple oarg option. */ if (argc < *oind + 2) - error (_("%s: Option %s requires an argument"), prefix, arg); + error (_ ("%s: Option %s requires an argument"), prefix, arg); *oarg = argv[(*oind) + 1]; *oind = (*oind) + 2; return opt->index; @@ -73,16 +74,14 @@ mi_getopt_1 (const char *prefix, int argc, char **argv, } if (error_on_unknown) - error (_("%s: Unknown option ``%s''"), prefix, arg + 1); + error (_ ("%s: Unknown option ``%s''"), prefix, arg + 1); else return -1; } int -mi_getopt (const char *prefix, - int argc, char **argv, - const struct mi_opt *opts, - int *oind, char **oarg) +mi_getopt (const char *prefix, int argc, char **argv, + const struct mi_opt *opts, int *oind, char **oarg) { return mi_getopt_1 (prefix, argc, argv, opts, oind, oarg, 1); } @@ -94,15 +93,12 @@ mi_getopt_allow_unknown (const char *prefix, int argc, char **argv, return mi_getopt_1 (prefix, argc, argv, opts, oind, oarg, 0); } -int -mi_valid_noargs (const char *prefix, int argc, char **argv) +int +mi_valid_noargs (const char *prefix, int argc, char **argv) { int oind = 0; char *oarg; - static const struct mi_opt opts[] = - { - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { 0, 0, 0 } }; if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) == -1) return 1; diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h index e418ae9..63ee0bd 100644 --- a/gdb/mi/mi-getopt.h +++ b/gdb/mi/mi-getopt.h @@ -24,11 +24,11 @@ requires an argument. INDEX is returned to identify the option. */ struct mi_opt - { - const char *name; - int index; - int arg_p; - }; +{ + const char *name; + int index; + int arg_p; +}; /* Like getopt() but with simpler semantics. @@ -52,9 +52,9 @@ struct mi_opt extern int mi_getopt (const char *prefix, int argc, char **argv, const struct mi_opt *opt, int *optind, char **optarg); -extern int mi_getopt_allow_unknown (const char *prefix, int argc, - char **argv, const struct mi_opt *opts, - int *oind, char **oarg); +extern int mi_getopt_allow_unknown (const char *prefix, int argc, char **argv, + const struct mi_opt *opts, int *oind, + char **oarg); /* mi_valid_noargs determines if ARGC/ARGV are a valid set of parameters to satisfy an MI function that is not supposed to diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 29d1aee..0076ea8 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -47,8 +47,8 @@ interpreter. */ static void mi_execute_command_wrapper (const char *cmd); -static void mi_execute_command_input_handler - (gdb::unique_xmalloc_ptr<char> &&cmd); +static void +mi_execute_command_input_handler (gdb::unique_xmalloc_ptr<char> &&cmd); /* These are hooks that we put in place while doing interpreter_exec so we can report interesting things that happened "behind the MI's @@ -69,7 +69,7 @@ static void mi_on_no_history (void); static void mi_new_thread (struct thread_info *t); static void mi_thread_exit (struct thread_info *t, int silent); -static void mi_record_changed (struct inferior*, int, const char *, +static void mi_record_changed (struct inferior *, int, const char *, const char *); static void mi_inferior_added (struct inferior *inf); static void mi_inferior_appeared (struct inferior *inf); @@ -159,13 +159,12 @@ mi_interp::init (bool top_level) target_terminal::scoped_restore_terminal_state term_state; target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-group-added,id=\"i%d\"", + gdb_printf (mi->event_channel, "thread-group-added,id=\"i%d\"", inf->num); gdb_flush (mi->event_channel); } - } + } } void @@ -212,12 +211,12 @@ mi_cmd_interpreter_exec (const char *command, char **argv, int argc) int i; if (argc < 2) - error (_("-interpreter-exec: " - "Usage: -interpreter-exec interp command")); + error (_ ("-interpreter-exec: " + "Usage: -interpreter-exec interp command")); interp_to_use = interp_lookup (current_ui, argv[0]); if (interp_to_use == NULL) - error (_("-interpreter-exec: could not find interpreter \"%s\""), + error (_ ("-interpreter-exec: could not find interpreter \"%s\""), argv[0]); /* Note that unlike the CLI version of this command, we don't @@ -234,9 +233,9 @@ mi_cmd_interpreter_exec (const char *command, char **argv, int argc) /* Now run the code. */ SCOPE_EXIT - { - mi_remove_notify_hooks (); - }; + { + mi_remove_notify_hooks (); + }; for (i = 1; i < argc; i++) interp_exec (interp_to_use, argv[i]); @@ -329,39 +328,37 @@ static void mi_new_thread (struct thread_info *t) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-created,id=\"%d\",group-id=\"i%d\"", - t->global_num, t->inf->num); - gdb_flush (mi->event_channel); - } + gdb_printf (mi->event_channel, "thread-created,id=\"%d\",group-id=\"i%d\"", + t->global_num, t->inf->num); + gdb_flush (mi->event_channel); + } } static void mi_thread_exit (struct thread_info *t, int silent) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-exited,id=\"%d\",group-id=\"i%d\"", - t->global_num, t->inf->num); - gdb_flush (mi->event_channel); - } + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + gdb_printf (mi->event_channel, "thread-exited,id=\"%d\",group-id=\"i%d\"", + t->global_num, t->inf->num); + gdb_flush (mi->event_channel); + } } /* Emit notification on changing the state of record. */ @@ -371,134 +368,130 @@ mi_record_changed (struct inferior *inferior, int started, const char *method, const char *format) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - - if (mi == NULL) - continue; - - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); - - if (started) - { - if (format != NULL) - { - gdb_printf (mi->event_channel, - "record-started,thread-group=\"i%d\"," - "method=\"%s\",format=\"%s\"", - inferior->num, method, format); - } - else - { - gdb_printf (mi->event_channel, - "record-started,thread-group=\"i%d\"," - "method=\"%s\"", - inferior->num, method); - } - } - else - { - gdb_printf (mi->event_channel, - "record-stopped,thread-group=\"i%d\"", - inferior->num); - } - - gdb_flush (mi->event_channel); - } + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + + if (mi == NULL) + continue; + + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + + if (started) + { + if (format != NULL) + { + gdb_printf (mi->event_channel, + "record-started,thread-group=\"i%d\"," + "method=\"%s\",format=\"%s\"", + inferior->num, method, format); + } + else + { + gdb_printf (mi->event_channel, + "record-started,thread-group=\"i%d\"," + "method=\"%s\"", + inferior->num, method); + } + } + else + { + gdb_printf (mi->event_channel, "record-stopped,thread-group=\"i%d\"", + inferior->num); + } + + gdb_flush (mi->event_channel); + } } static void mi_inferior_added (struct inferior *inf) { SWITCH_THRU_ALL_UIS () - { - struct interp *interp; - struct mi_interp *mi; + { + struct interp *interp; + struct mi_interp *mi; - /* We'll be called once for the initial inferior, before the top + /* We'll be called once for the initial inferior, before the top level interpreter is set. */ - interp = top_level_interpreter (); - if (interp == NULL) - continue; + interp = top_level_interpreter (); + if (interp == NULL) + continue; - mi = as_mi_interp (interp); - if (mi == NULL) - continue; + mi = as_mi_interp (interp); + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-group-added,id=\"i%d\"", - inf->num); - gdb_flush (mi->event_channel); - } + gdb_printf (mi->event_channel, "thread-group-added,id=\"i%d\"", inf->num); + gdb_flush (mi->event_channel); + } } static void mi_inferior_appeared (struct inferior *inf) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-group-started,id=\"i%d\",pid=\"%d\"", - inf->num, inf->pid); - gdb_flush (mi->event_channel); - } + gdb_printf (mi->event_channel, + "thread-group-started,id=\"i%d\",pid=\"%d\"", inf->num, + inf->pid); + gdb_flush (mi->event_channel); + } } static void mi_inferior_exit (struct inferior *inf) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - if (inf->has_exit_code) - gdb_printf (mi->event_channel, - "thread-group-exited,id=\"i%d\",exit-code=\"%s\"", - inf->num, int_string (inf->exit_code, 8, 0, 0, 1)); - else - gdb_printf (mi->event_channel, - "thread-group-exited,id=\"i%d\"", inf->num); + if (inf->has_exit_code) + gdb_printf (mi->event_channel, + "thread-group-exited,id=\"i%d\",exit-code=\"%s\"", inf->num, + int_string (inf->exit_code, 8, 0, 0, 1)); + else + gdb_printf (mi->event_channel, "thread-group-exited,id=\"i%d\"", + inf->num); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } static void mi_inferior_removed (struct inferior *inf) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "thread-group-removed,id=\"i%d\"", - inf->num); - gdb_flush (mi->event_channel); - } + gdb_printf (mi->event_channel, "thread-group-removed,id=\"i%d\"", + inf->num); + gdb_flush (mi->event_channel); + } } /* Return the MI interpreter, if it is active -- either because it's @@ -531,15 +524,15 @@ static void mi_on_signal_received (enum gdb_signal siggnal) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); + { + struct mi_interp *mi = find_mi_interp (); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - print_signal_received_reason (mi->mi_uiout, siggnal); - print_signal_received_reason (mi->cli_uiout, siggnal); - } + print_signal_received_reason (mi->mi_uiout, siggnal); + print_signal_received_reason (mi->cli_uiout, siggnal); + } } /* Observer for the end_stepping_range notification. */ @@ -548,15 +541,15 @@ static void mi_on_end_stepping_range (void) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); + { + struct mi_interp *mi = find_mi_interp (); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - print_end_stepping_range_reason (mi->mi_uiout); - print_end_stepping_range_reason (mi->cli_uiout); - } + print_end_stepping_range_reason (mi->mi_uiout); + print_end_stepping_range_reason (mi->cli_uiout); + } } /* Observer for the signal_exited notification. */ @@ -565,15 +558,15 @@ static void mi_on_signal_exited (enum gdb_signal siggnal) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); + { + struct mi_interp *mi = find_mi_interp (); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - print_signal_exited_reason (mi->mi_uiout, siggnal); - print_signal_exited_reason (mi->cli_uiout, siggnal); - } + print_signal_exited_reason (mi->mi_uiout, siggnal); + print_signal_exited_reason (mi->cli_uiout, siggnal); + } } /* Observer for the exited notification. */ @@ -582,15 +575,15 @@ static void mi_on_exited (int exitstatus) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); + { + struct mi_interp *mi = find_mi_interp (); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - print_exited_reason (mi->mi_uiout, exitstatus); - print_exited_reason (mi->cli_uiout, exitstatus); - } + print_exited_reason (mi->mi_uiout, exitstatus); + print_exited_reason (mi->cli_uiout, exitstatus); + } } /* Observer for the no_history notification. */ @@ -599,15 +592,15 @@ static void mi_on_no_history (void) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = find_mi_interp (); + { + struct mi_interp *mi = find_mi_interp (); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - print_no_history_reason (mi->mi_uiout); - print_no_history_reason (mi->cli_uiout); - } + print_no_history_reason (mi->mi_uiout); + print_no_history_reason (mi->cli_uiout); + } } static void @@ -627,8 +620,7 @@ mi_on_normal_stop_1 (struct bpstat *bs, int print_frame) tp = inferior_thread (); - if (tp->thread_fsm () != nullptr - && tp->thread_fsm ()->finished_p ()) + if (tp->thread_fsm () != nullptr && tp->thread_fsm ()->finished_p ()) { enum async_reply_reason reason; @@ -660,7 +652,7 @@ mi_on_normal_stop_1 (struct bpstat *bs, int print_frame) if (core != -1) mi_uiout->field_signed ("core", core); } - + gdb_puts ("*stopped", mi->raw_stdout); mi_out_put (mi_uiout, mi->raw_stdout); mi_out_rewind (mi_uiout); @@ -673,12 +665,12 @@ static void mi_on_normal_stop (struct bpstat *bs, int print_frame) { SWITCH_THRU_ALL_UIS () - { - if (as_mi_interp (top_level_interpreter ()) == NULL) - continue; + { + if (as_mi_interp (top_level_interpreter ()) == NULL) + continue; - mi_on_normal_stop_1 (bs, print_frame); - } + mi_on_normal_stop_1 (bs, print_frame); + } } static void @@ -700,13 +692,12 @@ mi_about_to_proceed (void) /* When the element is non-zero, no MI notifications will be emitted in response to the corresponding observers. */ -struct mi_suppress_notification mi_suppress_notification = - { - 0, - 0, - 0, - 0, - }; +struct mi_suppress_notification mi_suppress_notification = { + 0, + 0, + 0, + 0, +}; /* Emit notification on changing a traceframe. */ @@ -717,24 +708,25 @@ mi_traceframe_changed (int tfnum, int tpnum) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - if (tfnum >= 0) - gdb_printf (mi->event_channel, "traceframe-changed," - "num=\"%d\",tracepoint=\"%d\"", - tfnum, tpnum); - else - gdb_printf (mi->event_channel, "traceframe-changed,end"); + if (tfnum >= 0) + gdb_printf (mi->event_channel, + "traceframe-changed," + "num=\"%d\",tracepoint=\"%d\"", + tfnum, tpnum); + else + gdb_printf (mi->event_channel, "traceframe-changed,end"); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification on creating a trace state variable. */ @@ -743,21 +735,22 @@ static void mi_tsv_created (const struct trace_state_variable *tsv) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "tsv-created," - "name=\"%s\",initial=\"%s\"", - tsv->name.c_str (), plongest (tsv->initial_value)); + gdb_printf (mi->event_channel, + "tsv-created," + "name=\"%s\",initial=\"%s\"", + tsv->name.c_str (), plongest (tsv->initial_value)); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification on deleting a trace state variable. */ @@ -766,23 +759,25 @@ static void mi_tsv_deleted (const struct trace_state_variable *tsv) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - if (tsv != NULL) - gdb_printf (mi->event_channel, "tsv-deleted," - "name=\"%s\"", tsv->name.c_str ()); - else - gdb_printf (mi->event_channel, "tsv-deleted"); + if (tsv != NULL) + gdb_printf (mi->event_channel, + "tsv-deleted," + "name=\"%s\"", + tsv->name.c_str ()); + else + gdb_printf (mi->event_channel, "tsv-deleted"); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification on modifying a trace state variable. */ @@ -791,31 +786,29 @@ static void mi_tsv_modified (const struct trace_state_variable *tsv) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *mi_uiout; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *mi_uiout; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - mi_uiout = top_level_interpreter ()->interp_ui_out (); + mi_uiout = top_level_interpreter ()->interp_ui_out (); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "tsv-modified"); + gdb_printf (mi->event_channel, "tsv-modified"); - ui_out_redirect_pop redir (mi_uiout, mi->event_channel); + ui_out_redirect_pop redir (mi_uiout, mi->event_channel); - mi_uiout->field_string ("name", tsv->name); - mi_uiout->field_string ("initial", - plongest (tsv->initial_value)); - if (tsv->value_known) - mi_uiout->field_string ("current", plongest (tsv->value)); + mi_uiout->field_string ("name", tsv->name); + mi_uiout->field_string ("initial", plongest (tsv->initial_value)); + if (tsv->value_known) + mi_uiout->field_string ("current", plongest (tsv->value)); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Print breakpoint BP on MI's event channel. */ @@ -859,21 +852,20 @@ mi_breakpoint_created (struct breakpoint *b) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "breakpoint-created"); - mi_print_breakpoint_for_event (mi, b); + gdb_printf (mi->event_channel, "breakpoint-created"); + mi_print_breakpoint_for_event (mi, b); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification about deleted breakpoint. */ @@ -888,20 +880,19 @@ mi_breakpoint_deleted (struct breakpoint *b) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "breakpoint-deleted,id=\"%d\"", - b->number); + gdb_printf (mi->event_channel, "breakpoint-deleted,id=\"%d\"", b->number); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification about modified breakpoint. */ @@ -916,36 +907,34 @@ mi_breakpoint_modified (struct breakpoint *b) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "breakpoint-modified"); - mi_print_breakpoint_for_event (mi, b); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + gdb_printf (mi->event_channel, "breakpoint-modified"); + mi_print_breakpoint_for_event (mi, b); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } static void mi_output_running (struct thread_info *thread) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - gdb_printf (mi->raw_stdout, - "*running,thread-id=\"%d\"\n", - thread->global_num); - } + gdb_printf (mi->raw_stdout, "*running,thread-id=\"%d\"\n", + thread->global_num); + } } /* Return true if there are multiple inferiors loaded. This is used @@ -967,8 +956,8 @@ multiple_inferiors_p () } static void -mi_on_resume_1 (struct mi_interp *mi, - process_stratum_target *targ, ptid_t ptid) +mi_on_resume_1 (struct mi_interp *mi, process_stratum_target *targ, + ptid_t ptid) { /* To cater for older frontends, emit ^running, but do it only once per each command. We do it here, since at this point we know @@ -987,8 +976,7 @@ mi_on_resume_1 (struct mi_interp *mi, /* Backwards compatibility. If doing a wildcard resume and there's only one inferior, output "all", otherwise, output each resumed thread individually. */ - if ((ptid == minus_one_ptid || ptid.is_pid ()) - && !multiple_inferiors_p ()) + if ((ptid == minus_one_ptid || ptid.is_pid ()) && !multiple_inferiors_p ()) gdb_printf (mi->raw_stdout, "*running,thread-id=\"all\"\n"); else for (thread_info *tp : all_non_exited_threads (targ, ptid)) @@ -1022,17 +1010,17 @@ mi_on_resume (ptid_t ptid) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - if (mi == NULL) - continue; + if (mi == NULL) + continue; - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - mi_on_resume_1 (mi, target, ptid); - } + mi_on_resume_1 (mi, target, ptid); + } } /* See mi-interp.h. */ @@ -1047,7 +1035,7 @@ mi_output_solib_attribs (ui_out *uiout, struct so_list *solib) uiout->field_string ("host-name", solib->so_name); uiout->field_signed ("symbols-loaded", solib->symbols_loaded); if (!gdbarch_has_global_solist (target_gdbarch ())) - uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); + uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); ui_out_emit_list list_emitter (uiout, "ranges"); ui_out_emit_tuple tuple_emitter (uiout, NULL); @@ -1062,58 +1050,58 @@ static void mi_solib_loaded (struct so_list *solib) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *uiout; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *uiout; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - uiout = top_level_interpreter ()->interp_ui_out (); + uiout = top_level_interpreter ()->interp_ui_out (); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "library-loaded"); + gdb_printf (mi->event_channel, "library-loaded"); - ui_out_redirect_pop redir (uiout, mi->event_channel); + ui_out_redirect_pop redir (uiout, mi->event_channel); - mi_output_solib_attribs (uiout, solib); + mi_output_solib_attribs (uiout, solib); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } static void mi_solib_unloaded (struct so_list *solib) { SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *uiout; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *uiout; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - uiout = top_level_interpreter ()->interp_ui_out (); + uiout = top_level_interpreter ()->interp_ui_out (); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "library-unloaded"); + gdb_printf (mi->event_channel, "library-unloaded"); - ui_out_redirect_pop redir (uiout, mi->event_channel); + ui_out_redirect_pop redir (uiout, mi->event_channel); - uiout->field_string ("id", solib->so_original_name); - uiout->field_string ("target-name", solib->so_original_name); - uiout->field_string ("host-name", solib->so_name); - if (!gdbarch_has_global_solist (target_gdbarch ())) - { - uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); - } + uiout->field_string ("id", solib->so_original_name); + uiout->field_string ("target-name", solib->so_original_name); + uiout->field_string ("host-name", solib->so_name); + if (!gdbarch_has_global_solist (target_gdbarch ())) + { + uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); + } - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification about the command parameter change. */ @@ -1125,73 +1113,73 @@ mi_command_param_changed (const char *param, const char *value) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *mi_uiout; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *mi_uiout; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - mi_uiout = top_level_interpreter ()->interp_ui_out (); + mi_uiout = top_level_interpreter ()->interp_ui_out (); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "cmd-param-changed"); + gdb_printf (mi->event_channel, "cmd-param-changed"); - ui_out_redirect_pop redir (mi_uiout, mi->event_channel); + ui_out_redirect_pop redir (mi_uiout, mi->event_channel); - mi_uiout->field_string ("param", param); - mi_uiout->field_string ("value", value); + mi_uiout->field_string ("param", param); + mi_uiout->field_string ("value", value); - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit notification about the target memory change. */ static void -mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr, - ssize_t len, const bfd_byte *myaddr) +mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr, ssize_t len, + const bfd_byte *myaddr) { if (mi_suppress_notification.memory) return; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *mi_uiout; - struct obj_section *sec; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *mi_uiout; + struct obj_section *sec; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - mi_uiout = top_level_interpreter ()->interp_ui_out (); + mi_uiout = top_level_interpreter ()->interp_ui_out (); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, "memory-changed"); + gdb_printf (mi->event_channel, "memory-changed"); - ui_out_redirect_pop redir (mi_uiout, mi->event_channel); + ui_out_redirect_pop redir (mi_uiout, mi->event_channel); - mi_uiout->field_fmt ("thread-group", "i%d", inferior->num); - mi_uiout->field_core_addr ("addr", target_gdbarch (), memaddr); - mi_uiout->field_string ("len", hex_string (len)); + mi_uiout->field_fmt ("thread-group", "i%d", inferior->num); + mi_uiout->field_core_addr ("addr", target_gdbarch (), memaddr); + mi_uiout->field_string ("len", hex_string (len)); - /* Append 'type=code' into notification if MEMADDR falls in the range of + /* Append 'type=code' into notification if MEMADDR falls in the range of sections contain code. */ - sec = find_pc_section (memaddr); - if (sec != NULL && sec->objfile != NULL) - { - flagword flags = bfd_section_flags (sec->the_bfd_section); + sec = find_pc_section (memaddr); + if (sec != NULL && sec->objfile != NULL) + { + flagword flags = bfd_section_flags (sec->the_bfd_section); - if (flags & SEC_CODE) - mi_uiout->field_string ("type", "code"); - } + if (flags & SEC_CODE) + mi_uiout->field_string ("type", "code"); + } - gdb_flush (mi->event_channel); - } + gdb_flush (mi->event_channel); + } } /* Emit an event when the selection context (inferior, thread, frame) @@ -1212,42 +1200,41 @@ mi_user_selected_context_changed (user_selected_what selection) tp = NULL; SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - struct ui_out *mi_uiout; + { + struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + struct ui_out *mi_uiout; - if (mi == NULL) - continue; + if (mi == NULL) + continue; - mi_uiout = top_level_interpreter ()->interp_ui_out (); + mi_uiout = top_level_interpreter ()->interp_ui_out (); - ui_out_redirect_pop redirect_popper (mi_uiout, mi->event_channel); + ui_out_redirect_pop redirect_popper (mi_uiout, mi->event_channel); - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - if (selection & USER_SELECTED_INFERIOR) - print_selected_inferior (mi->cli_uiout); + if (selection & USER_SELECTED_INFERIOR) + print_selected_inferior (mi->cli_uiout); - if (tp != NULL - && (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME))) - { - print_selected_thread_frame (mi->cli_uiout, selection); - - gdb_printf (mi->event_channel, - "thread-selected,id=\"%d\"", - tp->global_num); - - if (tp->state != THREAD_RUNNING) - { - if (has_stack_frames ()) - print_stack_frame_to_uiout (mi_uiout, get_selected_frame (NULL), - 1, SRC_AND_LOC, 1); - } - } + if (tp != NULL + && (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME))) + { + print_selected_thread_frame (mi->cli_uiout, selection); - gdb_flush (mi->event_channel); - } + gdb_printf (mi->event_channel, "thread-selected,id=\"%d\"", + tp->global_num); + + if (tp->state != THREAD_RUNNING) + { + if (has_stack_frames ()) + print_stack_frame_to_uiout (mi_uiout, get_selected_frame (NULL), + 1, SRC_AND_LOC, 1); + } + } + + gdb_flush (mi->event_channel); + } } ui_out * @@ -1307,6 +1294,7 @@ mi_interp_factory (const char *name) } void _initialize_mi_interp (); + void _initialize_mi_interp () { @@ -1351,6 +1339,6 @@ _initialize_mi_interp () gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp"); gdb::observers::sync_execution_done.attach (mi_on_sync_execution_done, "mi-interp"); - gdb::observers::user_selected_context_changed.attach - (mi_user_selected_context_changed, "mi-interp"); + gdb::observers::user_selected_context_changed.attach ( + mi_user_selected_context_changed, "mi-interp"); } diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index e07be12..0afbbdc 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -29,9 +29,11 @@ struct mi_console_file; class mi_interp final : public interp { public: + mi_interp (const char *name) : interp (name) - {} + { + } void init (bool top_level) override; void resume () override; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index e0cade2..f7f4468 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -35,7 +35,7 @@ #include "interps.h" #include "gdbsupport/event-loop.h" #include "event-top.h" -#include "gdbcore.h" /* For write_memory(). */ +#include "gdbcore.h" /* For write_memory(). */ #include "value.h" #include "regcache.h" #include "frame.h" @@ -64,9 +64,9 @@ #include <map> enum - { - FROM_TTY = 0 - }; +{ + FROM_TTY = 0 +}; /* Debug flag */ static int mi_debug_p; @@ -91,10 +91,10 @@ int mi_proceeded; static void mi_cmd_execute (struct mi_parse *parse); -static void mi_execute_async_cli_command (const char *cli_command, - char **argv, int argc); +static void mi_execute_async_cli_command (const char *cli_command, char **argv, + int argc); static bool register_changed_p (int regnum, readonly_detached_regcache *, - readonly_detached_regcache *); + readonly_detached_regcache *); static void output_register (frame_info_ptr, int regnum, int format, int skip_unavailable); @@ -112,7 +112,7 @@ set_mi_async_command (const char *args, int from_tty, if (have_live_inferiors ()) { mi_async_1 = mi_async; - error (_("Cannot change this setting while the inferior is running.")); + error (_ ("Cannot change this setting while the inferior is running.")); } mi_async = mi_async_1; @@ -120,12 +120,9 @@ set_mi_async_command (const char *args, int from_tty, static void show_mi_async_command (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, - _("Whether MI is in asynchronous mode is %s.\n"), - value); + gdb_printf (file, _ ("Whether MI is in asynchronous mode is %s.\n"), value); } /* A wrapper for target_can_async_p that takes the MI setting into @@ -165,7 +162,7 @@ void mi_cmd_exec_next (const char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + if (argc > 0 && strcmp (argv[0], "--reverse") == 0) mi_execute_async_cli_command ("reverse-next", argv + 1, argc - 1); else mi_execute_async_cli_command ("next", argv, argc); @@ -175,7 +172,7 @@ void mi_cmd_exec_next_instruction (const char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + if (argc > 0 && strcmp (argv[0], "--reverse") == 0) mi_execute_async_cli_command ("reverse-nexti", argv + 1, argc - 1); else mi_execute_async_cli_command ("nexti", argv, argc); @@ -185,7 +182,7 @@ void mi_cmd_exec_step (const char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + if (argc > 0 && strcmp (argv[0], "--reverse") == 0) mi_execute_async_cli_command ("reverse-step", argv + 1, argc - 1); else mi_execute_async_cli_command ("step", argv, argc); @@ -195,7 +192,7 @@ void mi_cmd_exec_step_instruction (const char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + if (argc > 0 && strcmp (argv[0], "--reverse") == 0) mi_execute_async_cli_command ("reverse-stepi", argv + 1, argc - 1); else mi_execute_async_cli_command ("stepi", argv, argc); @@ -205,7 +202,7 @@ void mi_cmd_exec_finish (const char *command, char **argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ - if (argc > 0 && strcmp(argv[0], "--reverse") == 0) + if (argc > 0 && strcmp (argv[0], "--reverse") == 0) mi_execute_async_cli_command ("reverse-finish", argv + 1, argc - 1); else mi_execute_async_cli_command ("finish", argv, argc); @@ -254,7 +251,7 @@ proceed_thread (struct thread_info *thread, int pid) static int proceed_thread_callback (struct thread_info *thread, void *arg) { - int pid = *(int *)arg; + int pid = *(int *) arg; proceed_thread (thread, pid); return 0; @@ -263,8 +260,8 @@ proceed_thread_callback (struct thread_info *thread, void *arg) static void exec_continue (char **argv, int argc) { - prepare_execution_command (current_inferior ()->top_target (), mi_async_p ()); - + prepare_execution_command (current_inferior ()->top_target (), + mi_async_p ()); if (non_stop) { @@ -277,8 +274,8 @@ exec_continue (char **argv, int argc) if (current_context->all || current_context->thread_group != -1) { scoped_restore_current_thread restore_thread; - scoped_disable_commit_resumed disable_commit_resumed - ("MI continue all threads in non-stop"); + scoped_disable_commit_resumed disable_commit_resumed ( + "MI continue all threads in non-stop"); int pid = 0; if (!current_context->all) @@ -323,13 +320,14 @@ exec_reverse_continue (char **argv, int argc) enum exec_direction_kind dir = execution_direction; if (dir == EXEC_REVERSE) - error (_("Already in reverse mode.")); + error (_ ("Already in reverse mode.")); if (!target_can_execute_reverse ()) - error (_("Target %s does not support this command."), target_shortname ()); + error (_ ("Target %s does not support this command."), + target_shortname ()); - scoped_restore save_exec_dir = make_scoped_restore (&execution_direction, - EXEC_REVERSE); + scoped_restore save_exec_dir + = make_scoped_restore (&execution_direction, EXEC_REVERSE); exec_continue (argv, argc); } @@ -345,7 +343,7 @@ mi_cmd_exec_continue (const char *command, char **argv, int argc) static int interrupt_thread_callback (struct thread_info *thread, void *arg) { - int pid = *(int *)arg; + int pid = *(int *) arg; if (thread->state != THREAD_RUNNING) return 0; @@ -383,8 +381,8 @@ mi_cmd_exec_interrupt (const char *command, char **argv, int argc) { struct inferior *inf = find_inferior_id (current_context->thread_group); - scoped_disable_commit_resumed disable_commit_resumed - ("interrupting all threads of thread group"); + scoped_disable_commit_resumed disable_commit_resumed ( + "interrupting all threads of thread group"); iterate_over_threads (interrupt_thread_callback, &inf->pid); } @@ -413,14 +411,13 @@ run_one_inferior (inferior *inf, bool start_p) { thread_info *tp = any_thread_of_inferior (inf); if (tp == NULL) - error (_("Inferior has no threads.")); + error (_ ("Inferior has no threads.")); switch_to_thread (tp); } else switch_to_inferior_no_thread (inf); - mi_execute_cli_command (run_cmd, async_p, - async_p ? "&" : NULL); + mi_execute_cli_command (run_cmd, async_p, async_p ? "&" : NULL); } void @@ -430,14 +427,13 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) /* Parse the command options. */ enum opt - { - START_OPT, - }; - static const struct mi_opt opts[] = - { - {"-start", START_OPT, 0}, - {NULL, 0, 0}, - }; + { + START_OPT, + }; + static const struct mi_opt opts[] = { + { "-start", START_OPT, 0 }, + { NULL, 0, 0 }, + }; int oind = 0; char *oarg; @@ -459,7 +455,7 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) /* This command does not accept any argument. Make sure the user did not provide any. */ if (oind != argc) - error (_("Invalid argument: %s"), argv[oind]); + error (_ ("Invalid argument: %s"), argv[oind]); if (current_context->all) { @@ -474,16 +470,14 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) struct target_ops *run_target = find_run_target (); bool async_p = mi_async && target_can_async_p (run_target); - mi_execute_cli_command (run_cmd, async_p, - async_p ? "&" : NULL); + mi_execute_cli_command (run_cmd, async_p, async_p ? "&" : NULL); } } - static int find_thread_of_process (struct thread_info *ti, void *p) { - int pid = *(int *)p; + int pid = *(int *) p; if (ti->ptid.pid () == pid && ti->state != THREAD_EXITED) return 1; @@ -495,7 +489,7 @@ void mi_cmd_target_detach (const char *command, char **argv, int argc) { if (argc != 0 && argc != 1) - error (_("Usage: -target-detach [pid | thread-group]")); + error (_ ("Usage: -target-detach [pid | thread-group]")); if (argc == 1) { @@ -510,11 +504,11 @@ mi_cmd_target_detach (const char *command, char **argv, int argc) int id = strtoul (argv[0] + 1, &end, 0); if (*end != '\0') - error (_("Invalid syntax of thread-group id '%s'"), argv[0]); + error (_ ("Invalid syntax of thread-group id '%s'"), argv[0]); inf = find_inferior_id (id); if (!inf) - error (_("Non-existent thread-group id '%d'"), id); + error (_ ("Non-existent thread-group id '%d'"), id); pid = inf->pid; } @@ -524,14 +518,14 @@ mi_cmd_target_detach (const char *command, char **argv, int argc) pid = strtol (argv[0], &end, 10); if (*end != '\0') - error (_("Invalid identifier '%s'"), argv[0]); + error (_ ("Invalid identifier '%s'"), argv[0]); } /* Pick any thread in the desired process. Current target_detach detaches from the parent of inferior_ptid. */ tp = iterate_over_threads (find_thread_of_process, &pid); if (!tp) - error (_("Thread group is empty")); + error (_ ("Thread group is empty")); switch_to_thread (tp); } @@ -549,12 +543,12 @@ void mi_cmd_thread_select (const char *command, char **argv, int argc) { if (argc != 1) - error (_("-thread-select: USAGE: threadnum.")); + error (_ ("-thread-select: USAGE: threadnum.")); int num = value_as_long (parse_and_eval (argv[0])); thread_info *thr = find_thread_global_id (num); if (thr == NULL) - error (_("Thread ID %d not known."), num); + error (_ ("Thread ID %d not known."), num); thread_select (argv[0], thr); @@ -566,7 +560,7 @@ void mi_cmd_thread_list_ids (const char *command, char **argv, int argc) { if (argc != 0) - error (_("-thread-list-ids: No arguments required.")); + error (_ ("-thread-list-ids: No arguments required.")); int num = 0; int current_thread = -1; @@ -595,7 +589,7 @@ void mi_cmd_thread_info (const char *command, char **argv, int argc) { if (argc != 0 && argc != 1) - error (_("Invalid MI command")); + error (_ ("Invalid MI command")); print_thread_info (current_uiout, argv[0], -1); } @@ -684,7 +678,7 @@ output_cores (struct ui_out *uiout, const char *field_name, const char *xcores) char *p = cores.get (); char *saveptr; - for (p = strtok_r (p, ",", &saveptr); p; p = strtok_r (NULL, ",", &saveptr)) + for (p = strtok_r (p, ",", &saveptr); p; p = strtok_r (NULL, ",", &saveptr)) uiout->field_string (NULL, p); } @@ -775,22 +769,20 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) enum opt { - AVAILABLE_OPT, RECURSE_OPT + AVAILABLE_OPT, + RECURSE_OPT }; - static const struct mi_opt opts[] = - { - {"-available", AVAILABLE_OPT, 0}, - {"-recurse", RECURSE_OPT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "-available", AVAILABLE_OPT, 0 }, + { "-recurse", RECURSE_OPT, 1 }, + { 0, 0, 0 } }; int oind = 0; char *oarg; while (1) { - int opt = mi_getopt ("-list-thread-groups", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-list-thread-groups", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -805,8 +797,8 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) else if (strcmp (oarg, "1") == 0) recurse = 1; else - error (_("only '0' and '1' are valid values " - "for the '--recurse' option")); + error (_ ("only '0' and '1' are valid values " + "for the '--recurse' option")); break; } } @@ -817,12 +809,12 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) int inf; if (*(argv[oind]) != 'i') - error (_("invalid syntax of group id '%s'"), argv[oind]); + error (_ ("invalid syntax of group id '%s'"), argv[oind]); inf = strtoul (argv[oind] + 1, &end, 0); if (*end != '\0') - error (_("invalid syntax of group id '%s'"), argv[oind]); + error (_ ("invalid syntax of group id '%s'"), argv[oind]); ids.insert (inf); } @@ -837,7 +829,7 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) struct inferior *inf = find_inferior_id (id); if (!inf) - error (_("Non-existent thread group id '%d'"), id); + error (_ ("Non-existent thread group id '%d'"), id); print_thread_info (uiout, NULL, inf->pid); } @@ -874,16 +866,15 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) ui_out_emit_list list_emitter (uiout, "register-names"); - if (argc == 0) /* No args, just do all the regs. */ + if (argc == 0) /* No args, just do all the regs. */ { - for (regnum = 0; - regnum < numregs; - regnum++) + for (regnum = 0; regnum < numregs; regnum++) { if (*(gdbarch_register_name (gdbarch, regnum)) == '\0') uiout->field_string (NULL, ""); else - uiout->field_string (NULL, gdbarch_register_name (gdbarch, regnum)); + uiout->field_string (NULL, + gdbarch_register_name (gdbarch, regnum)); } } @@ -892,7 +883,7 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) { regnum = atoi (argv[i]); if (regnum < 0 || regnum >= numregs) - error (_("bad register number")); + error (_ ("bad register number")); if (*(gdbarch_register_name (gdbarch, regnum)) == '\0') uiout->field_string (NULL, ""); @@ -934,15 +925,12 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc) if (argc == 0) { /* No args, just do all the regs. */ - for (regnum = 0; - regnum < numregs; - regnum++) + for (regnum = 0; regnum < numregs; regnum++) { if (*(gdbarch_register_name (gdbarch, regnum)) == '\0') continue; - if (register_changed_p (regnum, prev_regs.get (), - this_regs.get ())) + if (register_changed_p (regnum, prev_regs.get (), this_regs.get ())) uiout->field_signed (NULL, regnum); } } @@ -952,16 +940,14 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc) { regnum = atoi (argv[i]); - if (regnum >= 0 - && regnum < numregs + if (regnum >= 0 && regnum < numregs && *gdbarch_register_name (gdbarch, regnum) != '\000') { - if (register_changed_p (regnum, prev_regs.get (), - this_regs.get ())) + if (register_changed_p (regnum, prev_regs.get (), this_regs.get ())) uiout->field_signed (NULL, regnum); } else - error (_("bad register number")); + error (_ ("bad register number")); } } @@ -1010,15 +996,13 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) int i; int skip_unavailable = 0; int oind = 0; + enum opt { SKIP_UNAVAILABLE, }; - static const struct mi_opt opts[] = - { - {"-skip-unavailable", SKIP_UNAVAILABLE, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "-skip-unavailable", SKIP_UNAVAILABLE, 0 }, { 0, 0, 0 } }; /* Note that the test for a valid register must include checking the gdbarch_register_name because gdbarch_num_regs may be allocated @@ -1030,8 +1014,8 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) while (1) { char *oarg; - int opt = mi_getopt ("-data-list-register-values", argc, argv, - opts, &oind, &oarg); + int opt = mi_getopt ("-data-list-register-values", argc, argv, opts, + &oind, &oarg); if (opt < 0) break; @@ -1044,9 +1028,9 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) } if (argc - oind < 1) - error (_("-data-list-register-values: Usage: " - "-data-list-register-values [--skip-unavailable] <format>" - " [<regnum1>...<regnumN>]")); + error (_ ("-data-list-register-values: Usage: " + "-data-list-register-values [--skip-unavailable] <format>" + " [<regnum1>...<regnumN>]")); format = (int) argv[oind][0]; @@ -1059,9 +1043,7 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) if (argc - oind == 1) { /* No args, beside the format: do all the regs. */ - for (regnum = 0; - regnum < numregs; - regnum++) + for (regnum = 0; regnum < numregs; regnum++) { if (*(gdbarch_register_name (gdbarch, regnum)) == '\0') continue; @@ -1075,12 +1057,11 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) { regnum = atoi (argv[i]); - if (regnum >= 0 - && regnum < numregs + if (regnum >= 0 && regnum < numregs && *gdbarch_register_name (gdbarch, regnum) != '\000') output_register (frame, regnum, format, skip_unavailable); else - error (_("bad register number")); + error (_ ("bad register number")); } } @@ -1139,18 +1120,18 @@ mi_cmd_data_write_register_values (const char *command, char **argv, int argc) numregs = gdbarch_num_cooked_regs (gdbarch); if (argc == 0) - error (_("-data-write-register-values: Usage: -data-write-register-" - "values <format> [<regnum1> <value1>...<regnumN> <valueN>]")); + error (_ ("-data-write-register-values: Usage: -data-write-register-" + "values <format> [<regnum1> <value1>...<regnumN> <valueN>]")); if (!target_has_registers ()) - error (_("-data-write-register-values: No registers.")); + error (_ ("-data-write-register-values: No registers.")); if (!(argc - 1)) - error (_("-data-write-register-values: No regs and values specified.")); + error (_ ("-data-write-register-values: No regs and values specified.")); if ((argc - 1) % 2) - error (_("-data-write-register-values: " - "Regs and vals are not in pairs.")); + error (_ ("-data-write-register-values: " + "Regs and vals are not in pairs.")); for (i = 1; i < argc; i = i + 2) { @@ -1168,7 +1149,7 @@ mi_cmd_data_write_register_values (const char *command, char **argv, int argc) regcache_cooked_write_signed (regcache, regnum, value); } else - error (_("bad register number")); + error (_ ("bad register number")); } } @@ -1184,8 +1165,8 @@ mi_cmd_data_evaluate_expression (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (argc != 1) - error (_("-data-evaluate-expression: " - "Usage: -data-evaluate-expression expression")); + error (_ ("-data-evaluate-expression: " + "Usage: -data-evaluate-expression expression")); expression_up expr = parse_expression (argv[0]); @@ -1236,20 +1217,17 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) long offset = 0; int oind = 0; char *oarg; + enum opt { OFFSET_OPT }; - static const struct mi_opt opts[] = - { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "o", OFFSET_OPT, 1 }, { 0, 0, 0 } }; while (1) { - int opt = mi_getopt ("-data-read-memory", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-data-read-memory", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -1264,8 +1242,8 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) argc -= oind; if (argc < 5 || argc > 6) - error (_("-data-read-memory: Usage: " - "ADDR WORD-FORMAT WORD-SIZE NR-ROWS NR-COLS [ASCHAR].")); + error (_ ("-data-read-memory: Usage: " + "ADDR WORD-FORMAT WORD-SIZE NR-ROWS NR-COLS [ASCHAR].")); /* Extract all the arguments. */ @@ -1301,12 +1279,12 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) /* The number of rows. */ nr_rows = atol (argv[3]); if (nr_rows <= 0) - error (_("-data-read-memory: invalid number of rows.")); + error (_ ("-data-read-memory: invalid number of rows.")); /* Number of bytes per row. */ nr_cols = atol (argv[4]); if (nr_cols <= 0) - error (_("-data-read-memory: invalid number of columns.")); + error (_ ("-data-read-memory: invalid number of columns.")); /* The un-printable character when printing ascii. */ if (argc == 6) @@ -1319,11 +1297,11 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) gdb::byte_vector mbuf (total_bytes); - nr_bytes = target_read (current_inferior ()->top_target (), - TARGET_OBJECT_MEMORY, NULL, - mbuf.data (), addr, total_bytes); + nr_bytes + = target_read (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY, + NULL, mbuf.data (), addr, total_bytes); if (nr_bytes <= 0) - error (_("Unable to read memory.")); + error (_ ("Unable to read memory.")); /* Output the header information. */ uiout->field_core_addr ("addr", gdbarch, addr); @@ -1342,8 +1320,7 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) string_file stream; ui_out_emit_list list_emitter (uiout, "memory"); - for (row = 0, row_byte = 0; - row < nr_rows; + for (row = 0, row_byte = 0; row < nr_rows; row++, row_byte += nr_cols * word_size) { int col; @@ -1357,8 +1334,7 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) { ui_out_emit_list list_data_emitter (uiout, "data"); get_formatted_print_options (&print_opts, word_format); - for (col = 0, col_byte = row_byte; - col < nr_cols; + for (col = 0, col_byte = row_byte; col < nr_cols; col++, col_byte += word_size) { if (col_byte + word_size > nr_bytes) @@ -1380,8 +1356,8 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) int byte; stream.clear (); - for (byte = row_byte; - byte < row_byte + word_size * nr_cols; byte++) + for (byte = row_byte; byte < row_byte + word_size * nr_cols; + byte++) { if (byte >= nr_bytes) stream.putc ('X'); @@ -1407,20 +1383,17 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); int oind = 0; char *oarg; + enum opt { OFFSET_OPT }; - static const struct mi_opt opts[] = - { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "o", OFFSET_OPT, 1 }, { 0, 0, 0 } }; while (1) { - int opt = mi_getopt ("-data-read-memory-bytes", argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt ("-data-read-memory-bytes", argc, argv, opts, &oind, + &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -1434,7 +1407,7 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) argc -= oind; if (argc != 2) - error (_("Usage: [ -o OFFSET ] ADDR LENGTH.")); + error (_ ("Usage: [ -o OFFSET ] ADDR LENGTH.")); addr = parse_and_eval_address (argv[0]) + offset; length = atol (argv[1]); @@ -1443,7 +1416,7 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) = read_memory_robust (current_inferior ()->top_target (), addr, length); if (result.size () == 0) - error (_("Unable to read memory.")); + error (_ ("Unable to read memory.")); ui_out_emit_list list_emitter (uiout, "memory"); for (const memory_read_result &read_result : result) @@ -1454,9 +1427,9 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) uiout->field_core_addr ("offset", gdbarch, read_result.begin - addr); uiout->field_core_addr ("end", gdbarch, read_result.end); - std::string data = bin2hex (read_result.data.get (), - (read_result.end - read_result.begin) - * unit_size); + std::string data + = bin2hex (read_result.data.get (), + (read_result.end - read_result.begin) * unit_size); uiout->field_string ("contents", data); } } @@ -1491,20 +1464,17 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc) long offset = 0; int oind = 0; char *oarg; + enum opt { OFFSET_OPT }; - static const struct mi_opt opts[] = - { - {"o", OFFSET_OPT, 1}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] = { { "o", OFFSET_OPT, 1 }, { 0, 0, 0 } }; while (1) { - int opt = mi_getopt ("-data-write-memory", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-data-write-memory", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -1519,8 +1489,8 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc) argc -= oind; if (argc != 4) - error (_("-data-write-memory: Usage: " - "[-o COLUMN_OFFSET] ADDR FORMAT WORD-SIZE VALUE.")); + error (_ ("-data-write-memory: Usage: " + "[-o COLUMN_OFFSET] ADDR FORMAT WORD-SIZE VALUE.")); /* Extract all the arguments. */ /* Start address of the memory dump. */ @@ -1556,7 +1526,7 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc) int unit_size; if (argc != 2 && argc != 3) - error (_("Usage: ADDR DATA [COUNT].")); + error (_ ("Usage: ADDR DATA [COUNT].")); addr = parse_and_eval_address (argv[0]); cdata = argv[1]; @@ -1564,8 +1534,8 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc) unit_size = gdbarch_addressable_memory_unit_size (get_current_arch ()); if (len_hex % (unit_size * 2) != 0) - error (_("Hex-encoded '%s' must represent an integral number of " - "addressable memory units."), + error (_ ("Hex-encoded '%s' must represent an integral number of " + "addressable memory units."), cdata); len_bytes = len_hex / 2; @@ -1582,7 +1552,7 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc) { int x; if (sscanf (cdata + i * 2, "%02x", &x) != 1) - error (_("Invalid argument")); + error (_ ("Invalid argument")); databuf[i] = (gdb_byte) x; } @@ -1633,8 +1603,8 @@ mi_cmd_enable_timings (const char *command, char **argv, int argc) return; - usage_error: - error (_("-enable-timings: Usage: %s {yes|no}"), command); +usage_error: + error (_ ("-enable-timings: Usage: %s {yes|no}"), command); } void @@ -1663,7 +1633,7 @@ mi_cmd_list_features (const char *command, char **argv, int argc) return; } - error (_("-list-features should be passed no arguments")); + error (_ ("-list-features should be passed no arguments")); } void @@ -1681,7 +1651,7 @@ mi_cmd_list_target_features (const char *command, char **argv, int argc) return; } - error (_("-list-target-features should be passed no arguments")); + error (_ ("-list-target-features should be passed no arguments")); } void @@ -1691,14 +1661,13 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) /* Parse the command options. */ enum opt - { - NO_CONNECTION_OPT, - }; - static const struct mi_opt opts[] = - { - {"-no-connection", NO_CONNECTION_OPT, 0}, - {NULL, 0, 0}, - }; + { + NO_CONNECTION_OPT, + }; + static const struct mi_opt opts[] = { + { "-no-connection", NO_CONNECTION_OPT, 0 }, + { NULL, 0, 0 }, + }; int oind = 0; char *oarg; @@ -1721,8 +1690,7 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) inferior *inf = add_inferior_with_spaces (); - switch_to_inferior_and_push_target (inf, no_connection, - current_inferior ()); + switch_to_inferior_and_push_target (inf, no_connection, current_inferior ()); current_uiout->field_fmt ("inferior", "i%d", inf->num); @@ -1743,17 +1711,17 @@ mi_cmd_remove_inferior (const char *command, char **argv, int argc) struct inferior *inf_to_remove; if (argc != 1) - error (_("-remove-inferior should be passed a single argument")); + error (_ ("-remove-inferior should be passed a single argument")); if (sscanf (argv[0], "i%d", &id) != 1) - error (_("the thread group id is syntactically invalid")); + error (_ ("the thread group id is syntactically invalid")); inf_to_remove = find_inferior_id (id); if (inf_to_remove == NULL) - error (_("the specified thread group does not exist")); + error (_ ("the specified thread group does not exist")); if (inf_to_remove->pid != 0) - error (_("cannot remove an active inferior")); + error (_ ("cannot remove an active inferior")); if (inf_to_remove == current_inferior ()) { @@ -1767,7 +1735,7 @@ mi_cmd_remove_inferior (const char *command, char **argv, int argc) } if (new_inferior == NULL) - error (_("Cannot remove last inferior")); + error (_ ("Cannot remove last inferior")); set_current_inferior (new_inferior); if (new_inferior->pid != 0) @@ -1782,8 +1750,6 @@ mi_cmd_remove_inferior (const char *command, char **argv, int argc) delete_inferior (inf_to_remove); } - - /* Execute a command within a safe environment. Return <0 for error; >=0 for ok. @@ -1799,8 +1765,8 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) if (do_timings) current_command_ts = context->cmd_start; - scoped_restore save_token = make_scoped_restore (¤t_token, - context->token); + scoped_restore save_token + = make_scoped_restore (¤t_token, context->token); running_result_record_printed = 0; mi_proceeded = 0; @@ -1809,8 +1775,7 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) case MI_COMMAND: /* A MI command was read from the input stream. */ if (mi_debug_p) - gdb_printf (gdb_stdlog, - " token=`%s' command=`%s' args=`%s'\n", + gdb_printf (gdb_stdlog, " token=`%s' command=`%s' args=`%s'\n", context->token, context->command, context->args); mi_cmd_execute (context); @@ -1827,7 +1792,9 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) /* There's no particularly good reason why target-connect results in not ^done. Should kill ^connected for MI3. */ gdb_puts (strcmp (context->command, "target-select") == 0 - ? "^connected" : "^done", mi->raw_stdout); + ? "^connected" + : "^done", + mi->raw_stdout); mi_out_put (uiout, mi->raw_stdout); mi_out_rewind (uiout); mi_print_timing_maybe (mi->raw_stdout); @@ -1894,9 +1861,9 @@ mi_print_exception (const char *token, const struct gdb_exception &exception) switch (exception.error) { - case UNDEFINED_COMMAND_ERROR: - gdb_puts (",code=\"undefined-command\"", mi->raw_stdout); - break; + case UNDEFINED_COMMAND_ERROR: + gdb_puts (",code=\"undefined-command\"", mi->raw_stdout); + break; } gdb_puts ("\n", mi->raw_stdout); @@ -1955,7 +1922,6 @@ mi_execute_command (const char *cmd, int from_tty) } bpstat_do_actions (); - } } @@ -1995,14 +1961,15 @@ struct user_selected_context null_frame_id. As comparing null_frame_id with itself always reports not-equal, we only do the equality test if we have something other than the innermost frame selected. */ - if (current_frame_level != -1 - && current_frame_id != m_previous_frame_id) + if (current_frame_level != -1 && current_frame_id != m_previous_frame_id) return true; /* Nothing changed! */ return false; } + private: + /* The previously selected thread. This might be null_ptid if there was no previously selected thread. */ ptid_t m_previous_ptid; @@ -2020,16 +1987,16 @@ mi_cmd_execute (struct mi_parse *parse) scoped_value_mark cleanup = prepare_execute_command (); if (parse->all && parse->thread_group != -1) - error (_("Cannot specify --thread-group together with --all")); + error (_ ("Cannot specify --thread-group together with --all")); if (parse->all && parse->thread != -1) - error (_("Cannot specify --thread together with --all")); + error (_ ("Cannot specify --thread together with --all")); if (parse->thread_group != -1 && parse->thread != -1) - error (_("Cannot specify --thread together with --thread-group")); + error (_ ("Cannot specify --thread together with --thread-group")); if (parse->frame != -1 && parse->thread == -1) - error (_("Cannot specify --frame without --thread")); + error (_ ("Cannot specify --frame without --thread")); if (parse->thread_group != -1) { @@ -2037,7 +2004,7 @@ mi_cmd_execute (struct mi_parse *parse) struct thread_info *tp = 0; if (!inf) - error (_("Invalid thread group for the --thread-group option")); + error (_ ("Invalid thread group for the --thread-group option")); set_current_inferior (inf); /* This behaviour means that if --thread-group option identifies @@ -2062,10 +2029,10 @@ mi_cmd_execute (struct mi_parse *parse) thread_info *tp = find_thread_global_id (parse->thread); if (tp == NULL) - error (_("Invalid thread id: %d"), parse->thread); + error (_ ("Invalid thread id: %d"), parse->thread); if (tp->state == THREAD_EXITED) - error (_("Thread id: %d has terminated"), parse->thread); + error (_ ("Thread id: %d has terminated"), parse->thread); if (parse->cmd->preserve_user_selected_context ()) thread_saver.emplace (); @@ -2088,7 +2055,7 @@ mi_cmd_execute (struct mi_parse *parse) select_frame (fid); } else - error (_("Invalid frame id: %d"), frame); + error (_ ("Invalid frame id: %d"), frame); } gdb::optional<scoped_restore_current_language> lang_saver; @@ -2109,8 +2076,8 @@ mi_cmd_execute (struct mi_parse *parse) if (!parse->cmd->preserve_user_selected_context () && current_user_selected_context.has_changed ()) - gdb::observers::user_selected_context_changed.notify - (USER_SELECTED_THREAD | USER_SELECTED_FRAME); + gdb::observers::user_selected_context_changed.notify ( + USER_SELECTED_THREAD | USER_SELECTED_FRAME); } /* See mi-main.h. */ @@ -2128,10 +2095,9 @@ mi_execute_cli_command (const char *cmd, bool args_p, const char *args) gdb_assert (args == nullptr); if (mi_debug_p) - gdb_printf (gdb_stdlog, "cli=%s run=%s\n", - cmd, run.c_str ()); + gdb_printf (gdb_stdlog, "cli=%s run=%s\n", cmd, run.c_str ()); - execute_command (run.c_str (), 0 /* from_tty */ ); + execute_command (run.c_str (), 0 /* from_tty */); } } @@ -2145,14 +2111,12 @@ mi_execute_async_cli_command (const char *cli_command, char **argv, int argc) if (mi_async_p ()) run += "&"; - execute_command (run.c_str (), 0 /* from_tty */ ); + execute_command (run.c_str (), 0 /* from_tty */); } void -mi_load_progress (const char *section_name, - unsigned long sent_so_far, - unsigned long total_section, - unsigned long total_sent, +mi_load_progress (const char *section_name, unsigned long sent_so_far, + unsigned long total_section, unsigned long total_sent, unsigned long grand_total) { using namespace std::chrono; @@ -2172,8 +2136,8 @@ mi_load_progress (const char *section_name, scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout.get ()); - new_section = (previous_sect_name ? - strcmp (previous_sect_name, section_name) : 1); + new_section + = (previous_sect_name ? strcmp (previous_sect_name, section_name) : 1); if (new_section) { xfree (previous_sect_name); @@ -2251,10 +2215,9 @@ print_diff (struct ui_file *file, struct mi_timestamp *start, duration<double> utime = end->utime - start->utime; duration<double> stime = end->stime - start->stime; - gdb_printf - (file, - ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", - wallclock.count (), utime.count (), stime.count ()); + gdb_printf (file, + ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", + wallclock.count (), utime.count (), stime.count ()); } void @@ -2265,11 +2228,11 @@ mi_cmd_trace_define_variable (const char *command, char **argv, int argc) char *name = 0; if (argc != 1 && argc != 2) - error (_("Usage: -trace-define-variable VARIABLE [VALUE]")); + error (_ ("Usage: -trace-define-variable VARIABLE [VALUE]")); name = argv[0]; if (*name++ != '$') - error (_("Name of trace variable should start with '$'")); + error (_ ("Name of trace variable should start with '$'")); validate_trace_state_variable_name (name); @@ -2287,7 +2250,7 @@ void mi_cmd_trace_list_variables (const char *command, char **argv, int argc) { if (argc != 0) - error (_("-trace-list-variables: no arguments allowed")); + error (_ ("-trace-list-variables: no arguments allowed")); tvariables_info_1 (); } @@ -2298,7 +2261,7 @@ mi_cmd_trace_find (const char *command, char **argv, int argc) char *mode; if (argc == 0) - error (_("trace selection mode is required")); + error (_ ("trace selection mode is required")); mode = argv[0]; @@ -2313,56 +2276,55 @@ mi_cmd_trace_find (const char *command, char **argv, int argc) if (strcmp (mode, "frame-number") == 0) { if (argc != 2) - error (_("frame number is required")); + error (_ ("frame number is required")); tfind_1 (tfind_number, atoi (argv[1]), 0, 0, 0); } else if (strcmp (mode, "tracepoint-number") == 0) { if (argc != 2) - error (_("tracepoint number is required")); + error (_ ("tracepoint number is required")); tfind_1 (tfind_tp, atoi (argv[1]), 0, 0, 0); } else if (strcmp (mode, "pc") == 0) { if (argc != 2) - error (_("PC is required")); + error (_ ("PC is required")); tfind_1 (tfind_pc, 0, parse_and_eval_address (argv[1]), 0, 0); } else if (strcmp (mode, "pc-inside-range") == 0) { if (argc != 3) - error (_("Start and end PC are required")); + error (_ ("Start and end PC are required")); tfind_1 (tfind_range, 0, parse_and_eval_address (argv[1]), parse_and_eval_address (argv[2]), 0); } else if (strcmp (mode, "pc-outside-range") == 0) { if (argc != 3) - error (_("Start and end PC are required")); + error (_ ("Start and end PC are required")); tfind_1 (tfind_outside, 0, parse_and_eval_address (argv[1]), parse_and_eval_address (argv[2]), 0); } else if (strcmp (mode, "line") == 0) { if (argc != 2) - error (_("Line is required")); + error (_ ("Line is required")); std::vector<symtab_and_line> sals - = decode_line_with_current_source (argv[1], - DECODE_LINE_FUNFIRSTLINE); + = decode_line_with_current_source (argv[1], DECODE_LINE_FUNFIRSTLINE); const symtab_and_line &sal = sals[0]; if (sal.symtab == 0) - error (_("Could not find the specified line")); + error (_ ("Could not find the specified line")); CORE_ADDR start_pc, end_pc; if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc)) tfind_1 (tfind_range, 0, start_pc, end_pc - 1, 0); else - error (_("Could not find the specified line")); + error (_ ("Could not find the specified line")); } else - error (_("Invalid mode '%s'"), mode); + error (_ ("Invalid mode '%s'"), mode); if (has_stack_frames () || get_traceframe_number () >= 0) print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 1); @@ -2379,19 +2341,15 @@ mi_cmd_trace_save (const char *command, char **argv, int argc) enum opt { - TARGET_SAVE_OPT, CTF_OPT + TARGET_SAVE_OPT, + CTF_OPT }; - static const struct mi_opt opts[] = - { - {"r", TARGET_SAVE_OPT, 0}, - {"ctf", CTF_OPT, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "r", TARGET_SAVE_OPT, 0 }, { "ctf", CTF_OPT, 0 }, { 0, 0, 0 } }; while (1) { - int opt = mi_getopt ("-trace-save", argc, argv, opts, - &oind, &oarg); + int opt = mi_getopt ("-trace-save", argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -2407,8 +2365,8 @@ mi_cmd_trace_save (const char *command, char **argv, int argc) } if (argc - oind != 1) - error (_("Exactly one argument required " - "(file in which to save trace data)")); + error (_ ("Exactly one argument required " + "(file in which to save trace data)")); filename = argv[oind]; @@ -2443,7 +2401,7 @@ void mi_cmd_ada_task_info (const char *command, char **argv, int argc) { if (argc != 0 && argc != 1) - error (_("Invalid MI command")); + error (_ ("Invalid MI command")); print_ada_task_info (current_uiout, argv[0], current_inferior ()); } @@ -2477,8 +2435,7 @@ print_variable_or_computed (const char *expression, enum print_values values) type = check_typedef (value_type (val)); type_print (value_type (val), "", &stb, -1); uiout->field_stream ("type", stb); - if (type->code () != TYPE_CODE_ARRAY - && type->code () != TYPE_CODE_STRUCT + if (type->code () != TYPE_CODE_ARRAY && type->code () != TYPE_CODE_STRUCT && type->code () != TYPE_CODE_UNION) { struct value_print_options opts; @@ -2518,6 +2475,7 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) int registers_format = 'x'; int memory_contents = 0; struct ui_out *uiout = current_uiout; + enum opt { VAR_PRINT_VALUES, @@ -2525,20 +2483,18 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) REGISTERS_FORMAT, MEMORY_CONTENTS, }; - static const struct mi_opt opts[] = - { - {"-var-print-values", VAR_PRINT_VALUES, 1}, - {"-comp-print-values", COMP_PRINT_VALUES, 1}, - {"-registers-format", REGISTERS_FORMAT, 1}, - {"-memory-contents", MEMORY_CONTENTS, 0}, - { 0, 0, 0 } - }; + static const struct mi_opt opts[] + = { { "-var-print-values", VAR_PRINT_VALUES, 1 }, + { "-comp-print-values", COMP_PRINT_VALUES, 1 }, + { "-registers-format", REGISTERS_FORMAT, 1 }, + { "-memory-contents", MEMORY_CONTENTS, 0 }, + { 0, 0, 0 } }; while (1) { char *oarg; - int opt = mi_getopt ("-trace-frame-collected", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-trace-frame-collected", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -2559,11 +2515,11 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) } if (oind != argc) - error (_("Usage: -trace-frame-collected " - "[--var-print-values PRINT_VALUES] " - "[--comp-print-values PRINT_VALUES] " - "[--registers-format FORMAT]" - "[--memory-contents]")); + error (_ ("Usage: -trace-frame-collected " + "[--var-print-values PRINT_VALUES] " + "[--comp-print-values PRINT_VALUES] " + "[--registers-format FORMAT]" + "[--memory-contents]")); /* This throws an error is not inspecting a trace frame. */ tloc = get_traceframe_location (&stepping_frame); @@ -2647,8 +2603,9 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) { uiout->field_fmt ("name", "$%s", tsv->name.c_str ()); - tsv->value_known = target_get_trace_state_variable_value (tsv->number, - &tsv->value); + tsv->value_known + = target_get_trace_state_variable_value (tsv->number, + &tsv->value); uiout->field_signed ("current", tsv->value); } else @@ -2704,7 +2661,8 @@ mi_cmd_fix_multi_location_breakpoint_output (const char *command, char **argv, /* See mi/mi-main.h. */ void -mi_cmd_fix_breakpoint_script_output (const char *command, char **argv, int argc) +mi_cmd_fix_breakpoint_script_output (const char *command, char **argv, + int argc) { fix_breakpoint_script_output_globally = true; } @@ -2715,10 +2673,10 @@ void mi_cmd_complete (const char *command, char **argv, int argc) { if (argc != 1) - error (_("Usage: -complete COMMAND")); + error (_ ("Usage: -complete COMMAND")); if (max_completions == 0) - error (_("max-completions is zero, completion is disabled.")); + error (_ ("max-completions is zero, completion is disabled.")); int quote_char = '\0'; const char *word; @@ -2730,22 +2688,22 @@ mi_cmd_complete (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (result.number_matches > 0) - uiout->field_fmt ("completion", "%s%s", - arg_prefix.c_str (),result.match_list[0]); + uiout->field_fmt ("completion", "%s%s", arg_prefix.c_str (), + result.match_list[0]); { ui_out_emit_list completions_emitter (uiout, "matches"); if (result.number_matches == 1) - uiout->field_fmt (NULL, "%s%s", - arg_prefix.c_str (), result.match_list[0]); + uiout->field_fmt (NULL, "%s%s", arg_prefix.c_str (), + result.match_list[0]); else { result.sort_match_list (); for (size_t i = 0; i < result.number_matches; i++) { - uiout->field_fmt (NULL, "%s%s", - arg_prefix.c_str (), result.match_list[i + 1]); + uiout->field_fmt (NULL, "%s%s", arg_prefix.c_str (), + result.match_list[i + 1]); } } } @@ -2753,24 +2711,25 @@ mi_cmd_complete (const char *command, char **argv, int argc) result.number_matches == max_completions ? "1" : "0"); } - void _initialize_mi_main (); + void _initialize_mi_main () { set_show_commands mi_async_cmds - = add_setshow_boolean_cmd ("mi-async", class_run, - &mi_async_1, _("\ -Set whether MI asynchronous mode is enabled."), _("\ -Show whether MI asynchronous mode is enabled."), _("\ + = add_setshow_boolean_cmd ("mi-async", class_run, &mi_async_1, _ ("\ +Set whether MI asynchronous mode is enabled."), + _ ("\ +Show whether MI asynchronous mode is enabled."), + _ ("\ Tells GDB whether MI should be in asynchronous mode."), - set_mi_async_command, - show_mi_async_command, + set_mi_async_command, show_mi_async_command, &setlist, &showlist); /* Alias old "target-async" to "mi-async". */ cmd_list_element *set_target_async_cmd - = add_alias_cmd ("target-async", mi_async_cmds.set, class_run, 0, &setlist); + = add_alias_cmd ("target-async", mi_async_cmds.set, class_run, 0, + &setlist); deprecate_cmd (set_target_async_cmd, "set mi-async"); cmd_list_element *show_target_async_cmd diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h index ff1d4ed..b8dd448 100644 --- a/gdb/mi/mi-main.h +++ b/gdb/mi/mi-main.h @@ -69,7 +69,8 @@ extern void mi_execute_cli_command (const char *cmd, bool args_p, /* Implementation of -fix-multi-location-breakpoint-output. */ extern void mi_cmd_fix_multi_location_breakpoint_output (const char *command, - char **argv, int argc); + char **argv, + int argc); /* Implementation of -fix-breakpoint-script-output. */ diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 5ce24a3..3bc780c 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -32,8 +32,7 @@ /* Mark beginning of a table. */ void -mi_ui_out::do_table_begin (int nr_cols, int nr_rows, - const char *tblid) +mi_ui_out::do_table_begin (int nr_cols, int nr_rows, const char *tblid) { open (tblid, ui_out_type_tuple); do_field_signed (-1, -1, ui_left, "nr_rows", nr_rows); @@ -167,8 +166,8 @@ mi_ui_out::do_text (const char *string) } void -mi_ui_out::do_message (const ui_file_style &style, - const char *format, va_list args) +mi_ui_out::do_message (const ui_file_style &style, const char *format, + va_list args) { } @@ -181,7 +180,6 @@ mi_ui_out::do_wrap_hint (int indent) void mi_ui_out::do_flush () { - gdb_flush (m_streams.back ()); } @@ -225,7 +223,7 @@ mi_ui_out::open (const char *name, ui_out_type type) break; default: - internal_error (_("bad switch")); + internal_error (_ ("bad switch")); } } @@ -245,7 +243,7 @@ mi_ui_out::close (ui_out_type type) break; default: - internal_error (_("bad switch")); + internal_error (_ ("bad switch")); } m_suppress_field_separator = false; @@ -321,25 +319,23 @@ mi_ui_out::version () /* Constructor for an `mi_out_data' object. */ mi_ui_out::mi_ui_out (int mi_version) -: ui_out (make_flags (mi_version)), - m_suppress_field_separator (false), - m_suppress_output (false), - m_mi_version (mi_version) + : ui_out (make_flags (mi_version)), + m_suppress_field_separator (false), + m_suppress_output (false), + m_mi_version (mi_version) { string_file *stream = new string_file (); m_streams.push_back (stream); } -mi_ui_out::~mi_ui_out () -{ -} +mi_ui_out::~mi_ui_out () {} /* See mi/mi-out.h. */ mi_ui_out * mi_out_new (const char *mi_version) { - if (streq (mi_version, INTERP_MI4) || streq (mi_version, INTERP_MI)) + if (streq (mi_version, INTERP_MI4) || streq (mi_version, INTERP_MI)) return new mi_ui_out (4); if (streq (mi_version, INTERP_MI3)) diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h index b63492f..c60ee58 100644 --- a/gdb/mi/mi-out.h +++ b/gdb/mi/mi-out.h @@ -25,7 +25,6 @@ struct ui_out; struct ui_file; - class mi_ui_out : public ui_out { public: @@ -40,19 +39,16 @@ public: /* Return the version number of the current MI. */ int version (); - bool can_emit_style_escape () const override - { - return false; - } + bool can_emit_style_escape () const override { return false; } protected: - virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid) - override; + virtual void do_table_begin (int nbrofcols, int nr_rows, + const char *tblid) override; virtual void do_table_body () override; virtual void do_table_header (int width, ui_align align, - const std::string &col_name, - const std::string &col_hdr) override; + const std::string &col_name, + const std::string &col_hdr) override; virtual void do_table_end () override; virtual void do_begin (ui_out_type type, const char *id) override; @@ -60,32 +56,30 @@ protected: virtual void do_field_signed (int fldno, int width, ui_align align, const char *fldname, LONGEST value) override; virtual void do_field_unsigned (int fldno, int width, ui_align align, - const char *fldname, ULONGEST value) - override; + const char *fldname, + ULONGEST value) override; virtual void do_field_skip (int fldno, int width, ui_align align, - const char *fldname) override; + const char *fldname) override; virtual void do_field_string (int fldno, int width, ui_align align, const char *fldname, const char *string, const ui_file_style &style) override; virtual void do_field_fmt (int fldno, int width, ui_align align, const char *fldname, const ui_file_style &style, - const char *format, va_list args) - override ATTRIBUTE_PRINTF (7,0); + const char *format, va_list args) override + ATTRIBUTE_PRINTF (7, 0); virtual void do_spaces (int numspaces) override; virtual void do_text (const char *string) override; - virtual void do_message (const ui_file_style &style, - const char *format, va_list args) override - ATTRIBUTE_PRINTF (3,0); + virtual void do_message (const ui_file_style &style, const char *format, + va_list args) override ATTRIBUTE_PRINTF (3, 0); virtual void do_wrap_hint (int indent) override; virtual void do_flush () override; virtual void do_redirect (struct ui_file *outstream) override; - virtual bool do_is_mi_like_p () const override - { return true; } + virtual bool do_is_mi_like_p () const override { return true; } virtual void do_progress_start () override; - virtual void do_progress_notify (const std::string &, const char *, - double, double) override; + virtual void do_progress_notify (const std::string &, const char *, double, + double) override; virtual void do_progress_end () override; @@ -103,7 +97,8 @@ private: mi_progress_info () : state (progress_update::START) - {} + { + } }; /* Stack of progress info. */ diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c index e334968..97af3e2 100644 --- a/gdb/mi/mi-parse.c +++ b/gdb/mi/mi-parse.c @@ -42,40 +42,40 @@ mi_parse_escape (const char **string_ptr) switch (c) { - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int i = fromhex (c); - int count = 0; - - while (++count < 3) - { - c = (**string_ptr); - if (isdigit (c) && c != '8' && c != '9') - { - (*string_ptr)++; - i *= 8; - i += fromhex (c); - } - else - { - break; - } - } - return i; - } + case '\n': + return -2; + case 0: + (*string_ptr)--; + return 0; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + int i = fromhex (c); + int count = 0; + + while (++count < 3) + { + c = (**string_ptr); + if (isdigit (c) && c != '8' && c != '9') + { + (*string_ptr)++; + i *= 8; + i += fromhex (c); + } + else + { + break; + } + } + return i; + } case 'a': c = '\a'; @@ -180,7 +180,7 @@ mi_parse_argv (const char *args, struct mi_parse *parse) len++; } arg[len] = '\0'; - chp++; /* That closing quote. */ + chp++; /* That closing quote. */ break; } default: @@ -262,7 +262,7 @@ mi_parse (const char *cmd, char **token) /* Extract the command. */ { - const char *tmp = chp + 1; /* discard ``-'' */ + const char *tmp = chp + 1; /* discard ``-'' */ for (; *chp && !isspace (*chp); chp++) ; @@ -274,8 +274,8 @@ mi_parse (const char *cmd, char **token) /* Find the command in the MI table. */ parse->cmd = mi_cmd_lookup (parse->command); if (parse->cmd == NULL) - throw_error (UNDEFINED_COMMAND_ERROR, - _("Undefined MI command: %s"), parse->command); + throw_error (UNDEFINED_COMMAND_ERROR, _ ("Undefined MI command: %s"), + parse->command); /* Skip white space following the command. */ chp = skip_spaces (chp); @@ -314,10 +314,10 @@ mi_parse (const char *cmd, char **token) option = "--thread-group"; if (parse->thread_group != -1) - error (_("Duplicate '--thread-group' option")); + error (_ ("Duplicate '--thread-group' option")); chp += tgs; if (*chp != 'i') - error (_("Invalid thread group id")); + error (_ ("Invalid thread group id")); chp += 1; parse->thread_group = strtol (chp, &endp, 10); chp = endp; @@ -328,7 +328,7 @@ mi_parse (const char *cmd, char **token) option = "--thread"; if (parse->thread != -1) - error (_("Duplicate '--thread' option")); + error (_ ("Duplicate '--thread' option")); chp += ts; parse->thread = strtol (chp, &endp, 10); chp = endp; @@ -339,7 +339,7 @@ mi_parse (const char *cmd, char **token) option = "--frame"; if (parse->frame != -1) - error (_("Duplicate '--frame' option")); + error (_ ("Duplicate '--frame' option")); chp += fs; parse->frame = strtol (chp, &endp, 10); chp = endp; @@ -353,13 +353,13 @@ mi_parse (const char *cmd, char **token) parse->language = language_enum (lang_name.c_str ()); if (parse->language == language_unknown || parse->language == language_auto) - error (_("Invalid --language argument: %s"), lang_name.c_str ()); + error (_ ("Invalid --language argument: %s"), lang_name.c_str ()); } else break; if (*chp != '\0' && !isspace (*chp)) - error (_("Invalid value for the '%s' option"), option); + error (_ ("Invalid value for the '%s' option"), option); chp = skip_spaces (chp); } @@ -374,17 +374,14 @@ mi_parse (const char *cmd, char **token) enum print_values mi_parse_print_values (const char *name) { - if (strcmp (name, "0") == 0 - || strcmp (name, mi_no_values) == 0) - return PRINT_NO_VALUES; - else if (strcmp (name, "1") == 0 - || strcmp (name, mi_all_values) == 0) - return PRINT_ALL_VALUES; - else if (strcmp (name, "2") == 0 - || strcmp (name, mi_simple_values) == 0) - return PRINT_SIMPLE_VALUES; - else - error (_("Unknown value for PRINT_VALUES: must be: \ + if (strcmp (name, "0") == 0 || strcmp (name, mi_no_values) == 0) + return PRINT_NO_VALUES; + else if (strcmp (name, "1") == 0 || strcmp (name, mi_all_values) == 0) + return PRINT_ALL_VALUES; + else if (strcmp (name, "2") == 0 || strcmp (name, mi_simple_values) == 0) + return PRINT_SIMPLE_VALUES; + else + error (_ ("Unknown value for PRINT_VALUES: must be: \ 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), - mi_no_values, mi_all_values, mi_simple_values); + mi_no_values, mi_all_values, mi_simple_values); } diff --git a/gdb/mi/mi-parse.h b/gdb/mi/mi-parse.h index e347969..97353e3 100644 --- a/gdb/mi/mi-parse.h +++ b/gdb/mi/mi-parse.h @@ -22,7 +22,7 @@ #include "gdbsupport/run-time-clock.h" #include <chrono> -#include "mi-cmds.h" /* For enum print_values. */ +#include "mi-cmds.h" /* For enum print_values. */ /* MI parser */ @@ -35,34 +35,35 @@ struct mi_timestamp }; enum mi_command_type - { - MI_COMMAND, CLI_COMMAND - }; +{ + MI_COMMAND, + CLI_COMMAND +}; struct mi_parse - { - mi_parse (); - ~mi_parse (); - - DISABLE_COPY_AND_ASSIGN (mi_parse); - - enum mi_command_type op; - char *command; - char *token; - const struct mi_command *cmd; - struct mi_timestamp *cmd_start; - char *args; - char **argv; - int argc; - int all; - int thread_group; /* At present, the same as inferior number. */ - int thread; - int frame; - - /* The language that should be used to evaluate the MI command. +{ + mi_parse (); + ~mi_parse (); + + DISABLE_COPY_AND_ASSIGN (mi_parse); + + enum mi_command_type op; + char *command; + char *token; + const struct mi_command *cmd; + struct mi_timestamp *cmd_start; + char *args; + char **argv; + int argc; + int all; + int thread_group; /* At present, the same as inferior number. */ + int thread; + int frame; + + /* The language that should be used to evaluate the MI command. Ignored if set to language_unknown. */ - enum language language; - }; + enum language language; +}; /* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 16947da..c407437 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -38,13 +38,13 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; if (argc != 1) - error (_("-symbol-list-lines: Usage: SOURCE_FILENAME")); + error (_ ("-symbol-list-lines: Usage: SOURCE_FILENAME")); filename = argv[0]; s = lookup_symtab (filename); if (s == NULL) - error (_("-symbol-list-lines: Unknown source file name.")); + error (_ ("-symbol-list-lines: Unknown source file name.")); /* Now, dump the associated line table. The pc addresses are already sorted by increasing values in the symbol table, so no @@ -99,8 +99,7 @@ output_nondebug_symbol (ui_out *uiout, struct gdbarch *gdbarch = msymbol.objfile->arch (); ui_out_emit_tuple tuple_emitter (uiout, NULL); - uiout->field_core_addr ("address", gdbarch, - msymbol.value_address ()); + uiout->field_core_addr ("address", gdbarch, msymbol.value_address ()); uiout->field_string ("name", msymbol.minsym->print_name ()); } @@ -142,8 +141,7 @@ mi_symbol_info (enum search_domain kind, const char *name_regexp, ui_out_emit_list symbols_list_emitter (uiout, "symbols"); /* As long as we have debug symbols from this symtab... */ - for (; (i < symbols.size () - && symbols[i].msymbol.minsym == nullptr + for (; (i < symbols.size () && symbols[i].msymbol.minsym == nullptr && symbols[i].symbol->symtab () == symtab); ++i) { @@ -177,7 +175,7 @@ parse_max_results_option (char *arg) char *ptr = arg; long long val = strtoll (arg, &ptr, 10); if (arg == ptr || *ptr != '\0' || val > SIZE_MAX || val < 0) - error (_("invalid value for --max-results argument")); + error (_ ("invalid value for --max-results argument")); size_t max_results = (size_t) val; return max_results; @@ -195,17 +193,18 @@ mi_info_functions_or_variables (enum search_domain kind, char **argv, int argc) bool exclude_minsyms = true; enum opt - { - INCLUDE_NONDEBUG_OPT, TYPE_REGEXP_OPT, NAME_REGEXP_OPT, MAX_RESULTS_OPT - }; - static const struct mi_opt opts[] = { - {"-include-nondebug" , INCLUDE_NONDEBUG_OPT, 0}, - {"-type", TYPE_REGEXP_OPT, 1}, - {"-name", NAME_REGEXP_OPT, 1}, - {"-max-results", MAX_RESULTS_OPT, 1}, - { 0, 0, 0 } + INCLUDE_NONDEBUG_OPT, + TYPE_REGEXP_OPT, + NAME_REGEXP_OPT, + MAX_RESULTS_OPT }; + static const struct mi_opt opts[] + = { { "-include-nondebug", INCLUDE_NONDEBUG_OPT, 0 }, + { "-type", TYPE_REGEXP_OPT, 1 }, + { "-name", NAME_REGEXP_OPT, 1 }, + { "-max-results", MAX_RESULTS_OPT, 1 }, + { 0, 0, 0 } }; int oind = 0; char *oarg = nullptr; @@ -213,8 +212,8 @@ mi_info_functions_or_variables (enum search_domain kind, char **argv, int argc) while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) - ? "-symbol-info-functions" : "-symbol-info-variables"); + = ((kind == FUNCTIONS_DOMAIN) ? "-symbol-info-functions" + : "-symbol-info-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -240,16 +239,16 @@ mi_info_functions_or_variables (enum search_domain kind, char **argv, int argc) /* Type for an iterator over a vector of module_symbol_search results. */ typedef std::vector<module_symbol_search>::const_iterator - module_symbol_search_iterator; + module_symbol_search_iterator; /* Helper for mi_info_module_functions_or_variables. Display the results from ITER up to END or until we find a symbol that is in a different module, or in a different symtab than the first symbol we print. Update and return the new value for ITER. */ static module_symbol_search_iterator -output_module_symbols_in_single_module_and_file - (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) +output_module_symbols_in_single_module_and_file ( + struct ui_out *uiout, module_symbol_search_iterator iter, + const module_symbol_search_iterator end, enum search_domain kind) { /* The symbol for the module in which the first result resides. */ const symbol *first_module_symbol = iter->first.symbol; @@ -267,12 +266,10 @@ output_module_symbols_in_single_module_and_file /* Repeatedly output result symbols until either we run out of symbols, we change module, or we change symtab. */ - for (; (iter != end - && first_module_symbol == iter->first.symbol + for (; (iter != end && first_module_symbol == iter->first.symbol && first_symbtab == iter->second.symbol->symtab ()); ++iter) - output_debug_symbol (uiout, kind, iter->second.symbol, - iter->second.block); + output_debug_symbol (uiout, kind, iter->second.symbol, iter->second.block); return iter; } @@ -282,9 +279,9 @@ output_module_symbols_in_single_module_and_file module than the first symbol we print. Update and return the new value for ITER. */ static module_symbol_search_iterator -output_module_symbols_in_single_module - (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) +output_module_symbols_in_single_module ( + struct ui_out *uiout, module_symbol_search_iterator iter, + const module_symbol_search_iterator end, enum search_domain kind) { gdb_assert (iter->first.symbol != nullptr); gdb_assert (iter->second.symbol != nullptr); @@ -302,8 +299,8 @@ output_module_symbols_in_single_module print all results within a single file. We keep calling the output function until we change module. */ while (iter != end && first_module_symbol == iter->first.symbol) - iter = output_module_symbols_in_single_module_and_file (uiout, iter, - end, kind); + iter = output_module_symbols_in_single_module_and_file (uiout, iter, end, + kind); return iter; } @@ -312,8 +309,8 @@ output_module_symbols_in_single_module command line options passed to the MI command. */ static void -mi_info_module_functions_or_variables (enum search_domain kind, - char **argv, int argc) +mi_info_module_functions_or_variables (enum search_domain kind, char **argv, + int argc) { const char *module_regexp = nullptr; const char *regexp = nullptr; @@ -322,16 +319,15 @@ mi_info_module_functions_or_variables (enum search_domain kind, /* Process the command line options. */ enum opt - { - MODULE_REGEXP_OPT, TYPE_REGEXP_OPT, NAME_REGEXP_OPT - }; - static const struct mi_opt opts[] = { - {"-module", MODULE_REGEXP_OPT, 1}, - {"-type", TYPE_REGEXP_OPT, 1}, - {"-name", NAME_REGEXP_OPT, 1}, - { 0, 0, 0 } + MODULE_REGEXP_OPT, + TYPE_REGEXP_OPT, + NAME_REGEXP_OPT }; + static const struct mi_opt opts[] = { { "-module", MODULE_REGEXP_OPT, 1 }, + { "-type", TYPE_REGEXP_OPT, 1 }, + { "-name", NAME_REGEXP_OPT, 1 }, + { 0, 0, 0 } }; int oind = 0; char *oarg = nullptr; @@ -339,9 +335,8 @@ mi_info_module_functions_or_variables (enum search_domain kind, while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) - ? "-symbol-info-module-functions" - : "-symbol-info-module-variables"); + = ((kind == FUNCTIONS_DOMAIN) ? "-symbol-info-module-functions" + : "-symbol-info-module-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); if (opt < 0) break; @@ -410,23 +405,21 @@ mi_cmd_symbol_info_modules (const char *command, char **argv, int argc) const char *regexp = nullptr; enum opt - { - NAME_REGEXP_OPT, MAX_RESULTS_OPT - }; - static const struct mi_opt opts[] = { - {"-name", NAME_REGEXP_OPT, 1}, - {"-max-results", MAX_RESULTS_OPT, 1}, - { 0, 0, 0 } + NAME_REGEXP_OPT, + MAX_RESULTS_OPT }; + static const struct mi_opt opts[] = { { "-name", NAME_REGEXP_OPT, 1 }, + { "-max-results", MAX_RESULTS_OPT, 1 }, + { 0, 0, 0 } }; int oind = 0; char *oarg = nullptr; while (1) { - int opt = mi_getopt ("-symbol-info-modules", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-symbol-info-modules", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) @@ -452,23 +445,21 @@ mi_cmd_symbol_info_types (const char *command, char **argv, int argc) const char *regexp = nullptr; enum opt - { - NAME_REGEXP_OPT, MAX_RESULTS_OPT - }; - static const struct mi_opt opts[] = { - {"-name", NAME_REGEXP_OPT, 1}, - {"-max-results", MAX_RESULTS_OPT, 1}, - { 0, 0, 0 } + NAME_REGEXP_OPT, + MAX_RESULTS_OPT }; + static const struct mi_opt opts[] = { { "-name", NAME_REGEXP_OPT, 1 }, + { "-max-results", MAX_RESULTS_OPT, 1 }, + { 0, 0, 0 } }; int oind = 0; char *oarg = nullptr; while (true) { - int opt = mi_getopt ("-symbol-info-types", argc, argv, opts, - &oind, &oarg); + int opt + = mi_getopt ("-symbol-info-types", argc, argv, opts, &oind, &oarg); if (opt < 0) break; switch ((enum opt) opt) |