• Simon Zünd's avatar
    [debug] Report variables in TDZ as 'value unavailable' · e417b339
    Simon Zünd authored
    Consider the function:
    
    function foo() {
      debugger;
      let y = 1;
    }
    
    V8 will elide the hole initialization for 'y'. When we pause at the
    debugger statement, then 'y' evaluates to 'undefined'.
    
    This CL fixes this in the ScopeIterator. When we encounter local
    variables with an `undefined` value we check the static scope
    information if we are stopped *before* the variable's initializer.
    If yes, then we are in the variable's TDZ and report
    "value unavailable".
    
    Drive-by: Mark `GetSourcePosition()` as `const` to make it available
    in the visitor method.
    
    R=bmeurer@chromium.org
    
    Bug: chromium:1328681
    Change-Id: I8b966eaa2af64a35a58095a744440851760921a0
    Fixed: chromium:1303493
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829539
    Commit-Queue: Simon Zünd <szuend@chromium.org>
    Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#82483}
    e417b339
debug-scopes.cc 40 KB