diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2020-12-18 18:29:49 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2021-02-08 19:15:53 -0800 |
commit | e5b1e32ae2f2afe3e3ce388aafcc1245ae41545e (patch) | |
tree | ae8da9e82851b74a48d2b523b6dc7dc7b4bb1a37 /modules/script | |
parent | 53603db3dd42e0e2c86bedaa3a5fbcfdeefadfb9 (diff) | |
download | gjs-e5b1e32ae2f2afe3e3ce388aafcc1245ae41545e.tar.gz |
debugger: Handle special return values from Environment.getVariable()
Debugger.Environment.getVariable() may return one of the three sentinel
values {missingArguments: true}, {optimizedOut: true}, or {uninitialized:
true} if a variable does not have a value for some reason. Handle these
special values in debuggeeValueToString().
"missingArguments" means that a function argument was optimized out,
"optimizedOut" means that a regular variable was optimized out, and
"uninitialized" means that a variable is present in the environment but
hasn't been initialized yet, for example when breaking on an exception
thrown while initializing it.
Also adds a test for the latter case (printing a backtrace with locals,
when breaking on an exception that leaves a local variable uninitialized.)
https://searchfox.org/mozilla-central/rev/6a6a366031680829746b5d2362610b868fd9571a/js/src/debugger/Debugger.cpp#1412-1435
Diffstat (limited to 'modules/script')
-rw-r--r-- | modules/script/_bootstrap/debugger.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js index d1b22ed9..0cffe703 100644 --- a/modules/script/_bootstrap/debugger.js +++ b/modules/script/_bootstrap/debugger.js @@ -48,6 +48,18 @@ function summarizeObject(dv) { } function debuggeeValueToString(dv, style = {pretty: options.pretty}) { + // Special sentinel values returned by Debugger.Environment.getVariable() + if (typeof dv === 'object' && dv !== null) { + if (dv.missingArguments) + return ['<missing>', undefined]; + if (dv.optimizedOut) + return ['<optimized out>', undefined]; + if (dv.uninitialized) + return ['<uninitialized>', undefined]; + if (!(dv instanceof Debugger.Object)) + return ['<unexpected object>', JSON.stringify(dv, null, 4)]; + } + const dvrepr = dvToString(dv); if (!style.pretty || dv === null || typeof dv !== 'object') return [dvrepr, undefined]; |