Browse Source

Merge pull request #1734 from svaarala/fix-debugger-stepover-tailcall

Fix debugger pause handling for StepOver and StepInto + tailcall
pull/1735/head
Sami Vaarala 7 years ago
committed by GitHub
parent
commit
8752e511b6
  1. 5
      RELEASES.rst
  2. 19
      src-input/duk_js_call.c
  3. 10
      tests/ecmascript/test-dev-debugger-step-tailcall.js

5
RELEASES.rst

@ -3096,9 +3096,8 @@ Planned
below the current call, leading potentially to a smaller reserve than below the current call, leading potentially to a smaller reserve than
requested (GH-1536) requested (GH-1536)
* Fix incorrect pausing by debugger StepOut command when current function has * Fix incorrect pausing by debugger StepOut, StepOver, and StepInto commands
a tail return; previously execution would pause on exit to tailcall target when stepping over a tail call (GH-1684, GH-1685, GH-1726, GH-1734)
(GH-1684, GH-1685)
* Fix duk_hbufobj assert in shared slice() handling (GH-1506) * Fix duk_hbufobj assert in shared slice() handling (GH-1506)

19
src-input/duk_js_call.c

@ -1501,6 +1501,18 @@ DUK_LOCAL duk_small_uint_t duk__call_setup_act_attempt_tailcall(duk_hthread *thr
* current activation must be closed, otherwise something like * current activation must be closed, otherwise something like
* test-bug-reduce-judofyr.js results. Also catchers need to be unwound * test-bug-reduce-judofyr.js results. Also catchers need to be unwound
* because there may be non-error-catching label entries in valid tail calls. * because there may be non-error-catching label entries in valid tail calls.
*
* Special attention is needed for debugger and pause behavior when
* reusing an activation.
* - Disable StepOut processing for the activation unwind because
* we reuse the activation, see:
* https://github.com/svaarala/duktape/issues/1684.
* - Disable line change pause flag permanently (if set) because
* it would no longer be relevant, see:
* https://github.com/svaarala/duktape/issues/1726.
* - Check for function entry (e.g. StepInto) pause flag here, because
* the executor pause check won't trigger due to shared activation, see:
* https://github.com/svaarala/duktape/issues/1726.
*/ */
DUK_DDD(DUK_DDDPRINT("is tail call, reusing activation at callstack top, at index %ld", DUK_DDD(DUK_DDDPRINT("is tail call, reusing activation at callstack top, at index %ld",
@ -1514,14 +1526,17 @@ DUK_LOCAL duk_small_uint_t duk__call_setup_act_attempt_tailcall(duk_hthread *thr
/* Unwind the topmost callstack entry before reusing it. This /* Unwind the topmost callstack entry before reusing it. This
* also unwinds the catchers related to the topmost entry. * also unwinds the catchers related to the topmost entry.
* Disable StepOut processing because we reuse the activation,
* see https://github.com/svaarala/duktape/issues/1684.
*/ */
DUK_ASSERT(thr->callstack_top > 0); DUK_ASSERT(thr->callstack_top > 0);
DUK_ASSERT(thr->callstack_curr != NULL); DUK_ASSERT(thr->callstack_curr != NULL);
#if defined(DUK_USE_DEBUGGER_SUPPORT) #if defined(DUK_USE_DEBUGGER_SUPPORT)
prev_pause_act = thr->heap->dbg_pause_act; prev_pause_act = thr->heap->dbg_pause_act;
thr->heap->dbg_pause_act = NULL; thr->heap->dbg_pause_act = NULL;
thr->heap->dbg_pause_flags &= ~DUK_PAUSE_FLAG_LINE_CHANGE;
if (thr->heap->dbg_pause_flags & DUK_PAUSE_FLAG_FUNC_ENTRY) {
DUK_D(DUK_DPRINT("PAUSE TRIGGERED by function entry (tailcall)"));
duk_debug_set_paused(thr->heap);
}
#endif #endif
duk_hthread_activation_unwind_reuse_norz(thr); duk_hthread_activation_unwind_reuse_norz(thr);
#if defined(DUK_USE_DEBUGGER_SUPPORT) #if defined(DUK_USE_DEBUGGER_SUPPORT)

10
tests/ecmascript/test-dev-debugger-stepout-tailcall.js → tests/ecmascript/test-dev-debugger-step-tailcall.js

@ -1,7 +1,13 @@
/* /*
* Test illustrating GH-1684. * Test illustrating GH-1684 and GH-1726.
* *
* Run with debugger attached, and StepOut from test1 and test2. * Run with debugger attached, and:
*
* - StepOut from test1 and test2.
*
* - StepOver the 'return' statement in test1 and test2.
*
* - StepInto anotherFunction in test1 and test2.
*/ */
/*=== /*===
Loading…
Cancel
Save