[PATCH]: Make Linux use the new unified x86 watchpoint support

Mark Salter msalter@redhat.com
Wed Mar 28 08:06:00 GMT 2001

>>>>> Eli Zaretskii writes:

> On Wed, 28 Mar 2001, Mark Salter wrote:

>> > Sorry, I don't understand: why does reading a watched region generate
>> > an error?  At least in the x86 implementation, watchpoints are set to
>> > be task-local, so reading the data from GDB, which is another process,
>> > should not produce any errors.  Am I missing something?
>> I'm using a remote target which has global hw watchpoints and no OS.
>> The remote target still has the watchpoints installed when gdb tries
>> to read the area being watched. I don't know. Maybe the target stub
>> should take it upon itself to remove the watchpoints before telling
>> gdb it stopped?

> Is there any reason that you can't define HAVE_NONSTEPPABLE_WATCHPOINT 
> (or some of its other brethren; see infrun.c) and get GDB to DTRT for 
> your target?

Hmm. So, what are the meanings of HAVE_NONSTEPPABLE_WATCHPOINT and
HAVE_STEPPABLE_WATCHPOINT? It seems if you have one, you don't have
the other, but infrun.c doesn't see it that way. The thing is that
the hw watchpoints on this architecture will not trap until the insn
which triggers the watchpoint finishes execution. That is, the PC 
reported to GDB is for the insn just past the insn which triggered
the watchpoint.

Anyway, if I don't define either, and debug this app:

  int foo = 3;

     printf("%d\n", foo);

I get this:

  (gdb) rwatch foo
  Hardware read watchpoint 1: foo
  (gdb) c
  Error evaluating expression for watchpoint 1
  Cannot access memory at address 0xa0028000
  Watchpoint 1 deleted.
  0xa0020028 in main () at wtest.c:6

Note that gdb stopped at the line that referenced the watched variable.
The only problem is the error message.


  (gdb) c
  Hardware read watchpoint 1: foo

  Value = 3
  0xa0020c4c in printf () at ....

Note that gdb stopped inside printf. This seems suboptimal but at least
there's not error.

I can't step or continue past insns that trigger watchpoints.


More information about the Gdb-patches mailing list