This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/856: Can't use [some] macro's in conditional breakpoints


>Number:         856
>Category:       gdb
>Synopsis:       Can't use [some] macro's in conditional breakpoints
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 28 18:38:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     ac131313@redhat.com
>Release:        2002-11-28
>Organization:
>Environment:
$ gcc --version
(er, lets just say 3.2 + some redhat fixes)
>Description:
The breakpoint code uses the call:

parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);

to pre-parse a conditional expression.  This leads to parse_exp_1() using:

  if (block)
    {
      expression_context_block = block;
      expression_context_pc = BLOCK_START (block);

as the expression's context.  The problem is, BLOCK_START() does not necessarially match the breakpoint line.  This leaves a window within which macros can be {re,un,}defined but not seen by the breakpoint expression parse.

     3  {
     4      int i;
     5      int j;
     6      i = 0;
     7      j = 1;
     8  #define K 2
     9      i = K;
    10  }

Perhaps parse_exp_1() should take a SAL instead of block.

[Disclaimer, I found what I thought was a think-o and then went backwards to a bug.   I was trying to figure out if get_*selected*_block(&addr) could be eliminated ....]
>How-To-Repeat:
Given the program:

$ cat -n macro.c
     1  #define L 3
     2  main ()
     3  {
     4      int i;
     5      int j;
     6      i = 0;
     7      j = 1;
     8  #define K 2
     9      i = K;
    10  }

Compiled with:

$ gcc -gdwarf-2 -g3 macro.c

I'm finding I can't use the macro `K' as part of a conditional breakpoint on line 9 vis:

(gdb) macro expand L
expands to: 3
(gdb) macro expand K
expands to: 2
(gdb) break 9 if i = L
Breakpoint 1 at 0x8048312: file macro.c, line 9.
(gdb) break 9 if i = K
No symbol "K" in current context.

and continuing on:

(gdb) list 9
4           int i;
5           int j;
6           i = 0;
7           j = 1;
8       #define K 2
9           i = K;
10      }
(gdb) break 9
Breakpoint 1 at 0x8048312: file macro.c, line 9.
(gdb) run
Starting program: /home/cagney/a.out 

Breakpoint 1, main () at macro.c:9
9           i = K;
(gdb) print K
$1 = 2
(gdb) print i
$2 = 0
(gdb) break if K == i
No symbol "K" in current context.
(gdb) 


>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]