From patchwork Mon Oct 16 03:22:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23592 Received: (qmail 105571 invoked by alias); 16 Oct 2017 03:22:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 105503 invoked by uid 89); 16 Oct 2017 03:22:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=bounce, 3947 X-HELO: gproxy2-pub.mail.unifiedlayer.com Received: from gproxy2-pub.mail.unifiedlayer.com (HELO gproxy2-pub.mail.unifiedlayer.com) (69.89.18.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Oct 2017 03:22:54 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id 17CAE1E0B88 for ; Sun, 15 Oct 2017 21:22:53 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id N3Np1w00f2f2jeq013NsPd; Sun, 15 Oct 2017 21:22:53 -0600 X-Authority-Analysis: v=2.2 cv=H76r+6Qi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=ddndc94xlsgCkSTSwYoA:9 a=yfKVlJ80bKlFzQHs:21 a=0ja8hpBECEBersw4:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 184-96-33-178.hlrn.qwest.net ([184.96.33.178]:40760 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e3vzN-003xuJ-Kx; Sun, 15 Oct 2017 21:22:49 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/4] Remove cmd_cfunc_ftype Date: Sun, 15 Oct 2017 21:22:37 -0600 Message-Id: <20171016032239.24561-3-tom@tromey.com> In-Reply-To: <20171016032239.24561-1-tom@tromey.com> References: <20171016032239.24561-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e3vzN-003xuJ-Kx X-Source-Sender: 184-96-33-178.hlrn.qwest.net (bapiya.localdomain) [184.96.33.178]:40760 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes cmd_cfunc_ftype and the non-const overload of add_cmd; then fixes up the fallout. For the most part this patch is straightforward. There are a few files (go32-nat.c, windows-nat.c, and gnu-nat.c) that I could not compile; so I made a best effort there. ChangeLog 2017-10-15 Tom Tromey * 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) : 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. --- gdb/ChangeLog | 48 +++++++++++++++++++++++++++++++++++++ gdb/auto-load.c | 6 ++--- gdb/breakpoint.c | 8 ++----- gdb/cli/cli-decode.c | 36 ++-------------------------- gdb/cli/cli-decode.h | 2 -- gdb/command.h | 8 ------- gdb/gnu-nat.c | 60 +++++++++++++++++++++++------------------------ gdb/go32-nat.c | 14 +++++------ gdb/guile/scm-auto-load.c | 2 +- gdb/linux-thread-db.c | 2 +- gdb/maint.c | 27 ++++++++++----------- gdb/source.c | 2 +- gdb/sparc64-tdep.c | 10 ++++---- gdb/symfile.c | 8 +++---- gdb/thread.c | 14 ++++------- gdb/top.h | 2 +- gdb/value.c | 6 +---- gdb/windows-nat.c | 2 +- 18 files changed, 123 insertions(+), 134 deletions(-) diff --git a/gdb/auto-load.c b/gdb/auto-load.c index a058c82585..6ef05fd913 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; @@ -1392,7 +1392,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 e0a510e61d..fc78f8ed81 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); @@ -14818,7 +14814,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); } @@ -14826,7 +14822,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 0c555268b3..459438e170 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 76f3ca9d7a..e3ac69ba66 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 258f7f7de2..cbcf523cc9 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 0095d729f9..06dfc1911f 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2749,7 +2749,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) { @@ -2764,7 +2764,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; @@ -2825,13 +2825,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 (); @@ -2843,14 +2843,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 " @@ -2860,7 +2860,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 (); @@ -2869,7 +2869,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; @@ -2881,7 +2881,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 (); @@ -2890,7 +2890,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 (); @@ -2900,14 +2900,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", @@ -2953,7 +2953,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 (); @@ -2963,13 +2963,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 (); @@ -2979,7 +2979,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 (); @@ -2997,7 +2997,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 (); @@ -3023,13 +3023,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 (); @@ -3052,13 +3052,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 (); @@ -3106,7 +3106,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; @@ -3308,7 +3308,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; @@ -3321,7 +3321,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; @@ -3334,7 +3334,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 (); @@ -3342,7 +3342,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 (); @@ -3353,14 +3353,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 (); @@ -3372,7 +3372,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 (); @@ -3396,7 +3396,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 582b0073a1..4d3e392810 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 8a04e9c7db..29f7357400 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 453505b3d7..1acb6ce0b2 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 65a056b25f..94293d58c7 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 . */ 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 and
")); - *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 cefc612f3e..b0bb4827bf 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 2fbeec0e98..32558b832e 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -460,7 +460,7 @@ do_assign (CORE_ADDR start, size_t bcnt, int version) adi (examine|x)/count */ 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) @@ -472,7 +472,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++; @@ -495,7 +495,7 @@ adi_examine_command (char *args, int from_tty) adi (assign|a)/count = */ 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) @@ -504,7 +504,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] = ")); @@ -515,7 +515,7 @@ adi_assign_command (char *args, int from_tty) error (_("Usage: adi assign|a[/count] = ")); 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 3e96ae6f83..4d6700c85b 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -83,8 +83,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); @@ -1796,7 +1794,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); @@ -1809,7 +1807,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); @@ -1826,7 +1824,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 55f2b38c17..565292d6ab 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); } } } diff --git a/gdb/top.h b/gdb/top.h index 7a8ffc82df..d5cce6861e 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -280,7 +280,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 493146e712..c5588947d7 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -882,10 +882,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 @@ -1965,7 +1961,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 57cf909beb..a6d34ea00a 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) {