diff options
author | Mike Pall <mike> | 2023-09-21 02:15:16 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2023-09-21 02:15:16 +0200 |
commit | b138ccfa918518a152bc830fef3d53cd0a922e36 (patch) | |
tree | 5dbdda343896985cfd87b7e22abe74d7d35fd546 | |
parent | 92b89d005ab721a61bce6d471b052bcb236b81d7 (diff) | |
download | luajit-b138ccfa918518a152bc830fef3d53cd0a922e36.tar.gz luajit-b138ccfa918518a152bc830fef3d53cd0a922e36.tar.bz2 luajit-b138ccfa918518a152bc830fef3d53cd0a922e36.zip |
Handle all stack layouts in (delayed) TRACE vmevent.
Thanks to Sergey Bronnikov and Peter Cawley. #1087
-rw-r--r-- | src/lj_trace.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lj_trace.c b/src/lj_trace.c index a72e73a3..25e610b5 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
@@ -524,21 +524,27 @@ static int trace_abort(jit_State *J) | |||
524 | J->cur.link = 0; | 524 | J->cur.link = 0; |
525 | J->cur.linktype = LJ_TRLINK_NONE; | 525 | J->cur.linktype = LJ_TRLINK_NONE; |
526 | lj_vmevent_send(L, TRACE, | 526 | lj_vmevent_send(L, TRACE, |
527 | TValue *frame; | 527 | cTValue *bot = tvref(L->stack); |
528 | cTValue *frame; | ||
528 | const BCIns *pc; | 529 | const BCIns *pc; |
529 | GCfunc *fn; | 530 | BCPos pos = 0; |
530 | setstrV(L, L->top++, lj_str_newlit(L, "abort")); | 531 | setstrV(L, L->top++, lj_str_newlit(L, "abort")); |
531 | setintV(L->top++, traceno); | 532 | setintV(L->top++, traceno); |
532 | /* Find original Lua function call to generate a better error message. */ | 533 | /* Find original Lua function call to generate a better error message. */ |
533 | frame = J->L->base-1; | 534 | for (frame = J->L->base-1, pc = J->pc; ; frame = frame_prev(frame)) { |
534 | pc = J->pc; | 535 | if (isluafunc(frame_func(frame))) { |
535 | while (!isluafunc(frame_func(frame))) { | 536 | pos = proto_bcpos(funcproto(frame_func(frame)), pc); |
536 | pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; | 537 | break; |
537 | frame = frame_prev(frame); | 538 | } else if (frame_prev(frame) <= bot) { |
539 | break; | ||
540 | } else if (frame_iscont(frame)) { | ||
541 | pc = frame_contpc(frame) - 1; | ||
542 | } else { | ||
543 | pc = frame_pc(frame) - 1; | ||
544 | } | ||
538 | } | 545 | } |
539 | fn = frame_func(frame); | 546 | setfuncV(L, L->top++, frame_func(frame)); |
540 | setfuncV(L, L->top++, fn); | 547 | setintV(L->top++, pos); |
541 | setintV(L->top++, proto_bcpos(funcproto(fn), pc)); | ||
542 | copyTV(L, L->top++, restorestack(L, errobj)); | 548 | copyTV(L, L->top++, restorestack(L, errobj)); |
543 | copyTV(L, L->top++, &J->errinfo); | 549 | copyTV(L, L->top++, &J->errinfo); |
544 | ); | 550 | ); |