recurse.exp: watch on local variable that goes out of scope

Orjan Friberg orjan.friberg@axis.com
Tue Jul 20 14:37:00 GMT 2004


I'm having problems with recurse.exp on CRISv32 with hardware watchpoint support 
- a local variable which goes out of scope isn't handled the same way as on the 
i386 ("second instance watchpoint deleted when leaving scope").  On the i386 
i386_stopped_data_address returns a proper address when I don't expect it to.

Here's a recap of what I think I've understood: in order to detect when a 
watched local variable goes out of scope, gdb inserts a breakpoint on the 
instruction where the function that the variable belongs to returns to.  In this 
case it shows up as ("maint info break"; local variable "b" is watched in 
recurse (a=5)):

4   hw watchpoint  keep y              b
         breakpoint already hit 2 times
-56 watchpoint scope del  y   0x08048403 <recurse+51>
         stop only in stack frame at 0xbffff4c4
         breakpoint already hit 4 times

When stopped at the return statement of recurse (a=5), a continue is issued, 
making recurse (a=5) return and the "watchpoint scope del" breakpoint is then 
hit (the bp_addr argument to bpstat_stop_status == 0x08048403).

Now for the confusing part: bpstat_stop_status is called with 
stopped_by_watchpoint == 1.  This is because, at this point, 
i386_stopped_data_address returns the address of the local variable "b" (the 
address it had in recurse (a=5)), as if it were stopped due to a watchpoint hit. 
  I would have expected i386_stopped_data_address to return 0 at this point, 
since it didn't stop due to a watchpoint hit.  What am I missing here?  Does 
i386_stopped_data_address retain the stopped data address from the previous hit?

Thanks in advance.

-- 
Orjan Friberg
Axis Communications



More information about the Gdb-patches mailing list