Re: Watchpoint on an unloaded shared library(1)

Joel Brobecker
2008-12-22T03:28:58Z

> > > How about replace all the code that's inside
> > >
> > > if (bpt->type == bp_watchpoint ||
> > > bpt->type == bp_hardware_watchpoint ||
> > > bpt->type == bp_read_watchpoint ||
> > > bpt->type == bp_access_watchpoint)
> > > {
> > > [re-create a lot of stuff for our watchpoint...]
> > >
> > > by a call to update_watchpoint (bpt, 1)? Would that work in your case?
> >
> > It works without merging the missing code each other, as long as we
> > don't have to care the hardware watchpoint resource count here: if the
> > user sets other watchpoints while the disabled hardware watchpoints
> > exist, re-enabling the disabled ones might fail out of the shortage of
> > resources.
>
> That's a good point.

As it turns out, I think we just got lucky thanks to Jan:
http://www.sourceware.org/ml/gdb-patches/2008-12/msg00363.html.

update_watchpoint now automagically downgrades hardware watchpoints
into a software watchpoints if needed. So we can get rid of that part.
So all we have to do, now is:

> if (bpt->type == bp_watchpoint ||
> bpt->type == bp_hardware_watchpoint ||
> bpt->type == bp_read_watchpoint ||
> bpt->type == bp_access_watchpoint)
> {
> struct gdb_exception e;
>
> TRY_CATCH (e, RETURN_MASK_ALL)
> {
> update_watchpoint (...);
> }
> if (e.reason < 0)
> {
> exception_fprintf (gdb_strerr, e, "Cannot enable watchpoint %d:",
> b->number);
> return;
> }

--
Joel