From: Tom Tromey Date: Fri, 10 May 2019 22:09:35 +0000 (-0600) Subject: Make MI commands const-correct X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9158e49a70386c3e883ad429d93fe31aa59c0918;p=binutils-gdb.git Make MI commands const-correct I've had this patch for a while now and figured I'd update it and send it. It changes MI commands to use a "const char * const" for their argv parameter. Regression tested on x86-64 Fedora 36. Acked-By: Simon Marchi --- diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index e5432d58990..48b58587488 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -97,7 +97,7 @@ setup_breakpoint_reporting (void) and return it. */ static std::string -mi_argv_to_format (char **argv, int argc) +mi_argv_to_format (const char *const *argv, int argc) { int i; std::string result; @@ -166,14 +166,15 @@ mi_argv_to_format (char **argv, int argc) If not, it will insert other type breakpoint. */ static void -mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) +mi_cmd_break_insert_1 (int dprintf, const char *command, + const char *const *argv, int argc) { const char *address = NULL; int hardware = 0; int temp_p = 0; int thread = -1; int ignore_count = 0; - char *condition = NULL; + const char *condition = NULL; int pending = 0; int enabled = 1; int tracepoint = 0; @@ -219,7 +220,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) /* Parse arguments. It could be -r or -h or -t, or ``--'' to denote the end of the option list. */ int oind = 0; - char *oarg; + const char *oarg; while (1) { @@ -373,7 +374,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) See the MI manual for the list of possible options. */ void -mi_cmd_break_insert (const char *command, char **argv, int argc) +mi_cmd_break_insert (const char *command, const char *const *argv, int argc) { mi_cmd_break_insert_1 (0, command, argv, argc); } @@ -382,7 +383,7 @@ mi_cmd_break_insert (const char *command, char **argv, int argc) See the MI manual for the list of possible options. */ void -mi_cmd_dprintf_insert (const char *command, char **argv, int argc) +mi_cmd_dprintf_insert (const char *command, const char *const *argv, int argc) { mi_cmd_break_insert_1 (1, command, argv, argc); } @@ -391,7 +392,8 @@ mi_cmd_dprintf_insert (const char *command, char **argv, int argc) See the MI manual for the list of options. */ void -mi_cmd_break_condition (const char *command, char **argv, int argc) +mi_cmd_break_condition (const char *command, const char *const *argv, + int argc) { enum option { @@ -406,7 +408,7 @@ mi_cmd_break_condition (const char *command, char **argv, int argc) /* Parse arguments. */ int oind = 0; - char *oarg; + const char *oarg; bool force_condition = false; while (true) @@ -451,7 +453,8 @@ enum wp_type }; void -mi_cmd_break_passcount (const char *command, char **argv, int argc) +mi_cmd_break_passcount (const char *command, const char *const *argv, + int argc) { int n; int p; @@ -482,9 +485,9 @@ mi_cmd_break_passcount (const char *command, char **argv, int argc) -break-watch -a --> insert an access wp. */ void -mi_cmd_break_watch (const char *command, char **argv, int argc) +mi_cmd_break_watch (const char *command, const char *const *argv, int argc) { - char *expr = NULL; + const char *expr = NULL; enum wp_type type = REG_WP; enum opt { @@ -499,7 +502,7 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) /* Parse arguments. */ int oind = 0; - char *oarg; + const char *oarg; while (1) { @@ -542,7 +545,7 @@ mi_cmd_break_watch (const char *command, char **argv, int argc) } void -mi_cmd_break_commands (const char *command, char **argv, int argc) +mi_cmd_break_commands (const char *command, const char *const *argv, int argc) { counted_command_line break_command; char *endptr; diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c index 082703740af..fdfbe2ed8b1 100644 --- a/gdb/mi/mi-cmd-catch.c +++ b/gdb/mi/mi-cmd-catch.c @@ -29,7 +29,7 @@ /* Handler for the -catch-assert command. */ void -mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) +mi_cmd_catch_assert (const char *cmd, const char *const *argv, int argc) { struct gdbarch *gdbarch = get_current_arch(); std::string condition; @@ -37,7 +37,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) int temp = 0; int oind = 0; - char *oarg; + const char *oarg; enum opt { @@ -86,7 +86,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) /* Handler for the -catch-exception command. */ void -mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) +mi_cmd_catch_exception (const char *cmd, const char *const *argv, int argc) { struct gdbarch *gdbarch = get_current_arch(); std::string condition; @@ -96,7 +96,7 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) enum ada_exception_catchpoint_kind ex_kind = ada_catch_exception; int oind = 0; - char *oarg; + const char *oarg; enum opt { @@ -160,7 +160,7 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) /* Handler for the -catch-handlers command. */ void -mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) +mi_cmd_catch_handlers (const char *cmd, const char *const *argv, int argc) { struct gdbarch *gdbarch = get_current_arch (); std::string condition; @@ -169,7 +169,7 @@ mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) int temp = 0; int oind = 0; - char *oarg; + const char *oarg; enum opt { @@ -224,13 +224,13 @@ mi_cmd_catch_handlers (const char *cmd, char *argv[], int argc) /* Common path for the -catch-load and -catch-unload. */ static void -mi_catch_load_unload (int load, char *argv[], int argc) +mi_catch_load_unload (int load, const char *const *argv, int argc) { const char *actual_cmd = load ? "-catch-load" : "-catch-unload"; int temp = 0; int enabled = 1; int oind = 0; - char *oarg; + const char *oarg; enum opt { OPT_TEMP, @@ -274,7 +274,7 @@ mi_catch_load_unload (int load, char *argv[], int argc) /* Handler for the -catch-load. */ void -mi_cmd_catch_load (const char *cmd, char *argv[], int argc) +mi_cmd_catch_load (const char *cmd, const char *const *argv, int argc) { mi_catch_load_unload (1, argv, argc); } @@ -283,7 +283,7 @@ mi_cmd_catch_load (const char *cmd, char *argv[], int argc) /* Handler for the -catch-unload. */ void -mi_cmd_catch_unload (const char *cmd, char *argv[], int argc) +mi_cmd_catch_unload (const char *cmd, const char *const *argv, int argc) { mi_catch_load_unload (0, argv, argc); } @@ -294,12 +294,13 @@ mi_cmd_catch_unload (const char *cmd, char *argv[], int argc) static void mi_cmd_catch_exception_event (enum exception_event_kind kind, - const char *cmd, char *argv[], int argc) + const char *cmd, const char *const *argv, + int argc) { - char *regex = NULL; + const char *regex = NULL; bool temp = false; int oind = 0; - char *oarg; + const char *oarg; enum opt { OPT_TEMP, @@ -338,7 +339,7 @@ mi_cmd_catch_exception_event (enum exception_event_kind kind, /* Handler for -catch-throw. */ void -mi_cmd_catch_throw (const char *cmd, char *argv[], int argc) +mi_cmd_catch_throw (const char *cmd, const char *const *argv, int argc) { mi_cmd_catch_exception_event (EX_EVENT_THROW, cmd, argv, argc); } @@ -346,7 +347,7 @@ mi_cmd_catch_throw (const char *cmd, char *argv[], int argc) /* Handler for -catch-rethrow. */ void -mi_cmd_catch_rethrow (const char *cmd, char *argv[], int argc) +mi_cmd_catch_rethrow (const char *cmd, const char *const *argv, int argc) { mi_cmd_catch_exception_event (EX_EVENT_RETHROW, cmd, argv, argc); } @@ -354,7 +355,7 @@ mi_cmd_catch_rethrow (const char *cmd, char *argv[], int argc) /* Handler for -catch-catch. */ void -mi_cmd_catch_catch (const char *cmd, char *argv[], int argc) +mi_cmd_catch_catch (const char *cmd, const char *const *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 fcda4a08918..849c2925d2e 100644 --- a/gdb/mi/mi-cmd-disas.c +++ b/gdb/mi/mi-cmd-disas.c @@ -51,7 +51,7 @@ 5 -- disassembly, source (pc-centric) and opcodes. */ void -mi_cmd_disassemble (const char *command, char **argv, int argc) +mi_cmd_disassemble (const char *command, const char *const *argv, int argc) { struct gdbarch *gdbarch = get_current_arch (); struct ui_out *uiout = current_uiout; @@ -72,7 +72,7 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) bool source_seen = false; /* ... and their corresponding value. */ - char *file_string = NULL; + const char *file_string = NULL; int line_num = -1; int how_many = -1; CORE_ADDR low = 0; @@ -91,7 +91,7 @@ mi_cmd_disassemble (const char *command, char **argv, int argc) /* Options processing stuff. */ int oind = 0; - char *oarg; + const char *oarg; enum opt { FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT, ADDR_OPT, OPCODES_OPT, diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c index 454f89503af..9259df0363a 100644 --- a/gdb/mi/mi-cmd-env.c +++ b/gdb/mi/mi-cmd-env.c @@ -58,7 +58,7 @@ env_execute_cli_command (const char *cmd, const char *args) /* Print working directory. */ void -mi_cmd_env_pwd (const char *command, char **argv, int argc) +mi_cmd_env_pwd (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; @@ -76,7 +76,7 @@ mi_cmd_env_pwd (const char *command, char **argv, int argc) /* Change working directory. */ void -mi_cmd_env_cd (const char *command, char **argv, int argc) +mi_cmd_env_cd (const char *command, const char *const *argv, int argc) { if (argc == 0 || argc > 1) error (_("-environment-cd: Usage DIRECTORY")); @@ -98,14 +98,14 @@ env_mod_path (const char *dirname, std::string &which_path) /* Add one or more directories to start of executable search path. */ void -mi_cmd_env_path (const char *command, char **argv, int argc) +mi_cmd_env_path (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; const char *env; int reset = 0; int oind = 0; int i; - char *oarg; + const char *oarg; enum opt { RESET_OPT @@ -164,13 +164,13 @@ mi_cmd_env_path (const char *command, char **argv, int argc) /* Add zero or more directories to the front of the source path. */ void -mi_cmd_env_dir (const char *command, char **argv, int argc) +mi_cmd_env_dir (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; int i; int oind = 0; int reset = 0; - char *oarg; + const char *oarg; enum opt { RESET_OPT @@ -216,7 +216,8 @@ mi_cmd_env_dir (const char *command, char **argv, int argc) /* Set the inferior terminal device name. */ void -mi_cmd_inferior_tty_set (const char *command, char **argv, int argc) +mi_cmd_inferior_tty_set (const char *command, const char *const *argv, + int argc) { if (argc > 0) current_inferior ()->set_tty (argv[0]); @@ -227,7 +228,8 @@ mi_cmd_inferior_tty_set (const char *command, char **argv, int argc) /* Print the inferior terminal device name. */ void -mi_cmd_inferior_tty_show (const char *command, char **argv, int argc) +mi_cmd_inferior_tty_show (const char *command, const char *const *argv, + int argc) { if ( !mi_valid_noargs ("-inferior-tty-show", argc, argv)) error (_("-inferior-tty-show: Usage: No args")); diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index 70c0a785f8f..0883cb6f978 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -34,7 +34,8 @@ current file being executed. */ void -mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc) +mi_cmd_file_list_exec_source_file (const char *command, + const char *const *argv, int argc) { struct symtab_and_line st; struct ui_out *uiout = current_uiout; @@ -65,7 +66,8 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc) /* Implement -file-list-exec-source-files command. */ void -mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) +mi_cmd_file_list_exec_source_files (const char *command, + const char *const *argv, int argc) { enum opt { @@ -83,7 +85,7 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) /* Parse arguments. */ int oind = 0; - char *oarg; + const char *oarg; bool group_by_objfile = false; bool match_on_basename = false; @@ -131,7 +133,8 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) /* See mi-cmds.h. */ void -mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) +mi_cmd_file_list_shared_libraries (const char *command, + const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; const char *pattern; diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c index 2ddf2df8d0b..c93d9f38eef 100644 --- a/gdb/mi/mi-cmd-info.c +++ b/gdb/mi/mi-cmd-info.c @@ -25,11 +25,12 @@ /* Implement the "-info-ada-exceptions" GDB/MI command. */ void -mi_cmd_info_ada_exceptions (const char *command, char **argv, int argc) +mi_cmd_info_ada_exceptions (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; struct gdbarch *gdbarch = get_current_arch (); - char *regexp; + const char *regexp; switch (argc) { @@ -64,7 +65,8 @@ mi_cmd_info_ada_exceptions (const char *command, char **argv, int argc) /* Implement the "-info-gdb-mi-command" GDB/MI command. */ void -mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc) +mi_cmd_info_gdb_mi_command (const char *command, const char *const *argv, + int argc) { const char *cmd_name; mi_command *cmd; @@ -89,7 +91,7 @@ mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc) } void -mi_cmd_info_os (const char *command, char **argv, int argc) +mi_cmd_info_os (const char *command, const char *const *argv, int argc) { switch (argc) { diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 0172bf9814d..e473be7d465 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -51,7 +51,8 @@ static void list_args_or_locals (const frame_print_options &fp_opts, static int frame_filters = 0; void -mi_cmd_enable_frame_filters (const char *command, char **argv, int argc) +mi_cmd_enable_frame_filters (const char *command, const char *const *argv, + int argc) { if (argc != 0) error (_("-enable-frame-filters: no arguments allowed")); @@ -82,7 +83,8 @@ mi_apply_ext_lang_frame_filter (frame_info_ptr frame, displayed. */ void -mi_cmd_stack_list_frames (const char *command, char **argv, int argc) +mi_cmd_stack_list_frames (const char *command, const char *const *argv, + int argc) { int frame_low; int frame_high; @@ -105,7 +107,7 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) --no-frame-filters. */ while (1) { - char *oarg; + const char *oarg; int opt = mi_getopt ("-stack-list-frames", argc, argv, opts, &oind, &oarg); if (opt < 0) @@ -185,7 +187,8 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) } void -mi_cmd_stack_info_depth (const char *command, char **argv, int argc) +mi_cmd_stack_info_depth (const char *command, const char *const *argv, + int argc) { int frame_high; int i; @@ -214,7 +217,8 @@ mi_cmd_stack_info_depth (const char *command, char **argv, int argc) values. */ void -mi_cmd_stack_list_locals (const char *command, char **argv, int argc) +mi_cmd_stack_list_locals (const char *command, const char *const *argv, + int argc) { frame_info_ptr frame; int raw_arg = 0; @@ -239,7 +243,7 @@ mi_cmd_stack_list_locals (const char *command, char **argv, int argc) while (1) { - char *oarg; + const char *oarg; /* Don't parse 'print-values' as an option. */ int opt = mi_getopt ("-stack-list-locals", argc - 1, argv, opts, &oind, &oarg); @@ -290,7 +294,7 @@ mi_cmd_stack_list_locals (const char *command, char **argv, int argc) values. */ void -mi_cmd_stack_list_args (const char *command, char **argv, int argc) +mi_cmd_stack_list_args (const char *command, const char *const *argv, int argc) { int frame_low; int frame_high; @@ -316,7 +320,7 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) while (1) { - char *oarg; + const char *oarg; int opt = mi_getopt_allow_unknown ("-stack-list-args", argc, argv, opts, &oind, &oarg); @@ -406,7 +410,8 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) parse_print_value for possible values. */ void -mi_cmd_stack_list_variables (const char *command, char **argv, int argc) +mi_cmd_stack_list_variables (const char *command, const char *const *argv, + int argc) { frame_info_ptr frame; int raw_arg = 0; @@ -431,7 +436,7 @@ mi_cmd_stack_list_variables (const char *command, char **argv, int argc) while (1) { - char *oarg; + const char *oarg; /* Don't parse 'print-values' as an option. */ int opt = mi_getopt ("-stack-list-variables", argc - 1, argv, opts, &oind, &oarg); @@ -746,7 +751,8 @@ parse_frame_specification (const char *frame_exp) /* Implement the -stack-select-frame MI command. */ void -mi_cmd_stack_select_frame (const char *command, char **argv, int argc) +mi_cmd_stack_select_frame (const char *command, const char *const *argv, + int argc) { if (argc == 0 || argc > 1) error (_("-stack-select-frame: Usage: FRAME_SPEC")); @@ -754,7 +760,8 @@ mi_cmd_stack_select_frame (const char *command, char **argv, int argc) } void -mi_cmd_stack_info_frame (const char *command, char **argv, int argc) +mi_cmd_stack_info_frame (const char *command, const char *const *argv, + int argc) { if (argc > 0) error (_("-stack-info-frame: No arguments allowed")); diff --git a/gdb/mi/mi-cmd-target.c b/gdb/mi/mi-cmd-target.c index d0d2ba5c652..22d34d9967a 100644 --- a/gdb/mi/mi-cmd-target.c +++ b/gdb/mi/mi-cmd-target.c @@ -24,10 +24,10 @@ /* Get a file from the target. */ void -mi_cmd_target_file_get (const char *command, char **argv, int argc) +mi_cmd_target_file_get (const char *command, const char *const *argv, int argc) { int oind = 0; - char *oarg; + const char *oarg; const char *remote_file, *local_file; static const struct mi_opt opts[] = { @@ -48,10 +48,10 @@ mi_cmd_target_file_get (const char *command, char **argv, int argc) /* Send a file to the target. */ void -mi_cmd_target_file_put (const char *command, char **argv, int argc) +mi_cmd_target_file_put (const char *command, const char *const *argv, int argc) { int oind = 0; - char *oarg; + const char *oarg; const char *remote_file, *local_file; static const struct mi_opt opts[] = { @@ -72,10 +72,11 @@ mi_cmd_target_file_put (const char *command, char **argv, int argc) /* Delete a file on the target. */ void -mi_cmd_target_file_delete (const char *command, char **argv, int argc) +mi_cmd_target_file_delete (const char *command, const char *const *argv, + int argc) { int oind = 0; - char *oarg; + const char *oarg; const char *remote_file; static const struct mi_opt opts[] = { diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 36eea4619a7..095790a36c4 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -89,13 +89,13 @@ print_varobj (struct varobj *var, enum print_values print_values, /* VAROBJ operations */ void -mi_cmd_var_create (const char *command, char **argv, int argc) +mi_cmd_var_create (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; CORE_ADDR frameaddr = 0; struct varobj *var; - char *frame; - char *expr; + const char *frame; + const char *expr; enum varobj_type var_type; if (argc != 3) @@ -140,9 +140,9 @@ mi_cmd_var_create (const char *command, char **argv, int argc) } void -mi_cmd_var_delete (const char *command, char **argv, int argc) +mi_cmd_var_delete (const char *command, const char *const *argv, int argc) { - char *name; + const char *name; struct varobj *var; int numdel; int children_only_p = 0; @@ -214,7 +214,7 @@ mi_parse_format (const char *arg) } void -mi_cmd_var_set_format (const char *command, char **argv, int argc) +mi_cmd_var_set_format (const char *command, const char *const *argv, int argc) { enum varobj_display_formats format; struct varobj *var; @@ -240,7 +240,8 @@ mi_cmd_var_set_format (const char *command, char **argv, int argc) } void -mi_cmd_var_set_visualizer (const char *command, char **argv, int argc) +mi_cmd_var_set_visualizer (const char *command, const char *const *argv, + int argc) { struct varobj *var; @@ -256,7 +257,7 @@ mi_cmd_var_set_visualizer (const char *command, char **argv, int argc) } void -mi_cmd_var_set_frozen (const char *command, char **argv, int argc) +mi_cmd_var_set_frozen (const char *command, const char *const *argv, int argc) { struct varobj *var; bool frozen; @@ -281,7 +282,7 @@ mi_cmd_var_set_frozen (const char *command, char **argv, int argc) } void -mi_cmd_var_show_format (const char *command, char **argv, int argc) +mi_cmd_var_show_format (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; enum varobj_display_formats format; @@ -300,7 +301,8 @@ mi_cmd_var_show_format (const char *command, char **argv, int argc) } void -mi_cmd_var_info_num_children (const char *command, char **argv, int argc) +mi_cmd_var_info_num_children (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -360,7 +362,8 @@ mi_simple_type_p (struct type *type) } void -mi_cmd_var_list_children (const char *command, char **argv, int argc) +mi_cmd_var_list_children (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -416,7 +419,7 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc) } void -mi_cmd_var_info_type (const char *command, char **argv, int argc) +mi_cmd_var_info_type (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -432,7 +435,8 @@ mi_cmd_var_info_type (const char *command, char **argv, int argc) } void -mi_cmd_var_info_path_expression (const char *command, char **argv, int argc) +mi_cmd_var_info_path_expression (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -449,7 +453,8 @@ mi_cmd_var_info_path_expression (const char *command, char **argv, int argc) } void -mi_cmd_var_info_expression (const char *command, char **argv, int argc) +mi_cmd_var_info_expression (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; const struct language_defn *lang; @@ -470,7 +475,8 @@ mi_cmd_var_info_expression (const char *command, char **argv, int argc) } void -mi_cmd_var_show_attributes (const char *command, char **argv, int argc) +mi_cmd_var_show_attributes (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; int attr; @@ -494,7 +500,8 @@ mi_cmd_var_show_attributes (const char *command, char **argv, int argc) } void -mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) +mi_cmd_var_evaluate_expression (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -502,7 +509,7 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) enum varobj_display_formats format; int formatFound; int oind; - char *oarg; + const char *oarg; enum opt { @@ -561,7 +568,7 @@ mi_cmd_var_evaluate_expression (const char *command, char **argv, int argc) } void -mi_cmd_var_assign (const char *command, char **argv, int argc) +mi_cmd_var_assign (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; struct varobj *var; @@ -619,10 +626,10 @@ mi_cmd_var_update_iter (struct varobj *var, bool only_floating, } void -mi_cmd_var_update (const char *command, char **argv, int argc) +mi_cmd_var_update (const char *command, const char *const *argv, int argc) { struct ui_out *uiout = current_uiout; - char *name; + const char *name; enum print_values print_values; if (argc != 1 && argc != 2) @@ -741,7 +748,8 @@ varobj_update_one (struct varobj *var, enum print_values print_values, } void -mi_cmd_enable_pretty_printing (const char *command, char **argv, int argc) +mi_cmd_enable_pretty_printing (const char *command, const char *const *argv, + int argc) { if (argc != 0) error (_("-enable-pretty-printing: no arguments allowed")); @@ -750,7 +758,8 @@ mi_cmd_enable_pretty_printing (const char *command, char **argv, int argc) } void -mi_cmd_var_set_update_range (const char *command, char **argv, int argc) +mi_cmd_var_set_update_range (const char *command, const char *const *argv, + int argc) { struct varobj *var; int from, to; diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index c62b134fe3d..e67c486a997 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -32,7 +32,8 @@ enum print_values { PRINT_SIMPLE_VALUES }; -typedef void (mi_cmd_argv_ftype) (const char *command, char **argv, int argc); +typedef void (mi_cmd_argv_ftype) (const char *command, const char *const *argv, + int argc); /* Declarations of the functions implementing each command. */ diff --git a/gdb/mi/mi-getopt.c b/gdb/mi/mi-getopt.c index 2fc26485650..94a25443f0f 100644 --- a/gdb/mi/mi-getopt.c +++ b/gdb/mi/mi-getopt.c @@ -24,11 +24,11 @@ throw an error, otherwise return -1. */ static int -mi_getopt_1 (const char *prefix, int argc, char **argv, - const struct mi_opt *opts, int *oind, char **oarg, +mi_getopt_1 (const char *prefix, int argc, const char *const *argv, + const struct mi_opt *opts, int *oind, const char **oarg, int error_on_unknown) { - char *arg; + const char *arg; const struct mi_opt *opt; /* We assume that argv/argc are ok. */ @@ -80,25 +80,27 @@ mi_getopt_1 (const char *prefix, int argc, char **argv, int mi_getopt (const char *prefix, - int argc, char **argv, + int argc, const char *const *argv, const struct mi_opt *opts, - int *oind, char **oarg) + int *oind, const char **oarg) { return mi_getopt_1 (prefix, argc, argv, opts, oind, oarg, 1); } int -mi_getopt_allow_unknown (const char *prefix, int argc, char **argv, - const struct mi_opt *opts, int *oind, char **oarg) +mi_getopt_allow_unknown (const char *prefix, int argc, + const char *const *argv, + const struct mi_opt *opts, int *oind, + const char **oarg) { return mi_getopt_1 (prefix, argc, argv, opts, oind, oarg, 0); } int -mi_valid_noargs (const char *prefix, int argc, char **argv) +mi_valid_noargs (const char *prefix, int argc, const char *const *argv) { int oind = 0; - char *oarg; + const char *oarg; static const struct mi_opt opts[] = { { 0, 0, 0 } diff --git a/gdb/mi/mi-getopt.h b/gdb/mi/mi-getopt.h index e418ae99da2..13fefd6f4d6 100644 --- a/gdb/mi/mi-getopt.h +++ b/gdb/mi/mi-getopt.h @@ -50,11 +50,13 @@ struct mi_opt ``error("%s: Unknown option %c", prefix, option)'' while mi_getopt_allow_unknown returns -1. */ -extern int mi_getopt (const char *prefix, int argc, char **argv, - const struct mi_opt *opt, int *optind, char **optarg); +extern int mi_getopt (const char *prefix, int argc, const char *const *argv, + const struct mi_opt *opt, int *optind, + const char **optarg); extern int mi_getopt_allow_unknown (const char *prefix, int argc, - char **argv, const struct mi_opt *opts, - int *oind, char **oarg); + const char *const *argv, + const struct mi_opt *opts, + int *oind, const 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 @@ -73,6 +75,7 @@ extern int mi_getopt_allow_unknown (const char *prefix, int argc, for an MI function that takes no arguments. Otherwise, it returns 0 and the appropriate error message is displayed by mi_getopt. */ -extern int mi_valid_noargs (const char *prefix, int argc, char **argv); +extern int mi_valid_noargs (const char *prefix, int argc, + const char *const *argv); #endif /* MI_MI_GETOPT_H */ diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index ad33a21374a..47aeabd8f00 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -205,7 +205,8 @@ mi_interp::exec (const char *command) } void -mi_cmd_interpreter_exec (const char *command, char **argv, int argc) +mi_cmd_interpreter_exec (const char *command, const char *const *argv, + int argc) { struct interp *interp_to_use; int i; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index f3b7490e089..7a8c35c8c49 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -93,7 +93,7 @@ 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); + const char *const *argv, int argc); static bool register_changed_p (int regnum, readonly_detached_regcache *, readonly_detached_regcache *); static void output_register (frame_info_ptr, int regnum, int format, @@ -148,7 +148,7 @@ static void print_diff (struct ui_file *file, struct mi_timestamp *start, struct mi_timestamp *end); void -mi_cmd_gdb_exit (const char *command, char **argv, int argc) +mi_cmd_gdb_exit (const char *command, const char *const *argv, int argc) { struct mi_interp *mi = (struct mi_interp *) current_interpreter (); @@ -163,7 +163,7 @@ mi_cmd_gdb_exit (const char *command, char **argv, int argc) } void -mi_cmd_exec_next (const char *command, char **argv, int argc) +mi_cmd_exec_next (const char *command, const char *const *argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ if (argc > 0 && strcmp(argv[0], "--reverse") == 0) @@ -173,7 +173,8 @@ mi_cmd_exec_next (const char *command, char **argv, int argc) } void -mi_cmd_exec_next_instruction (const char *command, char **argv, int argc) +mi_cmd_exec_next_instruction (const char *command, const char *const *argv, + int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ if (argc > 0 && strcmp(argv[0], "--reverse") == 0) @@ -183,7 +184,7 @@ mi_cmd_exec_next_instruction (const char *command, char **argv, int argc) } void -mi_cmd_exec_step (const char *command, char **argv, int argc) +mi_cmd_exec_step (const char *command, const char *const *argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ if (argc > 0 && strcmp(argv[0], "--reverse") == 0) @@ -193,7 +194,8 @@ mi_cmd_exec_step (const char *command, char **argv, int argc) } void -mi_cmd_exec_step_instruction (const char *command, char **argv, int argc) +mi_cmd_exec_step_instruction (const char *command, const char *const *argv, + int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ if (argc > 0 && strcmp(argv[0], "--reverse") == 0) @@ -203,7 +205,7 @@ mi_cmd_exec_step_instruction (const char *command, char **argv, int argc) } void -mi_cmd_exec_finish (const char *command, char **argv, int argc) +mi_cmd_exec_finish (const char *command, const char *const *argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ if (argc > 0 && strcmp(argv[0], "--reverse") == 0) @@ -213,7 +215,7 @@ mi_cmd_exec_finish (const char *command, char **argv, int argc) } void -mi_cmd_exec_return (const char *command, char **argv, int argc) +mi_cmd_exec_return (const char *command, const char *const *argv, int argc) { /* This command doesn't really execute the target, it just pops the specified number of frames. */ @@ -232,7 +234,7 @@ mi_cmd_exec_return (const char *command, char **argv, int argc) } void -mi_cmd_exec_jump (const char *args, char **argv, int argc) +mi_cmd_exec_jump (const char *args, const char *const *argv, int argc) { /* FIXME: Should call a libgdb function, not a cli wrapper. */ mi_execute_async_cli_command ("jump", argv, argc); @@ -262,7 +264,7 @@ proceed_thread_callback (struct thread_info *thread, void *arg) } static void -exec_continue (char **argv, int argc) +exec_continue (const char *const *argv, int argc) { prepare_execution_command (current_inferior ()->top_target (), mi_async_p ()); @@ -319,7 +321,7 @@ exec_continue (char **argv, int argc) } static void -exec_reverse_continue (char **argv, int argc) +exec_reverse_continue (const char *const *argv, int argc) { enum exec_direction_kind dir = execution_direction; @@ -335,7 +337,7 @@ exec_reverse_continue (char **argv, int argc) } void -mi_cmd_exec_continue (const char *command, char **argv, int argc) +mi_cmd_exec_continue (const char *command, const char *const *argv, int argc) { if (argc > 0 && strcmp (argv[0], "--reverse") == 0) exec_reverse_continue (argv + 1, argc - 1); @@ -365,7 +367,7 @@ interrupt_thread_callback (struct thread_info *thread, void *arg) mi_cmd_execute. */ void -mi_cmd_exec_interrupt (const char *command, char **argv, int argc) +mi_cmd_exec_interrupt (const char *command, const char *const *argv, int argc) { /* In all-stop mode, everything stops, so we don't need to try anything specific. */ @@ -425,7 +427,7 @@ run_one_inferior (inferior *inf, bool start_p) } void -mi_cmd_exec_run (const char *command, char **argv, int argc) +mi_cmd_exec_run (const char *command, const char *const *argv, int argc) { int start_p = 0; @@ -441,7 +443,7 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) }; int oind = 0; - char *oarg; + const char *oarg; while (1) { @@ -493,7 +495,7 @@ find_thread_of_process (struct thread_info *ti, void *p) } void -mi_cmd_target_detach (const char *command, char **argv, int argc) +mi_cmd_target_detach (const char *command, const char *const *argv, int argc) { if (argc != 0 && argc != 1) error (_("Usage: -target-detach [pid | thread-group]")); @@ -501,7 +503,7 @@ mi_cmd_target_detach (const char *command, char **argv, int argc) if (argc == 1) { struct thread_info *tp; - char *end = argv[0]; + char *end; int pid; /* First see if we are dealing with a thread-group id. */ @@ -541,13 +543,14 @@ mi_cmd_target_detach (const char *command, char **argv, int argc) } void -mi_cmd_target_flash_erase (const char *command, char **argv, int argc) +mi_cmd_target_flash_erase (const char *command, const char *const *argv, + int argc) { flash_erase_command (NULL, 0); } void -mi_cmd_thread_select (const char *command, char **argv, int argc) +mi_cmd_thread_select (const char *command, const char *const *argv, int argc) { if (argc != 1) error (_("-thread-select: USAGE: threadnum.")); @@ -564,7 +567,7 @@ mi_cmd_thread_select (const char *command, char **argv, int argc) } void -mi_cmd_thread_list_ids (const char *command, char **argv, int argc) +mi_cmd_thread_list_ids (const char *command, const char *const *argv, int argc) { if (argc != 0) error (_("-thread-list-ids: No arguments required.")); @@ -593,7 +596,7 @@ mi_cmd_thread_list_ids (const char *command, char **argv, int argc) } void -mi_cmd_thread_info (const char *command, char **argv, int argc) +mi_cmd_thread_info (const char *command, const char *const *argv, int argc) { if (argc != 0 && argc != 1) error (_("Invalid MI command")); @@ -767,7 +770,8 @@ list_available_thread_groups (const std::set &ids, int recurse) } void -mi_cmd_list_thread_groups (const char *command, char **argv, int argc) +mi_cmd_list_thread_groups (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; int available = 0; @@ -786,7 +790,7 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) }; int oind = 0; - char *oarg; + const char *oarg; while (1) { @@ -856,7 +860,8 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) } void -mi_cmd_data_list_register_names (const char *command, char **argv, int argc) +mi_cmd_data_list_register_names (const char *command, const char *const *argv, + int argc) { struct gdbarch *gdbarch; struct ui_out *uiout = current_uiout; @@ -903,7 +908,8 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) } void -mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc) +mi_cmd_data_list_changed_registers (const char *command, + const char *const *argv, int argc) { static std::unique_ptr this_regs; struct ui_out *uiout = current_uiout; @@ -1002,7 +1008,8 @@ register_changed_p (int regnum, readonly_detached_regcache *prev_regs, their values is returned. */ void -mi_cmd_data_list_register_values (const char *command, char **argv, int argc) +mi_cmd_data_list_register_values (const char *command, const char *const *argv, + int argc) { struct ui_out *uiout = current_uiout; frame_info_ptr frame; @@ -1030,7 +1037,7 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) while (1) { - char *oarg; + const char *oarg; int opt = mi_getopt ("-data-list-register-values", argc, argv, opts, &oind, &oarg); @@ -1122,7 +1129,8 @@ output_register (frame_info_ptr frame, int regnum, int format, -data-write-register-values [ ... ] */ void -mi_cmd_data_write_register_values (const char *command, char **argv, int argc) +mi_cmd_data_write_register_values (const char *command, + const char *const *argv, int argc) { struct regcache *regcache; struct gdbarch *gdbarch; @@ -1178,7 +1186,8 @@ mi_cmd_data_write_register_values (const char *command, char **argv, int argc) included in double quotes. */ void -mi_cmd_data_evaluate_expression (const char *command, char **argv, int argc) +mi_cmd_data_evaluate_expression (const char *command, const char *const *argv, + int argc) { struct value *val; struct value_print_options opts; @@ -1222,7 +1231,8 @@ mi_cmd_data_evaluate_expression (const char *command, char **argv, int argc) The number of bytes read is SIZE*ROW*COL. */ void -mi_cmd_data_read_memory (const char *command, char **argv, int argc) +mi_cmd_data_read_memory (const char *command, const char *const *argv, + int argc) { struct gdbarch *gdbarch = get_current_arch (); struct ui_out *uiout = current_uiout; @@ -1236,7 +1246,7 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) int nr_bytes; long offset = 0; int oind = 0; - char *oarg; + const char *oarg; enum opt { OFFSET_OPT @@ -1398,7 +1408,8 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc) } void -mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) +mi_cmd_data_read_memory_bytes (const char *command, const char *const *argv, + int argc) { struct gdbarch *gdbarch = get_current_arch (); struct ui_out *uiout = current_uiout; @@ -1407,7 +1418,7 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) long offset = 0; int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); int oind = 0; - char *oarg; + const char *oarg; enum opt { OFFSET_OPT @@ -1480,7 +1491,8 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc) Prints nothing. */ void -mi_cmd_data_write_memory (const char *command, char **argv, int argc) +mi_cmd_data_write_memory (const char *command, const char *const *argv, + int argc) { struct gdbarch *gdbarch = get_current_arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1491,7 +1503,7 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc) LONGEST value; long offset = 0; int oind = 0; - char *oarg; + const char *oarg; enum opt { OFFSET_OPT @@ -1548,10 +1560,11 @@ mi_cmd_data_write_memory (const char *command, char **argv, int argc) COUNT: number of bytes to be filled (decimal integer). */ void -mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc) +mi_cmd_data_write_memory_bytes (const char *command, const char *const *argv, + int argc) { CORE_ADDR addr; - char *cdata; + const char *cdata; size_t len_hex, len_bytes, len_units, i, steps, remaining_units; long int count_units; int unit_size; @@ -1616,7 +1629,7 @@ mi_cmd_data_write_memory_bytes (const char *command, char **argv, int argc) } void -mi_cmd_enable_timings (const char *command, char **argv, int argc) +mi_cmd_enable_timings (const char *command, const char *const *argv, int argc) { if (argc == 0) do_timings = 1; @@ -1639,7 +1652,7 @@ mi_cmd_enable_timings (const char *command, char **argv, int argc) } void -mi_cmd_list_features (const char *command, char **argv, int argc) +mi_cmd_list_features (const char *command, const char *const *argv, int argc) { if (argc == 0) { @@ -1669,7 +1682,8 @@ mi_cmd_list_features (const char *command, char **argv, int argc) } void -mi_cmd_list_target_features (const char *command, char **argv, int argc) +mi_cmd_list_target_features (const char *command, const char *const *argv, + int argc) { if (argc == 0) { @@ -1687,7 +1701,7 @@ mi_cmd_list_target_features (const char *command, char **argv, int argc) } void -mi_cmd_add_inferior (const char *command, char **argv, int argc) +mi_cmd_add_inferior (const char *command, const char *const *argv, int argc) { bool no_connection = false; @@ -1703,7 +1717,7 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) }; int oind = 0; - char *oarg; + const char *oarg; while (1) { @@ -1739,7 +1753,7 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) } void -mi_cmd_remove_inferior (const char *command, char **argv, int argc) +mi_cmd_remove_inferior (const char *command, const char *const *argv, int argc) { int id; struct inferior *inf_to_remove; @@ -1844,7 +1858,7 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) case CLI_COMMAND: { - char *argv[2]; + const char *argv[2]; /* A CLI command was read from the input stream. */ /* This "feature" will be removed as soon as we have a @@ -1852,7 +1866,7 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) /* Echo the command on the console. */ gdb_printf (gdb_stdlog, "%s\n", context->command); /* Call the "console" interpreter. */ - argv[0] = (char *) INTERP_CONSOLE; + argv[0] = INTERP_CONSOLE; argv[1] = context->command; mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2); @@ -2157,7 +2171,8 @@ mi_execute_cli_command (const char *cmd, bool args_p, const char *args) } void -mi_execute_async_cli_command (const char *cli_command, char **argv, int argc) +mi_execute_async_cli_command (const char *cli_command, const char *const *argv, + int argc) { std::string run = cli_command; @@ -2279,11 +2294,12 @@ print_diff (struct ui_file *file, struct mi_timestamp *start, } void -mi_cmd_trace_define_variable (const char *command, char **argv, int argc) +mi_cmd_trace_define_variable (const char *command, const char *const *argv, + int argc) { LONGEST initval = 0; struct trace_state_variable *tsv; - char *name = 0; + const char *name; if (argc != 1 && argc != 2) error (_("Usage: -trace-define-variable VARIABLE [VALUE]")); @@ -2305,7 +2321,8 @@ mi_cmd_trace_define_variable (const char *command, char **argv, int argc) } void -mi_cmd_trace_list_variables (const char *command, char **argv, int argc) +mi_cmd_trace_list_variables (const char *command, const char *const *argv, + int argc) { if (argc != 0) error (_("-trace-list-variables: no arguments allowed")); @@ -2314,9 +2331,9 @@ mi_cmd_trace_list_variables (const char *command, char **argv, int argc) } void -mi_cmd_trace_find (const char *command, char **argv, int argc) +mi_cmd_trace_find (const char *command, const char *const *argv, int argc) { - char *mode; + const char *mode; if (argc == 0) error (_("trace selection mode is required")); @@ -2390,13 +2407,13 @@ mi_cmd_trace_find (const char *command, char **argv, int argc) } void -mi_cmd_trace_save (const char *command, char **argv, int argc) +mi_cmd_trace_save (const char *command, const char *const *argv, int argc) { int target_saves = 0; int generate_ctf = 0; - char *filename; + const char *filename; int oind = 0; - char *oarg; + const char *oarg; enum opt { @@ -2440,19 +2457,19 @@ mi_cmd_trace_save (const char *command, char **argv, int argc) } void -mi_cmd_trace_start (const char *command, char **argv, int argc) +mi_cmd_trace_start (const char *command, const char *const *argv, int argc) { start_tracing (NULL); } void -mi_cmd_trace_status (const char *command, char **argv, int argc) +mi_cmd_trace_status (const char *command, const char *const *argv, int argc) { trace_status_mi (0); } void -mi_cmd_trace_stop (const char *command, char **argv, int argc) +mi_cmd_trace_stop (const char *command, const char *const *argv, int argc) { stop_tracing (NULL); trace_status_mi (1); @@ -2461,7 +2478,7 @@ mi_cmd_trace_stop (const char *command, char **argv, int argc) /* Implement the "-ada-task-info" command. */ void -mi_cmd_ada_task_info (const char *command, char **argv, int argc) +mi_cmd_ada_task_info (const char *command, const char *const *argv, int argc) { if (argc != 0 && argc != 1) error (_("Invalid MI command")); @@ -2522,7 +2539,8 @@ print_variable_or_computed (const char *expression, enum print_values values) /* Implement the "-trace-frame-collected" command. */ void -mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) +mi_cmd_trace_frame_collected (const char *command, const char *const *argv, + int argc) { struct bp_location *tloc; int stepping_frame; @@ -2553,7 +2571,7 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) while (1) { - char *oarg; + const char *oarg; int opt = mi_getopt ("-trace-frame-collected", argc, argv, opts, &oind, &oarg); if (opt < 0) @@ -2712,7 +2730,8 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) /* See mi/mi-main.h. */ void -mi_cmd_fix_multi_location_breakpoint_output (const char *command, char **argv, +mi_cmd_fix_multi_location_breakpoint_output (const char *command, + const char *const *argv, int argc) { fix_multi_location_breakpoint_output_globally = true; @@ -2721,7 +2740,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, + const char *const *argv, int argc) { fix_breakpoint_script_output_globally = true; } @@ -2729,7 +2749,7 @@ mi_cmd_fix_breakpoint_script_output (const char *command, char **argv, int argc) /* Implement the "-complete" command. */ void -mi_cmd_complete (const char *command, char **argv, int argc) +mi_cmd_complete (const char *command, const char *const *argv, int argc) { if (argc != 1) error (_("Usage: -complete COMMAND")); diff --git a/gdb/mi/mi-main.h b/gdb/mi/mi-main.h index ff1d4ed84bc..18687d59aad 100644 --- a/gdb/mi/mi-main.h +++ b/gdb/mi/mi-main.h @@ -69,11 +69,13 @@ 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); + const char *const *argv, + int argc); /* Implementation of -fix-breakpoint-script-output. */ extern void mi_cmd_fix_breakpoint_script_output (const char *command, - char **argv, int argc); + const char *const *argv, + int argc); #endif /* MI_MI_MAIN_H */ diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 08e6e15e14d..d26378e8310 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -29,10 +29,11 @@ in ascending PC order. */ void -mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) +mi_cmd_symbol_list_lines (const char *command, const char *const *argv, + int argc) { struct gdbarch *gdbarch; - char *filename; + const char *filename; struct symtab *s; int i; struct ui_out *uiout = current_uiout; @@ -174,9 +175,9 @@ mi_symbol_info (enum search_domain kind, const char *name_regexp, the parsed value. If the text can't be parsed then an error is thrown. */ static size_t -parse_max_results_option (char *arg) +parse_max_results_option (const char *arg) { - char *ptr = arg; + char *ptr; long long val = strtoll (arg, &ptr, 10); if (arg == ptr || *ptr != '\0' || val > SIZE_MAX || val < 0) error (_("invalid value for --max-results argument")); @@ -189,7 +190,8 @@ parse_max_results_option (char *arg) Processes command line options from ARGV and ARGC. */ static void -mi_info_functions_or_variables (enum search_domain kind, char **argv, int argc) +mi_info_functions_or_variables (enum search_domain kind, + const char *const *argv, int argc) { size_t max_results = SIZE_MAX; const char *regexp = nullptr; @@ -210,7 +212,7 @@ mi_info_functions_or_variables (enum search_domain kind, char **argv, int argc) }; int oind = 0; - char *oarg = nullptr; + const char *oarg = nullptr; while (1) { @@ -315,7 +317,7 @@ output_module_symbols_in_single_module static void mi_info_module_functions_or_variables (enum search_domain kind, - char **argv, int argc) + const char *const *argv, int argc) { const char *module_regexp = nullptr; const char *regexp = nullptr; @@ -336,7 +338,7 @@ mi_info_module_functions_or_variables (enum search_domain kind, }; int oind = 0; - char *oarg = nullptr; + const char *oarg = nullptr; while (1) { @@ -380,7 +382,8 @@ mi_info_module_functions_or_variables (enum search_domain kind, /* Implement -symbol-info-functions command. */ void -mi_cmd_symbol_info_functions (const char *command, char **argv, int argc) +mi_cmd_symbol_info_functions (const char *command, const char *const *argv, + int argc) { mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); } @@ -388,8 +391,8 @@ mi_cmd_symbol_info_functions (const char *command, char **argv, int argc) /* Implement -symbol-info-module-functions command. */ void -mi_cmd_symbol_info_module_functions (const char *command, char **argv, - int argc) +mi_cmd_symbol_info_module_functions (const char *command, + const char *const *argv, int argc) { mi_info_module_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); } @@ -397,8 +400,8 @@ mi_cmd_symbol_info_module_functions (const char *command, char **argv, /* Implement -symbol-info-module-variables command. */ void -mi_cmd_symbol_info_module_variables (const char *command, char **argv, - int argc) +mi_cmd_symbol_info_module_variables (const char *command, + const char *const *argv, int argc) { mi_info_module_functions_or_variables (VARIABLES_DOMAIN, argv, argc); } @@ -406,7 +409,8 @@ mi_cmd_symbol_info_module_variables (const char *command, char **argv, /* Implement -symbol-inf-modules command. */ void -mi_cmd_symbol_info_modules (const char *command, char **argv, int argc) +mi_cmd_symbol_info_modules (const char *command, const char *const *argv, + int argc) { size_t max_results = SIZE_MAX; const char *regexp = nullptr; @@ -423,7 +427,7 @@ mi_cmd_symbol_info_modules (const char *command, char **argv, int argc) }; int oind = 0; - char *oarg = nullptr; + const char *oarg = nullptr; while (1) { @@ -448,7 +452,8 @@ mi_cmd_symbol_info_modules (const char *command, char **argv, int argc) /* Implement -symbol-info-types command. */ void -mi_cmd_symbol_info_types (const char *command, char **argv, int argc) +mi_cmd_symbol_info_types (const char *command, const char *const *argv, + int argc) { size_t max_results = SIZE_MAX; const char *regexp = nullptr; @@ -465,7 +470,7 @@ mi_cmd_symbol_info_types (const char *command, char **argv, int argc) }; int oind = 0; - char *oarg = nullptr; + const char *oarg = nullptr; while (true) { @@ -490,7 +495,8 @@ mi_cmd_symbol_info_types (const char *command, char **argv, int argc) /* Implement -symbol-info-variables command. */ void -mi_cmd_symbol_info_variables (const char *command, char **argv, int argc) +mi_cmd_symbol_info_variables (const char *command, const char *const *argv, + int argc) { mi_info_functions_or_variables (VARIABLES_DOMAIN, argv, argc); }