aboutsummaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
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 @@
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)
49static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) 52static 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 -------------------------------------------------------- */