Skip to content

Commit 95b220c

Browse files
committed
build: add --v8-enable-wasm-gdb-remote-debugging configure option
This patch adds `--v8-enable-wasm-gdb-remote-debugging` & `--v8-disable-wasm-gdb-remote-debugging` configure options, enabled by default on linux/mac/win when wasm is enabled. The `--wasm-gdb-remote` & `--wasm-gdb-remote-port` v8 options are exposed and allows one to attach lldb to node and debug wasm modules with dwarf info. Assisted-by: Codex <codex@openai.com> Signed-off-by: Cheng Shao <terrorjack@type.dance>
1 parent 89310c7 commit 95b220c

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎configure.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,20 @@
12031203
help='Enable V8 transparent hugepage support. This feature is only '+
12041204
'available on Linux platform.')
12051205

1206+
parser.add_argument('--v8-enable-wasm-gdb-remote-debugging',
1207+
action='store_true',
1208+
dest='v8_enable_wasm_gdb_remote_debugging',
1209+
default=None,
1210+
help='Enable V8 WebAssembly debugging via the GDB-remote protocol. ' +
1211+
'Enabled by default on Linux, macOS, and Windows when WebAssembly ' +
1212+
'is enabled.')
1213+
1214+
parser.add_argument('--v8-disable-wasm-gdb-remote-debugging',
1215+
action='store_false',
1216+
dest='v8_enable_wasm_gdb_remote_debugging',
1217+
default=None,
1218+
help='Disable V8 WebAssembly debugging via the GDB-remote protocol.')
1219+
12061220
maglev_enabled_by_default_help = f"(Maglev is enabled by default on {','.join(maglev_enabled_architectures)})"
12071221

12081222
parser.add_argument('--v8-disable-maglev',
@@ -2179,6 +2193,18 @@ def configure_v8(o, configs):
21792193
set_configuration_variable(configs, 'v8_enable_v8_checks', release=0, debug=1)
21802194

21812195
o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1
2196+
if all(opt in sys.argv for opt in [
2197+
'--v8-enable-wasm-gdb-remote-debugging',
2198+
'--v8-disable-wasm-gdb-remote-debugging',
2199+
]):
2200+
raise Exception(
2201+
'Only one of the --v8-enable-wasm-gdb-remote-debugging or '
2202+
'--v8-disable-wasm-gdb-remote-debugging options can be specified at a time.')
2203+
wasm_gdb = options.v8_enable_wasm_gdb_remote_debugging
2204+
if wasm_gdb is None:
2205+
wasm_gdb = (o['variables']['v8_enable_webassembly'] and
2206+
flavor in ('linux', 'mac', 'win'))
2207+
o['variables']['v8_enable_wasm_gdb_remote_debugging'] = B(wasm_gdb)
21822208
o['variables']['v8_enable_javascript_promise_hooks'] = 1
21832209
o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0
21842210
is_gdbjit_supported_arch = (

‎tools/v8_gypfiles/features.gypi‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@
321321
# Sets -dV8_ENABLE_WEBASSEMBLY.
322322
'v8_enable_webassembly%': 1,
323323

324+
# Enable WebAssembly debugging via GDB-remote protocol.
325+
# Sets -dV8_ENABLE_WASM_GDB_REMOTE_DEBUGGING.
326+
'v8_enable_wasm_gdb_remote_debugging%': 0,
327+
324328
# Enable advanced BigInt algorithms, costing about 10-30 KiB binary size
325329
# depending on platform.
326330
'v8_advanced_bigint_algorithms%': 1,
@@ -524,6 +528,9 @@
524528
['v8_enable_webassembly==1', {
525529
'defines': ['V8_ENABLE_WEBASSEMBLY',],
526530
}],
531+
['v8_enable_wasm_gdb_remote_debugging==1', {
532+
'defines': ['V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING',],
533+
}],
527534
['v8_dict_property_const_tracking==1', {
528535
'defines': ['V8_DICT_PROPERTY_CONST_TRACKING',],
529536
}],

‎tools/v8_gypfiles/v8.gyp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,11 @@
709709
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_enable_webassembly.*?sources \\+= ")',
710710
],
711711
}],
712+
['v8_enable_wasm_gdb_remote_debugging==1', {
713+
'sources': [
714+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_enable_wasm_gdb_remote_debugging.*?sources \\+= ")',
715+
],
716+
}],
712717
['v8_enable_wasm_simd256_revec==1', {
713718
'sources': [
714719
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_enable_wasm_simd256_revec.*?sources \\+= ")',
@@ -1193,6 +1198,11 @@
11931198
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_webassembly.*?sources \\+= ")',
11941199
],
11951200
}],
1201+
['v8_enable_wasm_gdb_remote_debugging==1', {
1202+
'sources': [
1203+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_wasm_gdb_remote_debugging.*?sources \\+= ")',
1204+
],
1205+
}],
11961206
['v8_enable_heap_snapshot_verify==1', {
11971207
'sources': [
11981208
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_heap_snapshot_verify.*?sources \\+= ")',

0 commit comments

Comments
 (0)