* Instruction address catching
@ 2002-10-04 16:36 Fredrik Tolf
2002-10-04 17:11 ` Kevin Buettner
0 siblings, 1 reply; 7+ messages in thread
From: Fredrik Tolf @ 2002-10-04 16:36 UTC (permalink / raw)
To: gdb
Is it possible, with the current version of gdb, to make it detect every
time an address is written to, and to make it stop only if the address
of the instruction that wrote to that address isn't equal to a specific
value. If it's possible, does it work in a multithreaded application?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 16:36 Instruction address catching Fredrik Tolf
@ 2002-10-04 17:11 ` Kevin Buettner
2002-10-04 17:21 ` Fredrik Tolf
0 siblings, 1 reply; 7+ messages in thread
From: Kevin Buettner @ 2002-10-04 17:11 UTC (permalink / raw)
To: Fredrik Tolf, gdb
On Oct 5, 1:36am, Fredrik Tolf wrote:
> Is it possible, with the current version of gdb, to make it detect every
> time an address is written to, and to make it stop only if the address
> of the instruction that wrote to that address isn't equal to a specific
> value.
Do it like this:
(gdb) watch foo
Hardware watchpoint 1: foo
(gdb) condition 1 $pc != 0x80484c8
The address to compare $pc against should be the address of the
instruction *after* the one that writes to ``foo''. It's probably
easier to figure this out by simply setting a watchpoint on foo,
running 'til it's hit, and if that's not the one you're interested
in, add a condition so that it won't stop there again.
> If it's possible, does it work in a multithreaded application?
It should. If it doesn't, it's a bug.
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 17:11 ` Kevin Buettner
@ 2002-10-04 17:21 ` Fredrik Tolf
2002-10-04 17:52 ` Kevin Buettner
0 siblings, 1 reply; 7+ messages in thread
From: Fredrik Tolf @ 2002-10-04 17:21 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb
On Sat, 2002-10-05 at 02:11, Kevin Buettner wrote:
> On Oct 5, 1:36am, Fredrik Tolf wrote:
>
> > Is it possible, with the current version of gdb, to make it detect every
> > time an address is written to, and to make it stop only if the address
> > of the instruction that wrote to that address isn't equal to a specific
> > value.
>
> Do it like this:
>
> (gdb) watch foo
> Hardware watchpoint 1: foo
> (gdb) condition 1 $pc != 0x80484c8
>
> The address to compare $pc against should be the address of the
> instruction *after* the one that writes to ``foo''. It's probably
> easier to figure this out by simply setting a watchpoint on foo,
> running 'til it's hit, and if that's not the one you're interested
> in, add a condition so that it won't stop there again.
>
> > If it's possible, does it work in a multithreaded application?
>
> It should. If it doesn't, it's a bug.
Are you sure? Wouldn't the pc it compares to be that of the selected
thread and not that of the thread that wrote?
>
> Kevin
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 17:21 ` Fredrik Tolf
@ 2002-10-04 17:52 ` Kevin Buettner
2002-10-04 18:09 ` Fredrik Tolf
0 siblings, 1 reply; 7+ messages in thread
From: Kevin Buettner @ 2002-10-04 17:52 UTC (permalink / raw)
To: Fredrik Tolf; +Cc: gdb
On Oct 5, 2:21am, Fredrik Tolf wrote:
> On Sat, 2002-10-05 at 02:11, Kevin Buettner wrote:
> > On Oct 5, 1:36am, Fredrik Tolf wrote:
> >
> > > Is it possible, with the current version of gdb, to make it detect every
> > > time an address is written to, and to make it stop only if the address
> > > of the instruction that wrote to that address isn't equal to a specific
> > > value.
> >
> > Do it like this:
> >
> > (gdb) watch foo
> > Hardware watchpoint 1: foo
> > (gdb) condition 1 $pc != 0x80484c8
> >
> > The address to compare $pc against should be the address of the
> > instruction *after* the one that writes to ``foo''. It's probably
> > easier to figure this out by simply setting a watchpoint on foo,
> > running 'til it's hit, and if that's not the one you're interested
> > in, add a condition so that it won't stop there again.
> >
> > > If it's possible, does it work in a multithreaded application?
> >
> > It should. If it doesn't, it's a bug.
>
> Are you sure? Wouldn't the pc it compares to be that of the selected
> thread and not that of the thread that wrote?
The thread that triggers the watchpoint becomes the selected thread
for the purposes of checking the condition. (At least, I think that's
the way it works.) I've just tried it with a simple (threaded) example
and it seems to work as expected...
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 17:52 ` Kevin Buettner
@ 2002-10-04 18:09 ` Fredrik Tolf
2002-10-04 18:37 ` Fredrik Tolf
0 siblings, 1 reply; 7+ messages in thread
From: Fredrik Tolf @ 2002-10-04 18:09 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb
On Sat, 2002-10-05 at 02:52, Kevin Buettner wrote:
> On Oct 5, 2:21am, Fredrik Tolf wrote:
>
> > On Sat, 2002-10-05 at 02:11, Kevin Buettner wrote:
> > > On Oct 5, 1:36am, Fredrik Tolf wrote:
> > >
> > > > Is it possible, with the current version of gdb, to make it detect every
> > > > time an address is written to, and to make it stop only if the address
> > > > of the instruction that wrote to that address isn't equal to a specific
> > > > value.
> > >
> > > Do it like this:
> > >
> > > (gdb) watch foo
> > > Hardware watchpoint 1: foo
By the way: I don't seem to be able to set hardware watchpoints... I'm
running i 2.4.19 linux kernel on an AMD Thunderbird, could that have
something to do with it?
> > > (gdb) condition 1 $pc != 0x80484c8
> > >
> > > The address to compare $pc against should be the address of the
> > > instruction *after* the one that writes to ``foo''. It's probably
> > > easier to figure this out by simply setting a watchpoint on foo,
> > > running 'til it's hit, and if that's not the one you're interested
> > > in, add a condition so that it won't stop there again.
> > >
> > > > If it's possible, does it work in a multithreaded application?
> > >
> > > It should. If it doesn't, it's a bug.
> >
> > Are you sure? Wouldn't the pc it compares to be that of the selected
> > thread and not that of the thread that wrote?
>
> The thread that triggers the watchpoint becomes the selected thread
> for the purposes of checking the condition. (At least, I think that's
> the way it works.) I've just tried it with a simple (threaded) example
> and it seems to work as expected...
OK... if you say so... I'll try it! Thanks a thousandfold!
>
> Kevin
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 18:09 ` Fredrik Tolf
@ 2002-10-04 18:37 ` Fredrik Tolf
2002-10-08 13:09 ` Kevin Buettner
0 siblings, 1 reply; 7+ messages in thread
From: Fredrik Tolf @ 2002-10-04 18:37 UTC (permalink / raw)
To: Fredrik Tolf; +Cc: Kevin Buettner, gdb
On Sat, 2002-10-05 at 03:09, Fredrik Tolf wrote:
> On Sat, 2002-10-05 at 02:52, Kevin Buettner wrote:
> > On Oct 5, 2:21am, Fredrik Tolf wrote:
> >
> > > On Sat, 2002-10-05 at 02:11, Kevin Buettner wrote:
> > > > On Oct 5, 1:36am, Fredrik Tolf wrote:
> > > >
> > > > > Is it possible, with the current version of gdb, to make it detect every
> > > > > time an address is written to, and to make it stop only if the address
> > > > > of the instruction that wrote to that address isn't equal to a specific
> > > > > value.
> > > >
> > > > Do it like this:
> > > >
> > > > (gdb) watch foo
> > > > Hardware watchpoint 1: foo
> By the way: I don't seem to be able to set hardware watchpoints... I'm
> running i 2.4.19 linux kernel on an AMD Thunderbird, could that have
> something to do with it?
Sorry... I was wrong. I made a quick test before which was ultimately
wrong. I can set hardware watchpoints.
> > > > (gdb) condition 1 $pc != 0x80484c8
> > > >
> > > > The address to compare $pc against should be the address of the
> > > > instruction *after* the one that writes to ``foo''. It's probably
> > > > easier to figure this out by simply setting a watchpoint on foo,
> > > > running 'til it's hit, and if that's not the one you're interested
> > > > in, add a condition so that it won't stop there again.
> > > >
> > > > > If it's possible, does it work in a multithreaded application?
> > > >
> > > > It should. If it doesn't, it's a bug.
> > >
> > > Are you sure? Wouldn't the pc it compares to be that of the selected
> > > thread and not that of the thread that wrote?
> >
> > The thread that triggers the watchpoint becomes the selected thread
> > for the purposes of checking the condition. (At least, I think that's
> > the way it works.) I've just tried it with a simple (threaded) example
> > and it seems to work as expected...
> OK... if you say so... I'll try it! Thanks a thousandfold!
The strangest thing happened. I made a small test program to test this.
The program spawns two threads, each of which increments a variable of
its own once a second. Even when I set a watchpoint on any of the
variables (i.e. "watch var1"), the program doesn't halt. I checked
manually, and the vars are increased, but gdb won't stop the program.
What can I possibly have done wrong?
> >
> > Kevin
> >
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Instruction address catching
2002-10-04 18:37 ` Fredrik Tolf
@ 2002-10-08 13:09 ` Kevin Buettner
0 siblings, 0 replies; 7+ messages in thread
From: Kevin Buettner @ 2002-10-08 13:09 UTC (permalink / raw)
To: Fredrik Tolf; +Cc: gdb
On Oct 5, 3:37am, Fredrik Tolf wrote:
> The strangest thing happened. I made a small test program to test this.
> The program spawns two threads, each of which increments a variable of
> its own once a second. Even when I set a watchpoint on any of the
> variables (i.e. "watch var1"), the program doesn't halt. I checked
> manually, and the vars are increased, but gdb won't stop the program.
> What can I possibly have done wrong?
Are your variables local to a function or are they globals?
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-08 20:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-04 16:36 Instruction address catching Fredrik Tolf
2002-10-04 17:11 ` Kevin Buettner
2002-10-04 17:21 ` Fredrik Tolf
2002-10-04 17:52 ` Kevin Buettner
2002-10-04 18:09 ` Fredrik Tolf
2002-10-04 18:37 ` Fredrik Tolf
2002-10-08 13:09 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox