public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 0/4] finish command constification
@ 2017-10-16  3:22 Tom Tromey
  2017-10-16  3:22 ` [RFA 2/4] Remove cmd_cfunc_ftype Tom Tromey
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Tom Tromey @ 2017-10-16  3:22 UTC (permalink / raw)
  To: gdb-patches

This series completes my command constification efforts.  This turned
out to be much simpler than I had anticipated; partly because I
started automating some of the changes, and partly because C++ makes
some incremental refactorings simpler -- as discussed before, in this
case by allowing the introduction of const overloads.

This series touches some files I can't compile.  I made a best effort
to inspect them for const correctness; but it's hard to be sure.
Given the experience of this series as a whole, I think it is safe to
say that any required changes will be minimal.

These patches point out that a number of spots in gdb were not really
const-correct.  For example there was code like:

    some_command ((char *) "a constant"), ...)

These weren't actually unsafe but nevertheless were ugly.

Regression tested by the buildbot.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA 2/4] Remove cmd_cfunc_ftype
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
@ 2017-10-16  3:22 ` Tom Tromey
  2017-11-06 11:58   ` Yao Qi
  2017-10-16  3:23 ` [RFA 3/4] Constify add_setshow_* Tom Tromey
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2017-10-16  3:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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  <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.
---
 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)
 
 \f
 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)
 
 \f
 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\
 
 \f
 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 <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 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 <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)
@@ -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 <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)
@@ -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] <addr> = <version>"));
 
