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

Pedro Alves
2011-09-13T14:42:35Z

On Tuesday 13 September 2011 15:35:28, Edjunior Barbosa Machado wrote:
> On 09/13/2011 09:55 AM, Pedro Alves wrote:

> > Can you expand on this? I don't think I'm understanding that problem.
>
> The problem of setting watches before run the inferior occurs because
> update_watchpoint() expect that the watchpoint being parsed shouldn't be
> in the breakpoint_chain.
>
> When you adds the watchpoint it passes through update_watchpoint() the
> first time without reparsing it, but it adds the watch to the
> breakpoint_chain right after (in install_breakpoint()). Then, after
> start the inferior, when running update_watchpoint() again,
> hw_watchpoint_used_count() will count this watch previously added and
> reparse will not evaluate the available resources properly.
> Moreover, I've noticed it doesn't occur on x86 since
> target_can_use_hardware_watchpoint() (i386_can_use_hw_breakpoint())
> always returns 1, but affects archs such as ppc64. This problem in
> specific can be seen on gdb.base/watchpoint-hw.exp testcase.
>
> By the way, had the chance to retest your new patch on ppc64 and it
> seems to fix several issues related to watchpoints, including the
> failure pointed by gdb.base/watchpoint-hw.exp.

Ah, okay. I thought you were describing some other problem. That
happens if we just always added the current watchpoint's resources
in addition to the resources of the watchpoints already listed, because
we would count the same breakpoint twice in some paths.

Waiting on Ulrich (or anyone else) to comment then.

--
Pedro Alves