[Quipu-dev] quipu/quipu: Small fixes in backtrace generation

Back to archive index

scmno****@osdn***** scmno****@osdn*****
Wed Jun 20 01:40:04 JST 2018


changeset 7ded2ec411d9 in quipu/quipu
details: http://hg.osdn.jp/view/quipu/quipu?cmd=changeset;node=7ded2ec411d9
user: Agustina Arzille <avarz****@riseu*****>
date: Tue Jun 19 13:39:55 2018 -0300
description: Small fixes in backtrace generation

diffstat:

 compiler.cpp     |   2 +-
 continuation.cpp |  24 +++++++++++++++++-------
 interp.cpp       |  14 ++++++++++----
 3 files changed, 28 insertions(+), 12 deletions(-)

diffs (84 lines):

diff -r 3162caa55d5c -r 7ded2ec411d9 compiler.cpp
--- a/compiler.cpp	Tue Jun 19 12:34:31 2018 -0300
+++ b/compiler.cpp	Tue Jun 19 13:39:55 2018 -0300
@@ -2413,7 +2413,7 @@
         as_int (stack[interp->cur_frame - 3]) - 1];
       r_stkend(1) = retval;
 
-      lastf = interp->cur_frame - ((fn & EXTRA_BIT) ? intobj (fn) : 0);
+      lastf = interp->cur_frame - ((fn & EXTRA_BIT) ? as_int (fn) : 0);
       nargs = as_int (stack[lastf - 3]);
       bp = lastf - (interpreter::frame_size + nargs);
       fn = stack[bp - 1];
diff -r 3162caa55d5c -r 7ded2ec411d9 continuation.cpp
--- a/continuation.cpp	Tue Jun 19 12:34:31 2018 -0300
+++ b/continuation.cpp	Tue Jun 19 13:39:55 2018 -0300
@@ -71,15 +71,25 @@
   if (!continuation_p (cn))
     interp->raise2 ("arg-error", "iter-next: argument must be a generator");
 
-  cont_state state (interp);
   continuation *cnp = as_continuation (cn);
 
-  interp->stkobj = cnp->argv;
-  interp->stack = &xaref(interp->stkobj, 0);
-  interp->cur_frame = 0;
-  interp->stkend = interp->stack + cnp->sframes[1] + cnp->sp_diff;
-  object ret = call_continuation (interp, cn);
-  qp_return (continuation_p (ret) ? ret : NIL);
+  try
+    { // XXX: Implement chained backtraces instead.
+      cont_state state (interp);
+      interp->stkobj = cnp->argv;
+      interp->stack = &xaref(interp->stkobj, 0);
+      interp->cur_frame = 0;
+      interp->stkend = interp->stack + cnp->sframes[1] + cnp->sp_diff;
+      object ret = call_continuation (interp, cn);
+      qp_return (continuation_p (ret) ? ret : NIL);
+    }
+  catch (...)
+    {
+      if (interp->throw_frame != 0)
+        interp->throw_frame = interp->cur_frame;
+
+      throw;
+    }
 }
 
 continuation* continuation::alloc_raw ()
diff -r 3162caa55d5c -r 7ded2ec411d9 interp.cpp
--- a/interp.cpp	Tue Jun 19 12:34:31 2018 -0300
+++ b/interp.cpp	Tue Jun 19 13:39:55 2018 -0300
@@ -469,15 +469,20 @@
 object interpreter::stacktrace (uint32_t frame)
 {
   valref ret (this, NIL);
-  for (; frame > 0; frame = as_int (this->stack[frame - 4]))
+  while (frame > 0)
     {
       int size = as_int (this->stack[frame - 3]) + 1;
       int bp = frame - interpreter::frame_size - size;
       object caller = this->stack[bp];
 
-      if ((caller & EXTRA_BIT) || (fct_p (caller) &&
-          as_fct(caller)->flagged_p (function::artificial_flag)))
-        continue;
+      if ((caller & EXTRA_BIT) != 0)
+        {
+          frame -= as_int (caller);
+          continue;
+        }
+      else if (fct_p (caller) &&
+          as_fct(caller)->flagged_p (function::artificial_flag))
+        break;
 
       object vec = alloc_array (this, size, NIL);
 
@@ -492,6 +497,7 @@
             NIL : this->stack[bp + i];
 
       *ret = cons::make (this, vec, *ret);
+      frame = as_int (this->stack[frame - 4]);
     }
 
   return (this->retval = *ret);




More information about the Quipu-dev mailing list
Back to archive index