Fix regressions caused by thread-specific breakpoint deletion.
authorPedro Alves <palves@redhat.com>
Thu, 19 Sep 2013 14:45:33 +0000 (14:45 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 19 Sep 2013 14:45:33 +0000 (14:45 +0000)
The recent change to make GDB auto-delete thread-specific breakpoints
when the corresponding thread is deleted
(https://sourceware.org/ml/gdb-patches/2013-09/msg00038.html) caused
gdb.base/nextoverexit.exp to regress.

    Breakpoint 1, main () at .../gdb/testsuite/gdb.base/nextoverexit.c:21
    21        exit (0);
    (gdb) next
    [Inferior 1 (process 25208) exited normally]
    Thread-specific breakpoint -5 deleted - thread 1 is gone.
    Thread-specific breakpoint -6 deleted - thread 1 is gone.
    Thread-specific breakpoint -7 deleted - thread 1 is gone.
    Thread-specific breakpoint 0 deleted - thread 1 is gone.
    (gdb) FAIL: gdb.base/nextoverexit.exp: next over exit (the program exited)

We shouldn't be seeing this for internal or momentary breakpoints.  In
fact, we shouldn't even be trying to delete them, as whatever created
them will take care or it, and therefore it's dangerous to delete them
behind the creator's back.

I thought it'd still be good to tag thread-specific internal/momentary
breakpoints such that we'll no longer try to keep them insert in the
target, as they'll cause stops and thread hops in other threads, so I
tried disabling them instead.  That caused a problem when following a
child fork, and detaching from the parent, as we try to reset the
step-resume etc. breakpoints to the new child's thread
(breakpoint_re_set_thread), after the parent thread is already gone
(and the breakpoints are marked disabled).  I fixed that by
re-enabling internal/momentary breakpoints there, but, that didn't
feel super safe either (maybe we'd need a new flag in struct
breakpoint instead, to tag the thread-specific breakpoint as "not to
be inserted").  It felt like I was heading down a design rat hole,
and, other things will usually delete internal/momentary breakpoints
soon enough, so I left that little optimization for some other day.

So, internal/momentary breakpoints are no longer deleted/disabled at
all, and we end up with a one-liner fix.

Tested on x86_64 Fedora 17.

gdb/
2013-09-19  Pedro Alves  <palves@redhat.com>

* breakpoint.c (remove_threaded_breakpoints): Skip non-user
breakpoints.

gdb/ChangeLog
gdb/breakpoint.c

index 738d757b1f16d0784ae35e0a7202d9a49ab685dd..a71cc5ce9b7750f5d5151326102c433a37774452 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-19  Pedro Alves  <palves@redhat.com>
+
+       * breakpoint.c (remove_threaded_breakpoints): Skip non-user
+       breakpoints.
+
 2013-09-19  Pedro Alves  <palves@redhat.com>
            Thomas Schwinge  <thomas@codesourcery.com>
            Yue Lu  <hacklu.newborn@gmail.com>
index 734dfd6c114af743a3ac34f17270bd244c86cd27..c132e24aa6c69d40f4fe263ad9df8cf4b1d292c2 100644 (file)
@@ -2938,7 +2938,7 @@ remove_threaded_breakpoints (struct thread_info *tp, int silent)
 
   ALL_BREAKPOINTS_SAFE (b, b_tmp)
     {
-      if (b->thread == tp->num)
+      if (b->thread == tp->num && user_breakpoint_p (b))
        {
          b->disposition = disp_del_at_next_stop;