Previously `v8 args` only shows arguments of the functions in the stack
frames. This patch makes GetStackFrame in the debug helper forward the
context local information stored in ScopeInfo in the returned
properties, so the plugins can recover the parameter names in `bt` and
allow `v8 inspect` to resolve by parameter names.
The previews show the arguments as passed at the call site. Only the
names captured in the closures can be recovered, the rest still gets
positional [N] names. For example:
function outer(a, b, c) {
function capture() {
return a + c; // captures a and c, not b
}
}
(gdb) bt
#6 ... [outer @ captured-args.js:9:15]
(this=0x..., a=<Smi: 1>, [1]=<Smi: 2>, c=<Smi: 3>)
(gdb) v8 args 6
#6 outer @ captured-args.js:9:15
this = 0x... <JSGlobalProxy>
a = <Smi: 1>
[1] = <Smi: 2>
c = <Smi: 3>
(gdb) v8 inspect c
<Smi: 3>
To implement this, we expose the ScopeInfo::VariableProperties bitfield
aliases for the helper.
In order to support builds without pointer compression/cages, this also
includes isolate pointer in HeapAddresses in order to fill the
read_only_space_first_page and old_space_first_page of a HeapAddress
from the isolate root table, since without pointer compression, the
helper cannot derive these pages by itself.
Change-Id: Ie12b1e4e159836f30071cb009aadb46117064865
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8545535
Reviewed-by: Paolo Severini <paolosev@microsoft.com>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#111626}
V8 debug helper
This library is for debugging V8 itself, not debugging JavaScript running within V8. It is designed to be called from a debugger extension running within a native debugger such as WinDbg or LLDB. It can be used on live processes or crash dumps, and cannot assume that all memory is available in a dump.
The GDB and LLDB plugins uses a shared a Python FFI bridge over this library
and live under tools/debug_helper/plugins/.
The WinDbg plugin has different dependencies and lives under tools/windbg/.