Constify strings in tracepoint.c, lookup_cmd and the completers.
authorPedro Alves <palves@redhat.com>
Wed, 13 Mar 2013 18:34:55 +0000 (18:34 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 13 Mar 2013 18:34:55 +0000 (18:34 +0000)
This is sort of a continuation of Keith's parse_exp_1 constification
patch.  It started out by undoing these bits:

  @@ -754,9 +754,12 @@ validate_actionline (char **line, struct
      tmp_p = p;
      for (loc = t->base.loc; loc; loc = loc->next)
        {
  -       p = tmp_p;
  -       exp = parse_exp_1 (&p, loc->address,
  +       const char *q;
  +
  +       q = tmp_p;
  +       exp = parse_exp_1 (&q, loc->address,
     block_for_pc (loc->address), 1);
  +       p = (char *) q;

and progressively making more things const upwards, fixing fallout,
rinse repeat, until GDB built again (--enable-targets=all).

That ended up constifying lookup_cmd/add_cmd and (lots of) friends,
and the completers.

I didn't try to constify the command hooks themselves, because I know
upfront there are commands that write to the command string argument,
and I think I managed to stop at a nice non-hacky split point already.

I think the only non-really-super-obvious changes are
tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions.

The rest is just mostly about 'char *' => 'const char *', 'char **'=>
'const char **', and the occasional (e.g., deprecated_cmd_warning)
case of 'char **'=> 'const char *', where/when I noticed that nothing
actually cares about the pointer to pointer output.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2013-03-13  Pedro Alves  <palves@redhat.com>

* ada-lang.c (struct add_partial_datum) <text, text0, word>: Make
fields const.
(ada_make_symbol_completion_list): Make "text0" parameter const.
* ax-gdb.c (agent_eval_command_one): Make "exp" parameter const.
* breakpoint.c (condition_completer): Make "text" and "word"
parameters const.  Adjust.
(check_tracepoint_command): Adjust to validate_actionline
prototype change.
(catch_syscall_completer): Make "text" and "word" parameters
const.
* cli/cli-cmds.c (show_user): Make "comname" local const.
(valid_command_p): Make "command" parameter const.
(alias_command): Make "alias_prefix" and "command_prefix" locals
const.
* cli/cli-decode.c (add_cmd): Make "name" parameter const.
(add_alias_cmd): Make "name" and "oldname" parameters const.
Adjust.  No longer make copy of OLDNAME.
(add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd)
(add_setshow_cmd_full, 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_unlimited_cmd, add_setshow_zuinteger_cmd)
(delete_cmd, add_info, add_info_alias, add_com, add_com_alias):
Make "name" parameter const.
(help_cmd): Rename "command" parameter to "arg".  New const local
"command".
(find_cmd): Make "command" parameter const.
(lookup_cmd_1): Make "text" parameter pointer to const.  Adjust to
deprecated_cmd_warning prototype change.
(undef_cmd_error): Make "cmdtype" parameter const.
(lookup_cmd): Make "line" parameter const.
(deprecated_cmd_warning): Change type of "text" parameter to
pointer to const char, from pointer to pointer to char.  Adjust.
(lookup_cmd_composition): Make "text" parameter const.
(complete_on_cmdlist, complete_on_enum): Make "text" and "word"
parameters const.
* cli/cli-decode.h (struct cmd_list_element) <name>: Make field
const.
* cli/cli-script.c (validate_comname): Make "tem" local const.
(define_command): New const local "tem_c".  Use it in calls to
lookup_cmd.
(document_command): Make "tem" and "comfull" locals const.
(show_user_1): Make "prefix" and "name" parameters const.
* cli-script.h (show_user_1): Make "prefix" and "name" parameters
const.
* command.h (add_cmd, add_alias_cmd, add_prefix_cmd)
(add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1)
(deprecated_cmd_warning, lookup_cmd_composition, add_com)
(add_com_alias, add_info, add_info_alias, complete_on_cmdlist)
(complete_on_enum, 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):
Change prototypes, constifying strings.
* completer.c (noop_completer, filename_completer): Make "text"
and "prefix" parameters const.
(location_completer, expression_completer)
(complete_line_internal): Make "text" and "prefix" parameters
const and adjust.
(command_completer, signal_completer): Make "text" and "prefix"
parameters const.
* completer.h (noop_completer, filename_completer)
(expression_completer, location_completer, command_completer)
(signal_completer): Change prototypes.
* corefile.c (complete_set_gnutarget): Make "text" and "word"
parameters const.
* cp-abi.c (cp_abi_completer): Likewise.
* expression.h (parse_expression_for_completion): Change
prototype.
* f-lang.c (f_make_symbol_completion_list): Make "text" and "word"
parameters const.
* infcmd.c (_initialize_infcmd): Make "cmd_name" local const.
* infrun.c (handle_completer): Make "text" and "word" parameters
const.
* interps.c (interpreter_completer): Make "text" and "word"
parameters const.
* language.h (struct language_defn)
<la_make_symbol_completion_list>: Make "text" and "word"
parameters const.
* parse.c (parse_exp_1): Move const hack to parse_exp_in_context.
(parse_exp_in_context): Rename to ...
(parse_exp_in_context_1): ... this.
(parse_exp_in_context): Reimplement, with const hack from
parse_exp_1.
(parse_expression_for_completion): Make "string" parameter const.
* printcmd.c (decode_format): Make "string_ptr" parameter pointer
to pointer to const char.  Adjust.
(print_command_1): Make "exp" parameter const.
(output_command): Rename to ...
(output_command_const): ... this.  Make "exp" parameter const.
(output_command): Reimplement.
(x_command): Adjust.
(display_command): Rename "exp" parameter to "arg".  New "exp"
local, const version of "arg".
* python/py-auto-load.c (gdbpy_initialize_auto_load): Make
"cmd_name" local const.
* python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree
call.
(cmdpy_completer): Make "text" and "word" parameters const.
(gdbpy_parse_command_name): Make "prefix_text2" local const.
* python/py-param.c (add_setshow_generic): Make "tmp_name" local
const.
* remote.c (_initialize_remote): Make "cmd_name" local const.
* symtab.c (language_search_unquoted_string): Make "text" and "p"
parameters const.  Adjust.
(completion_list_add_fields): Make "sym_text", "text" and "word"
parameters const.
(struct add_name_data) <sym_text, text, word>: Make fields const.
(default_make_symbol_completion_list_break_on): Make "text" and
"word" parameters const.  Adjust locals.
(default_make_symbol_completion_list)
(make_symbol_completion_list, make_symbol_completion_type)
(make_symbol_completion_list_fn): Make "text" and "word"
parameters const.
(make_file_symbol_completion_list): Make "text", "word" and
"srcfile" parameters const.  Adjust locals.
(add_filename_to_list): Make "text" and "word" parameters const.
(struct add_partial_filename_data) <text, word>: Make fields
const.
(make_source_files_completion_list): Make "text" and "word"
parameters const.
* symtab.h (default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type enum type_code)
(make_symbol_completion_list_fn make_file_symbol_completion_list)
(make_source_files_completion_list): Change prototype.
* top.c (execute_command): Adjust to pass pointer to pointer to
const char to lookup_cmd, and to deprecated_cmd_warning prototype
change.
(set_verbose): Make "cmdname" local const.
* tracepoint.c (decode_agent_options): Make "exp" parameter const,
and adjust.
(validate_actionline): Make "line" parameter a pointer to const
char, and adjust.
(encode_actions_1): Make "action_exp" local const, and adjust.
(encode_actions): Adjust.
(replace_comma): Delete.
(trace_dump_actions): Make "action_exp" and "next_comma" locals
const, and adjust.  Don't frob the action string while splitting
it at commas.  Instead, make a copy of each split substring in
turn.
(trace_dump_command): Adjust to validate_actionline prototype
change.
* tracepoint.h (decode_agent_options, decode_agent_options)
(encode_actions, validate_actionline): Change prototypes.
* valprint.h (output_command): Delete declaration.
(output_command_const): Declare.
* value.c (function_destroyer): Cast const away in xfree call.

33 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ax-gdb.c
gdb/breakpoint.c
gdb/cli/cli-cmds.c
gdb/cli/cli-decode.c
gdb/cli/cli-decode.h
gdb/cli/cli-script.c
gdb/cli/cli-script.h
gdb/command.h
gdb/completer.c
gdb/completer.h
gdb/corefile.c
gdb/cp-abi.c
gdb/expression.h
gdb/f-lang.c
gdb/infcmd.c
gdb/infrun.c
gdb/interps.c
gdb/language.h
gdb/parse.c
gdb/printcmd.c
gdb/python/py-auto-load.c
gdb/python/py-cmd.c
gdb/python/py-param.c
gdb/remote.c
gdb/symtab.c
gdb/symtab.h
gdb/top.c
gdb/tracepoint.c
gdb/tracepoint.h
gdb/valprint.h
gdb/value.c

index ca5bc04bdaa4ab56826fef15ac8711432a858dd6..5d260aa7d9792a855d5aef4a27bfc92368d5038e 100644 (file)
@@ -1,3 +1,160 @@
+2013-03-13  Pedro Alves  <palves@redhat.com>
+
+       * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make
+       fields const.
+       (ada_make_symbol_completion_list): Make "text0" parameter const.
+       * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const.
+       * breakpoint.c (condition_completer): Make "text" and "word"
+       parameters const.  Adjust.
+       (check_tracepoint_command): Adjust to validate_actionline
+       prototype change.
+       (catch_syscall_completer): Make "text" and "word" parameters
+       const.
+       * cli/cli-cmds.c (show_user): Make "comname" local const.
+       (valid_command_p): Make "command" parameter const.
+       (alias_command): Make "alias_prefix" and "command_prefix" locals
+       const.
+       * cli/cli-decode.c (add_cmd): Make "name" parameter const.
+       (add_alias_cmd): Make "name" and "oldname" parameters const.
+       Adjust.  No longer make copy of OLDNAME.
+       (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd)
+       (add_setshow_cmd_full, 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_unlimited_cmd, add_setshow_zuinteger_cmd)
+       (delete_cmd, add_info, add_info_alias, add_com, add_com_alias):
+       Make "name" parameter const.
+       (help_cmd): Rename "command" parameter to "arg".  New const local
+       "command".
+       (find_cmd): Make "command" parameter const.
+       (lookup_cmd_1): Make "text" parameter pointer to const.  Adjust to
+       deprecated_cmd_warning prototype change.
+       (undef_cmd_error): Make "cmdtype" parameter const.
+       (lookup_cmd): Make "line" parameter const.
+       (deprecated_cmd_warning): Change type of "text" parameter to
+       pointer to const char, from pointer to pointer to char.  Adjust.
+       (lookup_cmd_composition): Make "text" parameter const.
+       (complete_on_cmdlist, complete_on_enum): Make "text" and "word"
+       parameters const.
+       * cli/cli-decode.h (struct cmd_list_element) <name>: Make field
+       const.
+       * cli/cli-script.c (validate_comname): Make "tem" local const.
+       (define_command): New const local "tem_c".  Use it in calls to
+       lookup_cmd.
+       (document_command): Make "tem" and "comfull" locals const.
+       (show_user_1): Make "prefix" and "name" parameters const.
+       * cli-script.h (show_user_1): Make "prefix" and "name" parameters
+       const.
+       * command.h (add_cmd, add_alias_cmd, add_prefix_cmd)
+       (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1)
+       (deprecated_cmd_warning, lookup_cmd_composition, add_com)
+       (add_com_alias, add_info, add_info_alias, complete_on_cmdlist)
+       (complete_on_enum, 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):
+       Change prototypes, constifying strings.
+       * completer.c (noop_completer, filename_completer): Make "text"
+       and "prefix" parameters const.
+       (location_completer, expression_completer)
+       (complete_line_internal): Make "text" and "prefix" parameters
+       const and adjust.
+       (command_completer, signal_completer): Make "text" and "prefix"
+       parameters const.
+       * completer.h (noop_completer, filename_completer)
+       (expression_completer, location_completer, command_completer)
+       (signal_completer): Change prototypes.
+       * corefile.c (complete_set_gnutarget): Make "text" and "word"
+       parameters const.
+       * cp-abi.c (cp_abi_completer): Likewise.
+       * expression.h (parse_expression_for_completion): Change
+       prototype.
+       * f-lang.c (f_make_symbol_completion_list): Make "text" and "word"
+       parameters const.
+       * infcmd.c (_initialize_infcmd): Make "cmd_name" local const.
+       * infrun.c (handle_completer): Make "text" and "word" parameters
+       const.
+       * interps.c (interpreter_completer): Make "text" and "word"
+       parameters const.
+       * language.h (struct language_defn)
+       <la_make_symbol_completion_list>: Make "text" and "word"
+       parameters const.
+       * parse.c (parse_exp_1): Move const hack to parse_exp_in_context.
+       (parse_exp_in_context): Rename to ...
+       (parse_exp_in_context_1): ... this.
+       (parse_exp_in_context): Reimplement, with const hack from
+       parse_exp_1.
+       (parse_expression_for_completion): Make "string" parameter const.
+       * printcmd.c (decode_format): Make "string_ptr" parameter pointer
+       to pointer to const char.  Adjust.
+       (print_command_1): Make "exp" parameter const.
+       (output_command): Rename to ...
+       (output_command_const): ... this.  Make "exp" parameter const.
+       (output_command): Reimplement.
+       (x_command): Adjust.
+       (display_command): Rename "exp" parameter to "arg".  New "exp"
+       local, const version of "arg".
+       * python/py-auto-load.c (gdbpy_initialize_auto_load): Make
+       "cmd_name" local const.
+       * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree
+       call.
+       (cmdpy_completer): Make "text" and "word" parameters const.
+       (gdbpy_parse_command_name): Make "prefix_text2" local const.
+       * python/py-param.c (add_setshow_generic): Make "tmp_name" local
+       const.
+       * remote.c (_initialize_remote): Make "cmd_name" local const.
+       * symtab.c (language_search_unquoted_string): Make "text" and "p"
+       parameters const.  Adjust.
+       (completion_list_add_fields): Make "sym_text", "text" and "word"
+       parameters const.
+       (struct add_name_data) <sym_text, text, word>: Make fields const.
+       (default_make_symbol_completion_list_break_on): Make "text" and
+       "word" parameters const.  Adjust locals.
+       (default_make_symbol_completion_list)
+       (make_symbol_completion_list, make_symbol_completion_type)
+       (make_symbol_completion_list_fn): Make "text" and "word"
+       parameters const.
+       (make_file_symbol_completion_list): Make "text", "word" and
+       "srcfile" parameters const.  Adjust locals.
+       (add_filename_to_list): Make "text" and "word" parameters const.
+       (struct add_partial_filename_data) <text, word>: Make fields
+       const.
+       (make_source_files_completion_list): Make "text" and "word"
+       parameters const.
+       * symtab.h (default_make_symbol_completion_list_break_on)
+       (default_make_symbol_completion_list, make_symbol_completion_list)
+       (make_symbol_completion_type enum type_code)
+       (make_symbol_completion_list_fn make_file_symbol_completion_list)
+       (make_source_files_completion_list): Change prototype.
+       * top.c (execute_command): Adjust to pass pointer to pointer to
+       const char to lookup_cmd, and to deprecated_cmd_warning prototype
+       change.
+       (set_verbose): Make "cmdname" local const.
+       * tracepoint.c (decode_agent_options): Make "exp" parameter const,
+       and adjust.
+       (validate_actionline): Make "line" parameter a pointer to const
+       char, and adjust.
+       (encode_actions_1): Make "action_exp" local const, and adjust.
+       (encode_actions): Adjust.
+       (replace_comma): Delete.
+       (trace_dump_actions): Make "action_exp" and "next_comma" locals
+       const, and adjust.  Don't frob the action string while splitting
+       it at commas.  Instead, make a copy of each split substring in
+       turn.
+       (trace_dump_command): Adjust to validate_actionline prototype
+       change.
+       * tracepoint.h (decode_agent_options, decode_agent_options)
+       (encode_actions, validate_actionline): Change prototypes.
+       * valprint.h (output_command): Delete declaration.
+       (output_command_const): Declare.
+       * value.c (function_destroyer): Cast const away in xfree call.
+
 2013-03-13  Pedro Alves  <palves@redhat.com>
 
        * ada-lang.c (ada_decode_symbol): Cast away constness of GSYMBOL
index 1e5c55e90cce2a5b239e2856494e4397cbe2c2f3..43d6e3c4fc366572e5694059574ffd9047b95805 100644 (file)
@@ -5807,10 +5807,10 @@ symbol_completion_add (VEC(char_ptr) **sv,
 struct add_partial_datum
 {
   VEC(char_ptr) **completions;
-  char *text;
+  const char *text;
   int text_len;
-  char *text0;
-  char *word;
+  const char *text0;
+  const char *word;
   int wild_match;
   int encoded;
 };
@@ -5829,7 +5829,8 @@ ada_expand_partial_symbol_name (const char *name, void *user_data)
    the entire command on which completion is made.  */
 
 static VEC (char_ptr) *
-ada_make_symbol_completion_list (char *text0, char *word, enum type_code code)
+ada_make_symbol_completion_list (const char *text0, const char *word,
+                                enum type_code code)
 {
   char *text;
   int text_len;
index 74824d373adb697f751b64e034b2e1c34c35fe04..93c87e7e396aa0018e8b9ba9378c0992d09bc92f 100644 (file)
@@ -2603,7 +2603,7 @@ gen_printf (CORE_ADDR scope, struct gdbarch *gdbarch,
 }
 
 static void
-agent_eval_command_one (char *exp, int eval, CORE_ADDR pc)
+agent_eval_command_one (const char *exp, int eval, CORE_ADDR pc)
 {
   struct cleanup *old_chain = 0;
   struct expression *expr;
index e5ee4d0e28fc343c6c5dda54dadc1f58d9940bb2..0ff4683362064a9a3d7244202eebb06557ccc781 100644 (file)
@@ -991,12 +991,13 @@ set_breakpoint_condition (struct breakpoint *b, char *exp,
 /* Completion for the "condition" command.  */
 
 static VEC (char_ptr) *
-condition_completer (struct cmd_list_element *cmd, char *text, char *word)
+condition_completer (struct cmd_list_element *cmd,
+                    const char *text, const char *word)
 {
-  char *space;
+  const char *space;
 
-  text = skip_spaces (text);
-  space = skip_to_space (text);
+  text = skip_spaces_const (text);
+  space = skip_to_space_const (text);
   if (*space == '\0')
     {
       int len;
@@ -1041,7 +1042,7 @@ condition_completer (struct cmd_list_element *cmd, char *text, char *word)
     }
 
   /* We're completing the expression part.  */
-  text = skip_spaces (space);
+  text = skip_spaces_const (space);
   return expression_completer (cmd, text, word);
 }
 
@@ -1264,7 +1265,7 @@ check_tracepoint_command (char *line, void *closure)
 {
   struct breakpoint *b = closure;
 
-  validate_actionline (&line, b);
+  validate_actionline (line, b);
 }
 
 /* A structure used to pass information through
@@ -15084,7 +15085,7 @@ catching_syscall_number (int syscall_number)
 /* Complete syscall names.  Used by "catch syscall".  */
 static VEC (char_ptr) *
 catch_syscall_completer (struct cmd_list_element *cmd,
-                         char *text, char *word)
+                         const char *text, const char *word)
 {
   const char **list = get_syscall_names ();
   VEC (char_ptr) *retlist
index 77da7382d0e17071b5d507b138c56edd4ae98652..c05f77f1d7654bda4b76990cb2828ff1f118d282 100644 (file)
@@ -1213,7 +1213,7 @@ show_user (char *args, int from_tty)
 
   if (args)
     {
-      char *comname = args;
+      const char *comname = args;
 
       c = lookup_cmd (&comname, cmdlist, "", 0, 1);
       /* c->user_commands would be NULL if it's a python command.  */
@@ -1291,7 +1291,7 @@ argv_to_dyn_string (char **argv, int n)
    Return TRUE if COMMAND exists, unambiguously.  Otherwise FALSE.  */
 
 static int
-valid_command_p (char *command)
+valid_command_p (const char *command)
 {
   struct cmd_list_element *c;
 
@@ -1400,7 +1400,7 @@ alias_command (char *args, int from_tty)
   else
     {
       dyn_string_t alias_prefix_dyn_string, command_prefix_dyn_string;
-      char *alias_prefix, *command_prefix;
+      const char *alias_prefix, *command_prefix;
       struct cmd_list_element *c_alias, *c_command;
 
       if (alias_argc != command_argc)
index a8f7747ea6e71a9294e00ed954b1e8d40f3865b9..61a7b5aa0a7895f87a59a9b3aaa816bc1ebaa079 100644 (file)
 
 /* Prototypes for local functions.  */
 
-static void undef_cmd_error (char *, char *);
+static void undef_cmd_error (const char *, const char *);
 
-static struct cmd_list_element *delete_cmd (char *name,
+static struct cmd_list_element *delete_cmd (const char *name,
                                            struct cmd_list_element **list,
                                            struct cmd_list_element **prehook,
                                            struct cmd_list_element **prehookee,
                                            struct cmd_list_element **posthook,
                                            struct cmd_list_element **posthookee);
 
-static struct cmd_list_element *find_cmd (char *command,
+static struct cmd_list_element *find_cmd (const char *command,
                                          int len,
                                          struct cmd_list_element *clist,
                                          int ignore_help_classes,
@@ -189,7 +189,7 @@ set_cmd_completer (struct cmd_list_element *cmd, completer_ftype *completer)
    of *LIST).  */
 
 struct cmd_list_element *
-add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
+add_cmd (const char *name, enum command_class class, void (*fun) (char *, int),
         char *doc, struct cmd_list_element **list)
 {
   struct cmd_list_element *c
@@ -278,18 +278,15 @@ deprecate_cmd (struct cmd_list_element *cmd, char *replacement)
 }
 
 struct cmd_list_element *
-add_alias_cmd (char *name, char *oldname, enum command_class class,
+add_alias_cmd (const char *name, const char *oldname, enum command_class class,
               int abbrev_flag, struct cmd_list_element **list)
 {
-  /* Must do this since lookup_cmd tries to side-effect its first
-     arg.  */
-  char *copied_name;
+  const char *tmp;
   struct cmd_list_element *old;
   struct cmd_list_element *c;
 
-  copied_name = (char *) alloca (strlen (oldname) + 1);
-  strcpy (copied_name, oldname);
-  old = lookup_cmd (&copied_name, *list, "", 1, 1);
+  tmp = oldname;
+  old = lookup_cmd (&tmp, *list, "", 1, 1);
 
   if (old == 0)
     {
@@ -333,7 +330,7 @@ add_alias_cmd (char *name, char *oldname, enum command_class class,
    containing that list.  */
 
 struct cmd_list_element *
-add_prefix_cmd (char *name, enum command_class class,
+add_prefix_cmd (const char *name, enum command_class class,
                void (*fun) (char *, int),
                char *doc, struct cmd_list_element **prefixlist,
                char *prefixname, int allow_unknown,
@@ -361,7 +358,7 @@ add_prefix_cmd (char *name, enum command_class class,
 /* Like add_prefix_cmd but sets the abbrev_flag on the new command.  */
 
 struct cmd_list_element *
-add_abbrev_prefix_cmd (char *name, enum command_class class,
+add_abbrev_prefix_cmd (const char *name, enum command_class class,
                       void (*fun) (char *, int), char *doc,
                       struct cmd_list_element **prefixlist, char *prefixname,
                       int allow_unknown, struct cmd_list_element **list)
@@ -398,7 +395,7 @@ empty_sfunc (char *args, int from_tty, struct cmd_list_element *c)
    DOC is the documentation string.  */
 
 static struct cmd_list_element *
-add_set_or_show_cmd (char *name,
+add_set_or_show_cmd (const char *name,
                     enum cmd_types type,
                     enum command_class class,
                     var_types var_type,
@@ -428,7 +425,7 @@ add_set_or_show_cmd (char *name,
    structures.  */
 
 static void
-add_setshow_cmd_full (char *name,
+add_setshow_cmd_full (const char *name,
                      enum command_class class,
                      var_types var_type, void *var,
                      const char *set_doc, const char *show_doc,
@@ -481,7 +478,7 @@ add_setshow_cmd_full (char *name,
    which will contain the matching string (from ENUMLIST).  */
 
 void
-add_setshow_enum_cmd (char *name,
+add_setshow_enum_cmd (const char *name,
                      enum command_class class,
                      const char *const *enumlist,
                      const char **var,
@@ -510,7 +507,7 @@ const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL };
    variable which will contain the value.  DOC is the documentation
    string.  FUNC is the corresponding callback.  */
 void
-add_setshow_auto_boolean_cmd (char *name,
+add_setshow_auto_boolean_cmd (const char *name,
                              enum command_class class,
                              enum auto_boolean *var,
                              const char *set_doc, const char *show_doc,
@@ -535,7 +532,7 @@ add_setshow_auto_boolean_cmd (char *name,
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
 void
-add_setshow_boolean_cmd (char *name, enum command_class class, int *var,
+add_setshow_boolean_cmd (const char *name, enum command_class class, int *var,
                         const char *set_doc, const char *show_doc,
                         const char *help_doc,
                         cmd_sfunc_ftype *set_func,
@@ -557,7 +554,7 @@ add_setshow_boolean_cmd (char *name, enum command_class class, int *var,
 /* Add element named NAME to both the set and show command LISTs (the
    list for set/show or some sublist thereof).  */
 void
-add_setshow_filename_cmd (char *name, enum command_class class,
+add_setshow_filename_cmd (const char *name, enum command_class class,
                          char **var,
                          const char *set_doc, const char *show_doc,
                          const char *help_doc,
@@ -579,7 +576,7 @@ add_setshow_filename_cmd (char *name, enum command_class class,
 /* Add element named NAME to both the set and show command LISTs (the
    list for set/show or some sublist thereof).  */
 void
-add_setshow_string_cmd (char *name, enum command_class class,
+add_setshow_string_cmd (const char *name, enum command_class class,
                        char **var,
                        const char *set_doc, const char *show_doc,
                        const char *help_doc,
@@ -598,7 +595,7 @@ add_setshow_string_cmd (char *name, enum command_class class,
 /* Add element named NAME to both the set and show command LISTs (the
    list for set/show or some sublist thereof).  */
 struct cmd_list_element *
-add_setshow_string_noescape_cmd (char *name, enum command_class class,
+add_setshow_string_noescape_cmd (const char *name, enum command_class class,
                                 char **var,
                                 const char *set_doc, const char *show_doc,
                                 const char *help_doc,
@@ -620,7 +617,7 @@ add_setshow_string_noescape_cmd (char *name, enum command_class class,
 /* Add element named NAME to both the set and show command LISTs (the
    list for set/show or some sublist thereof).  */
 void
-add_setshow_optional_filename_cmd (char *name, enum command_class class,
+add_setshow_optional_filename_cmd (const char *name, enum command_class class,
                                   char **var,
                                   const char *set_doc, const char *show_doc,
                                   const char *help_doc,
@@ -647,7 +644,7 @@ add_setshow_optional_filename_cmd (char *name, enum command_class class,
    value.  SET_DOC and SHOW_DOC are the documentation strings.  This
    function is only used in Python API.  Please don't use it elsewhere.  */
 void
-add_setshow_integer_cmd (char *name, enum command_class class,
+add_setshow_integer_cmd (const char *name, enum command_class class,
                         int *var,
                         const char *set_doc, const char *show_doc,
                         const char *help_doc,
@@ -668,7 +665,7 @@ add_setshow_integer_cmd (char *name, enum command_class class,
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
 void
-add_setshow_uinteger_cmd (char *name, enum command_class class,
+add_setshow_uinteger_cmd (const char *name, enum command_class class,
                          unsigned int *var,
                          const char *set_doc, const char *show_doc,
                          const char *help_doc,
@@ -689,7 +686,7 @@ add_setshow_uinteger_cmd (char *name, enum command_class class,
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
 void
-add_setshow_zinteger_cmd (char *name, enum command_class class,
+add_setshow_zinteger_cmd (const char *name, enum command_class class,
                          int *var,
                          const char *set_doc, const char *show_doc,
                          const char *help_doc,
@@ -706,7 +703,7 @@ add_setshow_zinteger_cmd (char *name, enum command_class class,
 }
 
 void
-add_setshow_zuinteger_unlimited_cmd (char *name,
+add_setshow_zuinteger_unlimited_cmd (const char *name,
                                     enum command_class class,
                                     int *var,
                                     const char *set_doc,
@@ -729,7 +726,7 @@ add_setshow_zuinteger_unlimited_cmd (char *name,
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
 void
-add_setshow_zuinteger_cmd (char *name, enum command_class class,
+add_setshow_zuinteger_cmd (const char *name, enum command_class class,
                           unsigned int *var,
                           const char *set_doc, const char *show_doc,
                           const char *help_doc,
@@ -753,7 +750,7 @@ add_setshow_zuinteger_cmd (char *name, enum command_class class,
    set to NULL.  */
 
 static struct cmd_list_element *
-delete_cmd (char *name, struct cmd_list_element **list,
+delete_cmd (const char *name, struct cmd_list_element **list,
            struct cmd_list_element **prehook,
            struct cmd_list_element **prehookee,
            struct cmd_list_element **posthook,
@@ -823,7 +820,7 @@ delete_cmd (char *name, struct cmd_list_element **list,
 /* Add an element to the list of info subcommands.  */
 
 struct cmd_list_element *
-add_info (char *name, void (*fun) (char *, int), char *doc)
+add_info (const char *name, void (*fun) (char *, int), char *doc)
 {
   return add_cmd (name, no_class, fun, doc, &infolist);
 }
@@ -831,7 +828,7 @@ add_info (char *name, void (*fun) (char *, int), char *doc)
 /* Add an alias to the list of info subcommands.  */
 
 struct cmd_list_element *
-add_info_alias (char *name, char *oldname, int abbrev_flag)
+add_info_alias (const char *name, char *oldname, int abbrev_flag)
 {
   return add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);
 }
@@ -839,7 +836,7 @@ add_info_alias (char *name, char *oldname, int abbrev_flag)
 /* Add an element to the list of commands.  */
 
 struct cmd_list_element *
-add_com (char *name, enum command_class class, void (*fun) (char *, int),
+add_com (const char *name, enum command_class class, void (*fun) (char *, int),
         char *doc)
 {
   return add_cmd (name, class, fun, doc, &cmdlist);
@@ -848,7 +845,7 @@ add_com (char *name, enum command_class class, void (*fun) (char *, int),
 /* Add an alias or abbreviation command to the list of commands.  */
 
 struct cmd_list_element *
-add_com_alias (char *name, char *oldname, enum command_class class,
+add_com_alias (const char *name, const char *oldname, enum command_class class,
               int abbrev_flag)
 {
   return add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist);
@@ -914,9 +911,10 @@ apropos_cmd (struct ui_file *stream,
    help_list.  */
 
 void
-help_cmd (char *command, struct ui_file *stream)
+help_cmd (char *arg, struct ui_file *stream)
 {
   struct cmd_list_element *c;
+  const char *command = arg;
 
   if (!command)
     {
@@ -1184,7 +1182,7 @@ help_cmd_list (struct cmd_list_element *list, enum command_class class,
    found in nfound.  */
 
 static struct cmd_list_element *
-find_cmd (char *command, int len, struct cmd_list_element *clist,
+find_cmd (const char *command, int len, struct cmd_list_element *clist,
          int ignore_help_classes, int *nfound)
 {
   struct cmd_list_element *found, *c;
@@ -1305,13 +1303,13 @@ valid_user_defined_cmd_name_p (const char *name)
    the struct cmd_list_element is NULL).  */
 
 struct cmd_list_element *
-lookup_cmd_1 (char **text, struct cmd_list_element *clist,
+lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
              struct cmd_list_element **result_list, int ignore_help_classes)
 {
   char *command;
   int len, tmp, nfound;
   struct cmd_list_element *found, *c;
-  char *line = *text;
+  const char *line = *text;
 
   while (**text == ' ' || **text == '\t')
     (*text)++;
@@ -1376,7 +1374,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
        flags.  */
       
       if (found->flags & DEPRECATED_WARN_USER)
-       deprecated_cmd_warning (&line);
+       deprecated_cmd_warning (line);
       found = found->cmd_pointer;
     }
   /* If we found a prefix command, keep looking.  */
@@ -1423,7 +1421,7 @@ lookup_cmd_1 (char **text, struct cmd_list_element *clist,
 /* All this hair to move the space to the front of cmdtype */
 
 static void
-undef_cmd_error (char *cmdtype, char *q)
+undef_cmd_error (const char *cmdtype, const char *q)
 {
   error (_("Undefined %scommand: \"%s\".  Try \"help%s%.*s\"."),
         cmdtype,
@@ -1448,7 +1446,7 @@ undef_cmd_error (char *cmdtype, char *q)
    the function field of the struct cmd_list_element is 0).  */
 
 struct cmd_list_element *
-lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
+lookup_cmd (const char **line, struct cmd_list_element *list, char *cmdtype,
            int allow_unknown, int ignore_help_classes)
 {
   struct cmd_list_element *last_list = 0;
@@ -1544,14 +1542,14 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
   return 0;
 }
 
-/* We are here presumably because an alias or command in *TEXT is
+/* We are here presumably because an alias or command in TEXT is
    deprecated and a warning message should be generated.  This
-   function decodes *TEXT and potentially generates a warning message
+   function decodes TEXT and potentially generates a warning message
    as outlined below.
    
    Example for 'set endian big' which has a fictitious alias 'seb'.
    
-   If alias wasn't used in *TEXT, and the command is deprecated:
+   If alias wasn't used in TEXT, and the command is deprecated:
    "warning: 'set endian big' is deprecated." 
    
    If alias was used, and only the alias is deprecated:
@@ -1567,13 +1565,13 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
    
 */
 void
-deprecated_cmd_warning (char **text)
+deprecated_cmd_warning (const char *text)
 {
   struct cmd_list_element *alias = NULL;
   struct cmd_list_element *prefix_cmd = NULL;
   struct cmd_list_element *cmd = NULL;
 
-  if (!lookup_cmd_composition (*text, &alias, &prefix_cmd, &cmd))
+  if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
     /* Return if text doesn't evaluate to a command.  */
     return;
 
@@ -1641,7 +1639,7 @@ deprecated_cmd_warning (char **text)
    
 */
 int
-lookup_cmd_composition (char *text,
+lookup_cmd_composition (const char *text,
                       struct cmd_list_element **alias,
                       struct cmd_list_element **prefix_cmd, 
                       struct cmd_list_element **cmd)
@@ -1738,7 +1736,8 @@ lookup_cmd_composition (char *text,
    "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
 
 VEC (char_ptr) *
-complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word,
+complete_on_cmdlist (struct cmd_list_element *list,
+                    const char *text, const char *word,
                     int ignore_help_classes)
 {
   struct cmd_list_element *ptr;
@@ -1808,8 +1807,7 @@ complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word,
 
 VEC (char_ptr) *
 complete_on_enum (const char *const *enumlist,
-                 char *text,
-                 char *word)
+                 const char *text, const char *word)
 {
   VEC (char_ptr) *matchlist = NULL;
   int textlen = strlen (text);
index 47e3a3b0b28e6281883f900b95adc4db6a5fa42b..bf4dd1d56138adc61a4619eb7d369161ea748df1 100644 (file)
@@ -59,7 +59,7 @@ struct cmd_list_element
     struct cmd_list_element *next;
 
     /* Name of this command.  */
-    char *name;
+    const char *name;
 
     /* Command class; class values are chosen by application program.  */
     enum command_class class;
index a96886685b1bd78daefb44f5908724796824c496..3b24799755289d853957fecae659aab3ec202cf0 100644 (file)
@@ -1416,7 +1416,8 @@ validate_comname (char **comname)
   if (last_word != *comname)
     {
       struct cmd_list_element *c;
-      char saved_char, *tem = *comname;
+      char saved_char;
+      const char *tem = *comname;
 
       /* Separate the prefix and the command.  */
       saved_char = last_word[-1];
@@ -1461,6 +1462,7 @@ define_command (char *comname, int from_tty)
   struct command_line *cmds;
   struct cmd_list_element *c, *newc, *hookc = 0, **list;
   char *tem, *comfull;
+  const char *tem_c;
   char tmpbuf[MAX_TMPBUF];
   int  hook_type      = CMD_NO_HOOK;
   int  hook_name_size = 0;
@@ -1474,8 +1476,8 @@ define_command (char *comname, int from_tty)
   list = validate_comname (&comname);
 
   /* Look it up, and verify that we got an exact match.  */
-  tem = comname;
-  c = lookup_cmd (&tem, *list, "", -1, 1);
+  tem_c = comname;
+  c = lookup_cmd (&tem_c, *list, "", -1, 1);
   if (c && strcmp (comname, c->name) != 0)
     c = 0;
 
@@ -1509,8 +1511,8 @@ define_command (char *comname, int from_tty)
   if (hook_type != CMD_NO_HOOK)
     {
       /* Look up cmd it hooks, and verify that we got an exact match.  */
-      tem = comname + hook_name_size;
-      hookc = lookup_cmd (&tem, *list, "", -1, 0);
+      tem_c = comname + hook_name_size;
+      hookc = lookup_cmd (&tem_c, *list, "", -1, 0);
       if (hookc && strcmp (comname + hook_name_size, hookc->name) != 0)
        hookc = 0;
       if (!hookc)
@@ -1570,7 +1572,8 @@ document_command (char *comname, int from_tty)
 {
   struct command_line *doclines;
   struct cmd_list_element *c, **list;
-  char *tem, *comfull;
+  const char *tem;
+  char *comfull;
   char tmpbuf[128];
 
   comfull = comname;
@@ -1676,7 +1679,7 @@ script_from_file (FILE *stream, const char *file)
    (recursively).  PREFIX and NAME combined are the name of the
    current command.  */
 void
-show_user_1 (struct cmd_list_element *c, char *prefix, char *name,
+show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name,
             struct ui_file *stream)
 {
   struct command_line *cmdlines;
index d02cb3644602ced00c408c649a3ffeb0dba364ff..31db811b87d099d655b0e6914bf5b3f2c32f58b9 100644 (file)
@@ -25,8 +25,10 @@ struct cmd_list_element;
 
 extern void script_from_file (FILE *stream, const char *file);
 
-extern void show_user_1 (struct cmd_list_element *c, char *prefix,
-                        char *name, struct ui_file *stream);
+extern void show_user_1 (struct cmd_list_element *c,
+                        const char *prefix,
+                        const char *name,
+                        struct ui_file *stream);
 
 /* Exported to gdb/breakpoint.c */
 
index a25fe04090a78ddfd332c6476d5b29799d3c7447..81edc4329819827b43f55d83472aab3ee49e3061 100644 (file)
@@ -119,22 +119,22 @@ struct cmd_list_element;
 
 extern int valid_user_defined_cmd_name_p (const char *name);
 
-extern struct cmd_list_element *add_cmd (char *, enum command_class,
+extern struct cmd_list_element *add_cmd (const char *, enum command_class,
                                         void (*fun) (char *, int), char *,
                                         struct cmd_list_element **);
 
-extern struct cmd_list_element *add_alias_cmd (char *, char *,
+extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
                                               enum command_class, int,
                                               struct cmd_list_element **);
 
-extern struct cmd_list_element *add_prefix_cmd (char *, enum command_class,
+extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
                                                void (*fun) (char *, int),
                                                char *,
                                                struct cmd_list_element **,
                                                char *, int,
                                                struct cmd_list_element **);
 
-extern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
+extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
                                                       enum command_class,
                                                       void (*fun) (char *,
                                                                    int),
@@ -156,7 +156,7 @@ extern void set_cmd_sfunc (struct cmd_list_element *cmd,
                           cmd_sfunc_ftype *sfunc);
 
 typedef VEC (char_ptr) *completer_ftype (struct cmd_list_element *,
-                                        char *, char *);
+                                        const char *, const char *);
 
 extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
 
@@ -183,11 +183,11 @@ extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
 /* Flag for an ambiguous cmd_list result.  */
 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
 
-extern struct cmd_list_element *lookup_cmd (char **,
+extern struct cmd_list_element *lookup_cmd (const char **,
                                            struct cmd_list_element *, char *,
                                            int, int);
 
-extern struct cmd_list_element *lookup_cmd_1 (char **,
+extern struct cmd_list_element *lookup_cmd_1 (const char **,
                                              struct cmd_list_element *,
                                              struct cmd_list_element **,
                                              int);
@@ -195,31 +195,31 @@ extern struct cmd_list_element *lookup_cmd_1 (char **,
 extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
                                               char * );
 
-extern void deprecated_cmd_warning (char **);
+extern void deprecated_cmd_warning (const char *);
 
-extern int lookup_cmd_composition (char *text,
+extern int lookup_cmd_composition (const char *text,
                                   struct cmd_list_element **alias,
                                   struct cmd_list_element **prefix_cmd,
                                   struct cmd_list_element **cmd);
 
-extern struct cmd_list_element *add_com (char *, enum command_class,
+extern struct cmd_list_element *add_com (const char *, enum command_class,
                                         void (*fun) (char *, int),
                                         char *);
 
-extern struct cmd_list_element *add_com_alias (char *, char *,
+extern struct cmd_list_element *add_com_alias (const char *, const char *,
                                               enum command_class, int);
 
-extern struct cmd_list_element *add_info (char *,
+extern struct cmd_list_element *add_info (const char *,
                                          void (*fun) (char *, int),
                                          char *);
 
-extern struct cmd_list_element *add_info_alias (char *, char *, int);
+extern struct cmd_list_element *add_info_alias (const char *, char *, int);
 
 extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
-                                           char *, char *, int);
+                                           const char *, const char *, int);
 
 extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist,
-                                        char *, char *);
+                                        const char *, const char *);
 
 /* Functions that implement commands about CLI commands.  */
 
@@ -237,7 +237,7 @@ typedef void (show_value_ftype) (struct ui_file *file,
    instead print the value out directly.  */
 extern show_value_ftype deprecated_show_value_hack;
 
-extern void add_setshow_enum_cmd (char *name,
+extern void add_setshow_enum_cmd (const char *name,
                                  enum command_class class,
                                  const char *const *enumlist,
                                  const char **var,
@@ -249,7 +249,7 @@ extern void add_setshow_enum_cmd (char *name,
                                  struct cmd_list_element **set_list,
                                  struct cmd_list_element **show_list);
 
-extern void add_setshow_auto_boolean_cmd (char *name,
+extern void add_setshow_auto_boolean_cmd (const char *name,
                                          enum command_class class,
                                          enum auto_boolean *var,
                                          const char *set_doc,
@@ -260,7 +260,7 @@ extern void add_setshow_auto_boolean_cmd (char *name,
                                          struct cmd_list_element **set_list,
                                          struct cmd_list_element **show_list);
 
-extern void add_setshow_boolean_cmd (char *name,
+extern void add_setshow_boolean_cmd (const char *name,
                                     enum command_class class,
                                     int *var,
                                     const char *set_doc, const char *show_doc,
@@ -270,7 +270,7 @@ extern void add_setshow_boolean_cmd (char *name,
                                     struct cmd_list_element **set_list,
                                     struct cmd_list_element **show_list);
 
-extern void add_setshow_filename_cmd (char *name,
+extern void add_setshow_filename_cmd (const char *name,
                                      enum command_class class,
                                      char **var,
                                      const char *set_doc,
@@ -281,7 +281,7 @@ extern void add_setshow_filename_cmd (char *name,
                                      struct cmd_list_element **set_list,
                                      struct cmd_list_element **show_list);
 
-extern void add_setshow_string_cmd (char *name,
+extern void add_setshow_string_cmd (const char *name,
                                    enum command_class class,
                                    char **var,
                                    const char *set_doc,
@@ -293,7 +293,7 @@ extern void add_setshow_string_cmd (char *name,
                                    struct cmd_list_element **show_list);
 
 extern struct cmd_list_element *add_setshow_string_noescape_cmd
-                     (char *name,
+                     (const char *name,
                       enum command_class class,
                       char **var,
                       const char *set_doc,
@@ -304,7 +304,7 @@ extern struct cmd_list_element *add_setshow_string_noescape_cmd
                       struct cmd_list_element **set_list,
                       struct cmd_list_element **show_list);
 
-extern void add_setshow_optional_filename_cmd (char *name,
+extern void add_setshow_optional_filename_cmd (const char *name,
                                               enum command_class class,
                                               char **var,
                                               const char *set_doc,
@@ -315,7 +315,7 @@ extern void add_setshow_optional_filename_cmd (char *name,
                                               struct cmd_list_element **set_list,
                                               struct cmd_list_element **show_list);
 
-extern void add_setshow_integer_cmd (char *name,
+extern void add_setshow_integer_cmd (const char *name,
                                     enum command_class class,
                                     int *var,
                                     const char *set_doc,
@@ -326,7 +326,7 @@ extern void add_setshow_integer_cmd (char *name,
                                     struct cmd_list_element **set_list,
                                     struct cmd_list_element **show_list);
 
-extern void add_setshow_uinteger_cmd (char *name,
+extern void add_setshow_uinteger_cmd (const char *name,
                                      enum command_class class,
                                      unsigned int *var,
                                      const char *set_doc,
@@ -337,7 +337,7 @@ extern void add_setshow_uinteger_cmd (char *name,
                                      struct cmd_list_element **set_list,
                                      struct cmd_list_element **show_list);
 
-extern void add_setshow_zinteger_cmd (char *name,
+extern void add_setshow_zinteger_cmd (const char *name,
                                      enum command_class class,
                                      int *var,
                                      const char *set_doc,
@@ -348,7 +348,7 @@ extern void add_setshow_zinteger_cmd (char *name,
                                      struct cmd_list_element **set_list,
                                      struct cmd_list_element **show_list);
 
-extern void add_setshow_zuinteger_cmd (char *name,
+extern void add_setshow_zuinteger_cmd (const char *name,
                                       enum command_class class,
                                       unsigned int *var,
                                       const char *set_doc,
@@ -360,7 +360,7 @@ extern void add_setshow_zuinteger_cmd (char *name,
                                       struct cmd_list_element **show_list);
 
 extern void
-  add_setshow_zuinteger_unlimited_cmd (char *name,
+  add_setshow_zuinteger_unlimited_cmd (const char *name,
                                       enum command_class class,
                                       int *var,
                                       const char *set_doc,
index 3b14fc942342af4876a6729e43975849eb3fd3dc..e13265131a4a29e79275766e8add43f4d00e484f 100644 (file)
@@ -107,7 +107,7 @@ readline_line_completion_function (const char *text, int matches)
    symbols but don't want to complete on anything else either.  */
 VEC (char_ptr) *
 noop_completer (struct cmd_list_element *ignore, 
-               char *text, char *prefix)
+               const char *text, const char *prefix)
 {
   return NULL;
 }
@@ -115,7 +115,7 @@ noop_completer (struct cmd_list_element *ignore,
 /* Complete on filenames.  */
 VEC (char_ptr) *
 filename_completer (struct cmd_list_element *ignore, 
-                   char *text, char *word)
+                   const char *text, const char *word)
 {
   int subsequent_name;
   VEC (char_ptr) *return_val = NULL;
@@ -184,19 +184,19 @@ filename_completer (struct cmd_list_element *ignore,
 
 VEC (char_ptr) *
 location_completer (struct cmd_list_element *ignore, 
-                   char *text, char *word)
+                   const char *text, const char *word)
 {
   int n_syms, n_files, ix;
   VEC (char_ptr) *fn_list = NULL;
   VEC (char_ptr) *list = NULL;
-  char *p;
+  const char *p;
   int quote_found = 0;
   int quoted = *text == '\'' || *text == '"';
   int quote_char = '\0';
-  char *colon = NULL;
+  const char *colon = NULL;
   char *file_to_match = NULL;
-  char *symbol_start = text;
-  char *orig_text = text;
+  const char *symbol_start = text;
+  const char *orig_text = text;
   size_t text_len;
 
   /* Do we have an unquoted colon, as in "break foo.c:bar"?  */
@@ -285,8 +285,10 @@ location_completer (struct cmd_list_element *ignore,
     }
   else
     {
-      for (ix = 0; VEC_iterate (char_ptr, fn_list, ix, p); ++ix)
-       VEC_safe_push (char_ptr, list, p);
+      char *fn;
+
+      for (ix = 0; VEC_iterate (char_ptr, fn_list, ix, fn); ++ix)
+       VEC_safe_push (char_ptr, list, fn);
       VEC_free (char_ptr, fn_list);
     }
 
@@ -296,6 +298,8 @@ location_completer (struct cmd_list_element *ignore,
     }
   else if (n_files)
     {
+      char *fn;
+
       /* If we only have file names as possible completion, we should
         bring them in sync with what rl_complete expects.  The
         problem is that if the user types "break /foo/b TAB", and the
@@ -311,10 +315,10 @@ location_completer (struct cmd_list_element *ignore,
         completion, because rl_complete will prepend "/foo/" to each
         candidate completion.  The loop below removes that leading
         part.  */
-      for (ix = 0; VEC_iterate (char_ptr, list, ix, p); ++ix)
+      for (ix = 0; VEC_iterate (char_ptr, list, ix, fn); ++ix)
        {
-         memmove (p, p + (word - text),
-                  strlen (p) + 1 - (word - text));
+         memmove (fn, fn + (word - text),
+                  strlen (fn) + 1 - (word - text));
        }
     }
   else if (!n_syms)
@@ -385,10 +389,11 @@ add_struct_fields (struct type *type, VEC (char_ptr) **output,
    field names.  */
 VEC (char_ptr) *
 expression_completer (struct cmd_list_element *ignore, 
-                     char *text, char *word)
+                     const char *text, const char *word)
 {
   struct type *type = NULL;
-  char *fieldname, *p;
+  char *fieldname;
+  const char *p;
   volatile struct gdb_exception except;
   enum type_code code = TYPE_CODE_UNDEF;
 
@@ -506,11 +511,12 @@ complete_line_internal_reason;
 
 static VEC (char_ptr) *
 complete_line_internal (const char *text, 
-                       char *line_buffer, int point,
+                       const char *line_buffer, int point,
                        complete_line_internal_reason reason)
 {
   VEC (char_ptr) *list = NULL;
-  char *tmp_command, *p;
+  char *tmp_command;
+  const char *p;
   int ignore_help_classes;
   /* Pointer within tmp_command which corresponds to text.  */
   char *word;
@@ -567,7 +573,7 @@ complete_line_internal (const char *text,
     }
   else if (c == CMD_LIST_AMBIGUOUS)
     {
-      char *q;
+      const char *q;
 
       /* lookup_cmd_1 advances p up to the first ambiguous thing, but
         doesn't advance over that thing itself.  Do so now.  */
@@ -682,7 +688,7 @@ complete_line_internal (const char *text,
                 complete on the command itself, e.g. "p" which is a
                 command itself but also can complete to "print", "ptype"
                 etc.  */
-             char *q;
+             const char *q;
 
              /* Find the command we are completing on.  */
              q = p;
@@ -775,7 +781,7 @@ complete_line (const char *text, char *line_buffer, int point)
 /* Complete on command names.  Used by "help".  */
 VEC (char_ptr) *
 command_completer (struct cmd_list_element *ignore, 
-                  char *text, char *word)
+                  const char *text, const char *word)
 {
   return complete_line_internal (word, text, 
                                 strlen (text), handle_help);
@@ -785,7 +791,7 @@ command_completer (struct cmd_list_element *ignore,
 
 VEC (char_ptr) *
 signal_completer (struct cmd_list_element *ignore,
-                 char *text, char *word)
+                 const char *text, const char *word)
 {
   VEC (char_ptr) *return_val = NULL;
   size_t len = strlen (word);
index f7fea6039a2483e1577ea8986c95333cef5c07e7..d6090f4cc7e422ea3b968bc8376c23c4a35d7233 100644 (file)
@@ -27,22 +27,22 @@ extern char *readline_line_completion_function (const char *text,
                                                int matches);
 
 extern VEC (char_ptr) *noop_completer (struct cmd_list_element *,
-                                      char *, char *);
+                                      const char *, const char *);
 
 extern VEC (char_ptr) *filename_completer (struct cmd_list_element *,
-                                          char *, char *);
+                                          const char *, const char *);
 
 extern VEC (char_ptr) *expression_completer (struct cmd_list_element *,
-                                            char *, char *);
+                                            const char *, const char *);
 
 extern VEC (char_ptr) *location_completer (struct cmd_list_element *,
-                                          char *, char *);
+                                          const char *, const char *);
 
 extern VEC (char_ptr) *command_completer (struct cmd_list_element *,
-                                         char *, char *);
+                                         const char *, const char *);
 
 extern VEC (char_ptr) *signal_completer (struct cmd_list_element *,
-                                        char *, char *);
+                                        const char *, const char *);
 
 extern char *get_gdb_completer_quote_characters (void);
 
index 9c795b855808c873b99026315c4f4024cd15016e..a86f4b335e2daed721aa443c03491324b63fdbb9 100644 (file)
@@ -434,7 +434,8 @@ set_gnutarget_command (char *ignore, int from_tty,
 /* A completion function for "set gnutarget".  */
 
 static VEC (char_ptr) *
-complete_set_gnutarget (struct cmd_list_element *cmd, char *text, char *word)
+complete_set_gnutarget (struct cmd_list_element *cmd,
+                       const char *text, const char *word)
 {
   static const char **bfd_targets;
 
index 366ba30ecfcc9c268a7c6bd78fe5d85c73c61b5b..8e9d545328e534e53243fd58e6f53404d7870ca6 100644 (file)
@@ -318,7 +318,7 @@ set_cp_abi_cmd (char *args, int from_tty)
 
 static VEC (char_ptr) *
 cp_abi_completer (struct cmd_list_element *ignore,
-                 char *text, char *word)
+                 const char *text, const char *word)
 {
   static const char **cp_abi_names;
 
index eea47dc6b2adb891a0434708767b67e61f8ac1de..6b96b12a78386dae2d0836a0537d57aa83f8fa74 100644 (file)
@@ -97,7 +97,7 @@ struct expression
 
 extern struct expression *parse_expression (const char *);
 
-extern struct type *parse_expression_for_completion (char *, char **,
+extern struct type *parse_expression_for_completion (const char *, char **,
                                                     enum type_code *);
 
 extern struct expression *parse_exp_1 (const char **, CORE_ADDR pc,
index 652da79ad7be56212097413ab0e72fc923da946d..f40e98d38223f8468714adae072b08d9e602f7b1 100644 (file)
@@ -229,7 +229,8 @@ f_word_break_characters (void)
    class.  */
 
 static VEC (char_ptr) *
-f_make_symbol_completion_list (char *text, char *word, enum type_code code)
+f_make_symbol_completion_list (const char *text, const char *word,
+                              enum type_code code)
 {
   return default_make_symbol_completion_list_break_on (text, word, ":", code);
 }
index 866388f3db7902429788d6d808b4db86c142c20a..0b40f22e7b5d3df44fa2dacd3237e96f750bd6f1 100644 (file)
@@ -2938,7 +2938,7 @@ _initialize_infcmd (void)
 {
   static struct cmd_list_element *info_proc_cmdlist;
   struct cmd_list_element *c = NULL;
-  char *cmd_name;
+  const char *cmd_name;
 
   /* Add the filename of the terminal connected to inferior I/O.  */
   add_setshow_filename_cmd ("inferior-tty", class_run,
index 92874e22b88fba2775042a31f6f72c7141975c42..7031ecc3f083de65f37b26f5ea68820daf48ca54 100644 (file)
@@ -6471,7 +6471,7 @@ Are you sure you want to change it? "),
 
 static VEC (char_ptr) *
 handle_completer (struct cmd_list_element *ignore,
-                 char *text, char *word)
+                 const char *text, const char *word)
 {
   VEC (char_ptr) *vec_signals, *vec_keywords, *return_val;
   static const char * const keywords[] =
index 9ddbf6d0f1422298a640c79c574e4e397b8efdf0..bd23118227e9ab7f015c1693a3c4f8bd15794832 100644 (file)
@@ -456,7 +456,8 @@ interpreter_exec_cmd (char *args, int from_tty)
 
 /* List the possible interpreters which could complete the given text.  */
 static VEC (char_ptr) *
-interpreter_completer (struct cmd_list_element *ignore, char *text, char *word)
+interpreter_completer (struct cmd_list_element *ignore,
+                      const char *text, const char *word)
 {
   int textlen;
   VEC (char_ptr) *matches = NULL;
index b191b364f199fdb1cdc3e5540be0827f49157e2b..e36da31be69d7b1f370e8d2cbeb874da2eacf551 100644 (file)
@@ -286,7 +286,8 @@ struct language_defn
        completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
        symbols should be examined; otherwise, only STRUCT_DOMAIN
        symbols whose type has a code of CODE should be matched.  */
-    VEC (char_ptr) *(*la_make_symbol_completion_list) (char *text, char *word,
+    VEC (char_ptr) *(*la_make_symbol_completion_list) (const char *text,
+                                                      const char *word,
                                                       enum type_code code);
 
     /* The per-architecture (OS/ABI) language information.  */
index 4c84b2bc7afab00ee09fc03a2a879babca6f791a..095d63d15b2e6a9cfae42465e4fa31361e7a3464 100644 (file)
@@ -120,9 +120,12 @@ static void free_funcalls (void *ignore);
 static int prefixify_subexp (struct expression *, struct expression *, int,
                             int);
 
-static struct expression *parse_exp_in_context (char **, CORE_ADDR,
+static struct expression *parse_exp_in_context (const char **, CORE_ADDR,
                                                const struct block *, int, 
                                                int, int *);
+static struct expression *parse_exp_in_context_1 (char **, CORE_ADDR,
+                                                 const struct block *, int,
+                                                 int, int *);
 
 void _initialize_parse (void);
 
@@ -1127,13 +1130,22 @@ prefixify_subexp (struct expression *inexpr,
 struct expression *
 parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block,
             int comma)
+{
+  return parse_exp_in_context (stringptr, pc, block, comma, 0, NULL);
+}
+
+static struct expression *
+parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
+                     const struct block *block,
+                     int comma, int void_context_p, int *out_subexp)
 {
   struct expression *expr;
   char *const_hack = *stringptr ? xstrdup (*stringptr) : NULL;
   char *orig = const_hack;
   struct cleanup *back_to = make_cleanup (xfree, const_hack);
 
-  expr = parse_exp_in_context (&const_hack, pc, block, comma, 0, NULL);
+  expr = parse_exp_in_context_1 (&const_hack, pc, block, comma,
+                                void_context_p, out_subexp);
   (*stringptr) += const_hack - orig;
   do_cleanups (back_to);
   return expr;
@@ -1147,8 +1159,9 @@ parse_exp_1 (const char **stringptr, CORE_ADDR pc, const struct block *block,
    is left untouched.  */
 
 static struct expression *
-parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
-                     int comma, int void_context_p, int *out_subexp)
+parse_exp_in_context_1 (char **stringptr, CORE_ADDR pc,
+                       const struct block *block,
+                       int comma, int void_context_p, int *out_subexp)
 {
   volatile struct gdb_exception except;
   struct cleanup *old_chain, *inner_chain;
@@ -1291,7 +1304,7 @@ parse_expression (const char *string)
    *NAME must be freed by the caller.  */
 
 struct type *
-parse_expression_for_completion (char *string, char **name,
+parse_expression_for_completion (const char *string, char **name,
                                 enum type_code *code)
 {
   struct expression *exp = NULL;
index 695c180c265ee2c3fca13589784aee88e7af1f85..3e1d0265356bba584faeeaf275225fbd35d09577 100644 (file)
@@ -191,10 +191,10 @@ static void do_one_display (struct display *);
    past the specification and past all whitespace following it.  */
 
 static struct format_data
-decode_format (char **string_ptr, int oformat, int osize)
+decode_format (const char **string_ptr, int oformat, int osize)
 {
   struct format_data val;
-  char *p = *string_ptr;
+  const char *p = *string_ptr;
 
   val.format = '?';
   val.size = '?';
@@ -933,7 +933,7 @@ validate_format (struct format_data fmt, char *cmdname)
    first argument ("/x myvar" for example, to print myvar in hex).  */
 
 static void
-print_command_1 (char *exp, int voidprint)
+print_command_1 (const char *exp, int voidprint)
 {
   struct expression *expr;
   struct cleanup *old_chain = 0;
@@ -1013,8 +1013,18 @@ call_command (char *exp, int from_tty)
   print_command_1 (exp, 0);
 }
 
-void
+/* Implementation of the "output" command.  */
+
+static void
 output_command (char *exp, int from_tty)
+{
+  output_command_const (exp, from_tty);
+}
+
+/* Like output_command, but takes a const string as argument.  */
+
+void
+output_command_const (const char *exp, int from_tty)
 {
   struct expression *expr;
   struct cleanup *old_chain;
@@ -1402,8 +1412,10 @@ x_command (char *exp, int from_tty)
 
   if (exp && *exp == '/')
     {
-      exp++;
-      fmt = decode_format (&exp, last_format, last_size);
+      const char *tmp = exp + 1;
+
+      fmt = decode_format (&tmp, last_format, last_size);
+      exp = (char *) tmp;
     }
 
   /* If we have an expression, evaluate it and use it as the address.  */
@@ -1473,12 +1485,13 @@ x_command (char *exp, int from_tty)
    Specify the expression.  */
 
 static void
-display_command (char *exp, int from_tty)
+display_command (char *arg, int from_tty)
 {
   struct format_data fmt;
   struct expression *expr;
   struct display *new;
   int display_it = 1;
+  const char *exp = arg;
 
 #if defined(TUI)
   /* NOTE: cagney/2003-02-13 The `tui_active' was previously
index a8cb79cfbd3afb1907d41eb04140d95f8f2b0019..53a8eb5eb3d525335365749bc59192f100286693 100644 (file)
@@ -242,7 +242,7 @@ void
 gdbpy_initialize_auto_load (void)
 {
   struct cmd_list_element *cmd;
-  char *cmd_name;
+  const char *cmd_name;
 
   add_setshow_boolean_cmd ("python-scripts", class_support,
                           &auto_load_python_scripts, _("\
index 76670eafe3bd2f5eabcdbcc582ca33901a24a460..161b4bcdc98bdf3daf1872acfe3159eacbaefe9d 100644 (file)
@@ -103,7 +103,7 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
 
   /* We allocated the name, doc string, and perhaps the prefix
      name.  */
-  xfree (self->name);
+  xfree ((char *) self->name);
   xfree (self->doc);
   xfree (self->prefixname);
 
@@ -207,7 +207,8 @@ cmdpy_function (struct cmd_list_element *command, char *args, int from_tty)
 /* Called by gdb for command completion.  */
 
 static VEC (char_ptr) *
-cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
+cmdpy_completer (struct cmd_list_element *command,
+                const char *text, const char *word)
 {
   cmdpy_object *obj = (cmdpy_object *) get_cmd_context (command);
   PyObject *textobj, *wordobj, *resultobj = NULL;
@@ -319,7 +320,8 @@ gdbpy_parse_command_name (const char *name,
   struct cmd_list_element *elt;
   int len = strlen (name);
   int i, lastchar;
-  char *prefix_text, *prefix_text2;
+  char *prefix_text;
+  const char *prefix_text2;
   char *result;
 
   /* Skip trailing whitespace.  */
index 1970714d097fd53659a0e0602be3360e641d9ca8..acb48cd3375cf14b06e30c05ab3a50249abfc765 100644 (file)
@@ -470,7 +470,7 @@ add_setshow_generic (int parmclass, enum command_class cmdclass,
                     struct cmd_list_element **show_list)
 {
   struct cmd_list_element *param = NULL;
-  char *tmp_name = NULL;
+  const char *tmp_name = NULL;
 
   switch (parmclass)
     {
index c4824e9fe7700f8ffec2118267bb1ee678f48aef..21d86f7b41e159406229ee439632dd321674390b 100644 (file)
@@ -11612,7 +11612,7 @@ _initialize_remote (void)
 {
   struct remote_state *rs;
   struct cmd_list_element *cmd;
-  char *cmd_name;
+  const char *cmd_name;
 
   /* architecture specific data */
   remote_gdbarch_data_handle =
index c0e588455e165345118eb28b149d683806d48e5a..346c162a6622196c31c72a1801c2099777f9f40b 100644 (file)
@@ -4108,8 +4108,8 @@ completion_list_objc_symbol (struct minimal_symbol *msymbol,
 /* Break the non-quoted text based on the characters which are in
    symbols.  FIXME: This should probably be language-specific.  */
 
-static char *
-language_search_unquoted_string (char *text, char *p)
+static const char *
+language_search_unquoted_string (const char *text, const char *p)
 {
   for (; p > text; --p)
     {
@@ -4125,7 +4125,7 @@ language_search_unquoted_string (char *text, char *p)
                p -= 2;             /* Beginning of a method name.  */
              else if (p[-1] == ' ' || p[-1] == '(' || p[-1] == ')')
                {                   /* Might be part of a method name.  */
-                 char *t = p;
+                 const char *t = p;
 
                  /* Seeing a ' ' or a '(' is not conclusive evidence
                     that we are in the middle of a method name.  However,
@@ -4152,8 +4152,9 @@ language_search_unquoted_string (char *text, char *p)
 }
 
 static void
-completion_list_add_fields (struct symbol *sym, char *sym_text,
-                           int sym_text_len, char *text, char *word)
+completion_list_add_fields (struct symbol *sym, const char *sym_text,
+                           int sym_text_len, const char *text,
+                           const char *word)
 {
   if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
     {
@@ -4174,10 +4175,10 @@ completion_list_add_fields (struct symbol *sym, char *sym_text,
    needed by completion_list_add_name.  */
 struct add_name_data
 {
-  char *sym_text;
+  const char *sym_text;
   int sym_text_len;
-  char *text;
-  char *word;
+  const char *text;
+  const char *word;
 };
 
 /* A callback used with macro_for_each and macro_for_each_in_scope.
@@ -4206,7 +4207,8 @@ expand_partial_symbol_name (const char *name, void *user_data)
 }
 
 VEC (char_ptr) *
-default_make_symbol_completion_list_break_on (char *text, char *word,
+default_make_symbol_completion_list_break_on (const char *text,
+                                             const char *word,
                                              const char *break_on,
                                              enum type_code code)
 {
@@ -4222,7 +4224,7 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
   const struct block *surrounding_static_block, *surrounding_global_block;
   struct block_iterator iter;
   /* The symbol we are completing on.  Points in same buffer as text.  */
-  char *sym_text;
+  const char *sym_text;
   /* Length of sym_text.  */
   int sym_text_len;
   struct add_name_data datum;
@@ -4230,9 +4232,9 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
 
   /* Now look for the symbol we are supposed to complete on.  */
   {
-    char *p;
+    const char *p;
     char quote_found;
-    char *quote_pos = NULL;
+    const char *quote_pos = NULL;
 
     /* First see if this is a quoted string.  */
     quote_found = '\0';
@@ -4437,7 +4439,7 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
 }
 
 VEC (char_ptr) *
-default_make_symbol_completion_list (char *text, char *word,
+default_make_symbol_completion_list (const char *text, const char *word,
                                     enum type_code code)
 {
   return default_make_symbol_completion_list_break_on (text, word, "", code);
@@ -4448,7 +4450,7 @@ default_make_symbol_completion_list (char *text, char *word,
    is NULL.  */
 
 VEC (char_ptr) *
-make_symbol_completion_list (char *text, char *word)
+make_symbol_completion_list (const char *text, const char *word)
 {
   return current_language->la_make_symbol_completion_list (text, word,
                                                           TYPE_CODE_UNDEF);
@@ -4458,7 +4460,8 @@ make_symbol_completion_list (char *text, char *word)
    symbols whose type code is CODE.  */
 
 VEC (char_ptr) *
-make_symbol_completion_type (char *text, char *word, enum type_code code)
+make_symbol_completion_type (const char *text, const char *word,
+                            enum type_code code)
 {
   gdb_assert (code == TYPE_CODE_UNION
              || code == TYPE_CODE_STRUCT
@@ -4472,7 +4475,7 @@ make_symbol_completion_type (char *text, char *word, enum type_code code)
 
 VEC (char_ptr) *
 make_symbol_completion_list_fn (struct cmd_list_element *ignore,
-                               char *text, char *word)
+                               const char *text, const char *word)
 {
   return make_symbol_completion_list (text, word);
 }
@@ -4481,23 +4484,24 @@ make_symbol_completion_list_fn (struct cmd_list_element *ignore,
    defined in a source file FILE.  */
 
 VEC (char_ptr) *
-make_file_symbol_completion_list (char *text, char *word, char *srcfile)
+make_file_symbol_completion_list (const char *text, const char *word,
+                                 const char *srcfile)
 {
   struct symbol *sym;
   struct symtab *s;
   struct block *b;
   struct block_iterator iter;
   /* The symbol we are completing on.  Points in same buffer as text.  */
-  char *sym_text;
+  const char *sym_text;
   /* Length of sym_text.  */
   int sym_text_len;
 
   /* Now look for the symbol we are supposed to complete on.
      FIXME: This should be language-specific.  */
   {
-    char *p;
+    const char *p;
     char quote_found;
-    char *quote_pos = NULL;
+    const char *quote_pos = NULL;
 
     /* First see if this is a quoted string.  */
     quote_found = '\0';
@@ -4579,7 +4583,7 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
    list as necessary.  */
 
 static void
-add_filename_to_list (const char *fname, char *text, char *word,
+add_filename_to_list (const char *fname, const char *text, const char *word,
                      VEC (char_ptr) **list)
 {
   char *new;
@@ -4630,8 +4634,8 @@ not_interesting_fname (const char *fname)
 struct add_partial_filename_data
 {
   struct filename_seen_cache *filename_seen_cache;
-  char *text;
-  char *word;
+  const char *text;
+  const char *word;
   int text_len;
   VEC (char_ptr) **list;
 };
@@ -4670,7 +4674,7 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
    NULL.  */
 
 VEC (char_ptr) *
-make_source_files_completion_list (char *text, char *word)
+make_source_files_completion_list (const char *text, const char *word)
 {
   struct symtab *s;
   struct objfile *objfile;
index 378e9332cd1aa9345a22498e9a5a57ab6a04d3d1..7f0a4e65b6fa0508dcddce26a108f62aaf0af55a 100644 (file)
@@ -1176,20 +1176,24 @@ extern void forget_cached_source_info (void);
 extern void select_source_symtab (struct symtab *);
 
 extern VEC (char_ptr) *default_make_symbol_completion_list_break_on
-  (char *text, char *word, const char *break_on,
+  (const char *text, const char *word, const char *break_on,
    enum type_code code);
-extern VEC (char_ptr) *default_make_symbol_completion_list (char *, char *,
+extern VEC (char_ptr) *default_make_symbol_completion_list (const char *,
+                                                           const char *,
                                                            enum type_code);
-extern VEC (char_ptr) *make_symbol_completion_list (char *, char *);
-extern VEC (char_ptr) *make_symbol_completion_type (char *, char *,
+extern VEC (char_ptr) *make_symbol_completion_list (const char *, const char *);
+extern VEC (char_ptr) *make_symbol_completion_type (const char *, const char *,
                                                    enum type_code);
 extern VEC (char_ptr) *make_symbol_completion_list_fn (struct cmd_list_element *,
-                                                      char *, char *);
+                                                      const char *,
+                                                      const char *);
 
-extern VEC (char_ptr) *make_file_symbol_completion_list (char *,
-                                                        char *, char *);
+extern VEC (char_ptr) *make_file_symbol_completion_list (const char *,
+                                                        const char *,
+                                                        const char *);
 
-extern VEC (char_ptr) *make_source_files_completion_list (char *, char *);
+extern VEC (char_ptr) *make_source_files_completion_list (const char *,
+                                                         const char *);
 
 /* symtab.c */
 
index e9a40fc0ccf53a060414fd2fb3f366165b0da689..3c6371ceb7af09216b61d995b8ae628634f551b5 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -432,13 +432,15 @@ execute_command (char *p, int from_tty)
     p++;
   if (*p)
     {
+      const char *cmd = p;
       char *arg;
       line = p;
 
       /* If trace-commands is set then this will print this command.  */
       print_command_trace (p);
 
-      c = lookup_cmd (&p, cmdlist, "", 0, 1);
+      c = lookup_cmd (&cmd, cmdlist, "", 0, 1);
+      p = (char *) cmd;
 
       /* Pass null arg rather than an empty one.  */
       arg = *p ? p : 0;
@@ -467,7 +469,7 @@ execute_command (char *p, int from_tty)
       execute_cmd_pre_hook (c);
 
       if (c->flags & DEPRECATED_WARN_USER)
-       deprecated_cmd_warning (&line);
+       deprecated_cmd_warning (line);
 
       /* c->user_commands would be NULL in the case of a python command.  */
       if (c->class == class_user && c->user_commands)
@@ -1475,7 +1477,7 @@ int info_verbose = 0;             /* Default verbose msgs off.  */
 void
 set_verbose (char *args, int from_tty, struct cmd_list_element *c)
 {
-  char *cmdname = "verbose";
+  const char *cmdname = "verbose";
   struct cmd_list_element *showcmd;
 
   showcmd = lookup_cmd_1 (&cmdname, showlist, NULL, 1);
index 513dccce57bdc8ce510545cc80fdad56409b9f9d..4db93cac0077eeaf5e760eb5b4ef63529e7ff3b0 100644 (file)
@@ -610,8 +610,8 @@ teval_pseudocommand (char *args, int from_tty)
 
 /* Parse any collection options, such as /s for strings.  */
 
-char *
-decode_agent_options (char *exp)
+const char *
+decode_agent_options (const char *exp)
 {
   struct value_print_options opts;
 
@@ -643,7 +643,7 @@ decode_agent_options (char *exp)
   else
     error (_("Undefined collection format \"%c\"."), *exp);
 
-  exp = skip_spaces (exp);
+  exp = skip_spaces_const (exp);
 
   return exp;
 }
@@ -700,21 +700,22 @@ report_agent_reqs_errors (struct agent_expr *aexpr)
 
 /* worker function */
 void
-validate_actionline (char **line, struct breakpoint *b)
+validate_actionline (const char *line, struct breakpoint *b)
 {
   struct cmd_list_element *c;
   struct expression *exp = NULL;
   struct cleanup *old_chain = NULL;
-  char *p, *tmp_p;
+  const char *tmp_p;
+  const char *p;
   struct bp_location *loc;
   struct agent_expr *aexpr;
   struct tracepoint *t = (struct tracepoint *) b;
 
   /* If EOF is typed, *line is NULL.  */
-  if (*line == NULL)
+  if (line == NULL)
     return;
 
-  p = skip_spaces (*line);
+  p = skip_spaces_const (line);
 
   /* Symbol lookup etc.  */
   if (*p == '\0')      /* empty line: just prompt for another line.  */
@@ -736,7 +737,7 @@ validate_actionline (char **line, struct breakpoint *b)
       do
        {                       /* Repeat over a comma-separated list.  */
          QUIT;                 /* Allow user to bail out with ^C.  */
-         p = skip_spaces (p);
+         p = skip_spaces_const (p);
 
          if (*p == '$')        /* Look for special pseudo-symbols.  */
            {
@@ -754,12 +755,9 @@ validate_actionline (char **line, struct breakpoint *b)
          tmp_p = p;
          for (loc = t->base.loc; loc; loc = loc->next)
            {
-             const char *q;
-
-             q = tmp_p;
-             exp = parse_exp_1 (&q, loc->address,
+             p = tmp_p;
+             exp = parse_exp_1 (&p, loc->address,
                                 block_for_pc (loc->address), 1);
-             p = (char *) q;
              old_chain = make_cleanup (free_current_contents, &exp);
 
              if (exp->elts[0].opcode == OP_VAR_VALUE)
@@ -804,18 +802,16 @@ validate_actionline (char **line, struct breakpoint *b)
       do
        {                       /* Repeat over a comma-separated list.  */
          QUIT;                 /* Allow user to bail out with ^C.  */
-         p = skip_spaces (p);
+         p = skip_spaces_const (p);
 
          tmp_p = p;
          for (loc = t->base.loc; loc; loc = loc->next)
            {
-             const char *q;
+             p = tmp_p;
 
-             q = tmp_p;
              /* Only expressions are allowed for this action.  */
-             exp = parse_exp_1 (&q, loc->address,
+             exp = parse_exp_1 (&p, loc->address,
                                 block_for_pc (loc->address), 1);
-             p = (char *) q;
              old_chain = make_cleanup (free_current_contents, &exp);
 
              /* We have something to evaluate, make sure that the expr to
@@ -838,20 +834,20 @@ validate_actionline (char **line, struct breakpoint *b)
 
   else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
     {
-      char *steparg;           /* In case warning is necessary.  */
-
-      p = skip_spaces (p);
-      steparg = p;
+      char *endp;
 
-      if (*p == '\0' || (t->step_count = strtol (p, &p, 0)) == 0)
-       error (_("while-stepping step count `%s' is malformed."), *line);
+      p = skip_spaces_const (p);
+      t->step_count = strtol (p, &endp, 0);
+      if (endp == p || t->step_count == 0)
+       error (_("while-stepping step count `%s' is malformed."), line);
+      p = endp;
     }
 
   else if (cmd_cfunc_eq (c, end_actions_pseudocommand))
     ;
 
   else
-    error (_("`%s' is not a supported tracepoint action."), *line);
+    error (_("`%s' is not a supported tracepoint action."), line);
 }
 
 enum {
@@ -1375,7 +1371,7 @@ encode_actions_1 (struct command_line *action,
                  struct collection_list *collect,
                  struct collection_list *stepping_list)
 {
-  char *action_exp;
+  const char *action_exp;
   struct expression *exp = NULL;
   int i;
   struct value *tempval;
@@ -1386,7 +1382,7 @@ encode_actions_1 (struct command_line *action,
     {
       QUIT;                    /* Allow user to bail out with ^C.  */
       action_exp = action->line;
-      action_exp = skip_spaces (action_exp);
+      action_exp = skip_spaces_const (action_exp);
 
       cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
       if (cmd == 0)
@@ -1401,7 +1397,7 @@ encode_actions_1 (struct command_line *action,
          do
            {                   /* Repeat over a comma-separated list.  */
              QUIT;             /* Allow user to bail out with ^C.  */
-             action_exp = skip_spaces (action_exp);
+             action_exp = skip_spaces_const (action_exp);
 
              if (0 == strncasecmp ("$reg", action_exp, 4))
                {
@@ -1476,12 +1472,9 @@ encode_actions_1 (struct command_line *action,
                  unsigned long addr;
                  struct cleanup *old_chain = NULL;
                  struct cleanup *old_chain1 = NULL;
-                 const char *q;
 
-                 q = action_exp;
-                 exp = parse_exp_1 (&q, tloc->address,
+                 exp = parse_exp_1 (&action_exp, tloc->address,
                                     block_for_pc (tloc->address), 1);
-                 action_exp = (char *) q;
                  old_chain = make_cleanup (free_current_contents, &exp);
 
                  switch (exp->elts[0].opcode)
@@ -1565,17 +1558,14 @@ encode_actions_1 (struct command_line *action,
          do
            {                   /* Repeat over a comma-separated list.  */
              QUIT;             /* Allow user to bail out with ^C.  */
-             action_exp = skip_spaces (action_exp);
+             action_exp = skip_spaces_const (action_exp);
 
                {
                  struct cleanup *old_chain = NULL;
                  struct cleanup *old_chain1 = NULL;
-                 const char *q;
 
-                 q = action_exp;
-                 exp = parse_exp_1 (&q, tloc->address,
+                 exp = parse_exp_1 (&action_exp, tloc->address,
                                     block_for_pc (tloc->address), 1);
-                 action_exp = (char *) q;
                  old_chain = make_cleanup (free_current_contents, &exp);
 
                  aexpr = gen_eval_for_expr (tloc->address, exp);
@@ -1643,18 +1633,15 @@ encode_actions (struct breakpoint *t, struct bp_location *tloc,
      the fly, and don't cache it.  */
   if (*default_collect)
     {
-      char *line;
-
       default_collect_line =  xstrprintf ("collect %s", default_collect);
       make_cleanup (xfree, default_collect_line);
 
-      line = default_collect_line;
-      validate_actionline (&line, t);
+      validate_actionline (default_collect_line, t);
 
       default_collect_action = xmalloc (sizeof (struct command_line));
       make_cleanup (xfree, default_collect_action);
       default_collect_action->next = actions;
-      default_collect_action->line = line;
+      default_collect_action->line = default_collect_line;
       actions = default_collect_action;
     }
   encode_actions_1 (actions, t, tloc, frame_reg, frame_offset,
@@ -2800,15 +2787,6 @@ scope_info (char *args, int from_tty)
                     save_args);
 }
 
-/* worker function (cleanup) */
-static void
-replace_comma (void *data)
-{
-  char *comma = data;
-  *comma = ',';
-}
-
-
 /* Helper for trace_dump_command.  Dump the action list starting at
    ACTION.  STEPPING_ACTIONS is true if we're iterating over the
    actions of the body of a while-stepping action.  STEPPING_FRAME is
@@ -2820,7 +2798,7 @@ trace_dump_actions (struct command_line *action,
                    int stepping_actions, int stepping_frame,
                    int from_tty)
 {
-  char *action_exp, *next_comma;
+  const char *action_exp, *next_comma;
 
   for (; action != NULL; action = action->next)
     {
@@ -2828,7 +2806,7 @@ trace_dump_actions (struct command_line *action,
 
       QUIT;                    /* Allow user to bail out with ^C.  */
       action_exp = action->line;
-      action_exp = skip_spaces (action_exp);
+      action_exp = skip_spaces_const (action_exp);
 
       /* The collection actions to be done while stepping are
          bracketed by the commands "while-stepping" and "end".  */
@@ -2858,6 +2836,10 @@ trace_dump_actions (struct command_line *action,
             STEPPING_ACTIONS should be equal.  */
          if (stepping_frame == stepping_actions)
            {
+             char *cmd = NULL;
+             struct cleanup *old_chain
+               = make_cleanup (free_current_contents, &cmd);
+
              if (*action_exp == '/')
                action_exp = decode_agent_options (action_exp);
 
@@ -2866,7 +2848,7 @@ trace_dump_actions (struct command_line *action,
                  QUIT;         /* Allow user to bail out with ^C.  */
                  if (*action_exp == ',')
                    action_exp++;
-                 action_exp = skip_spaces (action_exp);
+                 action_exp = skip_spaces_const (action_exp);
 
                  next_comma = strchr (action_exp, ',');
 
@@ -2880,20 +2862,31 @@ trace_dump_actions (struct command_line *action,
                    args_info (NULL, from_tty);
                  else
                    {           /* variable */
-                     if (next_comma)
+                     if (next_comma != NULL)
                        {
-                         make_cleanup (replace_comma, next_comma);
-                         *next_comma = '\0';
+                         size_t len = next_comma - action_exp;
+
+                         cmd = xrealloc (cmd, len + 1);
+                         memcpy (cmd, action_exp, len);
+                         cmd[len] = 0;
+                       }
+                     else
+                       {
+                         size_t len = strlen (action_exp);
+
+                         cmd = xrealloc (cmd, len + 1);
+                         memcpy (cmd, action_exp, len + 1);
                        }
-                     printf_filtered ("%s = ", action_exp);
-                     output_command (action_exp, from_tty);
+
+                     printf_filtered ("%s = ", cmd);
+                     output_command_const (cmd, from_tty);
                      printf_filtered ("\n");
                    }
-                 if (next_comma)
-                   *next_comma = ',';
                  action_exp = next_comma;
                }
              while (action_exp && *action_exp == ',');
+
+             do_cleanups (old_chain);
            }
        }
     }
@@ -2908,7 +2901,7 @@ trace_dump_command (char *args, int from_tty)
   struct tracepoint *t;
   int stepping_frame = 0;
   struct bp_location *loc;
-  char *line, *default_collect_line = NULL;
+  char *default_collect_line = NULL;
   struct command_line *actions, *default_collect_action = NULL;
   struct cleanup *old_chain = NULL;
 
@@ -2952,12 +2945,11 @@ trace_dump_command (char *args, int from_tty)
     {
       default_collect_line = xstrprintf ("collect %s", default_collect);
       old_chain = make_cleanup (xfree, default_collect_line);
-      line = default_collect_line;
-      validate_actionline (&line, &t->base);
+      validate_actionline (default_collect_line, &t->base);
       default_collect_action = xmalloc (sizeof (struct command_line));
       make_cleanup (xfree, default_collect_action);
       default_collect_action->next = actions;
-      default_collect_action->line = line;
+      default_collect_action->line = default_collect_line;
       actions = default_collect_action;
     }
 
index b2b9d7c9ce7b2e5208bae4bdf5872f0433c67545..b03c95b2cca1f96a775ac8802967977e0c780b11 100644 (file)
@@ -237,12 +237,12 @@ struct cleanup *make_cleanup_restore_traceframe_number (void);
 
 void free_actions (struct breakpoint *);
 
-extern char *decode_agent_options (char *exp);
+extern const char *decode_agent_options (const char *exp);
 
 extern void encode_actions (struct breakpoint *t, struct bp_location *tloc,
                            char ***tdp_actions, char ***stepping_actions);
 
-extern void validate_actionline (char **, struct breakpoint *);
+extern void validate_actionline (const char *, struct breakpoint *);
 extern void validate_trace_state_variable_name (const char *name);
 
 extern struct trace_state_variable *find_trace_state_variable (const char *name);
index 1aa5a1973b01ae931c28246ab44d316d084bc43a..7baef2f9a17f6481292bbc1ff09ac43cce7ac27f 100644 (file)
@@ -203,6 +203,10 @@ extern void generic_printstr (struct ui_file *stream, struct type *type,
                              int quote_char, int c_style_terminator,
                              const struct value_print_options *options);
 
-extern void output_command (char *exp, int from_tty);
+/* Run the "output" command.  ARGS and FROM_TTY are the usual
+   arguments passed to all command implementations, except ARGS is
+   const.  */
+
+extern void output_command_const (const char *args, int from_tty);
 
 #endif
index 4b70eceed9abd78e1eedc506a5f94ff10fd1e73d..90bc41535d897b3f0817c2a83980efc0b2d02e40 100644 (file)
@@ -2130,7 +2130,7 @@ function_command (char *command, int from_tty)
 static void
 function_destroyer (struct cmd_list_element *self, void *ignore)
 {
-  xfree (self->name);
+  xfree ((char *) self->name);
   xfree (self->doc);
 }
 
This page took 0.067898 seconds and 4 git commands to generate.