/* Look up the definition of the macro named NAME in scope at the source location given by BATON, which must be a pointer to a `struct macro_scope' structure. */ struct macro_definition * standard_macro_lookup (const char *name, void *baton) { struct macro_scope *ms = (struct macro_scope *) baton; struct macro_definition *result; /* Give user-defined macros priority over all others. */ result = macro_lookup_definition (macro_main (macro_user_macros), -1, name); if (! result) result = macro_lookup_definition (ms->file, ms->line, name); return result; }
/* Look up the definition of the macro named NAME in scope at the source location given by BATON, which must be a pointer to a `struct macro_scope' structure. */ struct macro_definition * standard_macro_lookup (const char *name, void *baton) { struct macro_scope *ms = (struct macro_scope *) baton; return macro_lookup_definition (ms->file, ms->line, name); }
static void info_macro_command (char *name, int from_tty) { struct macro_scope *ms = NULL; struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &ms); struct macro_definition *d; if (! name || ! *name) error ("You must follow the `info macro' command with the name" " of the macro\n" "whose definition you want to see."); ms = default_macro_scope (); if (! ms) error ("GDB has no preprocessor macro information for that code."); d = macro_lookup_definition (ms->file, ms->line, name); if (d) { int line; struct macro_source_file *file = macro_definition_location (ms->file, ms->line, name, &line); fprintf_filtered (gdb_stdout, "Defined at "); show_pp_source_pos (gdb_stdout, file, line); fprintf_filtered (gdb_stdout, "#define %s", name); if (d->kind == macro_function_like) { int i; fputs_filtered ("(", gdb_stdout); for (i = 0; i < d->argc; i++) { fputs_filtered (d->argv[i], gdb_stdout); if (i + 1 < d->argc) fputs_filtered (", ", gdb_stdout); } fputs_filtered (")", gdb_stdout); } fprintf_filtered (gdb_stdout, " %s\n", d->replacement); } else { fprintf_filtered (gdb_stdout, "The symbol `%s' has no definition as a C/C++" " preprocessor macro\n" "at ", name); show_pp_source_pos (gdb_stdout, ms->file, ms->line); } do_cleanups (cleanup_chain); }
/* The implementation of the `info macro' command. */ static void info_macro_command (char *args, int from_tty) { struct macro_scope *ms = NULL; struct cleanup *cleanup_chain; char *name; int show_all_macros_named = 0; char *arg_start = args; int processing_args = 1; while (processing_args && arg_start && *arg_start == '-' && *arg_start != '\0') { char *p = skip_to_space (arg_start); if (strncmp (arg_start, "-a", p - arg_start) == 0 || strncmp (arg_start, "-all", p - arg_start) == 0) show_all_macros_named = 1; else if (strncmp (arg_start, "--", p - arg_start) == 0) /* Our macro support seems rather C specific but this would seem necessary for languages allowing - in macro names. e.g. Scheme's (defmacro ->foo () "bar\n") */ processing_args = 0; else { /* Relies on modified 'args' not making it in to history */ *p = '\0'; error (_("Unrecognized option '%s' to info macro command. " "Try \"help info macro\"."), arg_start); } arg_start = skip_spaces (p); } name = arg_start; if (! name || ! *name) error (_("You must follow the `info macro' command with the name" " of the macro\n" "whose definition you want to see.")); ms = default_macro_scope (); cleanup_chain = make_cleanup (free_current_contents, &ms); if (! ms) macro_inform_no_debuginfo (); else if (show_all_macros_named) macro_for_each (ms->file->table, print_macro_callback, name); else { struct macro_definition *d; d = macro_lookup_definition (ms->file, ms->line, name); if (d) { int line; struct macro_source_file *file = macro_definition_location (ms->file, ms->line, name, &line); print_macro_definition (name, d, file, line); } else { fprintf_filtered (gdb_stdout, "The symbol `%s' has no definition as a C/C++" " preprocessor macro\n" "at ", name); show_pp_source_pos (gdb_stdout, ms->file, ms->line); } } do_cleanups (cleanup_chain); }
/* The implementation of the `info macro' command. */ static void info_macro_command (const char *args, int from_tty) { gdb::unique_xmalloc_ptr<struct macro_scope> ms; const char *name; int show_all_macros_named = 0; const char *arg_start = args; int processing_args = 1; while (processing_args && arg_start && *arg_start == '-' && *arg_start != '\0') { const char *p = skip_to_space (arg_start); if (strncmp (arg_start, "-a", p - arg_start) == 0 || strncmp (arg_start, "-all", p - arg_start) == 0) show_all_macros_named = 1; else if (strncmp (arg_start, "--", p - arg_start) == 0) /* Our macro support seems rather C specific but this would seem necessary for languages allowing - in macro names. e.g. Scheme's (defmacro ->foo () "bar\n") */ processing_args = 0; else { error (_("Unrecognized option '%.*s' to info macro command. " "Try \"help info macro\"."), int (p - arg_start), arg_start); } arg_start = skip_spaces (p); } name = arg_start; if (! name || ! *name) error (_("You must follow the `info macro' command with the name" " of the macro\n" "whose definition you want to see.")); ms = default_macro_scope (); if (! ms) macro_inform_no_debuginfo (); else if (show_all_macros_named) macro_for_each (ms->file->table, [&] (const char *macro_name, const macro_definition *macro, macro_source_file *source, int line) { if (strcmp (name, macro_name) == 0) print_macro_definition (name, macro, source, line); }); else { struct macro_definition *d; d = macro_lookup_definition (ms->file, ms->line, name); if (d) { int line; struct macro_source_file *file = macro_definition_location (ms->file, ms->line, name, &line); print_macro_definition (name, d, file, line); } else { fprintf_filtered (gdb_stdout, "The symbol `%s' has no definition as a C/C++" " preprocessor macro\n" "at ", name); show_pp_source_pos (gdb_stdout, ms->file, ms->line); } } }