+2017-11-07  Tom Tromey  <tom@tromey.com>
+
+       * go32-nat.c (go32_sysinfo, go32_sldt, go32_sgdt, go32_sidt)
+       (go32_pde, go32_pte, go32_pte_for_address): Constify.
+       * gnu-nat.c (_parse_bool_arg, show_thread_default_pause_cmd)
+       (set_thread_default_pause_cmd, set_thread_default_run_cmd)
+       (show_thread_default_run_cmd, set_thread_default_detach_sc_cmd)
+       (parse_int_arg, show_thread_default_detach_sc_cmd)
+       (set_signals_cmd, show_signals_cmd, set_sig_thread_cmd)
+       (show_sig_thread_cmd, set_stopped_cmd, show_stopped_cmd)
+       (set_exceptions_cmd, show_exceptions_cmd, set_task_pause_cmd)
+       (show_task_pause_cmd, set_task_detach_sc_cmd)
+       (show_task_detach_sc_cmd, set_task_exc_port_cmd)
+       (set_noninvasive_cmd, set_thread_pause_cmd)
+       (show_thread_pause_cmd, set_thread_run_cmd, show_thread_run_cmd)
+       (set_thread_detach_sc_cmd, show_thread_detach_sc_cmd)
+       (set_thread_exc_port_cmd, thread_takeover_sc_cmd): Constify.
+       * windows-nat.c (display_selectors): Constify.
+       * cli/cli-decode.h (struct cmd_list_element) <function>: Remove
+       non-const "cfunc".
+       * cli/cli-decode.c (set_cmd_cfunc): Remove non-const overload.
+       (cmd_cfunc_eq): Likewise.
+       (struct cmd_list_element): Likewise.
+       (do_cfunc): Remove.
+       (cli_user_command_p): Update.
+       * command.h (add_cmd): Remove non-const overload.
+       (cmd_cfunc_ftype): Remove typedef.
+       (cmd_cfunc_eq): Remove non-const overload.
+       * value.c (show_values): Constify.
+       * thread.c (thread_apply_all_command): Constify.
+       * symfile.c (load_command): Constify.
+       * source.c (directory_command): Constify.
+       * maint.c (maintenance_internal_error)
+       (maintenance_demangler_warning, maintenance_space_display)
+       (maintenance_print_architecture, maintenance_translate_address)
+       (maintenance_info_selftests, maintenance_internal_warning):
+       Constify.
+       * breakpoint.c (disable_trace_command, enable_trace_command):
+       Constify.
+       * auto-load.c (info_auto_load_local_gdbinit, add_auto_load_dir):
+       Constify.
+       (add_auto_load_safe_path): Constify.
+       * guile/scm-auto-load.c (info_auto_load_guile_scripts): Constify.
+       * top.h (show_commands): Constify.
+       * linux-thread-db.c (info_auto_load_libthread_db): Constify.
+       * sparc64-tdep.c (adi_examine_command): Constify.
+       (adi_assign_command): Constify.
+
 2017-11-07  Tom Tromey  <tom@tromey.com>
 
        * frame.h (info_locals_command, info_args_command): Constify.
 
    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;
 
    variable.  */
 
 static void
-add_auto_load_dir (char *args, int from_tty)
+add_auto_load_dir (const char *args, int from_tty)
 {
   char *s;
 
 /* 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"));
 
 
 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);
 /* 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);
 }
 /* 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);
 }
 
    the commands callback and func() are set.  The latter set to a
    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)
 {
   cmd->function.sfunc = 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 c;
 }
 
-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;
 }
 
 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));
 }
 
     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: */
 
 /* 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
 
 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,
 
 /* 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);
 
 
 }
 
 static int
-parse_int_arg (char *args, char *cmd_prefix)
+parse_int_arg (const char *args, char *cmd_prefix)
 {
   if (args)
     {
 }
 
 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;
 }
 
 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 ();
 
 }
 
 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 "
 
 \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 ();
 
 }
 
 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;
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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",
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 
 \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;
 
 \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;
 }
 
 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;
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 }
 
 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 ();
 
 #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 ();
 
 
 
 /* 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"
 }
 
 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;
 }
 
 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;
 }
 
 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;
 }
 
 static void
-go32_pde (char *arg, int from_tty)
+go32_pde (const char *arg, int from_tty)
 {
   long pde_idx = -1, i;
 
 }
 
 static void
-go32_pte (char *arg, int from_tty)
+go32_pte (const char *arg, int from_tty)
 {
   long pde_idx = -1L, i;
 
 }
 
 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;
 
 
 /* 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);
 }
 
 /* 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 : "";
 
 #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
    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));
 }
    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));
 }
    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));
 }
 }
 
 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");
 }
 
 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 ();
 
    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;
 
        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;
       }
 
 }
 
 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) {
 
 /* 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"...  */
 
      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)
   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++;
      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)
   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>"));
 
     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;
 
 
 /* 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);
 
 /* 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);
 
 
   if (arg == NULL)
     {
-      char *parg;
+      const char *parg;
       int count = 0;
 
       parg = arg = get_exec_file (1);
          /* 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);
 
 
    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
    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
 
   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)
     {
            printf_filtered (_("\nThread %s (%s):\n"),
                             print_thread_id (thr),
                             target_pid_to_str (inferior_ptid));
-           execute_command (cmd, from_tty);
 
-           /* Restore exact command used previously.  */
-           strcpy (cmd, saved_cmd.c_str ());
+           /* Use a copy of the command in case it is clobbered by
+              execute_command.  */
+           std::string copy = cmd;
+           execute_command (©[0], from_tty);
          }
     }
 }
 
 
 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);
 
 
                                 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
 }
 
 static void
-show_values (char *num_exp, int from_tty)
+show_values (const char *num_exp, int from_tty)
 {
   int i;
   struct value *val;
 
 }
 
 static void
-display_selectors (char * args, int from_tty)
+display_selectors (const char * args, int from_tty)
 {
   if (!current_thread)
     {