Re: Regression for watchpoint-fork.exp [Re: [PATCH v3 2/5] PR breakpoints/7143 - Watchpoint does not trigger when first set]

Jan Kratochvil
2014-06-19T17:00:38Z

On Thu, 19 Jun 2014 18:56:46 +0200, Pedro Alves wrote:
> On 06/19/2014 04:02 PM, Pedro Alves wrote:
>
> >> Attaching gzipped gdb.threads/watchpoint-fork-parent-st
> >> from gcc-4.9.0-9.fc21.x86_64.
> >
> > Thanks, I can reproduce it.
>
> Hmm, I suspect this might be related to kernel-side validation
> of DR_CONTROL vs DR0-3, like what we already handle in amd64_linux_prepare_to_resume.
> And indeed this below makes the error go away. Not exactly sure why yet.

Because there is a data watchpoint of size 4 bytes at that DRx slot and it is
being updated by that 'hbreak' unaligned watchpoint (after the data watchpoint
is no longer valid).

But DR_CONTROL is updated only afterwards.

Your patch seems to be right.

Thanks,
Jan

>
> diff --git c/gdb/amd64-linux-nat.c w/gdb/amd64-linux-nat.c
> index 06199af..5972415 100644
> --- c/gdb/amd64-linux-nat.c
> +++ w/gdb/amd64-linux-nat.c
> @@ -415,6 +415,8 @@ amd64_linux_prepare_to_resume (struct lwp_info *lwp)
>
> Ensure DR_CONTROL gets written as the very last register here. */
>
> + amd64_linux_dr_set (lwp->ptid, DR_CONTROL, 0);
> +
> for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
> if (state->dr_ref_count[i] > 0)
> {
>
> --
> Pedro Alves