Re: [RFA 2/3] Demote to sw watchpoint only in update_watchpoint

Pedro Alves
2011-05-05T15:21:41Z

On Thursday 05 May 2011 12:10:05, Ulrich Weigand wrote:
> Pedro Alves wrote:
> > On Wednesday 04 May 2011 23:20:48, Thiago Jung Bauermann wrote:
> > > Pedro's suggestion:
> > >
> > > 1. The inferior is stopped and software bp_locations (both breakpoints
> > > and watchpoints) are removed. Hardware ones stay in place.
> > > 2. The user asks for a new watchpoint.
> > > 3. GDB evaluates the expression and creates the bp_locations.
> > > 4. GDB tries to insert the bp_locations as hw watches. If that fails,
> > > then converts to sw and registers the watchpoint for insertion.
> > > 5. The user asks the inferior to be continued.
> > > 6. GDB inserts sw breakpoints and watchpoints and resumes the inferior.
> >
> > Either that or try keep hardware breakpoints and watchpoints uninserted,
> > and insert them just before 4. This variant is a bit safer in case GDB crashes,
> > but is a bit less efficient in case there are many watchpoints. But then
> > again we already remove/insert them all at each step, so that is kind of moot.
> > I've no real preference on which. This is a minor detail in the grand scheme
> > from my perspective.
>
> One thing I'm wondering about is the comment before update_watchpoints:
>
> Even with `set breakpoint always-inserted on' the watchpoints are
> removed + inserted on each stop here Normal breakpoints must
> never be removed because they might be missed by a running thread
> when debugging in non-stop mode. On the other hand, hardware
> watchpoints (is_hardware_watchpoint; processed here) are specific
> to each LWP since they are stored in each LWP's hardware debug
> registers. Therefore, such LWP must be stopped first in order to
> be able to modify its hardware watchpoints.
> [etc.]
>
> Is this still valid, and would it affect this current discussion if so?

This is stale. Watchpoints are no longer removed/inserted
on each stop with always-inserted on. It needed fixing for watchpoints+non-stop.
linux gdbserver copes with inserting breakpoints/watchpoints when
threads are running. Native linux doesn't, but that just it doesn't really
fully support watchpoints in non-stop mode currently.

--
Pedro Alves