This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Watchpoint on an unloaded shared library(1)
Hello Joel,
From: Joel Brobecker <brobecker at adacore.com>
Subject: Re: Watchpoint on an unloaded shared library(1)
Date: Mon, 22 Dec 2008 07:27:58 +0400
>> > > 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;
>> }
This does work for me, except one duplication of the codes (that you
may have noticed already):
static void
do_enable_breakpoint (struct breakpoint *bpt, enum bpdisp disposition)
{
int target_resources_ok, other_type_used;
struct value *mark;
if (bpt->type == bp_hardware_breakpoint)
{
int i;
i = hw_breakpoint_used_count ();
target_resources_ok =
TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint,
i + 1, 0);
if (target_resources_ok == 0)
error (_("No hardware breakpoint support in the target."));
else if (target_resources_ok < 0)
error (_("Hardware breakpoints used exceeds limit."));
}
That should be done in update_watchpoint.
I would try to address incapabilities on PPC after those codes are
committed. Thank you for taking care of it!
I wonder if I should greet for Christmas here...
--
Emi SUZUKI / emi-suzuki at tjsys.co.jp