From: Pedro Alves Date: Sat, 3 May 2008 22:30:51 +0000 (+0000) Subject: gdb/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d705c43c5aa1551e91d5dfbd73ea8d4ba0f0758d;p=binutils-gdb.git gdb/ * parse.c (parse_exp_in_context): Don't override expression_context_pc if get_selected_block returned a valid block. gdb/testsuite/ * gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing expressions with macros. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0f458237ea0..3e794a3f79b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2008-05-03 Pedro Alves + + * parse.c (parse_exp_in_context): Don't override + expression_context_pc if get_selected_block returned a valid + block. + 2008-05-03 Daniel Jacobowitz * alpha-tdep.h (ALPHA_REGISTER_BYTES): Delete. diff --git a/gdb/parse.c b/gdb/parse.c index 734739afea8..9c0edf52a22 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -961,26 +961,24 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma, old_chain = make_cleanup (free_funcalls, 0 /*ignore*/); funcall_chain = 0; - /* If no context specified, try using the current frame, if any. */ + expression_context_block = block; - if (!block) - block = get_selected_block (&expression_context_pc); + /* If no context specified, try using the current frame, if any. */ + if (!expression_context_block) + expression_context_block = get_selected_block (&expression_context_pc); + else + expression_context_pc = BLOCK_START (expression_context_block); - /* Fall back to using the current source static context, if any. */ + /* Fall back to using the current source static context, if any. */ - if (!block) + if (!expression_context_block) { struct symtab_and_line cursal = get_current_source_symtab_and_line (); if (cursal.symtab) - block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK); - } - - /* Save the context, if specified by caller, or found above. */ - - if (block) - { - expression_context_block = block; - expression_context_pc = BLOCK_START (block); + expression_context_block + = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK); + if (expression_context_block) + expression_context_pc = BLOCK_START (expression_context_block); } expout_size = 10; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0cd52d3bbe2..78454ce6d2c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-05-03 Pedro Alves + + * gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing + expressions with macros. + 2008-05-03 Jan Kratochvil * gdb.base/dfp-test.exp: Fix random FAIL risk on calling functions. diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index b04fc0697d1..ccefc85835b 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -24,6 +24,7 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +set srcfile macscp1.c set testfile "macscp" set binfile ${objdir}/${subdir}/${testfile} @@ -405,3 +406,25 @@ for {set i 0} {$i < [llength $funcs]} {incr i} { } } } + +gdb_test "break [gdb_get_line_number "set breakpoint here"]" \ + "Breakpoint.*at.* file .*, line.*" \ + "breakpoint macscp_expr" + +gdb_test "continue" "foo = 0;.*" "continue to macsp_expr" + +gdb_test "print M" \ + "No symbol \"M\" in current context\." \ + "print expression with macro before define." + +gdb_test "next" "foo = 1;" "next to definition" + +gdb_test "print M" \ + " = 0" \ + "print expression with macro in scope." + +gdb_test "next" "foo = 2;" "next to definition" + +gdb_test "print M" \ + "No symbol \"M\" in current context\." \ + "print expression with macro after undef." diff --git a/gdb/testsuite/gdb.base/macscp1.c b/gdb/testsuite/gdb.base/macscp1.c index 89a1b07d1e6..200ac262003 100644 --- a/gdb/testsuite/gdb.base/macscp1.c +++ b/gdb/testsuite/gdb.base/macscp1.c @@ -63,6 +63,18 @@ macscp1_3 () puts ("macscp1_3"); } +void +macscp_expr (void) +{ + int foo = -1; + + foo = 0; /* set breakpoint here */ +#define M foo + foo = 1; +#undef M + foo = 2; +} + int main (int argc, char **argv) { @@ -77,4 +89,5 @@ main (int argc, char **argv) macscp4_2_from_macscp3 (); macscp3_2 (); macscp1_3 (); + macscp_expr (); }