Fix PR gdb/19187 (process record over a fork causes internal error)
authorPedro Alves <palves@redhat.com>
Wed, 10 Aug 2016 22:03:29 +0000 (23:03 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 10 Aug 2016 22:03:29 +0000 (23:03 +0100)
Right after a fork is detected, we detach breakpoints from the child
(detach_breakpoints), which calls into target_remove_breakpoint with
inferior_ptid pointing at the child process, but leaves the breakpoint
marked inserted (in the parent).

The problem is that record-full.c always deletes all knowledge of the
breakpoint.  Then when we later really delete the breakpoint from the
parent, we fail the assertion, since the breakpoint is unexpectedly
not found in the record-full.c breakpoint table.

The fix is simply to not forget about the breakpoint if we're
detaching it from a fork child.

gdb/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* record-full.c (record_full_remove_breakpoint): Don't remove the
breakpoint from the record_full_breakpoints VEC if we're detaching
the breakpoint from a fork child.

gdb/testsuite/ChangeLog:
2016-08-10  Pedro Alves  <palves@redhat.com>

PR gdb/19187
* gdb.reverse/waitpid-reverse.exp: Add comment and remove
setup_kfails.

gdb/ChangeLog
gdb/record-full.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.reverse/waitpid-reverse.exp

index bdd28feef95556d87e406a77f39b59fa5a1c01f7..c5ffe4715b85e9be8551cfd34a03629e00c4f01a 100644 (file)
@@ -1,3 +1,10 @@
+2016-08-10  Pedro Alves  <palves@redhat.com>
+
+       PR gdb/19187
+       * record-full.c (record_full_remove_breakpoint): Don't remove the
+       breakpoint from the record_full_breakpoints VEC if we're detaching
+       the breakpoint from a fork child.
+
 2016-08-10  Pedro Alves  <palves@redhat.com>
 
        PR gdb/19187
index 4134f395e6be2768eea01d7f53d572b09aca3a93..37773159a682379ebf6acd6821ea00d406e819a7 100644 (file)
@@ -1731,8 +1731,11 @@ record_full_remove_breakpoint (struct target_ops *ops,
                return ret;
            }
 
-         VEC_unordered_remove (record_full_breakpoint_p,
-                               record_full_breakpoints, ix);
+         if (reason == REMOVE_BREAKPOINT)
+           {
+             VEC_unordered_remove (record_full_breakpoint_p,
+                                   record_full_breakpoints, ix);
+           }
          return 0;
        }
     }
index 1b9ffed384e5f0979de147a10ebfe76fe94349fc..bfd1748fbff61962b1746b83b4bf83374e0d44f9 100644 (file)
@@ -1,3 +1,9 @@
+2016-08-10  Pedro Alves  <palves@redhat.com>
+
+       PR gdb/19187
+       * gdb.reverse/waitpid-reverse.exp: Add comment and remove
+       setup_kfails.
+
 2016-08-09  Pedro Alves  <palves@redhat.com>
            Simon Marchi  <simon.marchi@ericsson.com>
 
index d583953ede75c04cbd0c62116375d906e1beb001..e8a16902682c3a4e3d91961b300ef2e079d7a9b7 100644 (file)
@@ -18,6 +18,8 @@
 #
 # This test tests waitpid syscall for reverse execution.
 #
+# Also serves as regression test for gdb/19187 (recording across a
+# fork).
 
 if ![supports_reverse] {
     return
@@ -40,14 +42,12 @@ gdb_test "break marker2" \
     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
     "set breakpoint at marker2"
 
-setup_kfail "gdb/19187" *-*-*
 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
 
 gdb_test "break marker1" \
     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
     "set breakpoint at marker1"
 
-setup_kfail "gdb/19187" *-*-*
 gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1"
 
 # If the variable was recorded properly on syscall, the old contents (-1)
This page took 0.030726 seconds and 4 git commands to generate.