This is the mail archive of the gdb@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]

Re: watchpoints inside 'commands'


Edward Peschko <edwardp@excitehome.net> writes:

> > Ah, okay, then how about setting a breakpoint near the exit from the
> > scope where the watchpoint is defined, and setting up the commands of
> > that breakpoint to silently delete the watchpoint and continue?  Would
> > that do what you want?
> 
> Ok, but there is no command - as far as I can tell - to 'silently delete the 
> watchpoint and continue'. Take the following code:
> 
> ---
> #include <stdio.h>
> 
> void a();
> 
> int main()
> {
> 	int xx;
> 	for (xx = 0; xx < 100; xx++)
> 	{
> 		function();
> 	}
> }
> 
> int yy = 0;
> 
> void a()
> {
> 
> 	char data[10]  = "hello";
> 	if (yy++%10 == 0) 
> 		data[0] = 'i';
> 
> 	
> }
> 
> if you say something like:
> 
> b 20
> Breakpoint 1 at 0x10924: file a.c, line 20.
> commands 1
> > silent
> > watch data[0];
> > continue
> 
> then, gdb will set up a watchpoint (which I assume is a breakpoint) at 20 when 
> line #20 is hit. So far so good.
> 
> But the watchpoint has a different *number* each time it comes up (ie: watch
> data[0] is 'watchpoint 2' on the first way round, watch data[0] is 'watchpoint
> 3' the second time round, etc. etc.

$bpnum will give you the number of the last breakpoint set (which
include watchpoints)

HTH,
Dan

-- 
I went to a general store.  They wouldn't let me buy anything
specifically.


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