aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2002-05-17 17:57:48 +0000
committerJim Blandy <jimb@codesourcery.com>2002-05-17 17:57:48 +0000
commit84f0252a038f4c2ceb70d076f58159eaa8e3dfab (patch)
treef941a69257718ec66cee427c3cc662eab4684fb7 /gdb/parse.c
parent1c509ca8216de106f508b463a13ceea60ccce878 (diff)
downloadgdb-84f0252a038f4c2ceb70d076f58159eaa8e3dfab.zip
gdb-84f0252a038f4c2ceb70d076f58159eaa8e3dfab.tar.gz
gdb-84f0252a038f4c2ceb70d076f58159eaa8e3dfab.tar.bz2
Expand preprocessor macros in C expressions.
* c-lang.h: #include "macroexp.h", for macro_lookup_ftype. (scan_macro_expansion, scanning_macro_expansion, finished_macro_expansion): New function declarations. (expression_macro_lookup_func, expression_macro_lookup_baton): New variable declarations. * parser-defs.h (expression_context_pc): New declaration. * parse.c (expression_context_pc): New variable. (parse_exp_1): Set expression_context_pc, as well as expression_context_block. * c-exp.y (yylex): If we're not already reading the result of a macro expansion, try to macro-expand the next token. When we're done scanning a macro expansion, switch back to the mainline text. Commas and `if's in a macro's expansion don't terminate the input. * c-lang.c: #include "macroscope.h" and "gdb_assert.h". (macro_original_text, macro_expanded_text, expression_macro_lookup_func, expression_macro_lookup_baton): New variables. (scan_macro_expansion, scanning_macro_expansion, finished_macro_expansion, scan_macro_cleanup, null_macro_lookup, c_preprocess_and_parse): New functions. (c_language_defn, cplus_language_defn, asm_language_defn): Call c_preprocess_and_parse, instead of c_parse. * Makefile.in (c_lang_h): Note that this #includes macroexp.h. (c-lang.o): Note dependency on macroscope.h and gdb_assert.h.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 9c1f3e1..bc81f22 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -71,6 +71,7 @@ struct expression *expout;
int expout_size;
int expout_ptr;
struct block *expression_context_block;
+CORE_ADDR expression_context_pc;
struct block *innermost_block;
int arglist_len;
union type_stack_elt *type_stack;
@@ -1140,7 +1141,13 @@ parse_exp_1 (char **stringptr, struct block *block, int comma)
old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
funcall_chain = 0;
- expression_context_block = block ? block : get_selected_block (0);
+ if (block)
+ {
+ expression_context_block = block;
+ expression_context_pc = block->startaddr;
+ }
+ else
+ expression_context_block = get_selected_block (&expression_context_pc);
namecopy = (char *) alloca (strlen (lexptr) + 1);
expout_size = 10;