summaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-10-17 20:06:04 +0200
committerMike Pall <mike>2011-10-17 20:06:04 +0200
commitf50075a9d71bcd2a19029d5bbf1d1d2af6c90bd6 (patch)
treee6ba12b6b3fcef71851a3e41a6608b2453fef698 /src/lj_debug.c
parente5f310eefac2e2b885082256fa39688efabba0c2 (diff)
downloadluajit2-f50075a9d71bcd2a19029d5bbf1d1d2af6c90bd6.tar.gz
Fixup PC in tracebacks after exits from down-recursive traces.
Diffstat (limited to 'src/lj_debug.c')
-rw-r--r--src/lj_debug.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index 1c4bac43..699fca28 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -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 -------------------------------------------------------- */