diff options
| -rw-r--r-- | src/Makefile.dep | 2 | ||||
| -rw-r--r-- | src/lj_debug.c | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index 3a5667bc..9c866050 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
| @@ -93,7 +93,7 @@ lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | |||
| 93 | lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h | 93 | lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h |
| 94 | lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 94 | lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
| 95 | lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ | 95 | lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ |
| 96 | lj_bc.h | 96 | lj_bc.h lj_jit.h lj_ir.h |
| 97 | lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 97 | lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
| 98 | lj_err.h lj_errmsg.h lj_debug.h lj_state.h lj_frame.h lj_bc.h lj_ff.h \ | 98 | lj_err.h lj_errmsg.h lj_debug.h lj_state.h lj_frame.h lj_bc.h lj_ff.h \ |
| 99 | lj_ffdef.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h lj_traceerr.h \ | 99 | lj_ffdef.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h lj_traceerr.h \ |
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 @@ | |||
| 14 | #include "lj_state.h" | 14 | #include "lj_state.h" |
| 15 | #include "lj_frame.h" | 15 | #include "lj_frame.h" |
| 16 | #include "lj_bc.h" | 16 | #include "lj_bc.h" |
| 17 | #if LJ_HASJIT | ||
| 18 | #include "lj_jit.h" | ||
| 19 | #endif | ||
| 17 | 20 | ||
| 18 | /* -- Frames -------------------------------------------------------------- */ | 21 | /* -- Frames -------------------------------------------------------------- */ |
| 19 | 22 | ||
| @@ -49,6 +52,8 @@ cTValue *lj_debug_frame(lua_State *L, int level, int *size) | |||
| 49 | static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) | 52 | static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) |
| 50 | { | 53 | { |
| 51 | const BCIns *ins; | 54 | const BCIns *ins; |
| 55 | GCproto *pt; | ||
| 56 | BCPos pos; | ||
| 52 | lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); | 57 | lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); |
| 53 | if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ | 58 | if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ |
| 54 | return NO_BCPOS; | 59 | return NO_BCPOS; |
| @@ -82,7 +87,16 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) | |||
| 82 | ins = cframe_pc(cf); | 87 | ins = cframe_pc(cf); |
| 83 | } | 88 | } |
| 84 | } | 89 | } |
| 85 | return proto_bcpos(funcproto(fn), ins) - 1; | 90 | pt = funcproto(fn); |
| 91 | pos = proto_bcpos(pt, ins) - 1; | ||
| 92 | #if LJ_HASJIT | ||
| 93 | if (pos >= pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ | ||
| 94 | GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); | ||
| 95 | lua_assert(bc_isret(bc_op(ins[-1]))); | ||
| 96 | pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); | ||
| 97 | } | ||
| 98 | #endif | ||
| 99 | return pos; | ||
| 86 | } | 100 | } |
| 87 | 101 | ||
| 88 | /* -- Line numbers -------------------------------------------------------- */ | 102 | /* -- Line numbers -------------------------------------------------------- */ |
