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
rather than casting 'const char * const *' to 'const char **'.
* ada-lex.l (processInt): Make "trailer" local const. Remove
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;
};
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;
}
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;
/* 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;
}
/* We're completing the expression part. */
- text = skip_spaces (space);
+ text = skip_spaces_const (space);
return expression_completer (cmd, text, word);
}
{
struct breakpoint *b = closure;
- validate_actionline (&line, b);
+ validate_actionline (line, b);
}
/* A structure used to pass information through
/* 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
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. */
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;
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)
/* 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,
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
}
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)
{
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,
/* 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)
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,
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,
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,
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,
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,
/* 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,
/* 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,
/* 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,
/* 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,
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,
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,
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,
}
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,
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,
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,
/* 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);
}
/* 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);
}
/* 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);
/* 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);
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)
{
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;
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)++;
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. */
/* 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,
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;
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:
*/
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;
*/
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)
"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;
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);
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;
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];
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;
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;
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)
{
struct command_line *doclines;
struct cmd_list_element *c, **list;
- char *tem, *comfull;
+ const char *tem;
+ char *comfull;
char tmpbuf[128];
comfull = comname;
(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;
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 */
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),
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 *);
/* 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);
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. */
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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;
}
/* 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;
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"? */
}
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);
}
}
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
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)
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;
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;
}
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. */
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;
/* 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);
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);
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);
/* 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;
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;
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,
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);
}
{
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,
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[] =
/* 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;
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. */
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);
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;
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;
*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;
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 = '?';
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;
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;
char format = 0;
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. */
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
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, _("\
/* We allocated the name, doc string, and perhaps the prefix
name. */
- xfree (self->name);
+ xfree ((char *) self->name);
xfree (self->doc);
xfree (self->prefixname);
/* 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;
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. */
struct cmd_list_element **show_list)
{
struct cmd_list_element *param = NULL;
- char *tmp_name = NULL;
+ const char *tmp_name = NULL;
switch (parmclass)
{
{
struct remote_state *rs;
struct cmd_list_element *cmd;
- char *cmd_name;
+ const char *cmd_name;
/* architecture specific data */
remote_gdbarch_data_handle =
/* 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)
{
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,
}
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)
{
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.
}
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)
{
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;
/* 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';
}
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);
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);
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
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);
}
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';
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;
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;
};
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;
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 */
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;
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)
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);
/* 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;
else
error (_("Undefined collection format \"%c\"."), *exp);
- exp = skip_spaces (exp);
+ exp = skip_spaces_const (exp);
return exp;
}
/* 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. */
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. */
{
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)
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
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 {
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;
{
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)
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))
{
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)
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);
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,
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
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)
{
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". */
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);
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, ',');
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);
}
}
}
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;
{
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;
}
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);
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
static void
function_destroyer (struct cmd_list_element *self, void *ignore)
{
- xfree (self->name);
+ xfree ((char *) self->name);
xfree (self->doc);
}