changeset 10210:752f349052a2

ensure correct backtraces after error in unwind_protect
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 27 Jan 2010 18:24:39 +0100
parents ea0d83b4470b
children 1ca904d74f78
files src/ChangeLog src/pt-eval.cc
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Jan 27 13:47:02 2010 +0100
+++ b/src/ChangeLog	Wed Jan 27 18:24:39 2010 +0100
@@ -1,3 +1,8 @@
+2010-01-27  Jaroslav Hajek  <highegg@gmail.com>
+
+	* pt-eval.cc (do_unwind_protect_cleanup_code): Save
+	current_statement and restore it after cleanup block.
+
 2010-01-27  Jaroslav Hajek  <highegg@gmail.com>
 
 	* oct-parse.yy (validate_matrix_row): New static helper func.
--- a/src/pt-eval.cc	Wed Jan 27 13:47:02 2010 +0100
+++ b/src/pt-eval.cc	Wed Jan 27 18:24:39 2010 +0100
@@ -901,6 +901,11 @@
   frame.protect_var (error_state);
   error_state = 0;
 
+  // We want to preserve the last statement indicator for possible
+  // backtracking.
+  frame.add_fcn (octave_call_stack::set_statement, 
+                 octave_call_stack::current_statement ());
+
   // Similarly, if we have seen a return or break statement, allow all
   // the cleanup code to run before returning or handling the break.
   // We don't have to worry about continue statements because they can
@@ -956,9 +961,9 @@
   // Otherwise, set it back to what it was before.
 
   if (error_state)
-    frame.discard_top ();
+    frame.discard_top (2);
   else
-    frame.run_top ();
+    frame.run_top (2);
 
   frame.run ();
 }