From 95b220c09f3938db01576ba464098e2be496f380 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 17 Aug 2026 20:14:36 +0200 Subject: [PATCH] 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 Signed-off-by: Cheng Shao --- configure.py | 26 ++++++++++++++++++++++++++ tools/v8_gypfiles/features.gypi | 7 +++++++ tools/v8_gypfiles/v8.gyp | 10 ++++++++++ 3 files changed, 43 insertions(+) diff --git a/configure.py b/configure.py index 3f4f9984d5a8..ec80d174c9a4 100755 --- a/configure.py +++ b/configure.py @@ -1203,6 +1203,20 @@ help='Enable V8 transparent hugepage support. This feature is only '+ 'available on Linux platform.') +parser.add_argument('--v8-enable-wasm-gdb-remote-debugging', + action='store_true', + dest='v8_enable_wasm_gdb_remote_debugging', + default=None, + help='Enable V8 WebAssembly debugging via the GDB-remote protocol. ' + + 'Enabled by default on Linux, macOS, and Windows when WebAssembly ' + + 'is enabled.') + +parser.add_argument('--v8-disable-wasm-gdb-remote-debugging', + action='store_false', + dest='v8_enable_wasm_gdb_remote_debugging', + default=None, + help='Disable V8 WebAssembly debugging via the GDB-remote protocol.') + maglev_enabled_by_default_help = f"(Maglev is enabled by default on {','.join(maglev_enabled_architectures)})" parser.add_argument('--v8-disable-maglev', @@ -2179,6 +2193,18 @@ def configure_v8(o, configs): set_configuration_variable(configs, 'v8_enable_v8_checks', release=0, debug=1) o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1 + if all(opt in sys.argv for opt in [ + '--v8-enable-wasm-gdb-remote-debugging', + '--v8-disable-wasm-gdb-remote-debugging', + ]): + raise Exception( + 'Only one of the --v8-enable-wasm-gdb-remote-debugging or ' + '--v8-disable-wasm-gdb-remote-debugging options can be specified at a time.') + wasm_gdb = options.v8_enable_wasm_gdb_remote_debugging + if wasm_gdb is None: + wasm_gdb = (o['variables']['v8_enable_webassembly'] and + flavor in ('linux', 'mac', 'win')) + o['variables']['v8_enable_wasm_gdb_remote_debugging'] = B(wasm_gdb) o['variables']['v8_enable_javascript_promise_hooks'] = 1 o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0 is_gdbjit_supported_arch = ( diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi index a5227687d22d..bcc2f1ff5887 100644 --- a/tools/v8_gypfiles/features.gypi +++ b/tools/v8_gypfiles/features.gypi @@ -321,6 +321,10 @@ # Sets -dV8_ENABLE_WEBASSEMBLY. 'v8_enable_webassembly%': 1, + # Enable WebAssembly debugging via GDB-remote protocol. + # Sets -dV8_ENABLE_WASM_GDB_REMOTE_DEBUGGING. + 'v8_enable_wasm_gdb_remote_debugging%': 0, + # Enable advanced BigInt algorithms, costing about 10-30 KiB binary size # depending on platform. 'v8_advanced_bigint_algorithms%': 1, @@ -524,6 +528,9 @@ ['v8_enable_webassembly==1', { 'defines': ['V8_ENABLE_WEBASSEMBLY',], }], + ['v8_enable_wasm_gdb_remote_debugging==1', { + 'defines': ['V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING',], + }], ['v8_dict_property_const_tracking==1', { 'defines': ['V8_DICT_PROPERTY_CONST_TRACKING',], }], diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 32fc99e2af9f..c4773dd1bb50 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -709,6 +709,11 @@ '