chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.06k stars 1.19k forks source link

Can’t access module-level variables from debugger breakpoint #6369

Open fatcerberus opened 4 years ago

fatcerberus commented 4 years ago

Attempting to evaluate a variable which exists in module scope, for example an imported identifier, while paused at a breakpoint inside a function within that same module, will throw a ReferenceError, as though the identifier isn’t in scope.

fatcerberus commented 4 years ago

Repro'd using SSj (miniSphere's commandline debugger). I don't know how to debug in ch so can't repro there.

src/main.js:20 main()
(ssj) l 20
     10 import TitleScreen from './titleScreen.js';
     11
     12 import './defineScenelets.js';
     13
     14 global.console =
     15         new Console({ hotKey: Key.Tilde });
     16
     17 export default
     18 async function main()
     19 {
->   20         Scene.defaultPriority = 99;
     21
     22         console.defineObject('bgm', null, {
     23                 'override'(fileName) { Music.override(fileName); },
     24                 'pop'() { Music.pop(); },
     25                 'play'(fileName) { Music.play(FS.fullPath(`${fileName}.ogg`, 'music')); },
     26                 'push'(fileName) { Music.push(FS.fullPath(`${fileName}.ogg`, 'music')); },
     27                 'reset'() { Music.reset(); },
     28                 'stop'() { Music.override(null); },
     29                 'volume'(value) { Music.adjustVolume(value); },

src/main.js:20 main()
(ssj) x TitleScreen
prop  __proto__    {...} *3
prop  message      "'TitleScreen' is not defined"
prop  description  "'TitleScreen' is not defined"
prop  number       -2.14682e+09
prop  stack        "ReferenceError: 'TitleScreen' is not defined
   at eval code (eval code:1:1)
   at main (src/main.js:20:2)
   at Generator.prototype.next (native code)"

Above you can see that that TitleScreen is in scope (as an import) but attempting to evaluate it at the breakpoint produces a ReferenceError.

rhuanjl commented 4 years ago

This is a debugger feature request - access to module scope variables.