* infrun.c (handle_inferior_event)
authorTom Tromey <tromey@redhat.com>
Mon, 11 Jun 2012 15:15:06 +0000 (15:15 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 11 Jun 2012 15:15:06 +0000 (15:15 +0000)
<BPSTAT_WHAT_SET_LONGJMP_RESUME>: Don't delete the step-resume
breakpoint.
<BPSTAT_WHAT_CLEAR_LONGJMP_RESUME>: Remove longjmp logic; use
exception logic in all cases.  Update comments.
(insert_longjmp_resume_breakpoint): Set the exception resume
breakpoint.
testsuite
* gdb.base/longjmp.c (hidden_longjmp): Move expected catch
location...
(main): ...here.

gdb/ChangeLog
gdb/infrun.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/longjmp.c

index 8480c7841f32fc41227ba34fd3c8d5895898205d..4690790ae168498ad9e286107c6d6b80cb81f15a 100644 (file)
@@ -1,3 +1,13 @@
+2012-06-11  Tom Tromey  <tromey@redhat.com>
+
+       * infrun.c (handle_inferior_event)
+       <BPSTAT_WHAT_SET_LONGJMP_RESUME>: Don't delete the step-resume
+       breakpoint.
+       <BPSTAT_WHAT_CLEAR_LONGJMP_RESUME>: Remove longjmp logic; use
+       exception logic in all cases.  Update comments.
+       (insert_longjmp_resume_breakpoint): Set the exception resume
+       breakpoint.
+
 2012-06-11  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * mips-tdep.c (mips_push_dummy_code): Handle microMIPS code.
index 210cdd7f49aec4d99ef76a91c5a8a34128622f96..b98e379d9b241fbac1ad8feb1e20e5fb9a953dca 100644 (file)
@@ -4423,10 +4423,6 @@ process_event_stop_test:
                return;
              }
 
-           /* We're going to replace the current step-resume breakpoint
-              with a longjmp-resume breakpoint.  */
-           delete_step_resume_breakpoint (ecs->event_thread);
-
            /* Insert a breakpoint at resume address.  */
            insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
          }
@@ -4436,62 +4432,59 @@ process_event_stop_test:
        return;
 
       case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME:
-        if (debug_infrun)
-         fprintf_unfiltered (gdb_stdlog,
-                             "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
+       {
+         struct frame_info *init_frame;
 
-       if (what.is_longjmp)
-         {
-           gdb_assert (ecs->event_thread->control.step_resume_breakpoint
-                       != NULL);
-           delete_step_resume_breakpoint (ecs->event_thread);
-         }
-       else
-         {
-           /* There are several cases to consider.
+         /* There are several cases to consider.
 
-              1. The initiating frame no longer exists.  In this case
-              we must stop, because the exception has gone too far.
+            1. The initiating frame no longer exists.  In this case
+            we must stop, because the exception or longjmp has gone
+            too far.
 
-              2. The initiating frame exists, and is the same as the
-              current frame.  We stop, because the exception has been
-              caught.
+            2. The initiating frame exists, and is the same as the
+            current frame.  We stop, because the exception or longjmp
+            has been caught.
 
-              3. The initiating frame exists and is different from
-              the current frame.  This means the exception has been
-              caught beneath the initiating frame, so keep going.  */
-           struct frame_info *init_frame
-             = frame_find_by_id (ecs->event_thread->initiating_frame);
+            3. The initiating frame exists and is different from the
+            current frame.  This means the exception or longjmp has
+            been caught beneath the initiating frame, so keep
+            going.  */
 
-           gdb_assert (ecs->event_thread->control.exception_resume_breakpoint
-                       != NULL);
-           delete_exception_resume_breakpoint (ecs->event_thread);
+         if (debug_infrun)
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
 
-           if (init_frame)
-             {
-               struct frame_id current_id
-                 = get_frame_id (get_current_frame ());
-               if (frame_id_eq (current_id,
-                                ecs->event_thread->initiating_frame))
-                 {
-                   /* Case 2.  Fall through.  */
-                 }
-               else
-                 {
-                   /* Case 3.  */
-                   keep_going (ecs);
-                   return;
-                 }
-             }
+         init_frame = frame_find_by_id (ecs->event_thread->initiating_frame);
 
-           /* For Cases 1 and 2, remove the step-resume breakpoint,
-              if it exists.  */
-           delete_step_resume_breakpoint (ecs->event_thread);
-         }
+         gdb_assert (ecs->event_thread->control.exception_resume_breakpoint
+                     != NULL);
+         delete_exception_resume_breakpoint (ecs->event_thread);
 
-       ecs->event_thread->control.stop_step = 1;
-       print_end_stepping_range_reason ();
-       stop_stepping (ecs);
+         if (init_frame)
+           {
+             struct frame_id current_id
+               = get_frame_id (get_current_frame ());
+             if (frame_id_eq (current_id,
+                              ecs->event_thread->initiating_frame))
+               {
+                 /* Case 2.  Fall through.  */
+               }
+             else
+               {
+                 /* Case 3.  */
+                 keep_going (ecs);
+                 return;
+               }
+           }
+
+         /* For Cases 1 and 2, remove the step-resume breakpoint,
+            if it exists.  */
+         delete_step_resume_breakpoint (ecs->event_thread);
+
+         ecs->event_thread->control.stop_step = 1;
+         print_end_stepping_range_reason ();
+         stop_stepping (ecs);
+       }
        return;
 
       case BPSTAT_WHAT_SINGLE:
@@ -5461,17 +5454,17 @@ insert_step_resume_breakpoint_at_caller (struct frame_info *next_frame)
 static void
 insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  /* There should never be more than one step-resume or longjmp-resume
-     breakpoint per thread, so we should never be setting a new
+  /* There should never be more than one longjmp-resume breakpoint per
+     thread, so we should never be setting a new
      longjmp_resume_breakpoint when one is already active.  */
-  gdb_assert (inferior_thread ()->control.step_resume_breakpoint == NULL);
+  gdb_assert (inferior_thread ()->control.exception_resume_breakpoint == NULL);
 
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
                        "infrun: inserting longjmp-resume breakpoint at %s\n",
                        paddress (gdbarch, pc));
 
-  inferior_thread ()->control.step_resume_breakpoint =
+  inferior_thread ()->control.exception_resume_breakpoint =
     set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume);
 }
 
index 3cba1480b33a5e10ec0cb757b621ae58cf000a80..c7b4272f483e5d137e812f4a946fe8b75a725767 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-11  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.base/longjmp.c (hidden_longjmp): Move expected catch
+       location...
+       (main): ...here.
+
 2012-06-07  Yao Qi  <yao@codesourcery.com>
 
        * gdb.trace/strace.exp: Shorten some too-long lines.
index e9e0e56d9f36b3eb7dddb2f580d9ae8f134bd181..b203a8d6c8d44fa6d87010ceeac7f3ede52d3f27 100644 (file)
@@ -33,7 +33,7 @@ call_longjmp (jmp_buf *buf)
 void
 hidden_longjmp (void)
 {
-  if (setjmp (env) == 0) /* longjmp caught */
+  if (setjmp (env) == 0)
     {
       call_longjmp (&env);
     }
@@ -75,6 +75,8 @@ main ()
   /* Pattern 3 - setjmp/longjmp inside stepped-over function.  */
   hidden_longjmp (); /* patt3 */
 
+  i = 77; /* longjmp caught */
+
   i = 3; /* patt_end3.  */
 
   return 0;