Re: [RFC] Wrong hw_watchpoint_used_count? (multiple location watchpoints)

Eli Zaretskii
2010-01-08T12:11:19Z

> Date: Fri, 8 Jan 2010 14:29:55 +0400
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: gdb-patches@sourceware.org
>
> > But this is something only the target knows. There's no way for
> > breakpoint.c to know that, unless we introduce an API through which
> > breakpoint.c can ask the target to provide that number.
>
> That's what I eventually thought as well... I have relatively little
> experience in how GDB is designed to handle watchpoints, but it seemed
> that the boundary between the what the target knows and how the core
> uses it provide watchpoint support is pretty hard to find...

The current boundary is the places where breakpoint.c calls the
various target_* methods which return information that only the target
knows.

It is my opinion that breakpoint.c currently tries to know too much
about the target-side implementation details of the watchpoints, and
that introduces unpleasant side effects and unwanted dependencies on
the underlying platforms. One unpleasant side effect is that we only
announce at "continue" time that too many hardware resources were
required; we should have announced that at "watchpoint" time.

In particular, I think that the bookkeeping of the various locations
where watchpoints are inserted should be left to the target. That
would allow, e.g., targets that don't support range watchpoints to
emulate them with multiple watchpoints.