1 /* Functions for deciding which macros are currently in scope.
2 Copyright 2002 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "macroscope.h"
32 sal_macro_scope (struct symtab_and_line sal
)
34 struct macro_source_file
*main
;
35 struct macro_scope
*ms
;
38 || ! sal
.symtab
->macro_table
)
41 ms
= (struct macro_scope
*) xmalloc (sizeof (*ms
));
43 main
= macro_main (sal
.symtab
->macro_table
);
44 ms
->file
= macro_lookup_inclusion (main
, sal
.symtab
->filename
);
50 "the symtab `%s' refers to a preprocessor macro table which doesn't\n"
51 "have any record of processing a file by that name.\n",
52 sal
.symtab
->filename
);
61 default_macro_scope (void)
63 struct symtab_and_line sal
;
64 struct macro_source_file
*main
;
65 struct macro_scope
*ms
;
67 /* If there's a selected frame, use its PC. */
69 sal
= find_pc_line (selected_frame
->pc
, 0);
71 /* If the target has any registers at all, then use its PC. Why we
72 would have registers but no stack, I'm not sure. */
73 else if (target_has_registers
)
74 sal
= find_pc_line (read_pc (), 0);
76 /* If all else fails, fall back to the current listing position. */
79 /* Don't call select_source_symtab here. That can raise an
80 error if symbols aren't loaded, but GDB calls the expression
81 evaluator in all sorts of contexts.
83 For example, commands like `set width' call the expression
84 evaluator to evaluate their numeric arguments. If the
85 current language is C, then that may call this function to
86 choose a scope for macro expansion. If you don't have any
87 symbol files loaded, then select_source_symtab will raise an
88 error. But `set width' shouldn't raise an error just because
89 it can't decide which scope to macro-expand its argument in. */
90 sal
.symtab
= current_source_symtab
;
91 sal
.line
= current_source_line
;
94 return sal_macro_scope (sal
);
98 /* Look up the definition of the macro named NAME in scope at the source
99 location given by BATON, which must be a pointer to a `struct
100 macro_scope' structure. */
101 struct macro_definition
*
102 standard_macro_lookup (const char *name
, void *baton
)
104 struct macro_scope
*ms
= (struct macro_scope
*) baton
;
106 return macro_lookup_definition (ms
->file
, ms
->line
, name
);
This page took 0.030505 seconds and 4 git commands to generate.