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

Re: Hardware watchpoints; dealing with false triggers?

Eli Zaretskii wrote:
> On Thu, 29 Nov 2001, Orjan Friberg wrote:
> > But consider the following: say your watchpoint registers can only watch
> > 4-byte aligned areas of 4 bytes, but you want to rwatch (or awatch) an
> > unaligned variable of size 4 bytes.  You'd have to use two watchpoint
> > registers, both covering too much, like this:
> >
> > Variable to watch:      | 0 1   2 3 |
> > Watchpoints:        | 0 1 2 3 | 0 1 2 3 |
> >                         wp1       wp2
> This shouldn't happen, and it indeed does not happen with x86.  x86 uses
> 2 debug registers in this case, like so:


Many thanks for your detailed response.

Maybe I should clarify that I'm not talking about the x86, but a
hypothetical target whose watchpoint mechanism would function this way. 
I was only using the i386 hardware watchpoint implementation as a
reference and a basis for discussion.

> > Now, say a there's a read of wp1's byte 0.  The hardware would trigger,
> > but it would be a false trigger.  Gdb would somehow have to find out the
> > actual address that was read and if it was found to be outside of the
> > variable's range it would not trigger the watchpoint.
> You can't do that, at least not with x86 debug registers: when a
> watchpoint triggers, you don't know what byte of its covered memory was
> written to.  All you know is that memory covered by a specific register
> was written.

Ok, but say that the actual address is shipped with the register packet
when the target stops so that gdb in fact knows what address was
actually read/written.  I'm thinking gdb could compare that address with
the watchpoints, and just send the target on its way if the address is
outside the watched ranges.

I'm thinking of the implementation of this in a cross-environment, and
while you could do it on the target side, say in the kernel, I'd rather
not since I could potentially have several stubs.  Handling it on the
host side would allow me to handle it in one place only.

> > are
> > there any major obstacles for implementing such target-dependent false
> > trigger handling in gdb?
> IIRC, no.  If you cannot do something similar to what x86 does, I think
> you are in for a bumpy ride, as GDB doesn't handle such problems very
> well.  Your best bet would be to solve this in the target-specific
> low-level code.

And this is the key issue: could the interface to the target-specific
code be extended to handle the concept of "actual watchpoint address"? 
Or rather, could it be made to fit in nicely with the existing
framework, or would it require a horrible kludge?  (Maybe this question
is on a too general level, and I just have to dig deeper into the code
to see what would actually be needed.)

> Do you really have such a strange target?  Can you tell the details?

No, I don't actually have such a target, so I'm sorry; I can't tell any

Orjan Friberg
Axis Communications AB

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