This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Don't delete local watchpoints just because a different thread stopped.

On Thu, Nov 19, 2009 at 02:07:01AM +0000, Pedro Alves wrote:
> One could even come up with a test case where the current
> frame id on this other thread does happen to be in the
> frame chain.  Shouldn't be hard to trigger if the threads
> are running the same function --- GDB can then mistakenly
> try to extract a new current watchpoint value on the wrong
> thread context.

I hope your threads have different stacks :-)  So I don't think this
case happens.

> Index: src/gdb/breakpoint.h
> ===================================================================
> --- src.orig/gdb/breakpoint.h	2009-11-19 01:10:05.000000000 +0000
> +++ src/gdb/breakpoint.h	2009-11-19 01:10:16.000000000 +0000
> @@ -457,6 +457,10 @@ struct breakpoint
>         should be evaluated on the outermost frame.  */
>      struct frame_id watchpoint_frame;
> +    /* Holds the thread which identifies the frame this watchpoint
> +       should be considered in scope for, or -1 if don't care.  */
> +    int watchpoint_thread;
> +
>      /* For hardware watchpoints, the triggered status according to the
>         hardware.  */
>      enum watchpoint_triggered watchpoint_triggered;

Why not just use a ptid?  If the answer has to do with ptid reuse,
then we ought to delete the watchpoint before that comes up - anyway,
at least deserves a comment of what units this is in.

> @@ -1004,6 +1028,12 @@ update_watchpoint (struct breakpoint *b,
>    bpstat bs;
>    struct program_space *frame_pspace;
> +  /* If this is a local watchpoint, we only want to check if the
> +     watchpoint frame is in scope if the current thread is the thread
> +     that was used to create the watchpoint.  */
> +  if (!watchpoint_thread_match (b))
> +    return;
> +
>    /* We don't free locations.  They are stored in bp_location array and
>       update_global_locations will eventually delete them and remove
>       breakpoints if needed.  */

For all-stop, do we want to check whenever the watchpoint's thread is

Daniel Jacobowitz

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]