@@ -515,7 +515,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 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 (&copy[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)
     {
-- 
2.13.6

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA 3/4] Constify add_setshow_*
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
  2017-10-16  3:22 ` [RFA 2/4] Remove cmd_cfunc_ftype Tom Tromey
@ 2017-10-16  3:23 ` Tom Tromey
  2017-10-16  3:23 ` [RFA 4/4] Constify execute_command Tom Tromey
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2017-10-16  3:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies the add_setshow_* family of functions, and then fixes
up the fallout.  The bulk of this patch was written by script.

gdb/ChangeLog
2017-10-15  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (catch_ada_exception_command): Constify.
	(catch_assert_command): Constify.
	* break-catch-throw.c (catch_catch_command, catch_throw_command)
	(catch_rethrow_command): Constify.
	(catch_exception_command_1): Constify.
	* breakpoint.h (add_catch_command): Constify.
	* break-catch-syscall.c (catch_syscall_command_1): Constify.
	(catch_syscall_split_args): Constify.
	* break-catch-sig.c (catch_signal_command): Constify.
	(catch_signal_split_args): Constify.
	* cli/cli-decode.h (struct cmd_list_element) <function>: Use
	cmd_const_sfunc_ftype.
	* cli/cli-decode.c (add_setshow_cmd_full): Constify.
	(add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
	(add_setshow_boolean_cmd, add_setshow_filename_cmd)
	(add_setshow_string_cmd, struct cmd_list_element)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd):
	Constify.
	(set_cmd_sfunc): Constify.
	(empty_sfunc): Constify.
	* command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
	(add_setshow_boolean_cmd, add_setshow_filename_cmd)
	(add_setshow_string_cmd, add_setshow_string_noescape_cmd)
	(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
	(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
	(add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd):
	Constify.
	(set_cmd_sfunc): Constify.
	(cmd_sfunc_ftype): Remove.
	* compile/compile.c (set_compile_args): Constify.
	* infrun.c (set_disable_randomization): Constify.
	* infcmd.c (set_args_command, set_cwd_command): Constify.
	* breakpoint.c (set_condition_evaluation_mode): Constify.
	(add_catch_command): Constify.
	(catch_fork_command_1, catch_exec_command_1)
	(catch_load_command_1, catch_unload_command_1): Constify.
	(catch_load_or_unload): Constify.
	* guile/scm-param.c (pascm_set_func): Constify.
	(add_setshow_generic): Constify.
	* python/py-param.c (get_set_value): Constify.
	* top.h (set_verbose): Constify.
	* tui/tui-win.c (tui_set_var_cmd): Constify.
	* mi/mi-main.c (set_mi_async_command): Constify.
	* cli/cli-logging.c (set_logging_overwrite)
	(set_logging_redirect): Constify.
	* value.c (set_max_value_size): Constify.
	* valprint.c (set_input_radix, set_output_radix): Constify.
	* utils.c (set_width_command, set_height_command): Constify.
	* typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify.
	* tracepoint.c (set_disconnected_tracing)
	(set_circular_trace_buffer, set_trace_buffer_size)
	(set_trace_user, set_trace_notes, set_trace_stop_notes): Constify.
	* top.c (set_history_size_command, set_verbose, set_editing)
	(set_gdb_datadir, set_history_filename): Constify.
	* target.c (set_targetdebug, maint_set_target_async_command)
	(maint_set_target_non_stop_command, set_target_permissions)
	(set_write_memory_permission): Constify.
	(open_target): Constify.
	* target-descriptions.c (set_tdesc_filename_cmd): Constify.
	* target-dcache.c (set_stack_cache, set_code_cache): Constify.
	* symtab.c (set_symbol_cache_size_handler): Constify.
	* symfile.c (set_ext_lang_command): Constify.
	* symfile-debug.c (set_debug_symfile): Constify.
	* source.c (set_directories_command): Constify.
	* solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify.
	* serial.c (set_parity): Constify.
	* rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify.
	* remote.c (set_remote_exec_file, set_remotebreak)
	(set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify.
	* record.c (set_record_insn_history_size)
	(set_record_call_history_size): Constify.
	* record-full.c (set_record_full_insn_max_num): Constify.
	* proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify.
	* osabi.c (set_osabi): Constify.
	* mips-tdep.c (set_mips64_transfers_32bit_regs)
	(reinit_frame_cache_sfunc, mips_abi_update): Constify.
	* maint.c (maintenance_set_profile_cmd): Constify.
	* linux-thread-db.c (set_libthread_db_search_path): Constify.
	* language.c (set_language_command, set_range_command)
	(set_case_command): Constify.
	* infrun.c (set_non_stop, set_observer_mode)
	(set_stop_on_solib_events, set_schedlock_func)
	(set_exec_direction_func): Constify.
	* infcmd.c (set_inferior_tty_command): Constify.
	* disasm.c (set_disassembler_options_sfunc): Constify.
	* demangle.c (set_demangling_command): Constify.
	* dcache.c (set_dcache_size, set_dcache_line_size): Constify.
	* cris-tdep.c (set_cris_version, set_cris_mode)
	(set_cris_dwarf2_cfi): Constify.
	* corefile.c (set_gnutarget_command): Constify.
	* charset.c (set_host_charset_sfunc, set_target_charset_sfunc)
	(set_target_wide_charset_sfunc): Constify.
	* breakpoint.c (update_dprintf_commands): Constify.
	* auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify.
	* arm-tdep.c (set_fp_model_sfunc, arm_set_abi)
	(set_disassembly_style_sfunc): Constify.
	* arch-utils.c (set_endian, set_architecture): Constify.
	* alpha-tdep.c (reinit_frame_cache_sfunc): Constify.
	* agent.c (set_can_use_agent): Constify.
---
 gdb/ChangeLog             | 104 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c            |   4 +-
 gdb/agent.c               |   2 +-
 gdb/alpha-tdep.c          |   3 +-
 gdb/arch-utils.c          |   5 ++-
 gdb/arm-tdep.c            |   8 ++--
 gdb/auto-load.c           |   5 ++-
 gdb/break-catch-sig.c     |   4 +-
 gdb/break-catch-syscall.c |   4 +-
 gdb/break-catch-throw.c   |  11 ++---
 gdb/breakpoint.c          |  18 ++++----
 gdb/breakpoint.h          |   2 +-
 gdb/charset.c             |   8 ++--
 gdb/cli/cli-decode.c      |  31 +++++++-------
 gdb/cli/cli-decode.h      |   2 +-
 gdb/cli/cli-logging.c     |   6 ++-
 gdb/command.h             |  30 ++++++-------
 gdb/compile/compile.c     |   2 +-
 gdb/corefile.c            |   5 +--
 gdb/cris-tdep.c           |  12 +++---
 gdb/dcache.c              |   4 +-
 gdb/demangle.c            |   3 +-
 gdb/disasm.c              |   2 +-
 gdb/guile/scm-param.c     |   4 +-
 gdb/infcmd.c              |   6 +--
 gdb/infrun.c              |  16 ++++---
 gdb/language.c            |   8 ++--
 gdb/linux-thread-db.c     |   2 +-
 gdb/maint.c               |   4 +-
 gdb/mi/mi-main.c          |   2 +-
 gdb/mips-tdep.c           |   9 ++--
 gdb/osabi.c               |   2 +-
 gdb/proc-api.c            |   6 ++-
 gdb/python/py-param.c     |   2 +-
 gdb/record-full.c         |   2 +-
 gdb/record.c              |   4 +-
 gdb/remote.c              |   8 ++--
 gdb/rs6000-tdep.c         |   4 +-
 gdb/serial.c              |   2 +-
 gdb/solib.c               |   4 +-
 gdb/source.c              |   3 +-
 gdb/symfile-debug.c       |   2 +-
 gdb/symfile.c             |   3 +-
 gdb/symtab.c              |   2 +-
 gdb/target-dcache.c       |   4 +-
 gdb/target-descriptions.c |   2 +-
 gdb/target.c              |  12 +++---
 gdb/top.c                 |  12 +++---
 gdb/top.h                 |   2 +-
 gdb/tracepoint.c          |  12 +++---
 gdb/tui/tui-win.c         |   3 +-
 gdb/typeprint.c           |   6 ++-
 gdb/utils.c               |   4 +-
 gdb/valprint.c            |   8 +---
 gdb/value.c               |   2 +-
 55 files changed, 273 insertions(+), 164 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0696edb740..f871edd5db 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13003,7 +13003,7 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch,
 /* Implement the "catch exception" command.  */
 
 static void
-catch_ada_exception_command (char *arg_entry, int from_tty,
+catch_ada_exception_command (const char *arg_entry, int from_tty,
 			     struct cmd_list_element *command)
 {
   const char *arg = arg_entry;
@@ -13058,7 +13058,7 @@ catch_ada_assert_command_split (const char *args, char **cond_string)
 /* Implement the "catch assert" command.  */
 
 static void
-catch_assert_command (char *arg_entry, int from_tty,
+catch_assert_command (const char *arg_entry, int from_tty,
 		      struct cmd_list_element *command)
 {
   const char *arg = arg_entry;
diff --git a/gdb/agent.c b/gdb/agent.c
index c0f10aa702..f04845e998 100644
--- a/gdb/agent.c
+++ b/gdb/agent.c
@@ -44,7 +44,7 @@ show_can_use_agent (struct ui_file *file, int from_tty,
 }
 
 static void
-set_can_use_agent (char *args, int from_tty, struct cmd_list_element *c)
+set_can_use_agent (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (target_use_agent (can_use_agent == can_use_agent_on) == 0)
     /* Something wrong during setting, set flag to default value.  */
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 89556956ab..2e520bcb41 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -1461,7 +1461,8 @@ static const struct frame_base alpha_heuristic_frame_base = {
    callable as an sfunc.  Used by the "set heuristic-fence-post" command.  */
 
 static void
-reinit_frame_cache_sfunc (char *args, int from_tty, struct cmd_list_element *c)
+reinit_frame_cache_sfunc (const char *args,
+			  int from_tty, struct cmd_list_element *c)
 {
   reinit_frame_cache ();
 }
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 6bdcc0126d..39de36909a 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -332,7 +332,7 @@ show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
 }
 
 static void
-set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
+set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
 {
   struct gdbarch_info info;
 
@@ -490,7 +490,8 @@ show_architecture (struct ui_file *file, int from_tty,
    argument.  */
 
 static void
-set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
+set_architecture (const char *ignore_args,
+		  int from_tty, struct cmd_list_element *c)
 {
   struct gdbarch_info info;
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 960696df93..c633cb3734 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -220,7 +220,7 @@ static const char *disassembly_style;
 
 /* This is used to keep the bfd arch_info in sync with the disassembly
    style.  */
-static void set_disassembly_style_sfunc(char *, int,
+static void set_disassembly_style_sfunc (const char *, int,
 					 struct cmd_list_element *);
 static void show_disassembly_style_sfunc (struct ui_file *, int,
 					  struct cmd_list_element *,
@@ -8384,7 +8384,7 @@ arm_update_current_architecture (void)
 }
 
 static void
-set_fp_model_sfunc (char *args, int from_tty,
+set_fp_model_sfunc (const char *args, int from_tty,
 		    struct cmd_list_element *c)
 {
   int fp_model;
@@ -8421,7 +8421,7 @@ The current ARM floating point model is \"%s\".\n"),
 }
 
 static void
-arm_set_abi (char *args, int from_tty,
+arm_set_abi (const char *args, int from_tty,
 	     struct cmd_list_element *c)
 {
   int arm_abi;
@@ -8482,7 +8482,7 @@ arm_show_force_mode (struct ui_file *file, int from_tty,
    arm disassembly" command, and does that.  */
 
 static void
-set_disassembly_style_sfunc (char *args, int from_tty,
+set_disassembly_style_sfunc (const char *args, int from_tty,
 			     struct cmd_list_element *c)
 {
   /* Convert the short style name into the long style name (eg, reg-names-*)
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 6ef05fd913..6d5c9a3b37 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -139,7 +139,7 @@ static char *auto_load_dir;
 /* "set" command for the auto_load_dir configuration variable.  */
 
 static void
-set_auto_load_dir (char *args, int from_tty, struct cmd_list_element *c)
+set_auto_load_dir (const char *args, int from_tty, struct cmd_list_element *c)
 {
   /* Setting the variable to "" resets it to the compile time defaults.  */
   if (auto_load_dir[0] == '\0')
@@ -262,7 +262,8 @@ auto_load_gdb_datadir_changed (void)
 /* "set" command for the auto_load_safe_path configuration variable.  */
 
 static void
-set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c)
+set_auto_load_safe_path (const char *args,
+			 int from_tty, struct cmd_list_element *c)
 {
   /* Setting the variable to "" resets it to the compile time defaults.  */
   if (auto_load_safe_path[0] == '\0')
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 5bc3aed09d..6100d1ee62 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -332,7 +332,7 @@ create_signal_catchpoint (int tempflag, std::vector<gdb_signal> &&filter,
    list, which is empty if no filtering is required.  */
 
 static std::vector<gdb_signal>
-catch_signal_split_args (char *arg, bool *catch_all)
+catch_signal_split_args (const char *arg, bool *catch_all)
 {
   std::vector<gdb_signal> result;
   bool first = true;
@@ -381,7 +381,7 @@ catch_signal_split_args (char *arg, bool *catch_all)
 /* Implement the "catch signal" command.  */
 
 static void
-catch_signal_command (char *arg, int from_tty,
+catch_signal_command (const char *arg, int from_tty,
 		      struct cmd_list_element *command)
 {
   int tempflag;
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 01e761ce37..be5933dbe2 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -382,7 +382,7 @@ create_syscall_event_catchpoint (int tempflag, std::vector<int> &&filter,
 /* Splits the argument using space as delimiter.  */
 
 static std::vector<int>
-catch_syscall_split_args (char *arg)
+catch_syscall_split_args (const char *arg)
 {
   std::vector<int> result;
   struct gdbarch *gdbarch = target_gdbarch ();
@@ -457,7 +457,7 @@ catch_syscall_split_args (char *arg)
 /* Implement the "catch syscall" command.  */
 
 static void
-catch_syscall_command_1 (char *arg, int from_tty, 
+catch_syscall_command_1 (const char *arg, int from_tty, 
 			 struct cmd_list_element *command)
 {
   int tempflag;
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index faa878e931..fd8a113803 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -430,11 +430,10 @@ extract_exception_regexp (const char **string)
 
 static void
 catch_exception_command_1 (enum exception_event_kind ex_event,
-			   char *arg_entry,
+			   const char *arg,
 			   int tempflag, int from_tty)
 {
   const char *cond_string = NULL;
-  const char *arg = arg_entry;
 
   if (!arg)
     arg = "";
@@ -459,7 +458,8 @@ catch_exception_command_1 (enum exception_event_kind ex_event,
 /* Implementation of "catch catch" command.  */
 
 static void
-catch_catch_command (char *arg, int from_tty, struct cmd_list_element *command)
+catch_catch_command (const char *arg, int from_tty,
+		     struct cmd_list_element *command)
 {
   int tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
 
@@ -469,7 +469,8 @@ catch_catch_command (char *arg, int from_tty, struct cmd_list_element *command)
 /* Implementation of "catch throw" command.  */
 
 static void
-catch_throw_command (char *arg, int from_tty, struct cmd_list_element *command)
+catch_throw_command (const char *arg, int from_tty,
+		     struct cmd_list_element *command)
 {
   int tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
 
@@ -479,7 +480,7 @@ catch_throw_command (char *arg, int from_tty, struct cmd_list_element *command)
 /* Implementation of "catch rethrow" command.  */
 
 static void
-catch_rethrow_command (char *arg, int from_tty,
+catch_rethrow_command (const char *arg, int from_tty,
 		       struct cmd_list_element *command)
 {
   int tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fc78f8ed81..16a34fb07a 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -712,7 +712,7 @@ mark_breakpoint_location_modified (struct bp_location *loc)
    condition_evaluation_mode.  */
 
 static void
-set_condition_evaluation_mode (char *args, int from_tty,
+set_condition_evaluation_mode (const char *args, int from_tty,
 			       struct cmd_list_element *c)
 {
   const char *old_mode, *new_mode;
@@ -8241,7 +8241,7 @@ add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
    "catch unload".  */
 
 static void
-catch_load_or_unload (char *arg, int from_tty, int is_load,
+catch_load_or_unload (const char *arg, int from_tty, int is_load,
 		      struct cmd_list_element *command)
 {
   int tempflag;
@@ -8253,14 +8253,14 @@ catch_load_or_unload (char *arg, int from_tty, int is_load,
 }
 
 static void
-catch_load_command_1 (char *arg, int from_tty,
+catch_load_command_1 (const char *arg, int from_tty,
 		      struct cmd_list_element *command)
 {
   catch_load_or_unload (arg, from_tty, 1, command);
 }
 
 static void
-catch_unload_command_1 (char *arg, int from_tty,
+catch_unload_command_1 (const char *arg, int from_tty,
 			struct cmd_list_element *command)
 {
   catch_load_or_unload (arg, from_tty, 0, command);
@@ -8867,7 +8867,7 @@ update_dprintf_command_list (struct breakpoint *b)
    current style settings.  */
 
 static void
-update_dprintf_commands (char *args, int from_tty,
+update_dprintf_commands (const char *args, int from_tty,
 			 struct cmd_list_element *c)
 {
   struct breakpoint *b;
@@ -11344,10 +11344,9 @@ typedef enum
 catch_fork_kind;
 
 static void
-catch_fork_command_1 (char *arg_entry, int from_tty,
+catch_fork_command_1 (const char *arg, int from_tty,
 		      struct cmd_list_element *command)
 {
-  const char *arg = arg_entry;
   struct gdbarch *gdbarch = get_current_arch ();
   const char *cond_string = NULL;
   catch_fork_kind fork_kind;
@@ -11392,10 +11391,9 @@ catch_fork_command_1 (char *arg_entry, int from_tty,
 }
 
 static void
-catch_exec_command_1 (char *arg_entry, int from_tty,
+catch_exec_command_1 (const char *arg, int from_tty,
 		      struct cmd_list_element *command)
 {
-  const char *arg = arg_entry;
   struct gdbarch *gdbarch = get_current_arch ();
   int tempflag;
   const char *cond_string = NULL;
@@ -15224,7 +15222,7 @@ static struct cmd_list_element *tcatch_cmdlist;
 
 void
 add_catch_command (const char *name, const char *docstring,
-		   cmd_sfunc_ftype *sfunc,
+		   cmd_const_sfunc_ftype *sfunc,
 		   completer_ftype *completer,
 		   void *user_data_catch,
 		   void *user_data_tcatch)
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index c75d5b5b1b..f256392663 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1277,7 +1277,7 @@ extern void initialize_breakpoint_ops (void);
 
 extern void
   add_catch_command (const char *name, const char *docstring,
-		     cmd_sfunc_ftype *sfunc,
+		     cmd_const_sfunc_ftype *sfunc,
 		     completer_ftype *completer,
 		     void *user_data_catch,
 		     void *user_data_tcatch);
diff --git a/gdb/charset.c b/gdb/charset.c
index cc74331058..709a314914 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -365,7 +365,7 @@ validate (struct gdbarch *gdbarch)
 
 /* This is the sfunc for the 'set charset' command.  */
 static void
-set_charset_sfunc (char *charset, int from_tty, 
+set_charset_sfunc (const char *charset, int from_tty, 
 		   struct cmd_list_element *c)
 {
   /* CAREFUL: set the target charset here as well.  */
@@ -376,7 +376,7 @@ set_charset_sfunc (char *charset, int from_tty,
 /* 'set host-charset' command sfunc.  We need a wrapper here because
    the function needs to have a specific signature.  */
 static void
-set_host_charset_sfunc (char *charset, int from_tty,
+set_host_charset_sfunc (const char *charset, int from_tty,
 			struct cmd_list_element *c)
 {
   validate (get_current_arch ());
@@ -384,7 +384,7 @@ set_host_charset_sfunc (char *charset, int from_tty,
 
 /* Wrapper for the 'set target-charset' command.  */
 static void
-set_target_charset_sfunc (char *charset, int from_tty,
+set_target_charset_sfunc (const char *charset, int from_tty,
 			  struct cmd_list_element *c)
 {
   validate (get_current_arch ());
@@ -392,7 +392,7 @@ set_target_charset_sfunc (char *charset, int from_tty,
 
 /* Wrapper for the 'set target-wide-charset' command.  */
 static void
-set_target_wide_charset_sfunc (char *charset, int from_tty,
+set_target_wide_charset_sfunc (const char *charset, int from_tty,
 			       struct cmd_list_element *c)
 {
   validate (get_current_arch ());
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 459438e170..c3e72283c5 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -123,7 +123,7 @@ do_sfunc (struct cmd_list_element *c, char *args, int from_tty)
 }
 
 void
-set_cmd_sfunc (struct cmd_list_element *cmd, cmd_sfunc_ftype *sfunc)
+set_cmd_sfunc (struct cmd_list_element *cmd, cmd_const_sfunc_ftype *sfunc)
 {
   if (sfunc == NULL)
     cmd->func = NULL;
@@ -414,10 +414,9 @@ not_just_help_class_command (const char *args, int from_tty)
 }
 
 /* This is an empty "sfunc".  */
-static void empty_sfunc (char *, int, struct cmd_list_element *);
 
 static void
-empty_sfunc (char *args, int from_tty, struct cmd_list_element *c)
+empty_sfunc (const char *args, int from_tty, struct cmd_list_element *c)
 {
 }
 
@@ -465,7 +464,7 @@ add_setshow_cmd_full (const char *name,
 		      var_types var_type, void *var,
 		      const char *set_doc, const char *show_doc,
 		      const char *help_doc,
-		      cmd_sfunc_ftype *set_func,
+		      cmd_const_sfunc_ftype *set_func,
 		      show_value_ftype *show_func,
 		      struct cmd_list_element **set_list,
 		      struct cmd_list_element **show_list,
@@ -520,7 +519,7 @@ add_setshow_enum_cmd (const char *name,
 		      const char *set_doc,
 		      const char *show_doc,
 		      const char *help_doc,
-		      cmd_sfunc_ftype *set_func,
+		      cmd_const_sfunc_ftype *set_func,
 		      show_value_ftype *show_func,
 		      struct cmd_list_element **set_list,
 		      struct cmd_list_element **show_list)
@@ -547,7 +546,7 @@ add_setshow_auto_boolean_cmd (const char *name,
 			      enum auto_boolean *var,
 			      const char *set_doc, const char *show_doc,
 			      const char *help_doc,
-			      cmd_sfunc_ftype *set_func,
+			      cmd_const_sfunc_ftype *set_func,
 			      show_value_ftype *show_func,
 			      struct cmd_list_element **set_list,
 			      struct cmd_list_element **show_list)
@@ -570,7 +569,7 @@ void
 add_setshow_boolean_cmd (const char *name, enum command_class theclass, int *var,
 			 const char *set_doc, const char *show_doc,
 			 const char *help_doc,
-			 cmd_sfunc_ftype *set_func,
+			 cmd_const_sfunc_ftype *set_func,
 			 show_value_ftype *show_func,
 			 struct cmd_list_element **set_list,
 			 struct cmd_list_element **show_list)
@@ -593,7 +592,7 @@ add_setshow_filename_cmd (const char *name, enum command_class theclass,
 			  char **var,
 			  const char *set_doc, const char *show_doc,
 			  const char *help_doc,
-			  cmd_sfunc_ftype *set_func,
+			  cmd_const_sfunc_ftype *set_func,
 			  show_value_ftype *show_func,
 			  struct cmd_list_element **set_list,
 			  struct cmd_list_element **show_list)
@@ -615,7 +614,7 @@ add_setshow_string_cmd (const char *name, enum command_class theclass,
 			char **var,
 			const char *set_doc, const char *show_doc,
 			const char *help_doc,
-			cmd_sfunc_ftype *set_func,
+			cmd_const_sfunc_ftype *set_func,
 			show_value_ftype *show_func,
 			struct cmd_list_element **set_list,
 			struct cmd_list_element **show_list)
@@ -634,7 +633,7 @@ add_setshow_string_noescape_cmd (const char *name, enum command_class theclass,
 				 char **var,
 				 const char *set_doc, const char *show_doc,
 				 const char *help_doc,
-				 cmd_sfunc_ftype *set_func,
+				 cmd_const_sfunc_ftype *set_func,
 				 show_value_ftype *show_func,
 				 struct cmd_list_element **set_list,
 				 struct cmd_list_element **show_list)
@@ -656,7 +655,7 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class theclass
 				   char **var,
 				   const char *set_doc, const char *show_doc,
 				   const char *help_doc,
-				   cmd_sfunc_ftype *set_func,
+				   cmd_const_sfunc_ftype *set_func,
 				   show_value_ftype *show_func,
 				   struct cmd_list_element **set_list,
 				   struct cmd_list_element **show_list)
@@ -700,7 +699,7 @@ add_setshow_integer_cmd (const char *name, enum command_class theclass,
 			 int *var,
 			 const char *set_doc, const char *show_doc,
 			 const char *help_doc,
-			 cmd_sfunc_ftype *set_func,
+			 cmd_const_sfunc_ftype *set_func,
 			 show_value_ftype *show_func,
 			 struct cmd_list_element **set_list,
 			 struct cmd_list_element **show_list)
@@ -725,7 +724,7 @@ add_setshow_uinteger_cmd (const char *name, enum command_class theclass,
 			  unsigned int *var,
 			  const char *set_doc, const char *show_doc,
 			  const char *help_doc,
-			  cmd_sfunc_ftype *set_func,
+			  cmd_const_sfunc_ftype *set_func,
 			  show_value_ftype *show_func,
 			  struct cmd_list_element **set_list,
 			  struct cmd_list_element **show_list)
@@ -750,7 +749,7 @@ add_setshow_zinteger_cmd (const char *name, enum command_class theclass,
 			  int *var,
 			  const char *set_doc, const char *show_doc,
 			  const char *help_doc,
-			  cmd_sfunc_ftype *set_func,
+			  cmd_const_sfunc_ftype *set_func,
 			  show_value_ftype *show_func,
 			  struct cmd_list_element **set_list,
 			  struct cmd_list_element **show_list)
@@ -769,7 +768,7 @@ add_setshow_zuinteger_unlimited_cmd (const char *name,
 				     const char *set_doc,
 				     const char *show_doc,
 				     const char *help_doc,
-				     cmd_sfunc_ftype *set_func,
+				     cmd_const_sfunc_ftype *set_func,
 				     show_value_ftype *show_func,
 				     struct cmd_list_element **set_list,
 				     struct cmd_list_element **show_list)
@@ -794,7 +793,7 @@ add_setshow_zuinteger_cmd (const char *name, enum command_class theclass,
 			   unsigned int *var,
 			   const char *set_doc, const char *show_doc,
 			   const char *help_doc,
-			   cmd_sfunc_ftype *set_func,
+			   cmd_const_sfunc_ftype *set_func,
 			   show_value_ftype *show_func,
 			   struct cmd_list_element **set_list,
 			   struct cmd_list_element **show_list)
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index e3ac69ba66..9b2d598ff5 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -116,7 +116,7 @@ struct cmd_list_element
 	cmd_const_cfunc_ftype *const_cfunc;
 	/* If type is set_cmd or show_cmd, first set the variables,
 	   and then call this: */
-	cmd_sfunc_ftype *sfunc;
+	cmd_const_sfunc_ftype *sfunc;
       }
     function;
 
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index ee31659389..8e86ce7295 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -44,7 +44,8 @@ maybe_warn_already_logging ()
 }
 
 static void
-set_logging_overwrite (char *args, int from_tty, struct cmd_list_element *c)
+set_logging_overwrite (const char *args,
+		       int from_tty, struct cmd_list_element *c)
 {
   maybe_warn_already_logging ();
 }
@@ -63,7 +64,8 @@ show_logging_overwrite (struct ui_file *file, int from_tty,
 static int logging_redirect;
 
 static void
-set_logging_redirect (char *args, int from_tty, struct cmd_list_element *c)
+set_logging_redirect (const char *args,
+		      int from_tty, struct cmd_list_element *c)
 {
   maybe_warn_already_logging ();
 }
diff --git a/gdb/command.h b/gdb/command.h
index cbcf523cc9..69e903fd1c 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -174,10 +174,10 @@ extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
 						       struct cmd_list_element
 						       **);
 
-typedef void cmd_sfunc_ftype (char *args, int from_tty,
-			      struct cmd_list_element *c);
+typedef void cmd_const_sfunc_ftype (const char *args, int from_tty,
+				    struct cmd_list_element *c);
 extern void set_cmd_sfunc (struct cmd_list_element *cmd,
-			   cmd_sfunc_ftype *sfunc);
+			   cmd_const_sfunc_ftype *sfunc);
 
 /* A completion routine.  Add possible completions to tracker.
 
@@ -297,7 +297,7 @@ extern void add_setshow_enum_cmd (const char *name,
 				  const char *set_doc,
 				  const char *show_doc,
 				  const char *help_doc,
-				  cmd_sfunc_ftype *set_func,
+				  cmd_const_sfunc_ftype *set_func,
 				  show_value_ftype *show_func,
 				  struct cmd_list_element **set_list,
 				  struct cmd_list_element **show_list);
@@ -308,7 +308,7 @@ extern void add_setshow_auto_boolean_cmd (const char *name,
 					  const char *set_doc,
 					  const char *show_doc,
 					  const char *help_doc,
-					  cmd_sfunc_ftype *set_func,
+					  cmd_const_sfunc_ftype *set_func,
 					  show_value_ftype *show_func,
 					  struct cmd_list_element **set_list,
 					  struct cmd_list_element **show_list);
@@ -318,7 +318,7 @@ extern void add_setshow_boolean_cmd (const char *name,
 				     int *var,
 				     const char *set_doc, const char *show_doc,
 				     const char *help_doc,
-				     cmd_sfunc_ftype *set_func,
+				     cmd_const_sfunc_ftype *set_func,
 				     show_value_ftype *show_func,
 				     struct cmd_list_element **set_list,
 				     struct cmd_list_element **show_list);
@@ -329,7 +329,7 @@ extern void add_setshow_filename_cmd (const char *name,
 				      const char *set_doc,
 				      const char *show_doc,
 				      const char *help_doc,
-				      cmd_sfunc_ftype *set_func,
+				      cmd_const_sfunc_ftype *set_func,
 				      show_value_ftype *show_func,
 				      struct cmd_list_element **set_list,
 				      struct cmd_list_element **show_list);
@@ -340,7 +340,7 @@ extern void add_setshow_string_cmd (const char *name,
 				    const char *set_doc,
 				    const char *show_doc,
 				    const char *help_doc,
-				    cmd_sfunc_ftype *set_func,
+				    cmd_const_sfunc_ftype *set_func,
 				    show_value_ftype *show_func,
 				    struct cmd_list_element **set_list,
 				    struct cmd_list_element **show_list);
@@ -352,7 +352,7 @@ extern struct cmd_list_element *add_setshow_string_noescape_cmd
 		       const char *set_doc,
 		       const char *show_doc,
 		       const char *help_doc,
-		       cmd_sfunc_ftype *set_func,
+		       cmd_const_sfunc_ftype *set_func,
 		       show_value_ftype *show_func,
 		       struct cmd_list_element **set_list,
 		       struct cmd_list_element **show_list);
@@ -363,7 +363,7 @@ extern void add_setshow_optional_filename_cmd (const char *name,
 					       const char *set_doc,
 					       const char *show_doc,
 					       const char *help_doc,
-					       cmd_sfunc_ftype *set_func,
+					       cmd_const_sfunc_ftype *set_func,
 					       show_value_ftype *show_func,
 					       struct cmd_list_element **set_list,
 					       struct cmd_list_element **show_list);
@@ -374,7 +374,7 @@ extern void add_setshow_integer_cmd (const char *name,
 				     const char *set_doc,
 				     const char *show_doc,
 				     const char *help_doc,
-				     cmd_sfunc_ftype *set_func,
+				     cmd_const_sfunc_ftype *set_func,
 				     show_value_ftype *show_func,
 				     struct cmd_list_element **set_list,
 				     struct cmd_list_element **show_list);
@@ -385,7 +385,7 @@ extern void add_setshow_uinteger_cmd (const char *name,
 				      const char *set_doc,
 				      const char *show_doc,
 				      const char *help_doc,
-				      cmd_sfunc_ftype *set_func,
+				      cmd_const_sfunc_ftype *set_func,
 				      show_value_ftype *show_func,
 				      struct cmd_list_element **set_list,
 				      struct cmd_list_element **show_list);
@@ -396,7 +396,7 @@ extern void add_setshow_zinteger_cmd (const char *name,
 				      const char *set_doc,
 				      const char *show_doc,
 				      const char *help_doc,
-				      cmd_sfunc_ftype *set_func,
+				      cmd_const_sfunc_ftype *set_func,
 				      show_value_ftype *show_func,
 				      struct cmd_list_element **set_list,
 				      struct cmd_list_element **show_list);
@@ -407,7 +407,7 @@ extern void add_setshow_zuinteger_cmd (const char *name,
 				       const char *set_doc,
 				       const char *show_doc,
 				       const char *help_doc,
-				       cmd_sfunc_ftype *set_func,
+				       cmd_const_sfunc_ftype *set_func,
 				       show_value_ftype *show_func,
 				       struct cmd_list_element **set_list,
 				       struct cmd_list_element **show_list);
@@ -419,7 +419,7 @@ extern void
 				       const char *set_doc,
 				       const char *show_doc,
 				       const char *help_doc,
-				       cmd_sfunc_ftype *set_func,
+				       cmd_const_sfunc_ftype *set_func,
 				       show_value_ftype *show_func,
 				       struct cmd_list_element **set_list,
 				       struct cmd_list_element **show_list);
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index cd8ce6a1c1..9de244a6ee 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -302,7 +302,7 @@ static char **compile_args_argv;
 /* Implement 'set compile-args'.  */
 
 static void
-set_compile_args (char *args, int from_tty, struct cmd_list_element *c)
+set_compile_args (const char *args, int from_tty, struct cmd_list_element *c)
 {
   freeargv (compile_args_argv);
   build_argc_argv (compile_args, &compile_args_argc, &compile_args_argv);
diff --git a/gdb/corefile.c b/gdb/corefile.c
index b9d95c07db..686603aaa8 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -452,11 +452,8 @@ show_gnutarget_string (struct ui_file *file, int from_tty,
 		    _("The current BFD target is \"%s\".\n"), value);
 }
 
-static void set_gnutarget_command (char *, int,
-				   struct cmd_list_element *);
-
 static void
-set_gnutarget_command (char *ignore, int from_tty,
+set_gnutarget_command (const char *ignore, int from_tty,
 		       struct cmd_list_element *c)
 {
   char *gend = gnutarget_string + strlen (gnutarget_string);
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index d64c99ac81..94dd227241 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -634,13 +634,13 @@ static struct gdbarch *cris_gdbarch_init (struct gdbarch_info,
 
 static void cris_dump_tdep (struct gdbarch *, struct ui_file *);
 
-static void set_cris_version (char *ignore_args, int from_tty, 
+static void set_cris_version (const char *ignore_args, int from_tty, 
 			      struct cmd_list_element *c);
 
-static void set_cris_mode (char *ignore_args, int from_tty, 
+static void set_cris_mode (const char *ignore_args, int from_tty, 
 			   struct cmd_list_element *c);
 
-static void set_cris_dwarf2_cfi (char *ignore_args, int from_tty, 
+static void set_cris_dwarf2_cfi (const char *ignore_args, int from_tty, 
 				 struct cmd_list_element *c);
 
 static CORE_ADDR cris_scan_prologue (CORE_ADDR pc, 
@@ -3926,7 +3926,7 @@ cris_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 }
 
 static void
-set_cris_version (char *ignore_args, int from_tty, 
+set_cris_version (const char *ignore_args, int from_tty, 
 		  struct cmd_list_element *c)
 {
   struct gdbarch_info info;
@@ -3941,7 +3941,7 @@ set_cris_version (char *ignore_args, int from_tty,
 }
 
 static void
-set_cris_mode (char *ignore_args, int from_tty, 
+set_cris_mode (const char *ignore_args, int from_tty, 
 	       struct cmd_list_element *c)
 {
   struct gdbarch_info info;
@@ -3954,7 +3954,7 @@ set_cris_mode (char *ignore_args, int from_tty,
 }
 
 static void
-set_cris_dwarf2_cfi (char *ignore_args, int from_tty, 
+set_cris_dwarf2_cfi (const char *ignore_args, int from_tty, 
 		     struct cmd_list_element *c)
 {
   struct gdbarch_info info;
diff --git a/gdb/dcache.c b/gdb/dcache.c
index e7b1e1440e..740438fe11 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -644,7 +644,7 @@ info_dcache_command (const char *exp, int tty)
 }
 
 static void
-set_dcache_size (char *args, int from_tty,
+set_dcache_size (const char *args, int from_tty,
 		 struct cmd_list_element *c)
 {
   if (dcache_size == 0)
@@ -656,7 +656,7 @@ set_dcache_size (char *args, int from_tty,
 }
 
 static void
-set_dcache_line_size (char *args, int from_tty,
+set_dcache_line_size (const char *args, int from_tty,
 		      struct cmd_list_element *c)
 {
   if (dcache_line_size < 2
diff --git a/gdb/demangle.c b/gdb/demangle.c
index 1a97fb7f28..696f2141fc 100644
--- a/gdb/demangle.c
+++ b/gdb/demangle.c
@@ -104,7 +104,8 @@ show_demangling_style_names(struct ui_file *file, int from_tty,
    a malloc'd string, even if it is a null-string.  */
 
 static void
-set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
+set_demangling_command (const char *ignore,
+			int from_tty, struct cmd_list_element *c)
 {
   const struct demangler_engine *dem;
   int i;
diff --git a/gdb/disasm.c b/gdb/disasm.c
index cdab181484..7f37b9b077 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -962,7 +962,7 @@ set_disassembler_options (char *prospective_options)
 }
 
 static void
-set_disassembler_options_sfunc (char *args, int from_tty,
+set_disassembler_options_sfunc (const char *args, int from_tty,
 				struct cmd_list_element *c)
 {
   set_disassembler_options (prospective_options);
diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c
index ab00fd93e5..94787787f1 100644
--- a/gdb/guile/scm-param.c
+++ b/gdb/guile/scm-param.c
@@ -269,7 +269,7 @@ pascm_signal_setshow_error (SCM exception, const char *msg)
    Note: ARGS is always passed as NULL.  */
 
 static void
-pascm_set_func (char *args, int from_tty, struct cmd_list_element *c)
+pascm_set_func (const char *args, int from_tty, struct cmd_list_element *c)
 {
   param_smob *p_smob = (param_smob *) get_cmd_context (c);
   SCM self, result, exception;
@@ -357,7 +357,7 @@ static void
 add_setshow_generic (enum var_types param_type, enum command_class cmd_class,
 		     char *cmd_name, param_smob *self,
 		     char *set_doc, char *show_doc, char *help_doc,
-		     cmd_sfunc_ftype *set_func,
+		     cmd_const_sfunc_ftype *set_func,
 		     show_value_ftype *show_func,
 		     struct cmd_list_element **set_list,
 		     struct cmd_list_element **show_list,
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 7b6ac9e84e..005074daf1 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -134,7 +134,7 @@ get_inferior_io_terminal (void)
 }
 
 static void
-set_inferior_tty_command (char *args, int from_tty,
+set_inferior_tty_command (const char *args, int from_tty,
 			  struct cmd_list_element *c)
 {
   /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
@@ -198,7 +198,7 @@ set_inferior_args_vector (int argc, char **argv)
 /* Notice when `set args' is run.  */
 
 static void
-set_args_command (char *args, int from_tty, struct cmd_list_element *c)
+set_args_command (const char *args, int from_tty, struct cmd_list_element *c)
 {
   /* CLI has assigned the user-provided value to inferior_args_scratch.
      Now route it to current inferior.  */
@@ -242,7 +242,7 @@ get_inferior_cwd ()
 /* Handle the 'set cwd' command.  */
 
 static void
-set_cwd_command (char *args, int from_tty, struct cmd_list_element *c)
+set_cwd_command (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (*inferior_cwd_scratch == '\0')
     set_inferior_cwd (NULL);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index e5e938d19d..514d1c1fea 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -82,9 +82,6 @@ static int follow_fork_inferior (int follow_child, int detach_fork);
 
 static void follow_inferior_reset_breakpoints (void);
 
-static void set_schedlock_func (char *args, int from_tty,
-				struct cmd_list_element *c);
-
 static int currently_stepping (struct thread_info *tp);
 
 void nullify_last_target_wait_ptid (void);
@@ -195,7 +192,7 @@ show_disable_randomization (struct ui_file *file, int from_tty,
 }
 
 static void
-set_disable_randomization (char *args, int from_tty,
+set_disable_randomization (const char *args, int from_tty,
 			   struct cmd_list_element *c)
 {
   if (!target_supports_disable_randomization ())
@@ -210,7 +207,7 @@ int non_stop = 0;
 static int non_stop_1 = 0;
 
 static void
-set_non_stop (char *args, int from_tty,
+set_non_stop (const char *args, int from_tty,
 	      struct cmd_list_element *c)
 {
   if (target_has_execution)
@@ -239,7 +236,7 @@ int observer_mode = 0;
 static int observer_mode_1 = 0;
 
 static void
-set_observer_mode (char *args, int from_tty,
+set_observer_mode (const char *args, int from_tty,
 		   struct cmd_list_element *c)
 {
   if (target_has_execution)
@@ -364,7 +361,8 @@ int stop_on_solib_events;
    as appropriate when the above flag is changed.  */
 
 static void
-set_stop_on_solib_events (char *args, int from_tty, struct cmd_list_element *c)
+set_stop_on_solib_events (const char *args,
+			  int from_tty, struct cmd_list_element *c)
 {
   update_solib_breakpoints ();
 }
@@ -2227,7 +2225,7 @@ show_scheduler_mode (struct ui_file *file, int from_tty,
 }
 
 static void
-set_schedlock_func (char *args, int from_tty, struct cmd_list_element *c)
+set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (!target_can_lock_scheduler)
     {
@@ -9095,7 +9093,7 @@ static const char *const exec_direction_names[] = {
 };
 
 static void
-set_exec_direction_func (char *args, int from_tty,
+set_exec_direction_func (const char *args, int from_tty,
 			 struct cmd_list_element *cmd)
 {
   if (target_can_execute_reverse)
diff --git a/gdb/language.c b/gdb/language.c
index ecdf431743..e67f9aea34 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -155,7 +155,8 @@ show_language_command (struct ui_file *file, int from_tty,
 
 /* Set command.  Change the current working language.  */
 static void
-set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
+set_language_command (const char *ignore,
+		      int from_tty, struct cmd_list_element *c)
 {
   enum language flang = language_unknown;
 
@@ -252,7 +253,8 @@ show_range_command (struct ui_file *file, int from_tty,
 
 /* Set command.  Change the setting for range checking.  */
 static void
-set_range_command (char *ignore, int from_tty, struct cmd_list_element *c)
+set_range_command (const char *ignore,
+		   int from_tty, struct cmd_list_element *c)
 {
   if (strcmp (range, "on") == 0)
     {
@@ -326,7 +328,7 @@ show_case_command (struct ui_file *file, int from_tty,
 /* Set command.  Change the setting for case sensitivity.  */
 
 static void
-set_case_command (char *ignore, int from_tty, struct cmd_list_element *c)
+set_case_command (const char *ignore, int from_tty, struct cmd_list_element *c)
 {
    if (strcmp (case_sensitive, "on") == 0)
      {
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 1acb6ce0b2..ea032fc63a 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -92,7 +92,7 @@ show_auto_load_thread_db (struct ui_file *file, int from_tty,
 }
 
 static void
-set_libthread_db_search_path (char *ignored, int from_tty,
+set_libthread_db_search_path (const char *ignored, int from_tty,
 			      struct cmd_list_element *c)
 {
   if (*libthread_db_search_path == '\0')
diff --git a/gdb/maint.c b/gdb/maint.c
index 94293d58c7..34b0462336 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -684,7 +684,7 @@ EXTERN_C void monstartup (unsigned long, unsigned long);
 extern int main ();
 
 static void
-maintenance_set_profile_cmd (char *args, int from_tty,
+maintenance_set_profile_cmd (const char *args, int from_tty,
 			     struct cmd_list_element *c)
 {
   if (maintenance_profile_p == profiling_state)
@@ -715,7 +715,7 @@ maintenance_set_profile_cmd (char *args, int from_tty,
 }
 #else
 static void
-maintenance_set_profile_cmd (char *args, int from_tty,
+maintenance_set_profile_cmd (const char *args, int from_tty,
 			     struct cmd_list_element *c)
 {
   error (_("Profiling support is not available on this system."));
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index a94e329af8..7d4514459b 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -108,7 +108,7 @@ static int mi_async = 0;
 static int mi_async_1 = 0;
 
 static void
-set_mi_async_command (char *args, int from_tty,
+set_mi_async_command (const char *args, int from_tty,
 		      struct cmd_list_element *c)
 {
   if (have_live_inferiors ())
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 4eafe3e308..c116c4c8c1 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -555,8 +555,6 @@ mips2_fp_compat (struct frame_info *frame)
 
 static CORE_ADDR heuristic_proc_start (struct gdbarch *, CORE_ADDR);
 
-static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
-
 /* The list of available "set mips " and "show mips " commands.  */
 
 static struct cmd_list_element *setmipscmdlist = NULL;
@@ -854,7 +852,7 @@ static int heuristic_fence_post = 0;
 static int mips64_transfers_32bit_regs_p = 0;
 
 static void
-set_mips64_transfers_32bit_regs (char *args, int from_tty,
+set_mips64_transfers_32bit_regs (const char *args, int from_tty,
 				 struct cmd_list_element *c)
 {
   struct gdbarch_info info;
@@ -6989,7 +6987,7 @@ set_mipsfpu_auto_command (const char *args, int from_tty)
    callable as an sfunc.  */
 
 static void
-reinit_frame_cache_sfunc (char *args, int from_tty,
+reinit_frame_cache_sfunc (const char *args, int from_tty,
 			  struct cmd_list_element *c)
 {
   reinit_frame_cache ();
@@ -8846,7 +8844,8 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 }
 
 static void
-mips_abi_update (char *ignore_args, int from_tty, struct cmd_list_element *c)
+mips_abi_update (const char *ignore_args,
+		 int from_tty, struct cmd_list_element *c)
 {
   struct gdbarch_info info;
 
diff --git a/gdb/osabi.c b/gdb/osabi.c
index b4850bc9ad..9f3fe3c9fa 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -592,7 +592,7 @@ generic_elf_osabi_sniffer (bfd *abfd)
 }
 \f
 static void
-set_osabi (char *args, int from_tty, struct cmd_list_element *c)
+set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
 {
   struct gdbarch_info info;
 
diff --git a/gdb/proc-api.c b/gdb/proc-api.c
index 2198b2678e..a03caa1d4e 100644
--- a/gdb/proc-api.c
+++ b/gdb/proc-api.c
@@ -71,7 +71,8 @@ prepare_to_trace (void)
 }
 
 static void
-set_procfs_trace_cmd (char *args, int from_tty, struct cmd_list_element *c)
+set_procfs_trace_cmd (const char *args,
+		      int from_tty, struct cmd_list_element *c)
 {
 #if 0	/* not sure what I might actually need to do here, if anything */
   if (procfs_file)
@@ -80,7 +81,8 @@ set_procfs_trace_cmd (char *args, int from_tty, struct cmd_list_element *c)
 }
 
 static void
-set_procfs_file_cmd (char *args, int from_tty, struct cmd_list_element *c)
+set_procfs_file_cmd (const char *args,
+		     int from_tty, struct cmd_list_element *c)
 {
   /* Just changed the filename for procfs tracing.
      If a file was already open, close it.  */
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 455c99e516..3f8d4e327d 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -357,7 +357,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
    neither exist, insert a string indicating the Parameter is not
    documented.  */
 static void
-get_set_value (char *args, int from_tty,
+get_set_value (const char *args, int from_tty,
 	       struct cmd_list_element *c)
 {
   PyObject *obj = (PyObject *) get_cmd_context (c);
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 37836e75d0..9530df228d 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2761,7 +2761,7 @@ cmd_record_full_start (const char *args, int from_tty)
 }
 
 static void
-set_record_full_insn_max_num (char *args, int from_tty,
+set_record_full_insn_max_num (const char *args, int from_tty,
 			      struct cmd_list_element *c)
 {
   if (record_full_insn_num > record_full_insn_max_num)
diff --git a/gdb/record.c b/gdb/record.c
index 5ecdcfc5f9..f3e493a34b 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -758,7 +758,7 @@ validate_history_size (unsigned int *command_var, unsigned int *setting)
    [0..UINT_MAX].  See command_size_to_target_size.  */
 
 static void
-set_record_insn_history_size (char *args, int from_tty,
+set_record_insn_history_size (const char *args, int from_tty,
 			      struct cmd_list_element *c)
 {
   validate_history_size (&record_insn_history_size_setshow_var,
@@ -770,7 +770,7 @@ set_record_insn_history_size (char *args, int from_tty,
    [0..UINT_MAX].  See command_size_to_target_size.  */
 
 static void
-set_record_call_history_size (char *args, int from_tty,
+set_record_call_history_size (const char *args, int from_tty,
 			      struct cmd_list_element *c)
 {
   validate_history_size (&record_call_history_size_setshow_var,
diff --git a/gdb/remote.c b/gdb/remote.c
index 81c8cd509d..5c7d06b3c7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -718,7 +718,7 @@ set_pspace_remote_exec_file (struct program_space *pspace,
 /* The "set/show remote exec-file" set command hook.  */
 
 static void
-set_remote_exec_file (char *ignored, int from_tty,
+set_remote_exec_file (const char *ignored, int from_tty,
 		      struct cmd_list_element *c)
 {
   gdb_assert (remote_exec_file_var != NULL);
@@ -985,7 +985,7 @@ static int interrupt_on_connect = 0;
 static int remote_break;
 
 static void
-set_remotebreak (char *args, int from_tty, struct cmd_list_element *c)
+set_remotebreak (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (remote_break)
     interrupt_sequence_mode = interrupt_sequence_break;
@@ -1619,7 +1619,7 @@ enum Z_packet_type
 static enum auto_boolean remote_Z_packet_detect;
 
 static void
-set_remote_protocol_Z_packet_cmd (char *args, int from_tty,
+set_remote_protocol_Z_packet_cmd (const char *args, int from_tty,
 				  struct cmd_list_element *c)
 {
   int i;
@@ -14071,7 +14071,7 @@ show_range_stepping (struct ui_file *file, int from_tty,
 /* The "set/show range-stepping" set hook.  */
 
 static void
-set_range_stepping (char *ignore_args, int from_tty,
+set_range_stepping (const char *ignore_args, int from_tty,
 		    struct cmd_list_element *c)
 {
   struct remote_state *rs = get_remote_state ();
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index df1a84d76e..092e680581 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -6631,7 +6631,7 @@ show_powerpc_command (const char *args, int from_tty)
 }
 
 static void
-powerpc_set_soft_float (char *args, int from_tty,
+powerpc_set_soft_float (const char *args, int from_tty,
 			struct cmd_list_element *c)
 {
   struct gdbarch_info info;
@@ -6643,7 +6643,7 @@ powerpc_set_soft_float (char *args, int from_tty,
 }
 
 static void
-powerpc_set_vector_abi (char *args, int from_tty,
+powerpc_set_vector_abi (const char *args, int from_tty,
 			struct cmd_list_element *c)
 {
   struct gdbarch_info info;
diff --git a/gdb/serial.c b/gdb/serial.c
index 6866549130..a602857783 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -669,7 +669,7 @@ static const char *parity = parity_none;
 /* Set serial_parity value.  */
 
 static void
-set_parity (char *ignore_args, int from_tty, struct cmd_list_element *c)
+set_parity (const char *ignore_args, int from_tty, struct cmd_list_element *c)
 {
   if (parity == parity_odd)
     serial_parity = GDBPARITY_ODD;
diff --git a/gdb/solib.c b/gdb/solib.c
index b63bb9d495..cb7a5c0b51 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1369,7 +1369,7 @@ reload_shared_libraries_1 (int from_tty)
 }
 
 static void
-reload_shared_libraries (char *ignored, int from_tty,
+reload_shared_libraries (const char *ignored, int from_tty,
 			 struct cmd_list_element *e)
 {
   const struct target_so_ops *ops;
@@ -1424,7 +1424,7 @@ reload_shared_libraries (char *ignored, int from_tty,
    at the start of gdb_sysroot with "target:".  */
 
 static void
-gdb_sysroot_changed (char *ignored, int from_tty,
+gdb_sysroot_changed (const char *ignored, int from_tty,
 		     struct cmd_list_element *e)
 {
   const char *old_prefix = "remote:";
diff --git a/gdb/source.c b/gdb/source.c
index b0bb4827bf..d9d3da051e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -314,7 +314,8 @@ select_source_symtab (struct symtab *s)
    path list.  The theory is that set(show(dir)) should be a no-op.  */
 
 static void
-set_directories_command (char *args, int from_tty, struct cmd_list_element *c)
+set_directories_command (const char *args,
+			 int from_tty, struct cmd_list_element *c)
 {
   /* This is the value that was set.
      It needs to be processed to maintain $cdir:$cwd and remove dups.  */
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 32dafa8602..d67985f695 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -645,7 +645,7 @@ objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf)
 }
 
 static void
-set_debug_symfile (char *args, int from_tty, struct cmd_list_element *c)
+set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c)
 {
   struct program_space *pspace;
   struct objfile *objfile;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 4d6700c85b..43c9febf85 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2667,7 +2667,8 @@ show_ext_args (struct ui_file *file, int from_tty,
 }
 
 static void
-set_ext_lang_command (char *args, int from_tty, struct cmd_list_element *e)
+set_ext_lang_command (const char *args,
+		      int from_tty, struct cmd_list_element *e)
 {
   int i;
   char *cp = ext_args;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c844617c7e..370daac8e8 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1256,7 +1256,7 @@ set_symbol_cache_size (unsigned int new_size)
 /* Called when symbol-cache-size is set.  */
 
 static void
-set_symbol_cache_size_handler (char *args, int from_tty,
+set_symbol_cache_size_handler (const char *args, int from_tty,
 			       struct cmd_list_element *c)
 {
   if (new_symbol_cache_size > MAX_SYMBOL_CACHE_SIZE)
diff --git a/gdb/target-dcache.c b/gdb/target-dcache.c
index 76024403aa..3759866330 100644
--- a/gdb/target-dcache.c
+++ b/gdb/target-dcache.c
@@ -105,7 +105,7 @@ static int stack_cache_enabled = 1;
    except cleanliness.  */
 
 static void
-set_stack_cache (char *args, int from_tty, struct cmd_list_element *c)
+set_stack_cache (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (stack_cache_enabled != stack_cache_enabled_1)
     target_dcache_invalidate ();
@@ -143,7 +143,7 @@ static int code_cache_enabled = 1;
    except cleanliness.  */
 
 static void
-set_code_cache (char *args, int from_tty, struct cmd_list_element *c)
+set_code_cache (const char *args, int from_tty, struct cmd_list_element *c)
 {
   if (code_cache_enabled != code_cache_enabled_1)
     target_dcache_invalidate ();
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 4f5e9d60a6..3a5999c50d 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1874,7 +1874,7 @@ unset_tdesc_cmd (const char *args, int from_tty)
 }
 
 static void
-set_tdesc_filename_cmd (char *args, int from_tty,
+set_tdesc_filename_cmd (const char *args, int from_tty,
 			struct cmd_list_element *c)
 {
   xfree (target_description_filename);
diff --git a/gdb/target.c b/gdb/target.c
index 8a3cb6e555..b10f744251 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -167,7 +167,7 @@ int may_stop = 1;
 static unsigned int targetdebug = 0;
 
 static void
-set_targetdebug  (char *args, int from_tty, struct cmd_list_element *c)
+set_targetdebug  (const char *args, int from_tty, struct cmd_list_element *c)
 {
   update_current_target ();
 }
@@ -345,7 +345,7 @@ complete_target_initialization (struct target_ops *t)
 /* This is used to implement the various target commands.  */
 
 static void
-open_target (char *args, int from_tty, struct cmd_list_element *command)
+open_target (const char *args, int from_tty, struct cmd_list_element *command)
 {
   struct target_ops *ops = (struct target_ops *) get_cmd_context (command);
 
@@ -3890,7 +3890,7 @@ int target_async_permitted = 1;
 static int target_async_permitted_1 = 1;
 
 static void
-maint_set_target_async_command (char *args, int from_tty,
+maint_set_target_async_command (const char *args, int from_tty,
 				struct cmd_list_element *c)
 {
   if (have_live_inferiors ())
@@ -3943,7 +3943,7 @@ static enum auto_boolean target_non_stop_enabled_1 = AUTO_BOOLEAN_AUTO;
 /* Implementation of "maint set target-non-stop".  */
 
 static void
-maint_set_target_non_stop_command (char *args, int from_tty,
+maint_set_target_non_stop_command (const char *args, int from_tty,
 				   struct cmd_list_element *c)
 {
   if (have_live_inferiors ())
@@ -3999,7 +3999,7 @@ update_target_permissions (void)
    way.  */
 
 static void
-set_target_permissions (char *args, int from_tty,
+set_target_permissions (const char *args, int from_tty,
 			struct cmd_list_element *c)
 {
   if (target_has_execution)
@@ -4020,7 +4020,7 @@ set_target_permissions (char *args, int from_tty,
 /* Set memory write permission independently of observer mode.  */
 
 static void
-set_write_memory_permission (char *args, int from_tty,
+set_write_memory_permission (const char *args, int from_tty,
 			struct cmd_list_element *c)
 {
   /* Make the real values match the user-changed values.  */
diff --git a/gdb/top.c b/gdb/top.c
index e0e7f917cf..b9c9d8b37f 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1771,7 +1771,8 @@ set_readline_history_size (int history_size)
 
 /* Called by do_setshow_command.  */
 static void
-set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
+set_history_size_command (const char *args,
+			  int from_tty, struct cmd_list_element *c)
 {
   set_readline_history_size (history_size_setshow_var);
 }
@@ -1794,7 +1795,7 @@ int info_verbose = 0;		/* Default verbose msgs off.  */
 
 /* Called by do_setshow_command.  An elaborate joke.  */
 void
-set_verbose (char *args, int from_tty, struct cmd_list_element *c)
+set_verbose (const char *args, int from_tty, struct cmd_list_element *c)
 {
   const char *cmdname = "verbose";
   struct cmd_list_element *showcmd;
@@ -1894,7 +1895,7 @@ show_prompt (struct ui_file *file, int from_tty,
 /* "set editing" command.  */
 
 static void
-set_editing (char *args, int from_tty, struct cmd_list_element *c)
+set_editing (const char *args, int from_tty, struct cmd_list_element *c)
 {
   change_line_handler (set_editing_cmd_var);
   /* Update the control variable so that MI's =cmd-param-changed event
@@ -1933,7 +1934,7 @@ static char *staged_gdb_datadir;
 /* "set" command for the gdb_datadir configuration variable.  */
 
 static void
-set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
+set_gdb_datadir (const char *args, int from_tty, struct cmd_list_element *c)
 {
   set_gdb_data_directory (staged_gdb_datadir);
   observer_notify_gdb_datadir_changed ();
@@ -1950,7 +1951,8 @@ show_gdb_datadir (struct ui_file *file, int from_tty,
 }
 
 static void
-set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
+set_history_filename (const char *args,
+		      int from_tty, struct cmd_list_element *c)
 {
   /* We include the current directory so that if the user changes
      directories the file written will be the same as the one
diff --git a/gdb/top.h b/gdb/top.h
index d5cce6861e..cbb3123cf9 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -286,7 +286,7 @@ extern void set_history (const char *, int);
 
 extern void show_history (const char *, int);
 
-extern void set_verbose (char *, int, struct cmd_list_element *);
+extern void set_verbose (const char *, int, struct cmd_list_element *);
 
 extern char *handle_line_of_input (struct buffer *cmd_line_buffer,
 				   char *rl, int repeat,
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 64158ca086..fdee944ed4 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2913,28 +2913,28 @@ encode_source_string (int tpnum, ULONGEST addr,
    disconnects for some reason.  */
 
 static void
-set_disconnected_tracing (char *args, int from_tty,
+set_disconnected_tracing (const char *args, int from_tty,
 			  struct cmd_list_element *c)
 {
   target_set_disconnected_tracing (disconnected_tracing);
 }
 
 static void
-set_circular_trace_buffer (char *args, int from_tty,
+set_circular_trace_buffer (const char *args, int from_tty,
 			   struct cmd_list_element *c)
 {
   target_set_circular_trace_buffer (circular_trace_buffer);
 }
 
 static void
-set_trace_buffer_size (char *args, int from_tty,
+set_trace_buffer_size (const char *args, int from_tty,
 			   struct cmd_list_element *c)
 {
   target_set_trace_buffer_size (trace_buffer_size);
 }
 
 static void
-set_trace_user (char *args, int from_tty,
+set_trace_user (const char *args, int from_tty,
 		struct cmd_list_element *c)
 {
   int ret;
@@ -2946,7 +2946,7 @@ set_trace_user (char *args, int from_tty,
 }
 
 static void
-set_trace_notes (char *args, int from_tty,
+set_trace_notes (const char *args, int from_tty,
 		 struct cmd_list_element *c)
 {
   int ret;
@@ -2958,7 +2958,7 @@ set_trace_notes (char *args, int from_tty,
 }
 
 static void
-set_trace_stop_notes (char *args, int from_tty,
+set_trace_stop_notes (const char *args, int from_tty,
 		      struct cmd_list_element *c)
 {
   int ret;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 685cf0621e..cbeff1f3a2 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -348,7 +348,8 @@ tui_get_cmd_list (void)
 /* The set_func hook of "set tui ..." commands that affect the window
    borders on the TUI display.  */
 void
-tui_set_var_cmd (char *null_args, int from_tty, struct cmd_list_element *c)
+tui_set_var_cmd (const char *null_args,
+		 int from_tty, struct cmd_list_element *c)
 {
   if (tui_update_variables () && tui_active)
     tui_rehighlight_all ();
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 15810e4555..427af17ad7 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -672,7 +672,8 @@ show_print_type (const char *args, int from_tty)
 static int print_methods = 1;
 
 static void
-set_print_type_methods (char *args, int from_tty, struct cmd_list_element *c)
+set_print_type_methods (const char *args,
+			int from_tty, struct cmd_list_element *c)
 {
   default_ptype_flags.print_methods = print_methods;
 }
@@ -688,7 +689,8 @@ show_print_type_methods (struct ui_file *file, int from_tty,
 static int print_typedefs = 1;
 
 static void
-set_print_type_typedefs (char *args, int from_tty, struct cmd_list_element *c)
+set_print_type_typedefs (const char *args,
+			 int from_tty, struct cmd_list_element *c)
 {
   default_ptype_flags.print_typedefs = print_typedefs;
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index dd746849c7..f3fc16c7ff 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1459,14 +1459,14 @@ set_width (void)
 }
 
 static void
-set_width_command (char *args, int from_tty, struct cmd_list_element *c)
+set_width_command (const char *args, int from_tty, struct cmd_list_element *c)
 {
   set_screen_size ();
   set_width ();
 }
 
 static void
-set_height_command (char *args, int from_tty, struct cmd_list_element *c)
+set_height_command (const char *args, int from_tty, struct cmd_list_element *c)
 {
   set_screen_size ();
 }
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 2dd383f6d4..f9f9234194 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -84,12 +84,8 @@ struct cmd_list_element *showprintrawlist;
 static int partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
 				int len, int *errptr);
 
-static void set_input_radix (char *, int, struct cmd_list_element *);
-
 static void set_input_radix_1 (int, unsigned);
 
-static void set_output_radix (char *, int, struct cmd_list_element *);
-
 static void set_output_radix_1 (int, unsigned);
 
 static void val_print_type_code_flags (struct type *type,
@@ -3001,7 +2997,7 @@ static unsigned input_radix_1 = 10;
    setting the input radix to "10" never changes it!  */
 
 static void
-set_input_radix (char *args, int from_tty, struct cmd_list_element *c)
+set_input_radix (const char *args, int from_tty, struct cmd_list_element *c)
 {
   set_input_radix_1 (from_tty, input_radix_1);
 }
@@ -3038,7 +3034,7 @@ set_input_radix_1 (int from_tty, unsigned radix)
 static unsigned output_radix_1 = 10;
 
 static void
-set_output_radix (char *args, int from_tty, struct cmd_list_element *c)
+set_output_radix (const char *args, int from_tty, struct cmd_list_element *c)
 {
   set_output_radix_1 (from_tty, output_radix_1);
 }
diff --git a/gdb/value.c b/gdb/value.c
index c5588947d7..1782da9a37 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -971,7 +971,7 @@ gdb_static_assert (sizeof (LONGEST) <= MIN_VALUE_FOR_MAX_VALUE_SIZE);
 /* Implement the "set max-value-size" command.  */
 
 static void
-set_max_value_size (char *args, int from_tty,
+set_max_value_size (const char *args, int from_tty,
 		    struct cmd_list_element *c)
 {
   gdb_assert (max_value_size == -1 || max_value_size >= 0);
-- 
2.13.6

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA 1/4] Constify add_info
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
                   ` (2 preceding siblings ...)
  2017-10-16  3:23 ` [RFA 4/4] Constify execute_command Tom Tromey
@ 2017-10-16  3:23 ` Tom Tromey
  2017-11-05 16:52 ` [RFA 0/4] finish command constification Tom Tromey
  2017-11-06 12:03 ` Yao Qi
  5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2017-10-16  3:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch constifies add_info and updates all the info commands.  The
bulk of this patch was written using a script; and then I did a manual
pass to fix up the remaining compilation errors.

I could not compile every changed file; in particular nto-procfs.c,
gnu-nat.c, and darwin-nat-info.c; but I at least tried to check the
correctness by inspection.

ChangeLog
2017-10-15  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.
	* copying.c: Rebuild.
	* copying.awk: Constify generated commands.
	* auto-load.c (auto_load_info_scripts)
	(info_auto_load_gdb_scripts): Constify.
	* cli/cli-decode.c (struct cmd_list_element): Take a
	cmd_const_cfunc_ftype.
	* command.h (add_info): Take a cmd_const_cfunc_ftype.
	* tui/tui-win.c (tui_all_windows_info): Constify.
	* python/py-auto-load.c (info_auto_load_python_scripts):
	Constify.
	* cli/cli-cmds.c (show_command): Remove non-const overload.
	* tracepoint.c (info_tvariables_command, info_scope_command):
	Constify.
	(info_static_tracepoint_markers_command): Constify.
	* thread.c (info_threads_command): Constify.
	(print_thread_info_1): Constify.
	* target.c (info_target_command): Constify.
	* symtab.c (info_sources_command, info_functions_command)
	(info_types_command): Constify.
	(info_variables_command): Remove non-const overload.
	* symfile.c (info_ext_lang_command): Constify.
	* stack.c (info_frame_command, info_locals_command)
	(info_args_command): Constify.
	(backtrace_command): Remove non-const overload.
	* source.c (info_source_command, info_line_command): Constify.
	* solib.c (info_sharedlibrary_command): Constify.
	* skip.c (info_skip_command): Constify.
	* ser-go32.c (info_serial_command): Constify.
	* reverse.c (info_bookmarks_command): Constify.
	* printcmd.c (info_symbol_command, info_address_command)
	(info_display_command): Constify.
	* osdata.c (info_osdata_command): Constify.
	* objc-lang.c (info_selectors_command, info_classes_command):
	Constify.
	* nto-procfs.c (procfs_pidlist, procfs_meminfo): Constify.
	* memattr.c (info_mem_command): Constify.
	* macrocmd.c (info_macro_command, info_macros_command): Constify.
	* linux-fork.c (info_checkpoints_command): Constify.
	* infrun.c (info_signals_command): Constify.
	* inflow.c (info_terminal_command): Constify.
	* inferior.c (info_inferiors_command): Constify.
	(print_inferior): Constify.
	* infcmd.c (info_program_command, info_all_registers_command)
	(info_registers_command, info_vector_command)
	(info_float_command): Constify.
	(registers_info): Constify.
	* gnu-nat.c (info_send_rights_cmd, info_recv_rights_cmd)
	(info_port_sets_cmd, info_dead_names_cmd, info_port_rights_cmd):
	Constify.
	* f-valprint.c (info_common_command): Constify.
	* dcache.c (info_dcache_command): Constify.
	(dcache_info_1): Constify.
	* darwin-nat-info.c (info_mach_tasks_command)
	(info_mach_task_command, info_mach_ports_command)
	(info_mach_port_command, info_mach_threads_command)
	(info_mach_thread_command, info_mach_regions_command)
	(info_mach_regions_recurse_command, info_mach_region_command)
	(info_mach_exceptions_command): Constify.
	(get_task_from_args): Constify.
	* cp-support.c (info_vtbl_command): Constify.
	* breakpoint.c (info_watchpoints_command)
	(info_tracepoints_command): Constify.
	(info_breakpoints_command): Remove non-const overload.
	* avr-tdep.c (avr_io_reg_read_command): Constify.
	* auxv.c (info_auxv_command): Constify.
	* ada-tasks.c (info_tasks_command): Constify.
	(info_task): Constify.
	* ada-lang.c (info_exceptions_command): Constify.
---
 gdb/ChangeLog             | 74 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c            |  2 +-
 gdb/ada-tasks.c           |  4 +--
 gdb/auto-load.c           |  4 +--
 gdb/auto-load.h           |  2 +-
 gdb/auxv.c                |  2 +-
 gdb/avr-tdep.c            |  2 +-
 gdb/breakpoint.c          | 16 ++--------
 gdb/cli/cli-cmds.c        |  8 -----
 gdb/cli/cli-decode.c      |  2 +-
 gdb/command.h             |  2 +-
 gdb/copying.awk           |  8 ++---
 gdb/copying.c             |  8 ++---
 gdb/cp-support.c          |  2 +-
 gdb/darwin-nat-info.c     | 22 +++++++-------
 gdb/dcache.c              |  6 ++--
 gdb/f-valprint.c          |  3 +-
 gdb/frame.h               |  4 +--
 gdb/gnu-nat.c             | 10 +++----
 gdb/infcmd.c              | 20 +++++--------
 gdb/inferior.c            |  4 +--
 gdb/inferior.h            |  2 +-
 gdb/inflow.c              |  2 +-
 gdb/infrun.c              |  4 +--
 gdb/linux-fork.c          |  2 +-
 gdb/macrocmd.c            | 17 +++++------
 gdb/memattr.c             |  2 +-
 gdb/nto-procfs.c          |  4 +--
 gdb/objc-lang.c           |  4 +--
 gdb/osdata.c              |  2 +-
 gdb/printcmd.c            |  6 ++--
 gdb/python/py-auto-load.c |  2 +-
 gdb/reverse.c             |  2 +-
 gdb/ser-go32.c            |  2 +-
 gdb/skip.c                |  2 +-
 gdb/solib.c               |  2 +-
 gdb/source.c              |  8 ++---
 gdb/stack.c               | 14 ++-------
 gdb/symfile.c             |  4 +--
 gdb/symtab.c              | 14 ++-------
 gdb/target.c              |  4 +--
 gdb/thread.c              |  5 ++--
 gdb/tracepoint.c          |  6 ++--
 gdb/tui/tui-win.c         |  4 +--
 44 files changed, 168 insertions(+), 151 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7409496ce7..0696edb740 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13374,7 +13374,7 @@ ada_exceptions_list (const char *regexp)
 /* Implement the "info exceptions" command.  */
 
 static void
-info_exceptions_command (char *regexp, int from_tty)
+info_exceptions_command (const char *regexp, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
 
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index e0070d5b9a..1d5542d5d6 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1147,7 +1147,7 @@ print_ada_task_info (struct ui_out *uiout,
    for the given inferior (INF).  */
 
 static void
-info_task (struct ui_out *uiout, char *taskno_str, struct inferior *inf)
+info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
 {
   const int taskno = value_as_long (parse_and_eval (taskno_str));
   struct ada_task_info *task_info;
@@ -1237,7 +1237,7 @@ info_task (struct ui_out *uiout, char *taskno_str, struct inferior *inf)
    Does nothing if the program doesn't use Ada tasking.  */
 
 static void
-info_tasks_command (char *arg, int from_tty)
+info_tasks_command (const char *arg, int from_tty)
 {
   struct ui_out *uiout = current_uiout;
 
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 9b1111d066..a058c82585 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -1298,7 +1298,7 @@ print_scripts (VEC (loaded_script_ptr) *scripts)
    PATTERN.  FROM_TTY is the usual GDB boolean for user interactivity.  */
 
 void
-auto_load_info_scripts (char *pattern, int from_tty,
+auto_load_info_scripts (const char *pattern, int from_tty,
 			const struct extension_language_defn *language)
 {
   struct ui_out *uiout = current_uiout;
@@ -1384,7 +1384,7 @@ auto_load_info_scripts (char *pattern, int from_tty,
 /* Wrapper for "info auto-load gdb-scripts".  */
 
 static void
-info_auto_load_gdb_scripts (char *pattern, int from_tty)
+info_auto_load_gdb_scripts (const char *pattern, int from_tty)
 {
   auto_load_info_scripts (pattern, from_tty, &extension_language_gdb);
 }
diff --git a/gdb/auto-load.h b/gdb/auto-load.h
index f8b5b0d7a7..f02a9043b1 100644
--- a/gdb/auto-load.h
+++ b/gdb/auto-load.h
@@ -37,7 +37,7 @@ extern void auto_load_objfile_script (struct objfile *objfile,
 				      const struct extension_language_defn *);
 extern void load_auto_scripts_for_objfile (struct objfile *objfile);
 extern char auto_load_info_scripts_pattern_nl[];
-extern void auto_load_info_scripts (char *pattern, int from_tty,
+extern void auto_load_info_scripts (const char *pattern, int from_tty,
 				    const struct extension_language_defn *);
 
 extern struct cmd_list_element **auto_load_set_cmdlist_get (void);
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 95cbeecd79..dfba94b4e1 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -552,7 +552,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 }
 
 static void
-info_auxv_command (char *cmd, int from_tty)
+info_auxv_command (const char *cmd, int from_tty)
 {
   if (! target_has_stack)
     error (_("The program has no auxiliary information now."));
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 9aca8c32e5..f4ce2706d4 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1546,7 +1546,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
    All io registers are 8-bit.  */
 
 static void
-avr_io_reg_read_command (char *args, int from_tty)
+avr_io_reg_read_command (const char *args, int from_tty)
 {
   LONGEST bufsiz = 0;
   gdb_byte *buf;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c05a2960ac..e0a510e61d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -161,8 +161,6 @@ static int breakpoint_location_address_range_overlap (struct bp_location *,
 						      struct address_space *,
 						      CORE_ADDR, int);
 
-static void info_watchpoints_command (char *, int);
-
 static int remove_breakpoint (struct bp_location *);
 static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason);
 
@@ -228,8 +226,6 @@ static int is_hardware_watchpoint (const struct breakpoint *bpt);
 
 static void insert_breakpoint_locations (void);
 
-static void info_tracepoints_command (char *, int);
-
 static void enable_trace_command (char *, int);
 
 static void disable_trace_command (char *, int);
@@ -6723,16 +6719,8 @@ info_breakpoints_command (const char *args, int from_tty)
   default_collect_info ();
 }
 
-/* Temporary non-const overload.  */
-
-static void
-info_breakpoints_command (char *args, int from_tty)
-{
-  info_breakpoints_command ((const char *) args, from_tty);
-}
-
 static void
-info_watchpoints_command (char *args, int from_tty)
+info_watchpoints_command (const char *args, int from_tty)
 {
   int num_printed = breakpoint_1 (args, 0, is_watchpoint);
   struct ui_out *uiout = current_uiout;
@@ -14809,7 +14797,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
    omitted.  */
 
 static void
-info_tracepoints_command (char *args, int from_tty)
+info_tracepoints_command (const char *args, int from_tty)
 {
   struct ui_out *uiout = current_uiout;
   int num_printed;
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index be022d3215..ccfedb2a5f 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -207,14 +207,6 @@ show_command (const char *arg, int from_tty)
   cmd_show_list (showlist, from_tty, "");
 }
 
-/* A temporary non-const overload of show_command.  */
-
-static void
-show_command (char *arg, int from_tty)
-{
-  cmd_show_list (showlist, from_tty, "");
-}
-
 \f
 /* Provide documentation on command or list given by COMMAND.  FROM_TTY
    is ignored.  */
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index e9baf38d13..0c555268b3 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -915,7 +915,7 @@ delete_cmd (const char *name, struct cmd_list_element **list,
 /* Add an element to the list of info subcommands.  */
 
 struct cmd_list_element *
-add_info (const char *name, cmd_cfunc_ftype *fun, const char *doc)
+add_info (const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
 {
   return add_cmd (name, class_info, fun, doc, &infolist);
 }
diff --git a/gdb/command.h b/gdb/command.h
index c3348bcede..258f7f7de2 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -268,7 +268,7 @@ extern struct cmd_list_element *add_com_suppress_notification
 			int *supress_notification);
 
 extern struct cmd_list_element *add_info (const char *,
-					  cmd_cfunc_ftype *fun,
+					  cmd_const_cfunc_ftype *fun,
 					  const char *);
 
 extern struct cmd_list_element *add_info_alias (const char *, const char *,
diff --git a/gdb/copying.awk b/gdb/copying.awk
index 2a71939a6f..1cd596a564 100644
--- a/gdb/copying.awk
+++ b/gdb/copying.awk
@@ -10,12 +10,12 @@ BEGIN	{
 	  print "#include \"command.h\""
 	  print "#include \"gdbcmd.h\""
 	  print ""
-	  print "static void show_copying_command (char *, int);"
+	  print "static void show_copying_command (const char *, int);"
 	  print ""
-	  print "static void show_warranty_command (char *, int);"
+	  print "static void show_warranty_command (const char *, int);"
 	  print ""
 	  print "static void";
-	  print "show_copying_command (char *ignore, int from_tty)";
+	  print "show_copying_command (const char *ignore, int from_tty)";
 	  print "{";
 	}
 NR == 1,/^[ 	]*15\. Disclaimer of Warranty\.[ 	]*$/	{
@@ -35,7 +35,7 @@ NR == 1,/^[ 	]*15\. Disclaimer of Warranty\.[ 	]*$/	{
 	  print "}";
 	  print "";
 	  print "static void";
-	  print "show_warranty_command (char *ignore, int from_tty)";
+	  print "show_warranty_command (const char *ignore, int from_tty)";
 	  print "{";
 	}
 /^[ 	]*15\. Disclaimer of Warranty\.[ 	]*$/, /^[ 	]*END OF TERMS AND CONDITIONS[ 	]*$/{  
diff --git a/gdb/copying.c b/gdb/copying.c
index db024627cd..8e4077ccb9 100644
--- a/gdb/copying.c
+++ b/gdb/copying.c
@@ -6,12 +6,12 @@
 #include "command.h"
 #include "gdbcmd.h"
 
-static void show_copying_command (char *, int);
+static void show_copying_command (const char *, int);
 
-static void show_warranty_command (char *, int);
+static void show_warranty_command (const char *, int);
 
 static void
-show_copying_command (char *ignore, int from_tty)
+show_copying_command (const char *ignore, int from_tty)
 {
   printf_filtered ("                    GNU GENERAL PUBLIC LICENSE\n");
   printf_filtered ("                       Version 3, 29 June 2007\n");
@@ -604,7 +604,7 @@ show_copying_command (char *ignore, int from_tty)
 }
 
 static void
-show_warranty_command (char *ignore, int from_tty)
+show_warranty_command (const char *ignore, int from_tty)
 {
   printf_filtered ("  15. Disclaimer of Warranty.\n");
   printf_filtered ("\n");
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 37b2b4af97..2a6d42af6d 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1616,7 +1616,7 @@ first_component_command (const char *arg, int from_tty)
 /* Implement "info vtbl".  */
 
 static void
-info_vtbl_command (char *arg, int from_tty)
+info_vtbl_command (const char *arg, int from_tty)
 {
   struct value *value;
 
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index fc9aeaaad7..44782bfa78 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -66,7 +66,7 @@
 #define port_type_array_t mach_port_array_t
 
 static void
-info_mach_tasks_command (char *args, int from_tty)
+info_mach_tasks_command (const char *args, int from_tty)
 {
   int sysControl[4];
   int count, index;
@@ -109,7 +109,7 @@ info_mach_tasks_command (char *args, int from_tty)
 }
 
 static task_t
-get_task_from_args (char *args)
+get_task_from_args (const char *args)
 {
   task_t task;
   char *eptr;
@@ -132,7 +132,7 @@ get_task_from_args (char *args)
 }
 
 static void
-info_mach_task_command (char *args, int from_tty)
+info_mach_task_command (const char *args, int from_tty)
 {
   union
   {
@@ -189,7 +189,7 @@ info_mach_task_command (char *args, int from_tty)
 }
 
 static void
-info_mach_ports_command (char *args, int from_tty)
+info_mach_ports_command (const char *args, int from_tty)
 {
   port_name_array_t names;
   port_type_array_t types;
@@ -326,7 +326,7 @@ darwin_debug_port_info (task_t task, mach_port_t port)
 }
 
 static void
-info_mach_port_command (char *args, int from_tty)
+info_mach_port_command (const char *args, int from_tty)
 {
   task_t task;
   mach_port_t port;
@@ -338,7 +338,7 @@ info_mach_port_command (char *args, int from_tty)
 }
 
 static void
-info_mach_threads_command (char *args, int from_tty)
+info_mach_threads_command (const char *args, int from_tty)
 {
   thread_array_t threads;
   unsigned int thread_count;
@@ -365,7 +365,7 @@ info_mach_threads_command (char *args, int from_tty)
 }
 
 static void
-info_mach_thread_command (char *args, int from_tty)
+info_mach_thread_command (const char *args, int from_tty)
 {
   union
   {
@@ -696,7 +696,7 @@ darwin_debug_region (task_t task, mach_vm_address_t address)
 }
 
 static void
-info_mach_regions_command (char *args, int from_tty)
+info_mach_regions_command (const char *args, int from_tty)
 {
   task_t task;
 
@@ -708,7 +708,7 @@ info_mach_regions_command (char *args, int from_tty)
 }
 
 static void
-info_mach_regions_recurse_command (char *args, int from_tty)
+info_mach_regions_recurse_command (const char *args, int from_tty)
 {
   task_t task;
 
@@ -720,7 +720,7 @@ info_mach_regions_recurse_command (char *args, int from_tty)
 }
 
 static void
-info_mach_region_command (char *exp, int from_tty)
+info_mach_region_command (const char *exp, int from_tty)
 {
   struct value *val;
   mach_vm_address_t address;
@@ -792,7 +792,7 @@ disp_exception (const darwin_exception_info *info)
 }
 
 static void
-info_mach_exceptions_command (char *args, int from_tty)
+info_mach_exceptions_command (const char *args, int from_tty)
 {
   int i;
   task_t task;
diff --git a/gdb/dcache.c b/gdb/dcache.c
index c8832fd36b..e7b1e1440e 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -125,8 +125,6 @@ static int dcache_read_line (DCACHE *dcache, struct dcache_block *db);
 
 static struct dcache_block *dcache_alloc (DCACHE *dcache, CORE_ADDR addr);
 
-static void info_dcache_command (char *exp, int tty);
-
 static int dcache_enabled_p = 0; /* OBSOLETE */
 
 static void
@@ -585,7 +583,7 @@ dcache_print_line (DCACHE *dcache, int index)
 /* Parse EXP and show the info about DCACHE.  */
 
 static void
-dcache_info_1 (DCACHE *dcache, char *exp)
+dcache_info_1 (DCACHE *dcache, const char *exp)
 {
   splay_tree_node n;
   int i, refcount;
@@ -640,7 +638,7 @@ dcache_info_1 (DCACHE *dcache, char *exp)
 }
 
 static void
-info_dcache_command (char *exp, int tty)
+info_dcache_command (const char *exp, int tty)
 {
   dcache_info_1 (target_dcache_get (), exp);
 }
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 5bcab9d525..c9ece0d5c0 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -34,7 +34,6 @@
 #include "block.h"
 #include "dictionary.h"
 
-static void info_common_command (char *, int);
 static void f77_get_dynamic_length_of_aggregate (struct type *);
 
 int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
@@ -433,7 +432,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
    given name.  */
 
 static void
-info_common_command (char *comname, int from_tty)
+info_common_command (const char *comname, int from_tty)
 {
   struct frame_info *fi;
   const struct block *block;
diff --git a/gdb/frame.h b/gdb/frame.h
index ce9d0bbefe..b56a164a85 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -784,9 +784,9 @@ extern void read_frame_arg (struct symbol *sym, struct frame_info *frame,
 extern void read_frame_local (struct symbol *sym, struct frame_info *frame,
 			      struct frame_arg *argp);
 
-extern void info_args_command (char *, int);
+extern void info_args_command (const char *, int);
 
-extern void info_locals_command (char *, int);
+extern void info_locals_command (const char *, int);
 
 extern void return_command (const char *, int);
 
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 7cb6e4a0dd..0095d729f9 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -3152,31 +3152,31 @@ info_port_rights (const char *args, mach_port_type_t only)
 }
 
 static void
-info_send_rights_cmd (char *args, int from_tty)
+info_send_rights_cmd (const char *args, int from_tty)
 {
   info_port_rights (args, MACH_PORT_TYPE_SEND);
 }
 
 static void
-info_recv_rights_cmd (char *args, int from_tty)
+info_recv_rights_cmd (const char *args, int from_tty)
 {
   info_port_rights (args, MACH_PORT_TYPE_RECEIVE);
 }
 
 static void
-info_port_sets_cmd (char *args, int from_tty)
+info_port_sets_cmd (const char *args, int from_tty)
 {
   info_port_rights (args, MACH_PORT_TYPE_PORT_SET);
 }
 
 static void
-info_dead_names_cmd (char *args, int from_tty)
+info_dead_names_cmd (const char *args, int from_tty)
 {
   info_port_rights (args, MACH_PORT_TYPE_DEAD_NAME);
 }
 
 static void
-info_port_rights_cmd (char *args, int from_tty)
+info_port_rights_cmd (const char *args, int from_tty)
 {
   info_port_rights (args, ~0);
 }
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f042ec2b8b..7b6ac9e84e 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -62,14 +62,8 @@
 
 /* Local functions: */
 
-static void info_registers_command (char *, int);
-
 static void until_next_command (int);
 
-static void info_float_command (char *, int);
-
-static void info_program_command (char *, int);
-
 static void step_1 (int, int, const char *);
 
 #define ERROR_NO_INFERIOR \
@@ -2083,7 +2077,7 @@ finish_command (const char *arg, int from_tty)
 \f
 
 static void
-info_program_command (char *args, int from_tty)
+info_program_command (const char *args, int from_tty)
 {
   bpstat bs;
   int num, stat;
@@ -2416,7 +2410,7 @@ default_print_registers_info (struct gdbarch *gdbarch,
 }
 
 void
-registers_info (char *addr_exp, int fpregs)
+registers_info (const char *addr_exp, int fpregs)
 {
   struct frame_info *frame;
   struct gdbarch *gdbarch;
@@ -2435,7 +2429,7 @@ registers_info (char *addr_exp, int fpregs)
 
   while (*addr_exp != '\0')
     {
-      char *start;
+      const char *start;
       const char *end;
 
       /* Skip leading white space.  */
@@ -2524,13 +2518,13 @@ registers_info (char *addr_exp, int fpregs)
 }
 
 static void
-info_all_registers_command (char *addr_exp, int from_tty)
+info_all_registers_command (const char *addr_exp, int from_tty)
 {
   registers_info (addr_exp, 1);
 }
 
 static void
-info_registers_command (char *addr_exp, int from_tty)
+info_registers_command (const char *addr_exp, int from_tty)
 {
   registers_info (addr_exp, 0);
 }
@@ -2565,7 +2559,7 @@ print_vector_info (struct ui_file *file,
 }
 
 static void
-info_vector_command (char *args, int from_tty)
+info_vector_command (const char *args, int from_tty)
 {
   if (!target_has_registers)
     error (_("The program has no registers now."));
@@ -3106,7 +3100,7 @@ default_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 }
 
 static void
-info_float_command (char *args, int from_tty)
+info_float_command (const char *args, int from_tty)
 {
   struct frame_info *frame;
 
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 0c60d30fa2..bcac98180a 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -529,7 +529,7 @@ print_selected_inferior (struct ui_out *uiout)
    printed.  */
 
 static void
-print_inferior (struct ui_out *uiout, char *requested_inferiors)
+print_inferior (struct ui_out *uiout, const char *requested_inferiors)
 {
   struct inferior *inf;
   int inf_count = 0;
@@ -718,7 +718,7 @@ inferior_command (const char *args, int from_tty)
 /* Print information about currently known inferiors.  */
 
 static void
-info_inferiors_command (char *args, int from_tty)
+info_inferiors_command (const char *args, int from_tty)
 {
   print_inferior (current_uiout, args);
 }
diff --git a/gdb/inferior.h b/gdb/inferior.h
index f70c0accc5..37252a695c 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -160,7 +160,7 @@ extern void set_inferior_args (const char *);
 
 extern void set_inferior_args_vector (int, char **);
 
-extern void registers_info (char *, int);
+extern void registers_info (const char *, int);
 
 extern void continue_1 (int all_threads);
 
diff --git a/gdb/inflow.c b/gdb/inflow.c
index d54b8f8345..8fd12a032a 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -534,7 +534,7 @@ copy_terminal_info (struct inferior *to, struct inferior *from)
 }
 
 void
-info_terminal_command (char *arg, int from_tty)
+info_terminal_command (const char *arg, int from_tty)
 {
   target_terminal::info (arg, from_tty);
 }
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 98a11a3957..e5e938d19d 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -70,8 +70,6 @@
 
 /* Prototypes for local functions */
 
-static void info_signals_command (char *, int);
-
 static void sig_print_info (enum gdb_signal);
 
 static void sig_print_header (void);
@@ -8678,7 +8676,7 @@ Use \"info signals\" for a list of symbolic signals."));
    targets, all signals should be in the signal tables).  */
 
 static void
-info_signals_command (char *signum_exp, int from_tty)
+info_signals_command (const char *signum_exp, int from_tty)
 {
   enum gdb_signal oursig;
 
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index c60d90c3e5..f55f743ed1 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -571,7 +571,7 @@ Please switch to another checkpoint before detaching the current one"));
 /* Print information about currently known checkpoints.  */
 
 static void
-info_checkpoints_command (char *arg, int from_tty)
+info_checkpoints_command (const char *arg, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
   struct symtab_and_line sal;
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 2bb8705fd6..0ec8f82287 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -188,19 +188,19 @@ print_macro_definition (const char *name,
 
 /* The implementation of the `info macro' command.  */
 static void
-info_macro_command (char *args, int from_tty)
+info_macro_command (const char *args, int from_tty)
 {
   struct macro_scope *ms = NULL;
   struct cleanup *cleanup_chain;
-  char *name;
+  const char *name;
   int show_all_macros_named = 0;
-  char *arg_start = args;
+  const char *arg_start = args;
   int processing_args = 1;
 
   while (processing_args
 	 && arg_start && *arg_start == '-' && *arg_start != '\0')
     {
-      char *p = skip_to_space (arg_start);
+      const char *p = skip_to_space (arg_start);
 
       if (strncmp (arg_start, "-a", p - arg_start) == 0
 	  || strncmp (arg_start, "-all", p - arg_start) == 0)
@@ -212,10 +212,9 @@ info_macro_command (char *args, int from_tty)
 	processing_args = 0;
       else
 	{
-	  /* Relies on modified 'args' not making it in to history */
-	  *p = '\0';
-	  error (_("Unrecognized option '%s' to info macro command.  "
-		   "Try \"help info macro\"."), arg_start);
+	  error (_("Unrecognized option '%.*s' to info macro command.  "
+		   "Try \"help info macro\"."),
+		 int (p - arg_start), arg_start);
 	}
 
         arg_start = skip_spaces (p);
@@ -270,7 +269,7 @@ info_macro_command (char *args, int from_tty)
 
 /* Implementation of the "info macros" command. */
 static void
-info_macros_command (char *args, int from_tty)
+info_macros_command (const char *args, int from_tty)
 {
   struct macro_scope *ms = NULL;
   struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms);
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 89adce85f4..cd323e9732 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -408,7 +408,7 @@ mem_command (const char *args, int from_tty)
 \f
 
 static void
-info_mem_command (char *args, int from_tty)
+info_mem_command (const char *args, int from_tty)
 {
   struct mem_region *m;
   struct mem_attrib *attrib;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index cabec0fa70..9fd54159b6 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -359,7 +359,7 @@ do_closedir_cleanup (void *dir)
 }
 
 static void
-procfs_pidlist (char *args, int from_tty)
+procfs_pidlist (const char *args, int from_tty)
 {
   DIR *dp = NULL;
   struct dirent *dirp = NULL;
@@ -461,7 +461,7 @@ procfs_pidlist (char *args, int from_tty)
 }
 
 static void
-procfs_meminfo (char *args, int from_tty)
+procfs_meminfo (const char *args, int from_tty)
 {
   procfs_mapinfo *mapinfos = NULL;
   static int num_mapinfos = 0;
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 43abf13bc3..eb9da74e7c 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -561,7 +561,7 @@ compare_selectors (const void *a, const void *b)
  */
 
 static void
-info_selectors_command (char *regexp, int from_tty)
+info_selectors_command (const char *regexp, int from_tty)
 {
   struct objfile	*objfile;
   struct minimal_symbol *msymbol;
@@ -723,7 +723,7 @@ compare_classes (const void *a, const void *b)
  */
 
 static void
-info_classes_command (char *regexp, int from_tty)
+info_classes_command (const char *regexp, int from_tty)
 {
   struct objfile	*objfile;
   struct minimal_symbol *msymbol;
diff --git a/gdb/osdata.c b/gdb/osdata.c
index 9da3d07cdb..14e24c6266 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -409,7 +409,7 @@ info_osdata (const char *type)
 }
 
 static void
-info_osdata_command (char *arg, int from_tty)
+info_osdata_command (const char *arg, int from_tty)
 {
   info_osdata (arg);
 }
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 11f666dd28..f01ab47494 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1286,7 +1286,7 @@ set_command (const char *exp, int from_tty)
 }
 
 static void
-info_symbol_command (char *arg, int from_tty)
+info_symbol_command (const char *arg, int from_tty)
 {
   struct minimal_symbol *msymbol;
   struct objfile *objfile;
@@ -1377,7 +1377,7 @@ info_symbol_command (char *arg, int from_tty)
 }
 
 static void
-info_address_command (char *exp, int from_tty)
+info_address_command (const char *exp, int from_tty)
 {
   struct gdbarch *gdbarch;
   int regno;
@@ -2043,7 +2043,7 @@ disable_current_display (void)
 }
 
 static void
-info_display_command (char *ignore, int from_tty)
+info_display_command (const char *ignore, int from_tty)
 {
   struct display *d;
 
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 32cb7e92b7..336955a678 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -52,7 +52,7 @@ gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
 /* Wrapper for "info auto-load python-scripts".  */
 
 static void
-info_auto_load_python_scripts (char *pattern, int from_tty)
+info_auto_load_python_scripts (const char *pattern, int from_tty)
 {
   auto_load_info_scripts (pattern, from_tty, &extension_language_python);
 }
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 0d1c6e6549..2ca8917258 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -305,7 +305,7 @@ bookmark_1 (int bnum)
 /* Implement "info bookmarks" command.  */
 
 static void
-info_bookmarks_command (char *args, int from_tty)
+info_bookmarks_command (const char *args, int from_tty)
 {
   if (!bookmark_chain)
     printf_filtered (_("No bookmarks.\n"));
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index e3528951b4..07f22b5c78 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -899,7 +899,7 @@ gdb_pipe (int pdes[2])
 }
 
 static void
-info_serial_command (char *arg, int from_tty)
+info_serial_command (const char *arg, int from_tty)
 {
   struct dos_ttystate *port;
 #ifdef DOS_STATS
diff --git a/gdb/skip.c b/gdb/skip.c
index af60eb7404..20fca78433 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -353,7 +353,7 @@ skip_command (const char *arg, int from_tty)
 }
 
 static void
-info_skip_command (char *arg, int from_tty)
+info_skip_command (const char *arg, int from_tty)
 {
   int num_printable_entries = 0;
   struct value_print_options opts;
diff --git a/gdb/solib.c b/gdb/solib.c
index c70b9d8193..b63bb9d495 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1045,7 +1045,7 @@ solib_add (const char *pattern, int from_tty, int readsyms)
    all.  */
 
 static void
-info_sharedlibrary_command (char *pattern, int from_tty)
+info_sharedlibrary_command (const char *pattern, int from_tty)
 {
   struct so_list *so = NULL;	/* link map state variable */
   int so_missing_debug_info = 0;
diff --git a/gdb/source.c b/gdb/source.c
index e67209e201..cefc612f3e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -52,10 +52,6 @@
 
 static int get_filename_and_charpos (struct symtab *, char **);
 
-static void info_line_command (char *, int);
-
-static void info_source_command (char *, int);
-
 /* Path of directories to search for source files.
    Same format as the PATH environment variable's value.  */
 
@@ -639,7 +635,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
 
 
 static void
-info_source_command (char *ignore, int from_tty)
+info_source_command (const char *ignore, int from_tty)
 {
   struct symtab *s = current_source_symtab;
   struct compunit_symtab *cust;
@@ -1480,7 +1476,7 @@ print_source_lines (struct symtab *s, int line, int stopline,
 /* Print info on range of pc's in a specified line.  */
 
 static void
-info_line_command (char *arg, int from_tty)
+info_line_command (const char *arg, int from_tty)
 {
   CORE_ADDR start_pc, end_pc;
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 946a2e243b..5e6c8ed20e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1380,7 +1380,7 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p)
    ADDR_EXP.  Absolutely all information in the frame is printed.  */
 
 static void
-info_frame_command (char *addr_exp, int from_tty)
+info_frame_command (const char *addr_exp, int from_tty)
 {
   struct frame_info *fi;
   struct symbol *func;
@@ -1903,14 +1903,6 @@ backtrace_command (const char *arg, int from_tty)
 		       no_filters >= 0 /* no frame-filters */, from_tty);
 }
 
-/* Temporary non-const overload.  */
-
-static void
-backtrace_command (char *arg, int from_tty)
-{
-  backtrace_command ((const char *) arg, from_tty);
-}
-
 /* Iterate over the local variables of a block B, calling CB with
    CB_DATA.  */
 
@@ -2114,7 +2106,7 @@ print_frame_local_vars (struct frame_info *frame, int num_tabs,
 }
 
 void
-info_locals_command (char *args, int from_tty)
+info_locals_command (const char *args, int from_tty)
 {
   print_frame_local_vars (get_selected_frame (_("No frame selected.")),
 			  0, gdb_stdout);
@@ -2196,7 +2188,7 @@ print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream)
 }
 
 void
-info_args_command (char *ignore, int from_tty)
+info_args_command (const char *ignore, int from_tty)
 {
   print_frame_arg_vars (get_selected_frame (_("No frame selected.")),
 			gdb_stdout);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index a7d8553bb0..3e96ae6f83 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -101,8 +101,6 @@ static int simple_read_overlay_table (void);
 
 static int simple_overlay_update_1 (struct obj_section *);
 
-static void info_ext_lang_command (char *args, int from_tty);
-
 static void symfile_find_segment_sections (struct objfile *objfile);
 
 /* List of all available sym_fns.  On gdb startup, each object file reader
@@ -2734,7 +2732,7 @@ set_ext_lang_command (char *args, int from_tty, struct cmd_list_element *e)
 }
 
 static void
-info_ext_lang_command (char *args, int from_tty)
+info_ext_lang_command (const char *args, int from_tty)
 {
   int i;
   filename_language *entry;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f4deace2fd..c844617c7e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4033,7 +4033,7 @@ output_partial_symbol_filename (const char *filename, const char *fullname,
 }
 
 static void
-info_sources_command (char *ignore, int from_tty)
+info_sources_command (const char *ignore, int from_tty)
 {
   struct compunit_symtab *cu;
   struct symtab *s;
@@ -4485,23 +4485,15 @@ info_variables_command (const char *regexp, int from_tty)
   symtab_symbol_info (regexp, VARIABLES_DOMAIN, from_tty);
 }
 
-/* Temporary non-const overload.  */
-
-static void
-info_variables_command (char *regexp, int from_tty)
-{
-  symtab_symbol_info (regexp, VARIABLES_DOMAIN, from_tty);
-}
-
 static void
-info_functions_command (char *regexp, int from_tty)
+info_functions_command (const char *regexp, int from_tty)
 {
   symtab_symbol_info (regexp, FUNCTIONS_DOMAIN, from_tty);
 }
 
 
 static void
-info_types_command (char *regexp, int from_tty)
+info_types_command (const char *regexp, int from_tty)
 {
   symtab_symbol_info (regexp, TYPES_DOMAIN, from_tty);
 }
diff --git a/gdb/target.c b/gdb/target.c
index d89d0558ec..8a3cb6e555 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -48,8 +48,6 @@
 #include <algorithm>
 #include "byte-vector.h"
 
-static void info_target_command (char *, int);
-
 static void generic_tls_error (void) ATTRIBUTE_NORETURN;
 
 static void default_terminal_info (struct target_ops *, const char *, int);
@@ -2026,7 +2024,7 @@ target_remove_breakpoint (struct gdbarch *gdbarch,
 }
 
 static void
-info_target_command (char *args, int from_tty)
+info_target_command (const char *args, int from_tty)
 {
   struct target_ops *t;
   int has_all_mem = 0;
diff --git a/gdb/thread.c b/gdb/thread.c
index df04b4ed6a..55f2b38c17 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -62,7 +62,6 @@ static int threads_executing;
 
 static void thread_apply_all_command (char *, int);
 static int thread_alive (struct thread_info *);
-static void info_threads_command (char *, int);
 
 /* RAII type used to increase / decrease the refcount of each thread
    in a given list of threads.  */
@@ -1197,7 +1196,7 @@ should_print_thread (const char *requested_threads, int default_inf_num,
    thread ids.  */
 
 static void
-print_thread_info_1 (struct ui_out *uiout, char *requested_threads,
+print_thread_info_1 (struct ui_out *uiout, const char *requested_threads,
 		     int global_ids, int pid,
 		     int show_global_ids)
 {
@@ -1384,7 +1383,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
 	 effects info-threads command would be nicer.  */
 
 static void
-info_threads_command (char *arg, int from_tty)
+info_threads_command (const char *arg, int from_tty)
 {
   int show_global_ids = 0;
 
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4a06caf0f9..64158ca086 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -492,7 +492,7 @@ tvariables_info_1 (void)
 /* List all the trace state variables.  */
 
 static void
-info_tvariables_command (char *args, int from_tty)
+info_tvariables_command (const char *args, int from_tty)
 {
   tvariables_info_1 ();
 }
@@ -2514,7 +2514,7 @@ tfind_outside_command (const char *args, int from_tty)
 
 /* info scope command: list the locals for a scope.  */
 static void
-info_scope_command (char *args_in, int from_tty)
+info_scope_command (const char *args_in, int from_tty)
 {
   struct symbol *sym;
   struct bound_minimal_symbol msym;
@@ -3874,7 +3874,7 @@ print_one_static_tracepoint_marker (int count,
 }
 
 static void
-info_static_tracepoint_markers_command (char *arg, int from_tty)
+info_static_tracepoint_markers_command (const char *arg, int from_tty)
 {
   VEC(static_tracepoint_marker_p) *markers;
   struct cleanup *old_chain;
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 9482646c95..685cf0621e 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -64,7 +64,7 @@ static int new_height_ok (struct tui_win_info *, int);
 static void tui_set_tab_width_command (const char *, int);
 static void tui_refresh_all_command (const char *, int);
 static void tui_set_win_height_command (const char *, int);
-static void tui_all_windows_info (char *, int);
+static void tui_all_windows_info (const char *, int);
 static void tui_set_focus_command (const char *, int);
 static void tui_scroll_forward_command (const char *, int);
 static void tui_scroll_backward_command (const char *, int);
@@ -1087,7 +1087,7 @@ tui_set_focus_command (const char *arg, int from_tty)
 
 
 static void
-tui_all_windows_info (char *arg, int from_tty)
+tui_all_windows_info (const char *arg, int from_tty)
 {
   int type;
   struct tui_win_info *win_with_focus = tui_win_with_focus ();
-- 
2.13.6

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA 4/4] Constify execute_command
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
  2017-10-16  3:22 ` [RFA 2/4] Remove cmd_cfunc_ftype Tom Tromey
  2017-10-16  3:23 ` [RFA 3/4] Constify add_setshow_* Tom Tromey
@ 2017-10-16  3:23 ` Tom Tromey
  2017-10-16  3:23 ` [RFA 1/4] Constify add_info Tom Tromey
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2017-10-16  3:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies execute_command and fixes up the callers.

2017-10-15  Tom Tromey  <tom@tromey.com>

	* event-top.h (command_handler): Constify.
	* record-full.c (cmd_record_full_start): Update.
	* thread.c (thread_apply_all_command): Update.
	* printcmd.c (eval_command): Update.
	* mi/mi-main.c (mi_execute_cli_command): Update.
	(mi_execute_async_cli_command): Update.
	* tui/tui-stack.c (tui_update_command): Update.
	* cli/cli-interp.c (safe_execute_command): Constify.
	* record.c (record_start): Update.
	(record_start, record_stop, cmd_record_start): Update.
	* record-btrace.c (cmd_record_btrace_bts_start): Update.
	(cmd_record_btrace_pt_start): Update.
	(cmd_record_btrace_start): Update.
	(cmd_record_btrace_start): Update.
	* reverse.c (exec_reverse_once): Update.
	* python/python.c (execute_gdb_command): Don't copy the command.
	* event-top.c (command_line_handler): Update.
	(command_handler): Constify.
	* defs.h (deprecated_call_command_hook): Constify.
	* cli/cli-script.h (execute_user_command): Constify.
	* cli/cli-script.c (execute_user_command): Constify.
	(execute_cmd_pre_hook, execute_cmd_post_hook): Constify.
	(enum command_control_type): Update.
	* main.c (catch_command_errors): Remove non-const overload.
	(catch_command_errors_ftype): Remove.
	* python/py-cmd.c (cmdpy_function): Constify.
	* guile/scm-cmd.c (cmdscm_function): Constify.
	* cli/cli-dump.c (call_dump_func): Constify.
	* cli/cli-decode.c (do_const_cfunc): Constify.
	(do_sfunc): Constify.
	(cmd_func): Constify.
	* gdbcmd.h (execute_command, execute_command_to_string): Constify.
	* top.h (execute_command): Constify.
	* top.c (execute_command): Constify.
	(execute_command_to_string): Constify.
	(deprecated_call_command_hook): Constify.
	* command.h (cmd_func): Constify.
	* cli/cli-decode.h (struct cmd_list_element) <func>: Constify.
---
 gdb/ChangeLog        | 41 +++++++++++++++++++++++++++++++++++++++++
 gdb/cli/cli-decode.c |  6 +++---
 gdb/cli/cli-decode.h |  2 +-
 gdb/cli/cli-dump.c   |  2 +-
 gdb/cli/cli-interp.c | 12 ++++--------
 gdb/cli/cli-script.c |  8 ++++----
 gdb/cli/cli-script.h |  2 +-
 gdb/command.h        |  2 +-
 gdb/defs.h           |  2 +-
 gdb/event-top.c      |  6 +++---
 gdb/event-top.h      |  2 +-
 gdb/gdbcmd.h         |  4 ++--
 gdb/guile/scm-cmd.c  |  3 +--
 gdb/main.c           | 29 +----------------------------
 gdb/mi/mi-main.c     |  4 ++--
 gdb/printcmd.c       |  2 +-
 gdb/python/py-cmd.c  |  3 +--
 gdb/python/python.c  |  6 ++----
 gdb/record-btrace.c  |  8 ++++----
 gdb/record-full.c    |  2 +-
 gdb/record.c         | 14 +++++++-------
 gdb/reverse.c        |  2 +-
 gdb/thread.c         | 16 +++-------------
 gdb/top.c            | 30 +++++++++++++++++++-----------
 gdb/top.h            |  2 +-
 gdb/tui/tui-stack.c  |  5 +----
 26 files changed, 108 insertions(+), 107 deletions(-)

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index c3e72283c5..b9110976b9 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -101,7 +101,7 @@ print_help_for_command (struct cmd_list_element *c, const char *prefix,
    bounce function (unless cfunc / sfunc is NULL that is).  */
 
 static void
-do_const_cfunc (struct cmd_list_element *c, char *args, int from_tty)
+do_const_cfunc (struct cmd_list_element *c, const char *args, int from_tty)
 {
   c->function.const_cfunc (args, from_tty);
 }
@@ -117,7 +117,7 @@ set_cmd_cfunc (struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc)
 }
 
 static void
-do_sfunc (struct cmd_list_element *c, char *args, int from_tty)
+do_sfunc (struct cmd_list_element *c, const char *args, int from_tty)
 {
   c->function.sfunc (args, from_tty, c);
 }
@@ -1909,7 +1909,7 @@ cmd_func_p (struct cmd_list_element *cmd)
 
 /* Call the command function.  */
 void
-cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
+cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
 {
   if (cmd_func_p (cmd))
     {
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 9b2d598ff5..09d5c49137 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -107,7 +107,7 @@ struct cmd_list_element
        cagney/2002-02-02: This function signature is evolving.  For
        the moment suggest sticking with either set_cmd_cfunc() or
        set_cmd_sfunc().  */
-    void (*func) (struct cmd_list_element *c, char *args, int from_tty);
+    void (*func) (struct cmd_list_element *c, const char *args, int from_tty);
     /* The command's real callback.  At present func() bounces through
        to one of the below.  */
     union
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 3443299e9a..e97dabfbf2 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -344,7 +344,7 @@ struct dump_context
 };
 
 static void
-call_dump_func (struct cmd_list_element *c, char *args, int from_tty)
+call_dump_func (struct cmd_list_element *c, const char *args, int from_tty)
 {
   struct dump_context *d = (struct dump_context *) get_cmd_context (c);
 
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 609a419fe8..9477ac8fad 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -80,7 +80,7 @@ as_cli_interp (struct interp *interp)
 
 /* Longjmp-safe wrapper for "execute_command".  */
 static struct gdb_exception safe_execute_command (struct ui_out *uiout,
-						  char *command, 
+						  const char *command, 
 						  int from_tty);
 
 /* See cli-interp.h.
@@ -332,11 +332,6 @@ cli_interp::exec (const char *command_str)
   struct ui_file *old_stream;
   struct gdb_exception result;
 
-  /* FIXME: cagney/2003-02-01: Need to const char *propogate
-     safe_execute_command.  */
-  char *str = (char *) alloca (strlen (command_str) + 1);
-  strcpy (str, command_str);
-
   /* gdb_stdout could change between the time cli_uiout was
      initialized and now.  Since we're probably using a different
      interpreter which has a new ui_file for gdb_stdout, use that one
@@ -345,7 +340,7 @@ cli_interp::exec (const char *command_str)
      It is important that it gets reset everytime, since the user
      could set gdb to use a different interpreter.  */
   old_stream = cli->cli_uiout->set_stream (gdb_stdout);
-  result = safe_execute_command (cli->cli_uiout, str, 1);
+  result = safe_execute_command (cli->cli_uiout, command_str, 1);
   cli->cli_uiout->set_stream (old_stream);
   return result;
 }
@@ -357,7 +352,8 @@ cli_interp_base::supports_command_editing ()
 }
 
 static struct gdb_exception
-safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty)
+safe_execute_command (struct ui_out *command_uiout, const char *command,
+		      int from_tty)
 {
   struct gdb_exception e = exception_none;
   struct ui_out *saved_uiout;
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4a66db80d8..cec8ba20ca 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -369,7 +369,7 @@ execute_cmd_pre_hook (struct cmd_list_element *c)
     {
       scoped_restore_hook_in restore_hook (c);
       c->hook_in = 1; /* Prevent recursive hooking.  */
-      execute_user_command (c->hook_pre, (char *) 0);
+      execute_user_command (c->hook_pre, nullptr);
     }
 }
 
@@ -380,12 +380,12 @@ execute_cmd_post_hook (struct cmd_list_element *c)
     {
       scoped_restore_hook_in restore_hook (c);
       c->hook_in = 1; /* Prevent recursive hooking.  */
-      execute_user_command (c->hook_post, (char *) 0);
+      execute_user_command (c->hook_post, nullptr);
     }
 }
 
 void
-execute_user_command (struct cmd_list_element *c, char *args)
+execute_user_command (struct cmd_list_element *c, const char *args)
 {
   struct ui *ui = current_ui;
   struct command_line *cmdlines;
@@ -482,7 +482,7 @@ execute_control_command (struct command_line *cmd)
       {
 	/* A simple command, execute it and return.  */
 	std::string new_line = insert_user_defined_cmd_args (cmd->line);
-	execute_command (&new_line[0], 0);
+	execute_command (new_line.c_str (), 0);
 	ret = cmd->control_type;
 	break;
       }
diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h
index 234faf7c0b..eaca0cd180 100644
--- a/gdb/cli/cli-script.h
+++ b/gdb/cli/cli-script.h
@@ -122,7 +122,7 @@ extern command_line_up copy_command_lines (struct command_line *cmds);
 
 /* Exported to gdb/infrun.c */
 
-extern void execute_user_command (struct cmd_list_element *c, char *args);
+extern void execute_user_command (struct cmd_list_element *c, const char *args);
 
 /* If we're in a user-defined command, replace any $argc/$argN
    reference found in LINE with the arguments that were passed to the
diff --git a/gdb/command.h b/gdb/command.h
index 69e903fd1c..505375e9ed 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -453,6 +453,6 @@ extern int cmd_func_p (struct cmd_list_element *cmd);
 
 /* Call the command function.  */
 extern void cmd_func (struct cmd_list_element *cmd,
-		      char *args, int from_tty);
+		      const char *args, int from_tty);
 
 #endif /* !defined (COMMAND_H) */
diff --git a/gdb/defs.h b/gdb/defs.h
index 675c239af2..f76293fedf 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -660,7 +660,7 @@ extern ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
 extern void (*deprecated_attach_hook) (void);
 extern void (*deprecated_detach_hook) (void);
 extern void (*deprecated_call_command_hook) (struct cmd_list_element * c,
-					     char *cmd, int from_tty);
+					     const char *cmd, int from_tty);
 
 extern int (*deprecated_ui_load_progress_hook) (const char *section,
 						unsigned long num);
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 43e2a27163..d674f3fcda 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -565,10 +565,10 @@ async_disable_stdin (void)
    a whole command.  */
 
 void
-command_handler (char *command)
+command_handler (const char *command)
 {
   struct ui *ui = current_ui;
-  char *c;
+  const char *c;
 
   if (ui->instream == ui->stdin_stream)
     reinitialize_more_filter ();
@@ -759,7 +759,7 @@ command_line_handler (char *rl)
 	 hung up but GDB is still alive.  In such a case, we just quit
 	 gdb killing the inferior program too.  */
       printf_unfiltered ("quit\n");
-      execute_command ((char *) "quit", 1);
+      execute_command ("quit", 1);
     }
   else if (cmd == NULL)
     {
diff --git a/gdb/event-top.h b/gdb/event-top.h
index 05241ad0a6..c84980154c 100644
--- a/gdb/event-top.h
+++ b/gdb/event-top.h
@@ -34,7 +34,7 @@ extern void async_init_signals (void);
 extern void change_line_handler (int);
 
 extern void command_line_handler (char *rl);
-extern void command_handler (char *command);
+extern void command_handler (const char *command);
 
 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT.  */
 #ifndef STOP_SIGNAL
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h
index 3191ecd7fe..4a3e94ab3a 100644
--- a/gdb/gdbcmd.h
+++ b/gdb/gdbcmd.h
@@ -132,8 +132,8 @@ extern struct cmd_list_element *showchecklist;
 
 extern struct cmd_list_element *save_cmdlist;
 
-extern void execute_command (char *, int);
-extern std::string execute_command_to_string (char *p, int from_tty);
+extern void execute_command (const char *, int);
+extern std::string execute_command_to_string (const char *p, int from_tty);
 
 enum command_control_type execute_control_command (struct command_line *);
 
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index 0bd5105da5..4745defb27 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -292,9 +292,8 @@ cmdscm_destroyer (struct cmd_list_element *self, void *context)
 
 static void
 cmdscm_function (struct cmd_list_element *command,
-		 char *args_entry, int from_tty)
+		 const char *args, int from_tty)
 {
-  const char *args = args_entry;
   command_smob *c_smob/*obj*/ = (command_smob *) get_cmd_context (command);
   SCM arg_scm, tty_scm, result;
 
diff --git a/gdb/main.c b/gdb/main.c
index beb820351d..70e0cc12cc 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -355,39 +355,12 @@ handle_command_errors (struct gdb_exception e)
   return 1;
 }
 
-/* Type of the command callback passed to catch_command_errors.  */
-
-typedef void (catch_command_errors_ftype) (char *, int);
-
-/* Wrap calls to commands run before the event loop is started.  */
-
-static int
-catch_command_errors (catch_command_errors_ftype *command,
-		      char *arg, int from_tty)
-{
-  TRY
-    {
-      int was_sync = current_ui->prompt_state == PROMPT_BLOCKED;
-
-      command (arg, from_tty);
-
-      maybe_wait_sync_command_done (was_sync);
-    }
-  CATCH (e, RETURN_MASK_ALL)
-    {
-      return handle_command_errors (e);
-    }
-  END_CATCH
-
-  return 1;
-}
-
 /* Type of the command callback passed to the const
    catch_command_errors.  */
 
 typedef void (catch_command_errors_const_ftype) (const char *, int);
 
-/* Const-correct catch_command_errors.  */
+/* Wrap calls to commands run before the event loop is started.  */
 
 static int
 catch_command_errors (catch_command_errors_const_ftype command,
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 7d4514459b..5095264b2d 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2209,7 +2209,7 @@ mi_execute_cli_command (const char *cmd, int args_p, const char *args)
 	/* FIXME: gdb_???? */
 	fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n",
 			    cmd, run.c_str ());
-      execute_command (&run[0], 0 /* from_tty */ );
+      execute_command (run.c_str (), 0 /* from_tty */ );
     }
 }
 
@@ -2223,7 +2223,7 @@ mi_execute_async_cli_command (const char *cli_command, char **argv, int argc)
   if (mi_async_p ())
     run += "&";
 
-  execute_command (&run[0], 0 /* from_tty */ );
+  execute_command (run.c_str (), 0 /* from_tty */ );
 }
 
 void
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index f01ab47494..dbdec34325 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2652,7 +2652,7 @@ eval_command (const char *arg, int from_tty)
 
   std::string expanded = insert_user_defined_cmd_args (stb.c_str ());
 
-  execute_command (&expanded[0], from_tty);
+  execute_command (expanded.c_str (), from_tty);
 }
 
 void
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index d969b12157..d848600bf5 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -110,9 +110,8 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
 
 static void
 cmdpy_function (struct cmd_list_element *command,
-		char *args_entry, int from_tty)
+		const char *args, int from_tty)
 {
-  const char *args = args_entry;
   cmdpy_object *obj = (cmdpy_object *) get_cmd_context (command);
 
   gdbpy_enter enter_py (get_current_arch (), current_language);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 88a31b0c99..03ea5d5286 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -584,8 +584,6 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 
   TRY
     {
-      /* Copy the argument text in case the command modifies it.  */
-      std::string copy (arg);
       struct interp *interp;
 
       scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
@@ -599,9 +597,9 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 
       scoped_restore preventer = prevent_dont_repeat ();
       if (to_string)
-	to_string_res = execute_command_to_string (&copy[0], from_tty);
+	to_string_res = execute_command_to_string (arg, from_tty);
       else
-	execute_command (&copy[0], from_tty);
+	execute_command (arg, from_tty);
     }
   CATCH (except, RETURN_MASK_ALL)
     {
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 36ddf1c223..050e4cbb4b 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2892,7 +2892,7 @@ cmd_record_btrace_bts_start (const char *args, int from_tty)
 
   TRY
     {
-      execute_command ((char *) "target record-btrace", from_tty);
+      execute_command ("target record-btrace", from_tty);
     }
   CATCH (exception, RETURN_MASK_ALL)
     {
@@ -2914,7 +2914,7 @@ cmd_record_btrace_pt_start (const char *args, int from_tty)
 
   TRY
     {
-      execute_command ((char *) "target record-btrace", from_tty);
+      execute_command ("target record-btrace", from_tty);
     }
   CATCH (exception, RETURN_MASK_ALL)
     {
@@ -2936,7 +2936,7 @@ cmd_record_btrace_start (const char *args, int from_tty)
 
   TRY
     {
-      execute_command ((char *) "target record-btrace", from_tty);
+      execute_command ("target record-btrace", from_tty);
     }
   CATCH (exception, RETURN_MASK_ALL)
     {
@@ -2944,7 +2944,7 @@ cmd_record_btrace_start (const char *args, int from_tty)
 
       TRY
 	{
-	  execute_command ((char *) "target record-btrace", from_tty);
+	  execute_command ("target record-btrace", from_tty);
 	}
       CATCH (exception, RETURN_MASK_ALL)
 	{
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 9530df228d..fc5923efe3 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2757,7 +2757,7 @@ record_full_goto_insn (struct record_full_entry *entry,
 static void
 cmd_record_full_start (const char *args, int from_tty)
 {
-  execute_command ((char *) "target record-full", from_tty);
+  execute_command ("target record-full", from_tty);
 }
 
 static void
diff --git a/gdb/record.c b/gdb/record.c
index f3e493a34b..fe5b6b480f 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -99,25 +99,25 @@ record_start (const char *method, const char *format, int from_tty)
   if (method == NULL)
     {
       if (format == NULL)
-	execute_command_to_string ((char *) "record", from_tty);
+	execute_command_to_string ("record", from_tty);
       else
 	error (_("Invalid format."));
     }
   else if (strcmp (method, "full") == 0)
     {
       if (format == NULL)
-	execute_command_to_string ((char *) "record full", from_tty);
+	execute_command_to_string ("record full", from_tty);
       else
 	error (_("Invalid format."));
     }
   else if (strcmp (method, "btrace") == 0)
     {
       if (format == NULL)
-	execute_command_to_string ((char *) "record btrace", from_tty);
+	execute_command_to_string ("record btrace", from_tty);
       else if (strcmp (format, "bts") == 0)
-	execute_command_to_string ((char *) "record btrace bts", from_tty);
+	execute_command_to_string ("record btrace bts", from_tty);
       else if (strcmp (format, "pt") == 0)
-	execute_command_to_string ((char *) "record btrace pt", from_tty);
+	execute_command_to_string ("record btrace pt", from_tty);
       else
 	error (_("Invalid format."));
     }
@@ -130,7 +130,7 @@ record_start (const char *method, const char *format, int from_tty)
 void
 record_stop (int from_tty)
 {
-  execute_command_to_string ((char *) "record stop", from_tty);
+  execute_command_to_string ("record stop", from_tty);
 }
 
 /* See record.h.  */
@@ -265,7 +265,7 @@ show_record_debug (struct ui_file *file, int from_tty,
 static void
 cmd_record_start (const char *args, int from_tty)
 {
-  execute_command ((char *) "target record-full", from_tty);
+  execute_command ("target record-full", from_tty);
 }
 
 /* Truncate the record log from the present point
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 2ca8917258..2a83ab1c48 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -50,7 +50,7 @@ exec_reverse_once (const char *cmd, const char *args, int from_tty)
   std::string reverse_command = string_printf ("%s %s", cmd, args ? args : "");
   scoped_restore restore_exec_dir
     = make_scoped_restore (&execution_direction, EXEC_REVERSE);
-  execute_command (&reverse_command[0], from_tty);
+  execute_command (reverse_command.c_str (), from_tty);
 }
 
 static void
diff --git a/gdb/thread.c b/gdb/thread.c
index 565292d6ab..396fb6d736 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1704,10 +1704,7 @@ thread_apply_all_command (const char *cmd, int from_tty)
 			     print_thread_id (thr),
 			     target_pid_to_str (inferior_ptid));
 
-	    /* Use a copy of the command in case it is clobbered by
-	       execute_command.  */
-	    std::string copy = cmd;
-	    execute_command (&copy[0], from_tty);
+	    execute_command (cmd, from_tty);
 	  }
     }
 }
@@ -1717,7 +1714,7 @@ thread_apply_all_command (const char *cmd, int from_tty)
 static void
 thread_apply_command (const char *tidlist, int from_tty)
 {
-  char *cmd = NULL;
+  const char *cmd = NULL;
   tid_range_parser parser;
 
   if (tidlist == NULL || *tidlist == '\000')
@@ -1730,7 +1727,7 @@ thread_apply_command (const char *tidlist, int from_tty)
 
       if (!parser.get_tid_range (&inf_num, &thr_start, &thr_end))
 	{
-	  cmd = (char *) parser.cur_tok ();
+	  cmd = parser.cur_tok ();
 	  break;
 	}
     }
@@ -1741,10 +1738,6 @@ thread_apply_command (const char *tidlist, int from_tty)
   if (tidlist == cmd || !isalpha (cmd[0]))
     invalid_thread_id_error (cmd);
 
-  /* Save a copy of the command in case it is clobbered by
-     execute_command.  */
-  std::string saved_cmd = cmd;
-
   scoped_restore_current_thread restore_thread;
 
   parser.init (tidlist, current_inferior ()->num);
@@ -1798,9 +1791,6 @@ thread_apply_command (const char *tidlist, int from_tty)
       printf_filtered (_("\nThread %s (%s):\n"), print_thread_id (tp),
 		       target_pid_to_str (inferior_ptid));
       execute_command (cmd, from_tty);
-
-      /* Restore exact command used previously.  */
-      strcpy (cmd, saved_cmd.c_str ());
     }
 }
 
diff --git a/gdb/top.c b/gdb/top.c
index b9c9d8b37f..8cdf7eb4fd 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -237,7 +237,7 @@ ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
    things like enabling/disabling buttons, etc...  */
 
 void (*deprecated_call_command_hook) (struct cmd_list_element * c, 
-				      char *cmd, int from_tty);
+				      const char *cmd, int from_tty);
 
 /* Called when the current thread changes.  Argument is thread id.  */
 
@@ -545,11 +545,12 @@ set_repeat_arguments (const char *args)
    Pass FROM_TTY as second argument to the defining function.  */
 
 void
-execute_command (char *p, int from_tty)
+execute_command (const char *p, int from_tty)
 {
   struct cleanup *cleanup_if_error, *cleanup;
   struct cmd_list_element *c;
-  char *line;
+  const char *line;
+  const char *cmd_start = p;
 
   cleanup_if_error = make_bpstat_clear_actions_cleanup ();
   cleanup = prepare_execute_command ();
@@ -573,7 +574,7 @@ execute_command (char *p, int from_tty)
   if (*p)
     {
       const char *cmd = p;
-      char *arg;
+      const char *arg;
       int was_sync = current_ui->prompt_state == PROMPT_BLOCKED;
 
       line = p;
@@ -582,11 +583,11 @@ execute_command (char *p, int from_tty)
       print_command_trace (p);
 
       c = lookup_cmd (&cmd, cmdlist, "", 0, 1);
-      p = (char *) cmd;
+      p = cmd;
 
       scoped_restore save_repeat_args
 	= make_scoped_restore (&repeat_arguments, nullptr);
-      char *args_pointer = p;
+      const char *args_pointer = p;
 
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
@@ -601,14 +602,20 @@ execute_command (char *p, int from_tty)
          is_complete_command hack is testing for.  */
       /* Clear off trailing whitespace, except for set and complete
          command.  */
+      std::string without_whitespace;
       if (arg
 	  && c->type != set_cmd
 	  && !is_complete_command (c))
 	{
-	  p = arg + strlen (arg) - 1;
+	  const char *old_end = arg + strlen (arg) - 1;
+	  p = old_end;
 	  while (p >= arg && (*p == ' ' || *p == '\t'))
 	    p--;
-	  *(p + 1) = '\0';
+	  if (p != old_end)
+	    {
+	      without_whitespace = std::string (arg, p + 1);
+	      arg = without_whitespace.c_str ();
+	    }
 	}
 
       /* If this command has been pre-hooked, run the hook first.  */
@@ -636,10 +643,11 @@ execute_command (char *p, int from_tty)
       /* If this command has been post-hooked, run the hook last.  */
       execute_cmd_post_hook (c);
 
-      if (repeat_arguments != NULL)
+      if (repeat_arguments != NULL && cmd_start == saved_command_line)
 	{
 	  gdb_assert (strlen (args_pointer) >= strlen (repeat_arguments));
-	  strcpy (args_pointer, repeat_arguments);
+	  strcpy (saved_command_line + (args_pointer - cmd_start),
+		  repeat_arguments);
 	}
     }
 
@@ -654,7 +662,7 @@ execute_command (char *p, int from_tty)
    temporarily set to true.  */
 
 std::string
-execute_command_to_string (char *p, int from_tty)
+execute_command_to_string (const char *p, int from_tty)
 {
   /* GDB_STDOUT should be better already restored during these
      restoration callbacks.  */
diff --git a/gdb/top.h b/gdb/top.h
index cbb3123cf9..d69942a538 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -231,7 +231,7 @@ extern int quit_confirm (void);
 extern void quit_force (int *, int);
 extern void quit_command (const char *, int);
 extern void quit_cover (void);
-extern void execute_command (char *, int);
+extern void execute_command (const char *, int);
 
 /* If the interpreter is in sync mode (we're running a user command's
    list, running command hooks or similars), and we just ran a
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 4a69b97b9d..d5d18e23dc 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -499,8 +499,5 @@ _initialize_tui_stack (void)
 static void
 tui_update_command (const char *arg, int from_tty)
 {
-  char cmd[sizeof("frame 0")];
-
-  strcpy (cmd, "frame 0");
-  execute_command (cmd, from_tty);
+  execute_command ("frame 0", from_tty);
 }
-- 
2.13.6

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 0/4] finish command constification
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
                   ` (3 preceding siblings ...)
  2017-10-16  3:23 ` [RFA 1/4] Constify add_info Tom Tromey
@ 2017-11-05 16:52 ` Tom Tromey
  2017-11-06 12:03 ` Yao Qi
  5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2017-11-05 16:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This series completes my command constification efforts.

Ping.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 2/4] Remove cmd_cfunc_ftype
  2017-10-16  3:22 ` [RFA 2/4] Remove cmd_cfunc_ftype Tom Tromey
@ 2017-11-06 11:58   ` Yao Qi
  2017-11-06 16:39     ` Tom Tromey
  0 siblings, 1 reply; 11+ messages in thread
From: Yao Qi @ 2017-11-06 11:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 17-10-15 21:22:37, Tom Tromey wrote:
> 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.
> 

You can use x86_64-w64-mingw32 cross compiler to verify your changes
in windows-nat.c at least.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 0/4] finish command constification
  2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
                   ` (4 preceding siblings ...)
  2017-11-05 16:52 ` [RFA 0/4] finish command constification Tom Tromey
@ 2017-11-06 12:03 ` Yao Qi
  2017-11-07 20:55   ` Tom Tromey
  5 siblings, 1 reply; 11+ messages in thread
From: Yao Qi @ 2017-11-06 12:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 17-10-15 21:22:35, Tom Tromey wrote:
> This series completes my command constification efforts.  This turned
> out to be much simpler than I had anticipated; partly because I
> started automating some of the changes, and partly because C++ makes
> some incremental refactorings simpler -- as discussed before, in this
> case by allowing the introduction of const overloads.

Thanks for the efforts.

> 
> This series touches some files I can't compile.  I made a best effort
> to inspect them for const correctness; but it's hard to be sure.
> Given the experience of this series as a whole, I think it is safe to
> say that any required changes will be minimal.

I gave a comment about using x86_64-w64-mingw32 cross compiler to verify
the changes in windows-nat.c.  If the build is OK, this patch series
is good to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 2/4] Remove cmd_cfunc_ftype
  2017-11-06 11:58   ` Yao Qi
@ 2017-11-06 16:39     ` Tom Tromey
  0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2017-11-06 16:39 UTC (permalink / raw)
  To: Yao Qi; +Cc: Tom Tromey, gdb-patches

>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:

Yao> On 17-10-15 21:22:37, Tom Tromey wrote:
>> 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.
>> 

Yao> You can use x86_64-w64-mingw32 cross compiler to verify your changes
Yao> in windows-nat.c at least.

Thanks for the reminder.  I did that and it compiled fine.
However this series is based on an earlier one, so I won't be checking
it in until that is complete.

thanks,
Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 0/4] finish command constification
  2017-11-06 12:03 ` Yao Qi
@ 2017-11-07 20:55   ` Tom Tromey
  2017-11-08  9:50     ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2017-11-07 20:55 UTC (permalink / raw)
  To: Yao Qi; +Cc: Tom Tromey, gdb-patches

>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:

Yao> I gave a comment about using x86_64-w64-mingw32 cross compiler to verify
Yao> the changes in windows-nat.c.  If the build is OK, this patch series
Yao> is good to me.

I'm checking in both this series and the earlier constification series.

It's possible that this will break the build on some configuration that
I'm unable to test.  I'm happy to help unbreak things if needed, just
send me an email.

thanks,
Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA 0/4] finish command constification
  2017-11-07 20:55   ` Tom Tromey
@ 2017-11-08  9:50     ` Pedro Alves
  0 siblings, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2017-11-08  9:50 UTC (permalink / raw)
  To: Tom Tromey, Yao Qi; +Cc: gdb-patches

On 11/07/2017 08:54 PM, Tom Tromey wrote:
>>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:
> 
> Yao> I gave a comment about using x86_64-w64-mingw32 cross compiler to verify
> Yao> the changes in windows-nat.c.  If the build is OK, this patch series
> Yao> is good to me.
> 
> I'm checking in both this series and the earlier constification series.

Yay, congrats!  Thanks much for pushing it through.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-11-08  9:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16  3:22 [RFA 0/4] finish command constification Tom Tromey
2017-10-16  3:22 ` [RFA 2/4] Remove cmd_cfunc_ftype Tom Tromey
2017-11-06 11:58   ` Yao Qi
2017-11-06 16:39     ` Tom Tromey
2017-10-16  3:23 ` [RFA 3/4] Constify add_setshow_* Tom Tromey
2017-10-16  3:23 ` [RFA 4/4] Constify execute_command Tom Tromey
2017-10-16  3:23 ` [RFA 1/4] Constify add_info Tom Tromey
2017-11-05 16:52 ` [RFA 0/4] finish command constification Tom Tromey
2017-11-06 12:03 ` Yao Qi
2017-11-07 20:55   ` Tom Tromey
2017-11-08  9:50     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).