2012-03-02 Tom Tromey <tromey@redhat.com>
authorPedro Alves <palves@redhat.com>
Fri, 2 Mar 2012 19:26:10 +0000 (19:26 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 2 Mar 2012 19:26:10 +0000 (19:26 +0000)
    Pedro Alves  <palves@redhat.com>

PR breakpoints/13776:
* breakpoint.c (breakpoint_init_inferior): Delete step-resume
breakpoints.
(delete_longjmp_breakpoint_at_next_stop): New.
* breakpoint.h (delete_longjmp_breakpoint_at_next_stop): Declare.
* target.c (generic_mourn_inferior): Call mark_breakpoints_out
before deleting the inferior.  Add comments.
* thread.c (clear_thread_inferior_resources): Don't delete lonjmp
breakpoints immediately, but only on next stop.  Move that code
next to where we mark other breakpoints for deletion.

gdb/ChangeLog
gdb/breakpoint.c
gdb/breakpoint.h
gdb/target.c
gdb/thread.c

index 2ef95916d29b9ac965d90c754d21d9fa3847b522..41d0277a53ffbc8e1c690774cbf1938cd6e054a5 100644 (file)
@@ -1,3 +1,17 @@
+2012-03-02  Tom Tromey  <tromey@redhat.com>
+           Pedro Alves  <palves@redhat.com>
+
+       PR breakpoints/13776:
+       * breakpoint.c (breakpoint_init_inferior): Delete step-resume
+       breakpoints.
+       (delete_longjmp_breakpoint_at_next_stop): New.
+       * breakpoint.h (delete_longjmp_breakpoint_at_next_stop): Declare.
+       * target.c (generic_mourn_inferior): Call mark_breakpoints_out
+       before deleting the inferior.  Add comments.
+       * thread.c (clear_thread_inferior_resources): Don't delete lonjmp
+       breakpoints immediately, but only on next stop.  Move that code
+       next to where we mark other breakpoints for deletion.
+
 2012-03-02  Joel Brobecker  <brobecker@adacore.com>
 
        * mips-linux-nat.c (mips_linux_read_description): Add missing i18n
index ce35da29edc8312aad4a62e00df714475e2e42b1..3decd9205279128a03995f41c50bd500f531a101 100644 (file)
@@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context)
           (gdb) tar rem :9999     # remote Windows gdbserver.
        */
 
+      case bp_step_resume:
+
+       /* Also remove step-resume breakpoints.  */
+
        delete_breakpoint (b);
        break;
 
@@ -6624,6 +6628,19 @@ delete_longjmp_breakpoint (int thread)
       }
 }
 
+void
+delete_longjmp_breakpoint_at_next_stop (int thread)
+{
+  struct breakpoint *b, *b_tmp;
+
+  ALL_BREAKPOINTS_SAFE (b, b_tmp)
+    if (b->type == bp_longjmp || b->type == bp_exception)
+      {
+       if (b->thread == thread)
+         b->disposition = disp_del_at_next_stop;
+      }
+}
+
 void
 enable_overlay_breakpoints (void)
 {
index 7e8c597c245179e2e249a97669cd41dcce1c3622..5b5172ee6b4f77ad63b67e24ed5021bc3afcc527 100644 (file)
@@ -1254,6 +1254,9 @@ extern void set_longjmp_breakpoint (struct thread_info *tp,
                                    struct frame_id frame);
 extern void delete_longjmp_breakpoint (int thread);
 
+/* Mark all longjmp breakpoints from THREAD for later deletion.  */
+extern void delete_longjmp_breakpoint_at_next_stop (int thread);
+
 extern void enable_overlay_breakpoints (void);
 extern void disable_overlay_breakpoints (void);
 
index 1f408f6f5756d4131036b741e4e0b24572a21b5b..d29d37a1f0d6c1de7ce21f2a776a26d5bbe2a28f 100644 (file)
@@ -3583,13 +3583,22 @@ generic_mourn_inferior (void)
   ptid = inferior_ptid;
   inferior_ptid = null_ptid;
 
+  /* Mark breakpoints uninserted in case something tries to delete a
+     breakpoint while we delete the inferior's threads (which would
+     fail, since the inferior is long gone).  */
+  mark_breakpoints_out ();
+
   if (!ptid_equal (ptid, null_ptid))
     {
       int pid = ptid_get_pid (ptid);
       exit_inferior (pid);
     }
 
+  /* Note this wipes step-resume breakpoints, so needs to be done
+     after exit_inferior, which ends up referencing the step-resume
+     breakpoints through clear_thread_inferior_resources.  */
   breakpoint_init_inferior (inf_exited);
+
   registers_changed ();
 
   reopen_exec_file ();
index 22d8b236b95bd1e10e39252a42242ff82fc02d00..97f283cc6be56e2ff8851b82e98c0c980c43666c 100644 (file)
@@ -113,12 +113,12 @@ clear_thread_inferior_resources (struct thread_info *tp)
       tp->control.exception_resume_breakpoint = NULL;
     }
 
+  delete_longjmp_breakpoint_at_next_stop (tp->num);
+
   bpstat_clear (&tp->control.stop_bpstat);
 
   do_all_intermediate_continuations_thread (tp, 1);
   do_all_continuations_thread (tp, 1);
-
-  delete_longjmp_breakpoint (tp->num);
 }
 
 static void