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++)
196 int show_all_macros_named = 0;
197 const char *arg_start = args;
198 int processing_args = 1;
200 while (processing_args
201 && arg_start && *arg_start ==
'-' && *arg_start !=
'\0')
205 if (strncmp (arg_start,
"-a", p - arg_start) == 0
206 || strncmp (arg_start,
"-all", p - arg_start) == 0)
207 show_all_macros_named = 1;
208 else if (strncmp (arg_start,
"--", p - arg_start) == 0)
215 error (
_(
"Unrecognized option '%.*s' to info macro command. " 216 "Try \"help info macro\"."),
217 int (p - arg_start), arg_start);
226 error (
_(
"You must follow the `info macro' command with the name" 228 "whose definition you want to see."));
235 else if (show_all_macros_named)
241 if (strcmp (name, macro_name) == 0)
242 print_macro_definition (name, macro, source, line);
260 "The symbol `%s' has no definition as a C/C++" 261 " preprocessor macro\n" 281 std::vector<symtab_and_line> sals
317 const char *p = *expp;
338 result = (
char *)
xmalloc (len + 1);
339 memcpy (result, *expp, len);
353 for (i = 0; i <
loc->argc; ++i)
367 error (
_(
"usage: macro define NAME[(ARGUMENT-LIST)] [REPLACEMENT-LIST]"));
377 error (
_(
"Invalid macro name."));
386 new_macro.
argv = (
const char *
const *)
argv;
396 if (new_macro.
argc == alloced)
401 new_macro.
argv = (
const char *
const *)
argv;
405 error (
_(
"Macro is missing an argument."));
408 for (i = new_macro.
argc - 2; i >= 0; --i)
411 error (
_(
"Two macro arguments with identical names."));
420 else if (*exp !=
')')
421 error (
_(
"',' or ')' expected at end of macro arguments."));
428 new_macro.
argc, (
const char **) new_macro.
argv,
447 error (
_(
"usage: macro undef NAME"));
452 error (
_(
"Invalid macro name."));
468 for (i = 0; i < macro->
argc; ++i)
491 _(
"Prefix for commands dealing with C preprocessor macros."),
495 Fully expand any C/C++ preprocessor macro invocations in EXPRESSION.\n\ 496 Show the expanded expression."),
500 Expand C/C++ preprocessor macro invocations appearing directly in EXPRESSION.\n\ 501 Show the expanded expression.\n\ 503 This command differs from `macro expand' in that it only expands macro\n\ 504 invocations that appear directly in EXPRESSION; if expanding a macro\n\ 505 introduces further macro invocations, those are left unexpanded.\n\ 507 `macro expand-once' helps you see how a particular macro expands,\n\ 508 whereas `macro expand' shows you how all the macros involved in an\n\ 509 expression work together to yield a pre-processed expression."),
514 _(
"Show the definition of MACRO, and it's source location.\n\ 515 Usage: info macro [-a|-all] [--] MACRO\n\ 517 -a, --all Output all definitions of MACRO in the current compilation\ 519 -- Specify the end of arguments and the beginning of the MACRO."));
522 _(
"Show the definitions of all macros at LINESPEC, or the current \ 524 Usage: info macros [LINESPEC]"));
527 Define a new C/C++ preprocessor macro.\n\ 528 The GDB command `macro define DEFINITION' is equivalent to placing a\n\ 529 preprocessor directive of the form `#define DEFINITION' such that the\n\ 530 definition is visible in all the inferior's source files.\n\ 532 (gdb) macro define PI (3.1415926)\n\ 533 (gdb) macro define MIN(x,y) ((x) < (y) ? (x) : (y))"),
537 Remove the definition of the C/C++ preprocessor macro with the given name."),
541 _(
"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)
int macro_is_digit(int c)
static char * extract_identifier(const char **expp, int is_parameter)
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 struct cleanup * cleanup_chain
static void skip_ws(const char **expp)
struct macro_table * table
struct macro_source_file * included_by
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
void * memset(T *s, int c, size_t n)=delete
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)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
static void macro_inform_no_debuginfo(void)
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)
struct macro_scope * default_macro_scope(void)
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 * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void macro_for_each(struct macro_table *table, gdb::function_view< macro_callback_fn > fn)
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)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
void puts_filtered(const char *string)
void free_current_contents(void *ptr)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static int startswith(const char *string, const char *pattern)
static void macro_expand_once_command(const char *exp, int from_tty)
const char * skip_to_space(const char *chp)
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 info_macros_command(const char *args, int from_tty)
static void macro_list_command(const char *exp, int from_tty)
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
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 macro_command(const char *arg, int from_tty)
static void macro_define_command(const char *exp, int from_tty)
static void macro_expand_command(const char *exp, int from_tty)
std::vector< symtab_and_line > decode_line_with_current_source(const char *string, int flags)
static void show_pp_source_pos(struct ui_file *stream, struct macro_source_file *file, int line)
static void macro_undef_command(const char *exp, int from_tty)
void macro_for_each_in_scope(struct macro_source_file *file, int line, gdb::function_view< macro_callback_fn > fn)
struct macro_source_file * macro_main(struct macro_table *t)
static void print_one_macro(const char *name, const struct macro_definition *macro, struct macro_source_file *source, int line)
static struct cmd_list_element * macrolist
void _initialize_macrocmd(void)
static void info_macro_command(const 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)
void do_cleanups(struct cleanup *old_chain)
int macro_is_whitespace(int c)