Watchpoint resource accounting broken (Re: [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type)

Edjunior Barbosa Machado emachado@linux.vnet.ibm.com
Mon Sep 12 15:23:00 GMT 2011


On 09/12/2011 12:03 PM, Ulrich Weigand wrote:
> However, update_watchpoint relies on having the watchpoint under
> investigation be on the breakpoint list; see the comment:
> 
>               /* We need to determine how many resources are already
>                  used for all other hardware watchpoints plus this one
>                  to see if we still have enough resources to also fit
>                  this watchpoint in as well.  To guarantee the
>                  hw_watchpoint_used_count call below counts this
>                  watchpoint, make sure that it is marked as a hardware
>                  watchpoint.  */
>               if (b->base.type == bp_watchpoint)
>                 b->base.type = bp_hardware_watchpoint;
> 
>               i = hw_watchpoint_used_count (b->base.type, &other_type_used);
>               target_resources_ok = target_can_use_hardware_watchpoint
>                     (b->base.type, i, other_type_used);
> 
> Note how just "i", the result of hw_watchpoint_used_count, is passed to
> target_can_use_hardware_watchpoint -- this works only if the current
> watchpoint is on the list that hw_watchpoint_used_count iterates over.

I noticed this problem too and was considering use "i + reg_cnt" instead
of only "i" when calling hw_watchpoint_used_count() (actually, I saw gdb
used to use this previously).
However, with this change, due to the same problem with the watchpoint
added to breakpoint list that Ulrich mentioned, watchpoints added before
run the inferior will not work.

-- 
Edjunior



More information about the Gdb-patches mailing list