diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 48 | ||||
-rw-r--r-- | gdb/auto-load.c | 6 | ||||
-rw-r--r-- | gdb/breakpoint.c | 8 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 36 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 2 | ||||
-rw-r--r-- | gdb/command.h | 8 | ||||
-rw-r--r-- | gdb/gnu-nat.c | 60 | ||||
-rw-r--r-- | gdb/go32-nat.c | 14 | ||||
-rw-r--r-- | gdb/guile/scm-auto-load.c | 2 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 2 | ||||
-rw-r--r-- | gdb/maint.c | 27 | ||||
-rw-r--r-- | gdb/source.c | 2 | ||||
-rw-r--r-- | gdb/sparc64-tdep.c | 10 | ||||
-rw-r--r-- | gdb/symfile.c | 8 | ||||
-rw-r--r-- | gdb/thread.c | 14 | ||||
-rw-r--r-- | gdb/top.h | 2 | ||||
-rw-r--r-- | gdb/value.c | 6 | ||||
-rw-r--r-- | gdb/windows-nat.c | 2 |
18 files changed, 123 insertions, 134 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 94cee5f..a19e628 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,53 @@ 2017-11-07 Tom Tromey <tom@tromey.com> + * go32-nat.c (go32_sysinfo, go32_sldt, go32_sgdt, go32_sidt) + (go32_pde, go32_pte, go32_pte_for_address): Constify. + * gnu-nat.c (_parse_bool_arg, show_thread_default_pause_cmd) + (set_thread_default_pause_cmd, set_thread_default_run_cmd) + (show_thread_default_run_cmd, set_thread_default_detach_sc_cmd) + (parse_int_arg, show_thread_default_detach_sc_cmd) + (set_signals_cmd, show_signals_cmd, set_sig_thread_cmd) + (show_sig_thread_cmd, set_stopped_cmd, show_stopped_cmd) + (set_exceptions_cmd, show_exceptions_cmd, set_task_pause_cmd) + (show_task_pause_cmd, set_task_detach_sc_cmd) + (show_task_detach_sc_cmd, set_task_exc_port_cmd) + (set_noninvasive_cmd, set_thread_pause_cmd) + (show_thread_pause_cmd, set_thread_run_cmd, show_thread_run_cmd) + (set_thread_detach_sc_cmd, show_thread_detach_sc_cmd) + (set_thread_exc_port_cmd, thread_takeover_sc_cmd): Constify. + * windows-nat.c (display_selectors): Constify. + * cli/cli-decode.h (struct cmd_list_element) <function>: Remove + non-const "cfunc". + * cli/cli-decode.c (set_cmd_cfunc): Remove non-const overload. + (cmd_cfunc_eq): Likewise. + (struct cmd_list_element): Likewise. + (do_cfunc): Remove. + (cli_user_command_p): Update. + * command.h (add_cmd): Remove non-const overload. + (cmd_cfunc_ftype): Remove typedef. + (cmd_cfunc_eq): Remove non-const overload. + * value.c (show_values): Constify. + * thread.c (thread_apply_all_command): Constify. + * symfile.c (load_command): Constify. + * source.c (directory_command): Constify. + * maint.c (maintenance_internal_error) + (maintenance_demangler_warning, maintenance_space_display) + (maintenance_print_architecture, maintenance_translate_address) + (maintenance_info_selftests, maintenance_internal_warning): + Constify. + * breakpoint.c (disable_trace_command, enable_trace_command): + Constify. + * auto-load.c (info_auto_load_local_gdbinit, add_auto_load_dir): + Constify. + (add_auto_load_safe_path): Constify. + * guile/scm-auto-load.c (info_auto_load_guile_scripts): Constify. + * top.h (show_commands): Constify. + * linux-thread-db.c (info_auto_load_libthread_db): Constify. + * sparc64-tdep.c (adi_examine_command): Constify. + (adi_assign_command): Constify. + +2017-11-07 Tom Tromey <tom@tromey.com> + * frame.h (info_locals_command, info_args_command): Constify. * auto-load.h (auto_load_info_scripts): Constify. * inferior.h (registers_info): Constify. diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 47533da..63366df 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -301,7 +301,7 @@ show_auto_load_safe_path (struct ui_file *file, int from_tty, variable. */ static void -add_auto_load_safe_path (char *args, int from_tty) +add_auto_load_safe_path (const char *args, int from_tty) { char *s; @@ -322,7 +322,7 @@ Use 'set auto-load safe-path /' for disabling the auto-load safe-path security.\ variable. */ static void -add_auto_load_dir (char *args, int from_tty) +add_auto_load_dir (const char *args, int from_tty) { char *s; @@ -1381,7 +1381,7 @@ info_auto_load_gdb_scripts (const char *pattern, int from_tty) /* Implement 'info auto-load local-gdbinit'. */ static void -info_auto_load_local_gdbinit (char *args, int from_tty) +info_auto_load_local_gdbinit (const char *args, int from_tty) { if (auto_load_local_gdbinit_pathname == NULL) printf_filtered (_("Local .gdbinit file was not found.\n")); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 5645ecd..0d78141 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -226,10 +226,6 @@ static int is_hardware_watchpoint (const struct breakpoint *bpt); static void insert_breakpoint_locations (void); -static void enable_trace_command (char *, int); - -static void disable_trace_command (char *, int); - static void trace_pass_command (const char *, int); static void set_tracepoint_count (int num); @@ -14928,7 +14924,7 @@ info_tracepoints_command (const char *args, int from_tty) /* The 'enable trace' command enables tracepoints. Not supported by all targets. */ static void -enable_trace_command (char *args, int from_tty) +enable_trace_command (const char *args, int from_tty) { enable_command (args, from_tty); } @@ -14936,7 +14932,7 @@ enable_trace_command (char *args, int from_tty) /* The 'disable trace' command disables tracepoints. Not supported by all targets. */ static void -disable_trace_command (char *args, int from_tty) +disable_trace_command (const char *args, int from_tty) { disable_command (args, from_tty); } diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0c55526..459438e 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -101,22 +101,6 @@ print_help_for_command (struct cmd_list_element *c, const char *prefix, bounce function (unless cfunc / sfunc is NULL that is). */ static void -do_cfunc (struct cmd_list_element *c, char *args, int from_tty) -{ - c->function.cfunc (args, from_tty); -} - -static void -set_cmd_cfunc (struct cmd_list_element *cmd, cmd_cfunc_ftype *cfunc) -{ - if (cfunc == NULL) - cmd->func = NULL; - else - cmd->func = do_cfunc; - cmd->function.cfunc = cfunc; -} - -static void do_const_cfunc (struct cmd_list_element *c, char *args, int from_tty) { c->function.const_cfunc (args, from_tty); @@ -149,12 +133,6 @@ set_cmd_sfunc (struct cmd_list_element *cmd, cmd_sfunc_ftype *sfunc) } int -cmd_cfunc_eq (struct cmd_list_element *cmd, cmd_cfunc_ftype *cfunc) -{ - return cmd->func == do_cfunc && cmd->function.cfunc == cfunc; -} - -int cmd_cfunc_eq (struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc) { return cmd->func == do_const_cfunc && cmd->function.const_cfunc == cfunc; @@ -281,21 +259,12 @@ do_add_cmd (const char *name, enum command_class theclass, } struct cmd_list_element * -add_cmd (const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, - const char *doc, struct cmd_list_element **list) -{ - cmd_list_element *result = do_add_cmd (name, theclass, doc, list); - set_cmd_cfunc (result, fun); - return result; -} - -struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list) { cmd_list_element *result = do_add_cmd (name, theclass, doc, list); result->func = NULL; - result->function.cfunc = NULL; /* Ok. */ + result->function.const_cfunc = NULL; return result; } @@ -1960,6 +1929,5 @@ int cli_user_command_p (struct cmd_list_element *cmd) { return (cmd->theclass == class_user - && (cmd->func == do_cfunc || cmd->func == do_sfunc - || cmd->func == do_const_cfunc)); + && (cmd->func == do_const_cfunc || cmd->func == do_sfunc)); } diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 76f3ca9..e3ac69b 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -113,8 +113,6 @@ struct cmd_list_element union { /* If type is not_set_cmd, call it like this: */ - cmd_cfunc_ftype *cfunc; - /* ... or like this. */ cmd_const_cfunc_ftype *const_cfunc; /* If type is set_cmd or show_cmd, first set the variables, and then call this: */ diff --git a/gdb/command.h b/gdb/command.h index 258f7f7..cbcf523 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -116,7 +116,6 @@ var_types; /* This structure records one command'd definition. */ struct cmd_list_element; -typedef void cmd_cfunc_ftype (char *args, int from_tty); typedef void cmd_const_cfunc_ftype (const char *args, int from_tty); /* This structure specifies notifications to be suppressed by a cli @@ -136,11 +135,6 @@ extern struct cli_suppress_notification cli_suppress_notification; extern int valid_user_defined_cmd_name_p (const char *name); -extern struct cmd_list_element *add_cmd (const char *, enum command_class, - cmd_cfunc_ftype *fun, - const char *, - struct cmd_list_element **); - /* Const-correct variant of the above. */ extern struct cmd_list_element *add_cmd (const char *, enum command_class, @@ -213,8 +207,6 @@ extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *, /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs around in cmd objects to test the value of the commands sfunc(). */ extern int cmd_cfunc_eq (struct cmd_list_element *cmd, - cmd_cfunc_ftype *cfun); -extern int cmd_cfunc_eq (struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfun); /* Each command object has a local context attached to it. */ diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 609ba50..0d500ea 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2742,7 +2742,7 @@ show_thread_default_cmd (const char *args, int from_tty) } static int -parse_int_arg (char *args, char *cmd_prefix) +parse_int_arg (const char *args, char *cmd_prefix) { if (args) { @@ -2757,7 +2757,7 @@ parse_int_arg (char *args, char *cmd_prefix) } static int -_parse_bool_arg (char *args, char *t_val, char *f_val, char *cmd_prefix) +_parse_bool_arg (const char *args, char *t_val, char *f_val, char *cmd_prefix) { if (!args || strcmp (args, t_val) == 0) return 1; @@ -2818,13 +2818,13 @@ set_task_pause_cmd (int arg, int from_tty) } static void -set_task_pause_cmd (char *args, int from_tty) +set_task_pause_cmd (const char *args, int from_tty) { set_task_pause_cmd (parse_bool_arg (args, "set task pause"), from_tty); } static void -show_task_pause_cmd (char *args, int from_tty) +show_task_pause_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2836,14 +2836,14 @@ show_task_pause_cmd (char *args, int from_tty) } static void -set_task_detach_sc_cmd (char *args, int from_tty) +set_task_detach_sc_cmd (const char *args, int from_tty) { cur_inf ()->detach_sc = parse_int_arg (args, "set task detach-suspend-count"); } static void -show_task_detach_sc_cmd (char *args, int from_tty) +show_task_detach_sc_cmd (const char *args, int from_tty) { check_empty (args, "show task detach-suspend-count"); printf_unfiltered ("The inferior task will be left with a " @@ -2853,7 +2853,7 @@ show_task_detach_sc_cmd (char *args, int from_tty) static void -set_thread_default_pause_cmd (char *args, int from_tty) +set_thread_default_pause_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2862,7 +2862,7 @@ set_thread_default_pause_cmd (char *args, int from_tty) } static void -show_thread_default_pause_cmd (char *args, int from_tty) +show_thread_default_pause_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); int sc = inf->default_thread_pause_sc; @@ -2874,7 +2874,7 @@ show_thread_default_pause_cmd (char *args, int from_tty) } static void -set_thread_default_run_cmd (char *args, int from_tty) +set_thread_default_run_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2883,7 +2883,7 @@ set_thread_default_run_cmd (char *args, int from_tty) } static void -show_thread_default_run_cmd (char *args, int from_tty) +show_thread_default_run_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2893,14 +2893,14 @@ show_thread_default_run_cmd (char *args, int from_tty) } static void -set_thread_default_detach_sc_cmd (char *args, int from_tty) +set_thread_default_detach_sc_cmd (const char *args, int from_tty) { cur_inf ()->default_thread_detach_sc = parse_int_arg (args, "set thread default detach-suspend-count"); } static void -show_thread_default_detach_sc_cmd (char *args, int from_tty) +show_thread_default_detach_sc_cmd (const char *args, int from_tty) { check_empty (args, "show thread default detach-suspend-count"); printf_unfiltered ("New threads will get a detach-suspend-count of %d.\n", @@ -2946,7 +2946,7 @@ steal_exc_port (struct proc *proc, mach_port_t name) } static void -set_task_exc_port_cmd (char *args, int from_tty) +set_task_exc_port_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2956,13 +2956,13 @@ set_task_exc_port_cmd (char *args, int from_tty) } static void -set_stopped_cmd (char *args, int from_tty) +set_stopped_cmd (const char *args, int from_tty) { cur_inf ()->stopped = _parse_bool_arg (args, "yes", "no", "set stopped"); } static void -show_stopped_cmd (char *args, int from_tty) +show_stopped_cmd (const char *args, int from_tty) { struct inf *inf = active_inf (); @@ -2972,7 +2972,7 @@ show_stopped_cmd (char *args, int from_tty) } static void -set_sig_thread_cmd (char *args, int from_tty) +set_sig_thread_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -2990,7 +2990,7 @@ set_sig_thread_cmd (char *args, int from_tty) } static void -show_sig_thread_cmd (char *args, int from_tty) +show_sig_thread_cmd (const char *args, int from_tty) { struct inf *inf = active_inf (); @@ -3016,13 +3016,13 @@ set_signals_cmd (int arg, int from_tty) } static void -set_signals_cmd (char *args, int from_tty) +set_signals_cmd (const char *args, int from_tty) { set_signals_cmd(parse_bool_arg (args, "set signals"), from_tty); } static void -show_signals_cmd (char *args, int from_tty) +show_signals_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -3045,13 +3045,13 @@ set_exceptions_cmd (int arg, int from_tty) } static void -set_exceptions_cmd (char *args, int from_tty) +set_exceptions_cmd (const char *args, int from_tty) { set_exceptions_cmd (parse_bool_arg (args, "set exceptions"), from_tty); } static void -show_exceptions_cmd (char *args, int from_tty) +show_exceptions_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); @@ -3099,7 +3099,7 @@ show_task_cmd (const char *args, int from_tty) static void -set_noninvasive_cmd (char *args, int from_tty) +set_noninvasive_cmd (const char *args, int from_tty) { /* Invert the sense of the arg for each component. */ int inv_arg = parse_bool_arg (args, "set noninvasive") ? 0 : 1; @@ -3301,7 +3301,7 @@ This is the same as setting `task pause', `exceptions', and\n\ static void -set_thread_pause_cmd (char *args, int from_tty) +set_thread_pause_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); int old_sc = thread->pause_sc; @@ -3314,7 +3314,7 @@ set_thread_pause_cmd (char *args, int from_tty) } static void -show_thread_pause_cmd (char *args, int from_tty) +show_thread_pause_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); int sc = thread->pause_sc; @@ -3327,7 +3327,7 @@ show_thread_pause_cmd (char *args, int from_tty) } static void -set_thread_run_cmd (char *args, int from_tty) +set_thread_run_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); @@ -3335,7 +3335,7 @@ set_thread_run_cmd (char *args, int from_tty) } static void -show_thread_run_cmd (char *args, int from_tty) +show_thread_run_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); @@ -3346,14 +3346,14 @@ show_thread_run_cmd (char *args, int from_tty) } static void -set_thread_detach_sc_cmd (char *args, int from_tty) +set_thread_detach_sc_cmd (const char *args, int from_tty) { cur_thread ()->detach_sc = parse_int_arg (args, "set thread detach-suspend-count"); } static void -show_thread_detach_sc_cmd (char *args, int from_tty) +show_thread_detach_sc_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); @@ -3365,7 +3365,7 @@ show_thread_detach_sc_cmd (char *args, int from_tty) } static void -set_thread_exc_port_cmd (char *args, int from_tty) +set_thread_exc_port_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); @@ -3389,7 +3389,7 @@ show_thread_cmd (char *args, int from_tty) #endif static void -thread_takeover_sc_cmd (char *args, int from_tty) +thread_takeover_sc_cmd (const char *args, int from_tty) { struct proc *thread = cur_thread (); diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 6abd734..5bf262f 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -1061,7 +1061,7 @@ print_mem (unsigned long datum, const char *header, int in_pages_p) /* Display assorted information about the underlying OS. */ static void -go32_sysinfo (char *arg, int from_tty) +go32_sysinfo (const char *arg, int from_tty) { static const char test_pattern[] = "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf" @@ -1658,7 +1658,7 @@ display_descriptor (unsigned type, unsigned long base_addr, int idx, int force) } static void -go32_sldt (char *arg, int from_tty) +go32_sldt (const char *arg, int from_tty) { struct dtr_reg gdtr; unsigned short ldtr = 0; @@ -1731,7 +1731,7 @@ go32_sldt (char *arg, int from_tty) } static void -go32_sgdt (char *arg, int from_tty) +go32_sgdt (const char *arg, int from_tty) { struct dtr_reg gdtr; long gdt_entry = -1L; @@ -1772,7 +1772,7 @@ go32_sgdt (char *arg, int from_tty) } static void -go32_sidt (char *arg, int from_tty) +go32_sidt (const char *arg, int from_tty) { struct dtr_reg idtr; long idt_entry = -1L; @@ -1944,7 +1944,7 @@ display_ptable_entry (unsigned long entry, int is_dir, int force, unsigned off) } static void -go32_pde (char *arg, int from_tty) +go32_pde (const char *arg, int from_tty) { long pde_idx = -1, i; @@ -1994,7 +1994,7 @@ display_page_table (long n, int force) } static void -go32_pte (char *arg, int from_tty) +go32_pte (const char *arg, int from_tty) { long pde_idx = -1L, i; @@ -2021,7 +2021,7 @@ go32_pte (char *arg, int from_tty) } static void -go32_pte_for_address (char *arg, int from_tty) +go32_pte_for_address (const char *arg, int from_tty) { CORE_ADDR addr = 0, i; diff --git a/gdb/guile/scm-auto-load.c b/gdb/guile/scm-auto-load.c index 8a04e9c..29f7357 100644 --- a/gdb/guile/scm-auto-load.c +++ b/gdb/guile/scm-auto-load.c @@ -53,7 +53,7 @@ gdbscm_auto_load_enabled (const struct extension_language_defn *extlang) /* Wrapper for "info auto-load guile-scripts". */ static void -info_auto_load_guile_scripts (char *pattern, int from_tty) +info_auto_load_guile_scripts (const char *pattern, int from_tty) { auto_load_info_scripts (pattern, from_tty, &extension_language_guile); } diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 453505b..1acb6ce0 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1580,7 +1580,7 @@ info_auto_load_libthread_db_compare (const void *ap, const void *bp) /* Implement 'info auto-load libthread-db'. */ static void -info_auto_load_libthread_db (char *args, int from_tty) +info_auto_load_libthread_db (const char *args, int from_tty) { struct ui_out *uiout = current_uiout; const char *cs = args ? args : ""; diff --git a/gdb/maint.c b/gdb/maint.c index 65a056b..94293d5 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -44,10 +44,6 @@ #include "cli/cli-utils.h" #include "cli/cli-setshow.h" -static void maintenance_internal_error (char *args, int from_tty); - -static void maintenance_space_display (char *, int); - static void maintenance_do_deprecate (const char *, int); /* Set this to the maximum number of seconds to wait instead of waiting forever @@ -98,7 +94,7 @@ maintenance_dump_me (const char *args, int from_tty) GDB. */ static void -maintenance_internal_error (char *args, int from_tty) +maintenance_internal_error (const char *args, int from_tty) { internal_error (__FILE__, __LINE__, "%s", (args == NULL ? "" : args)); } @@ -109,7 +105,7 @@ maintenance_internal_error (char *args, int from_tty) GDB. */ static void -maintenance_internal_warning (char *args, int from_tty) +maintenance_internal_warning (const char *args, int from_tty) { internal_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args)); } @@ -118,7 +114,7 @@ maintenance_internal_warning (char *args, int from_tty) demangler problem is detected. Allows testing of the mechanism. */ static void -maintenance_demangler_warning (char *args, int from_tty) +maintenance_demangler_warning (const char *args, int from_tty) { demangler_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args)); } @@ -143,7 +139,7 @@ maintenance_time_display (const char *args, int from_tty) } static void -maintenance_space_display (char *args, int from_tty) +maintenance_space_display (const char *args, int from_tty) { if (args == NULL || *args == '\0') printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n"); @@ -394,7 +390,7 @@ maintenance_print_statistics (const char *args, int from_tty) } static void -maintenance_print_architecture (char *args, int from_tty) +maintenance_print_architecture (const char *args, int from_tty) { struct gdbarch *gdbarch = get_current_arch (); @@ -429,11 +425,11 @@ maintenance_print_command (const char *arg, int from_tty) or maintenance translate-address <addr>. */ static void -maintenance_translate_address (char *arg, int from_tty) +maintenance_translate_address (const char *arg, int from_tty) { CORE_ADDR address; struct obj_section *sect; - char *p; + const char *p; struct bound_minimal_symbol sym; struct objfile *objfile; @@ -449,12 +445,13 @@ maintenance_translate_address (char *arg, int from_tty) p++; if (*p == '\000') /* End of command? */ error (_("Need to specify <section-name> and <address>")); - *p++ = '\000'; - p = skip_spaces (p); + + int arg_len = p - arg; + p = skip_spaces (p + 1); ALL_OBJSECTIONS (objfile, sect) { - if (strcmp (sect->the_bfd_section->name, arg) == 0) + if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0) break; } @@ -946,7 +943,7 @@ maintenance_selftest (const char *args, int from_tty) } static void -maintenance_info_selftests (char *arg, int from_tty) +maintenance_info_selftests (const char *arg, int from_tty) { printf_filtered ("Registered selftests:\n"); selftests::for_each_selftest ([] (const std::string &name) { diff --git a/gdb/source.c b/gdb/source.c index cefc612..b0bb482 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -411,7 +411,7 @@ init_source_path (void) /* Add zero or more directories to the front of the source path. */ static void -directory_command (char *dirname, int from_tty) +directory_command (const char *dirname, int from_tty) { dont_repeat (); /* FIXME, this goes to "delete dir"... */ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index eade046..55aef13 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -452,7 +452,7 @@ do_assign (CORE_ADDR start, size_t bcnt, int version) adi (examine|x)/count <addr> */ static void -adi_examine_command (char *args, int from_tty) +adi_examine_command (const char *args, int from_tty) { /* make sure program is active and adi is available */ if (!target_has_execution) @@ -464,7 +464,7 @@ adi_examine_command (char *args, int from_tty) pid_t pid = ptid_get_pid (inferior_ptid); sparc64_adi_info *proc = get_adi_info_proc (pid); int cnt = 1; - char *p = args; + const char *p = args; if (p && *p == '/') { p++; @@ -487,7 +487,7 @@ adi_examine_command (char *args, int from_tty) adi (assign|a)/count <addr> = <version> */ static void -adi_assign_command (char *args, int from_tty) +adi_assign_command (const char *args, int from_tty) { /* make sure program is active and adi is available */ if (!target_has_execution) @@ -496,7 +496,7 @@ adi_assign_command (char *args, int from_tty) if (!adi_available ()) error (_("No ADI information")); - char *exp = args; + const char *exp = args; if (exp == 0) error_no_arg (_("Usage: adi assign|a[/count] <addr> = <version>")); @@ -507,7 +507,7 @@ adi_assign_command (char *args, int from_tty) error (_("Usage: adi assign|a[/count] <addr> = <version>")); size_t cnt = 1; - char *p = args; + const char *p = args; if (exp && *exp == '/') { p = exp + 1; diff --git a/gdb/symfile.c b/gdb/symfile.c index 8cc76e3..c29ab8e 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -84,8 +84,6 @@ int readnow_symbol_files; /* Read full symbols immediately. */ /* Functions this file defines. */ -static void load_command (char *, int); - static void symbol_file_add_main_1 (const char *args, symfile_add_flags add_flags, objfile_flags flags); @@ -1791,7 +1789,7 @@ find_sym_fns (bfd *abfd) /* This function runs the load command of our current target. */ static void -load_command (char *arg, int from_tty) +load_command (const char *arg, int from_tty) { struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); @@ -1804,7 +1802,7 @@ load_command (char *arg, int from_tty) if (arg == NULL) { - char *parg; + const char *parg; int count = 0; parg = arg = get_exec_file (1); @@ -1821,7 +1819,7 @@ load_command (char *arg, int from_tty) /* We need to quote this string so buildargv can pull it apart. */ char *temp = (char *) xmalloc (strlen (arg) + count + 1 ); char *ptemp = temp; - char *prev; + const char *prev; make_cleanup (xfree, temp); diff --git a/gdb/thread.c b/gdb/thread.c index 7309302..1e81a61 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -60,7 +60,6 @@ static int highest_thread_num; spawned new threads we haven't heard of yet. */ static int threads_executing; -static void thread_apply_all_command (char *, int); static int thread_alive (struct thread_info *); /* RAII type used to increase / decrease the refcount of each thread @@ -1652,7 +1651,7 @@ tp_array_compar (const thread_info *a, const thread_info *b) thread apply all p x/i $pc Apply x/i $pc cmd to all threads. */ static void -thread_apply_all_command (char *cmd, int from_tty) +thread_apply_all_command (const char *cmd, int from_tty) { tp_array_compar_ascending = false; if (cmd != NULL @@ -1667,10 +1666,6 @@ thread_apply_all_command (char *cmd, int from_tty) update_thread_list (); - /* Save a copy of the command in case it is clobbered by - execute_command. */ - std::string saved_cmd = cmd; - int tc = live_threads_count (); if (tc != 0) { @@ -1708,10 +1703,11 @@ thread_apply_all_command (char *cmd, int from_tty) printf_filtered (_("\nThread %s (%s):\n"), print_thread_id (thr), target_pid_to_str (inferior_ptid)); - execute_command (cmd, from_tty); - /* Restore exact command used previously. */ - strcpy (cmd, saved_cmd.c_str ()); + /* Use a copy of the command in case it is clobbered by + execute_command. */ + std::string copy = cmd; + execute_command (©[0], from_tty); } } } @@ -281,7 +281,7 @@ extern char *lim_at_start; extern void gdb_add_history (const char *); -extern void show_commands (char *args, int from_tty); +extern void show_commands (const char *args, int from_tty); extern void set_history (const char *, int); diff --git a/gdb/value.c b/gdb/value.c index d8d40c2..5225e4e 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -880,10 +880,6 @@ value_contents_eq (const struct value *val1, LONGEST offset1, length * TARGET_CHAR_BIT); } -/* Prototypes for local functions. */ - -static void show_values (char *, int); - /* The value-history records all the values printed by print commands during this session. Each chunk @@ -1963,7 +1959,7 @@ access_value_history (int num) } static void -show_values (char *num_exp, int from_tty) +show_values (const char *num_exp, int from_tty) { int i; struct value *val; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index b7ff5cc..dc6dbdd 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1020,7 +1020,7 @@ display_selector (HANDLE thread, DWORD sel) } static void -display_selectors (char * args, int from_tty) +display_selectors (const char * args, int from_tty) { if (!current_thread) { |