static void write_macro_definitions (const struct block *block, CORE_ADDR pc, struct ui_file *file) { struct macro_scope *scope; if (block != NULL) scope = sal_macro_scope (find_pc_line (pc, 0)); else scope = default_macro_scope (); if (scope == NULL) scope = user_macro_scope (); if (scope != NULL && scope->file != NULL && scope->file->table != NULL) macro_for_each_in_scope (scope->file, scope->line, print_one_macro, file); }
struct macro_scope * default_macro_scope (void) { struct symtab_and_line sal; struct macro_scope *ms; struct frame_info *frame; CORE_ADDR pc; /* If there's a selected frame, use its PC. */ frame = deprecated_safe_get_selected_frame (); if (frame && get_frame_pc_if_available (frame, &pc)) sal = find_pc_line (pc, 0); /* Fall back to the current listing position. */ else { /* Don't call select_source_symtab here. That can raise an error if symbols aren't loaded, but GDB calls the expression evaluator in all sorts of contexts. For example, commands like `set width' call the expression evaluator to evaluate their numeric arguments. If the current language is C, then that may call this function to choose a scope for macro expansion. If you don't have any symbol files loaded, then get_current_or_default would raise an error. But `set width' shouldn't raise an error just because it can't decide which scope to macro-expand its argument in. */ struct symtab_and_line cursal = get_current_source_symtab_and_line (); sal.symtab = cursal.symtab; sal.line = cursal.line; } ms = sal_macro_scope (sal); if (! ms) ms = user_macro_scope (); return ms; }