]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fixup PC in tracebacks after exits from down-recursive traces.
authorMike Pall <mike>
Mon, 17 Oct 2011 18:06:04 +0000 (20:06 +0200)
committerMike Pall <mike>
Mon, 17 Oct 2011 18:06:04 +0000 (20:06 +0200)
src/Makefile.dep
src/lj_debug.c

index 3a5667bcd967a9a9878f265ba29d3e01ac84ab94..9c866050e87b5d9b070ff7636e4cf1006ce61830 100644 (file)
@@ -93,7 +93,7 @@ lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
  lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h
 lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
  lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \
- lj_bc.h
+ lj_bc.h lj_jit.h lj_ir.h
 lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
  lj_err.h lj_errmsg.h lj_debug.h lj_state.h lj_frame.h lj_bc.h lj_ff.h \
  lj_ffdef.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h lj_traceerr.h \
index 1c4bac43b6a5742dc634b64407d3674b2decbaae..699fca28c286096e48981abd18db80338e7e0c54 100644 (file)
@@ -14,6 +14,9 @@
 #include "lj_state.h"
 #include "lj_frame.h"
 #include "lj_bc.h"
+#if LJ_HASJIT
+#include "lj_jit.h"
+#endif
 
 /* -- Frames -------------------------------------------------------------- */
 
@@ -49,6 +52,8 @@ cTValue *lj_debug_frame(lua_State *L, int level, int *size)
 static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
 {
   const BCIns *ins;
+  GCproto *pt;
+  BCPos pos;
   lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD);
   if (!isluafunc(fn)) {  /* Cannot derive a PC for non-Lua functions. */
     return NO_BCPOS;
@@ -82,7 +87,16 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
       ins = cframe_pc(cf);
     }
   }
-  return proto_bcpos(funcproto(fn), ins) - 1;
+  pt = funcproto(fn);
+  pos = proto_bcpos(pt, ins) - 1;
+#if LJ_HASJIT
+  if (pos >= pt->sizebc) {  /* Undo the effects of lj_trace_exit for JLOOP. */
+    GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
+    lua_assert(bc_isret(bc_op(ins[-1])));
+    pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
+  }
+#endif
+  return pos;
 }
 
 /* -- Line numbers -------------------------------------------------------- */