This is the mail archive of the gdb-patches@sourceware.org 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: RFC: next/finish/etc -vs- exceptions


>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> The new field `tp->control.exception_resume_breakpoint' should be
Jan> probably handled by existing save_infcall_control_state,
Jan> restore_infcall_control_state and discard_infcall_control_state
Jan> somehow like step_resume_breakpoint is.

Thanks for the test case.

Here is what I am testing.

It just mirrors the existing step_resume_breakpoint code.
I think that this is the right thing to do -- stash any
exception-related breakpoint while doing the infcall, then restore it
if the infcall succeeds.

Tom

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 1bc00a4..f72a18d 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6379,6 +6379,7 @@ save_infcall_control_state (void)
   inf_status->inferior_control = inf->control;
 
   tp->control.step_resume_breakpoint = NULL;
+  tp->control.exception_resume_breakpoint = NULL;
 
   /* Save original bpstat chain to INF_STATUS; replace it in TP with copy of
      chain.  If caller's caller is walking the chain, they'll be happier if we
@@ -6428,6 +6429,10 @@ restore_infcall_control_state (struct infcall_control_state *inf_status)
   if (tp->control.step_resume_breakpoint)
     tp->control.step_resume_breakpoint->disposition = disp_del_at_next_stop;
 
+  if (tp->control.exception_resume_breakpoint)
+    tp->control.exception_resume_breakpoint->disposition
+      = disp_del_at_next_stop;
+
   /* Handle the bpstat_copy of the chain.  */
   bpstat_clear (&tp->control.stop_bpstat);
 
@@ -6476,6 +6481,10 @@ discard_infcall_control_state (struct infcall_control_state *inf_status)
     inf_status->thread_control.step_resume_breakpoint->disposition
       = disp_del_at_next_stop;
 
+  if (inf_status->thread_control.exception_resume_breakpoint)
+    inf_status->thread_control.exception_resume_breakpoint->disposition
+      = disp_del_at_next_stop;
+
   /* See save_infcall_control_state for info on stop_bpstat. */
   bpstat_clear (&inf_status->thread_control.stop_bpstat);
 
diff --git a/gdb/testsuite/gdb.cp/nextoverthrow.cc b/gdb/testsuite/gdb.cp/nextoverthrow.cc
index b25cb34..c3da516 100644
--- a/gdb/testsuite/gdb.cp/nextoverthrow.cc
+++ b/gdb/testsuite/gdb.cp/nextoverthrow.cc
@@ -19,8 +19,9 @@
 
 using namespace std;
 
-void dummy ()
+int dummy ()
 {
+  return 0;
 }
 
 class NextOverThrowDerivates
@@ -89,6 +90,18 @@ public:
     function1 (val);		// until here
   }
 
+  void resumebpt (int val)
+  {
+    try
+      {
+	throw val;
+      }
+    catch (int x)
+      {
+	dummy ();
+      }
+  }
+
 };
 NextOverThrowDerivates next_cases;
 
@@ -198,6 +211,18 @@ int main ()
       testval = val;		// End: advance
     }
 
+  // Test of "resumebpt".
+  try
+    {
+      next_cases.resumebpt (10);	// Start: resumebpt
+      next_cases.resumebpt (11);	// Second: resumebpt
+    }
+  catch (int val)
+    {
+      dummy ();
+      testval = val;		// End: resumebpt
+    }
+
   testval = 32;			// done
 }
 
diff --git a/gdb/testsuite/gdb.cp/nextoverthrow.exp b/gdb/testsuite/gdb.cp/nextoverthrow.exp
index 960ea0d..c19674f 100644
--- a/gdb/testsuite/gdb.cp/nextoverthrow.exp
+++ b/gdb/testsuite/gdb.cp/nextoverthrow.exp
@@ -149,5 +149,14 @@ gdb_test "advance $line" ".*" "advance-over-throw"
 tbreak_and_cont "End: advance"
 verify_testval "pre-check - advance" 8
 
+tbreak_and_cont "Start: resumebpt"
+gdb_test "tbreak _Unwind_RaiseException"
+gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
+gdb_test "finish" "Run till exit .*"
+gdb_test {set $retpc=$pc}
+gdb_test {break *$retpc if dummy ()}
+tbreak_and_cont "Second: resumebpt"
+gdb_test "next"
+
 tbreak_and_cont "done"
 verify_testval "post-check - advance" 9


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