Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step Into for Generator Function triggers Continue #29079

Open
cefn opened this issue Aug 10, 2019 · 0 comments
Open

Step Into for Generator Function triggers Continue #29079

cefn opened this issue Aug 10, 2019 · 0 comments
Labels
inspector Issues and PRs related to the V8 inspector protocol v8 engine Issues and PRs related to the V8 dependency.

Comments

@cefn
Copy link

cefn commented Aug 10, 2019

When debugging, trying to STEP-IN to a generator function call causes the debugger session to CONTINUE.

This is inconsistent when...

  • STEP-IN on a regular function call triggers STEP-IN (steps to first line in the called function)
  • STEP-IN on a NON-function-call triggers STEP-OVER (steps to next line in the current function)
  • STEP-IN on a NON-function-call at the end of a function triggers STEP-OUT (steps to a line following the original function-call)

The above three seem to me to be correct behaviour, consistent with using STEP-IN as a shortcut for go-to-the-next-line-of-code.

This inconsistency is a particular problem because it is impossible to judge from the interactive debugger session whether the apparent function call you are stepping into is a generator or a regular function. Therefore you might try to STEP-IN, then find that the debugger has chosen to CONTINUE because it was a generator call, making that stack call in the debugger session unrecoverable unless you had another breakpoint to catch it. The only workaround is to have a 100% accurate model of which calls are generators and Never call STEP-IN on a generator call.

Taking the below example, assuming just two manually-inserted Debugger breakpoints.

  • One at run()
  • One at: console.log("Finished script"). This is jumped to if you hit CONTINUE at any time.

Pressing the STEP-IN control in Chrome Inspector or VSCode ...

  • STEP-IN on run() triggers STEP-IN
  • STEP-IN on const nothing = makeNothing() triggers STEP-IN
  • STEP-IN on functionRunning = makeNothing.name triggers STEP-OVER
  • STEP-IN on return triggers STEP-OUT
  • STEP-IN on const sequence = makeSequence(5) then surprisingly triggers CONTINUE - jumping to the next manually-inserted breakpoint at console.log("Finished script") instead of the expected behaviour - stepping over to the line console.log("Arbitrary logging")
let lastFunctionName = null

function makeNothing() {
  lastFunctionName = makeNothing.name
  return
}

function* makeSequence(limit) {
  lastFunctionName = makeSequence.name
  for (let i = 0; i < limit; i++) {
    yield i
  }
}

function run() {
  const nothing = makeNothing()
  const sequence = makeSequence(5)
  console.log("Arbitrary logging")
}

console.log("Starting script")
run()
console.log("X")
console.log("X")
console.log("X")
console.log("Finished script")
@Fishrock123 Fishrock123 added inspector Issues and PRs related to the V8 inspector protocol v8 engine Issues and PRs related to the V8 dependency. labels Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

2 participants