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.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index 2f2ea9f0..c1f0f314 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -55,7 +55,8 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
55 const BCIns *ins; 55 const BCIns *ins;
56 GCproto *pt; 56 GCproto *pt;
57 BCPos pos; 57 BCPos pos;
58 lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); 58 lj_assertL(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD,
59 "function or frame expected");
59 if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ 60 if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */
60 return NO_BCPOS; 61 return NO_BCPOS;
61 } else if (nextframe == NULL) { /* Lua function on top. */ 62 } else if (nextframe == NULL) { /* Lua function on top. */
@@ -100,7 +101,7 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
100#if LJ_HASJIT 101#if LJ_HASJIT
101 if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ 102 if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */
102 GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); 103 GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
103 lua_assert(bc_isret(bc_op(ins[-1]))); 104 lj_assertL(bc_isret(bc_op(ins[-1])), "return bytecode expected");
104 pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); 105 pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
105 } 106 }
106#endif 107#endif
@@ -133,7 +134,7 @@ static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe)
133 BCPos pc = debug_framepc(L, fn, nextframe); 134 BCPos pc = debug_framepc(L, fn, nextframe);
134 if (pc != NO_BCPOS) { 135 if (pc != NO_BCPOS) {
135 GCproto *pt = funcproto(fn); 136 GCproto *pt = funcproto(fn);
136 lua_assert(pc <= pt->sizebc); 137 lj_assertL(pc <= pt->sizebc, "PC out of range");
137 return lj_debug_line(pt, pc); 138 return lj_debug_line(pt, pc);
138 } 139 }
139 return -1; 140 return -1;
@@ -214,7 +215,7 @@ static TValue *debug_localname(lua_State *L, const lua_Debug *ar,
214const char *lj_debug_uvname(GCproto *pt, uint32_t idx) 215const char *lj_debug_uvname(GCproto *pt, uint32_t idx)
215{ 216{
216 const uint8_t *p = proto_uvinfo(pt); 217 const uint8_t *p = proto_uvinfo(pt);
217 lua_assert(idx < pt->sizeuv); 218 lj_assertX(idx < pt->sizeuv, "bad upvalue index");
218 if (!p) return ""; 219 if (!p) return "";
219 if (idx) while (*p++ || --idx) ; 220 if (idx) while (*p++ || --idx) ;
220 return (const char *)p; 221 return (const char *)p;
@@ -439,13 +440,14 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
439 } else { 440 } else {
440 uint32_t offset = (uint32_t)ar->i_ci & 0xffff; 441 uint32_t offset = (uint32_t)ar->i_ci & 0xffff;
441 uint32_t size = (uint32_t)ar->i_ci >> 16; 442 uint32_t size = (uint32_t)ar->i_ci >> 16;
442 lua_assert(offset != 0); 443 lj_assertL(offset != 0, "bad frame offset");
443 frame = tvref(L->stack) + offset; 444 frame = tvref(L->stack) + offset;
444 if (size) nextframe = frame + size; 445 if (size) nextframe = frame + size;
445 lua_assert(frame <= tvref(L->maxstack) && 446 lj_assertL(frame <= tvref(L->maxstack) &&
446 (!nextframe || nextframe <= tvref(L->maxstack))); 447 (!nextframe || nextframe <= tvref(L->maxstack)),
448 "broken frame chain");
447 fn = frame_func(frame); 449 fn = frame_func(frame);
448 lua_assert(fn->c.gct == ~LJ_TFUNC); 450 lj_assertL(fn->c.gct == ~LJ_TFUNC, "bad frame function");
449 } 451 }
450 for (; *what; what++) { 452 for (; *what; what++) {
451 if (*what == 'S') { 453 if (*what == 'S') {