Runtiming hw watchpoints; Was: Split up Z packet enable/disable cmd

Eli Zaretskii eliz@delorie.com
Fri Aug 4 11:11:00 GMT 2000


> Date: Fri, 04 Aug 2000 13:51:05 +0000
> From: Fernando Nasser <fnasser@cygnus.com>
> 
> > >       i = hw_watchpoint_used_count (bp_type, &other_type_used);
> > >       target_resources_ok =
> > > !       TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type, j, i + mem_cnt,
> > >                                             other_type_used);
> > 
> > The problem here is that the mere _count_ of the used up break- and
> > watch-points is not enough to return an accurate answer to the
> > question asked by TARGET_CAN_USE_HARDWARE_WATCHPOINT.  At least in the
> > DJGPP case (and I believe for every other x86 target, too), I need to
> > know the addresses and the size of watched regions of all watchpoints,
> > and also the addresses of all hardware-assisted breakpoints.  If
> > TARGET_CAN_USE_HARDWARE_WATCHPOINT will get that info, it could be
> > implemented so as to return a meaningful result.
> 
> That is taken care of in breakpoints.c also.  The function can_use_hardware_watchpoint()
> checks how many hardware registers will be necessary for implementing a watchpoint.
> It may need fix or parametrization, but it is in there.

can_use_hardware_watchpoint could do this if it gets the info about all
the watchpoints and hardware breakpoints defined previously.
Currently, it only gets information about one single watchpoint at a
time, and that is not enough, at least on x86.

Alternatively, we could request the target to remember all watchpoints
that GDB intends to insert when it resumes the debuggee, but that
calls for a change in the API, since currently
can_use_hardware_watchpoint does not guarantee the watchpoint will
actually be inserted.

> You see, nobody even know that these things are there because the macros/functions to 
> do the actual check for most targets did not get implemented.

I completely agree.  It took me quite a while, at the time, to
untangle the logic of the decisions made by
can_use_hardware_watchpoint and TARGET_CAN_USE_HARDWARE_WATCHPOINT,
and then get them right by introducing
TARGET_REGION_OK_FOR_HW_WATCHPOINT (before this, GDB only tested the
size of the region with TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT).

One problem with that code is that, originally, it was written for
Sparc Lite (I think) where the hardware watchpoints are handled in a
very different way.


More information about the Gdb-patches mailing list