[Lldb-commits] [lldb] cc7d719 - [lldb] Launch the Wasm runtime with the file the target has (#213384)

via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 31 18:40:19 PDT 2026


Author: Jonas Devlieghere
Date: 2026-07-31T18:40:15-07:00
New Revision: cc7d719fd9ad74ae251da7b4f4abf3af01ba32ac

URL: https://github.com/llvm/llvm-project/commit/cc7d719fd9ad74ae251da7b4f4abf3af01ba32ac
DIFF: https://github.com/llvm/llvm-project/commit/cc7d719fd9ad74ae251da7b4f4abf3af01ba32ac.diff

LOG: [lldb] Launch the Wasm runtime with the file the target has (#213384)

PlatformWasm hands the runtime the module to run as a path on the host
it launches the runtime on. It takes that path from the launch info,
whose executable is the name the module goes by on the platform. That
name is whatever a stub reported the module under, which need not be a
path that resolves on this host, so a relaunch runs a file that does not
exist:

```
(lldb) run
error: WebAssembly runtime exited with exit code 255
```

Run the file the target has instead. Only a runtime launched on this
host is affected, since a connection to a remote Wasm platform delegates
the launch to that platform.

Added: 
    

Modified: 
    lldb/source/Plugins/Platform/WebAssembly/PlatformWasm.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Platform/WebAssembly/PlatformWasm.cpp b/lldb/source/Plugins/Platform/WebAssembly/PlatformWasm.cpp
index 31b4754599f72..eb1cdac11c146 100644
--- a/lldb/source/Plugins/Platform/WebAssembly/PlatformWasm.cpp
+++ b/lldb/source/Plugins/Platform/WebAssembly/PlatformWasm.cpp
@@ -10,6 +10,7 @@
 #include "Plugins/Platform/WebAssembly/PlatformWasmRemoteGDBServer.h"
 #include "Plugins/Platform/WebAssembly/PlatformWebInspectorWasm.h"
 #include "Plugins/Process/wasm/ProcessWasm.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
@@ -183,7 +184,19 @@ lldb::ProcessSP PlatformWasm::DebugProcess(ProcessLaunchInfo &launch_info,
       args.AppendArgument(
           llvm::formatv("{0}{1}", env_arg, Environment::compose(kv)).str());
 
-  args.AppendArguments(launch_info.GetArguments());
+  // The runtime is handed the module to run as a path on this host. A launch
+  // takes its executable from the name the module goes by on the platform,
+  // which for a module reported by a stub is a name of the stub's choosing
+  // rather than a path that resolves here, so run the file the target has.
+  Args inferior_args = launch_info.GetArguments();
+  if (ModuleSP exe_module_sp = target.GetExecutableModule()) {
+    const std::string exe_path = exe_module_sp->GetFileSpec().GetPath();
+    if (inferior_args.GetArgumentCount() > 0)
+      inferior_args.ReplaceArgumentAtIndex(0, exe_path);
+    else
+      inferior_args.AppendArgument(exe_path);
+  }
+  args.AppendArguments(inferior_args);
 
   launch_info.SetArguments(args, true);
   launch_info.SetLaunchInSeparateProcessGroup(true);


        


More information about the lldb-commits mailing list