39 (
"\"macro\" must be followed by the name of a macro command.\n");
52 puts_filtered (
"GDB has no preprocessor macro information for that code.\n");
59 char *expanded = NULL;
70 error (
_(
"You must follow the `macro expand' command with the"
94 char *expanded = NULL;
104 error (
_(
"You must follow the `macro expand-once' command with"
106 "you want to expand."));
174 for (i = 0; i < d->
argc; i++)
199 if (! user_data || strcmp (user_data, name) == 0)
210 int show_all_macros_named = 0;
211 char *arg_start = args;
212 int processing_args = 1;
214 while (processing_args
215 && arg_start && *arg_start ==
'-' && *arg_start !=
'\0')
219 if (strncmp (arg_start,
"-a", p - arg_start) == 0
220 || strncmp (arg_start,
"-all", p - arg_start) == 0)
221 show_all_macros_named = 1;
222 else if (strncmp (arg_start,
"--", p - arg_start) == 0)
231 error (
_(
"Unrecognized option '%s' to info macro command. "
232 "Try \"help info macro\"."), arg_start);
240 if (! name || ! *name)
241 error (
_(
"You must follow the `info macro' command with the name"
243 "whose definition you want to see."));
250 else if (show_all_macros_named)
268 "The symbol `%s' has no definition as a C/C++"
269 " preprocessor macro\n"
346 result = (
char *)
xmalloc (len + 1);
347 memcpy (result, *expp, len);
361 for (i = 0; i < loc->
argc; ++i)
375 error (
_(
"usage: macro define NAME[(ARGUMENT-LIST)] [REPLACEMENT-LIST]"));
385 error (
_(
"Invalid macro name."));
390 char **argv = (
char **)
xmalloc (alloced *
sizeof (
char *));
394 new_macro.
argv = (
const char *
const *) argv;
404 if (new_macro.
argc == alloced)
407 argv = (
char **)
xrealloc (argv, alloced *
sizeof (
char *));
409 new_macro.
argv = (
const char *
const *) argv;
412 if (! argv[new_macro.
argc])
413 error (
_(
"Macro is missing an argument."));
416 for (i = new_macro.
argc - 2; i >= 0; --i)
418 if (! strcmp (argv[i], argv[new_macro.
argc - 1]))
419 error (
_(
"Two macro arguments with identical names."));
428 else if (*exp !=
')')
429 error (
_(
"',' or ')' expected at end of macro arguments."));
436 new_macro.
argc, (
const char **) new_macro.
argv,
455 error (
_(
"usage: macro undef NAME"));
460 error (
_(
"Invalid macro name."));
477 for (i = 0; i < macro->
argc; ++i)
503 _(
"Prefix for commands dealing with C preprocessor macros."),
504 ¯olist,
"macro ", 0, &
cmdlist);
507 Fully expand any C/C++ preprocessor macro invocations in EXPRESSION.\n\
508 Show the expanded expression."),
512 Expand C/C++ preprocessor macro invocations appearing directly in EXPRESSION.\n\
513 Show the expanded expression.\n\
515 This command differs from `macro expand' in that it only expands macro\n\
516 invocations that appear directly in EXPRESSION; if expanding a macro\n\
517 introduces further macro invocations, those are left unexpanded.\n\
519 `macro expand-once' helps you see how a particular macro expands,\n\
520 whereas `macro expand' shows you how all the macros involved in an\n\
521 expression work together to yield a pre-processed expression."),
526 _(
"Show the definition of MACRO, and it's source location.\n\
527 Usage: info macro [-a|-all] [--] MACRO\n\
529 -a, --all Output all definitions of MACRO in the current compilation\
531 -- Specify the end of arguments and the beginning of the MACRO."),
536 _(
"Show the definitions of all macros at LINESPEC, or the current \
538 Usage: info macros [LINESPEC]"),
542 Define a new C/C++ preprocessor macro.\n\
543 The GDB command `macro define DEFINITION' is equivalent to placing a\n\
544 preprocessor directive of the form `#define DEFINITION' such that the\n\
545 definition is visible in all the inferior's source files.\n\
547 (gdb) macro define PI (3.1415926)\n\
548 (gdb) macro define MIN(x,y) ((x) < (y) ? (x) : (y))"),
552 Remove the definition of the C/C++ preprocessor macro with the given name."),
556 _(
"List all the macros defined using the `macro define' command."),
void macro_define_function(struct macro_source_file *source, int line, const char *name, int argc, const char **argv, const char *replacement)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
int macro_is_digit(int c)
struct macro_source_file * file
char * macro_expand(const char *source, macro_lookup_ftype *lookup_func, void *lookup_func_baton)
int macro_is_identifier_nondigit(int c)
__extension__ enum macro_kind kind
static void skip_ws(char **expp)
initialize_file_ftype _initialize_macrocmd
static struct cleanup * cleanup_chain
struct macro_table * table
struct macro_source_file * included_by
struct ui_file * gdb_stdout
struct macro_definition * standard_macro_lookup(const char *name, void *baton)
static void print_macro_definition(const char *name, const struct macro_definition *d, struct macro_source_file *file, int line)
static void macro_inform_no_debuginfo(void)
void macro_for_each_in_scope(struct macro_source_file *file, int line, macro_callback_fn fn, void *user_data)
static void free_macro_definition_ptr(void *ptr)
struct cmd_list_element * cmdlist
char * skip_spaces(char *chp)
struct macro_scope * sal_macro_scope(struct symtab_and_line sal)
static void macro_command(char *arg, int from_tty)
struct macro_scope * default_macro_scope(void)
static void macro_define_command(char *exp, int from_tty)
struct macro_table * macro_user_macros
void macro_define_object(struct macro_source_file *source, int line, const char *name, const char *replacement)
struct cmd_list_element * infolist
void initialize_file_ftype(void)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct macro_definition * macro_lookup_definition(struct macro_source_file *source, int line, const char *name)
static char * extract_identifier(char **expp, int is_parameter)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
void puts_filtered(const char *string)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
static void macro_undef_command(char *exp, int from_tty)
void free_current_contents(void *ptr)
static void macro_expand_once_command(char *exp, int from_tty)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static int startswith(const char *string, const char *pattern)
struct cmd_list_element * add_alias_cmd(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
void printf_unfiltered(const char *format,...)
char * macro_source_fullname(struct macro_source_file *file)
struct macro_source_file * macro_definition_location(struct macro_source_file *source, int line, const char *name, int *definition_line)
static void macro_list_command(char *exp, int from_tty)
void macro_for_each(struct macro_table *table, macro_callback_fn fn, void *user_data)
static void info_macro_command(char *args, int from_tty)
static void print_one_macro(const char *name, const struct macro_definition *macro, struct macro_source_file *source, int line, void *ignore)
PTR xrealloc(PTR ptr, size_t size)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
static void show_pp_source_pos(struct ui_file *stream, struct macro_source_file *file, int line)
struct symtabs_and_lines decode_line_with_current_source(char *string, int flags)
static void print_macro_callback(const char *name, const struct macro_definition *macro, struct macro_source_file *source, int line, void *user_data)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
struct symtab_and_line * sals
struct macro_source_file * macro_main(struct macro_table *t)
static struct cmd_list_element * macrolist
static void info_macros_command(char *args, int from_tty)
void error(const char *fmt,...)
void macro_undef(struct macro_source_file *source, int line, const char *name)
char * macro_expand_once(const char *source, macro_lookup_ftype *lookup_func, void *lookup_func_baton)
#define skip_to_space(INP)
static void macro_expand_command(char *exp, int from_tty)
void do_cleanups(struct cleanup *old_chain)
const ULONGEST const LONGEST len
int macro_is_whitespace(int c)