[Lldb-commits] [PATCH] D155117: Platform qemu-user: Build path to qemu automatically if not specified

Ted Woodward via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 12 14:09:05 PDT 2023


ted created this revision.
Herald added a project: All.
ted requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Get the path to qemu in the following order:

1. From the property platform.plugin.qemu-user.emulator-path
2. If that property is not set, from PATH, building the name of the qemu binary from the triple in  property platform.plugin.qemu-user.architecture
3. If that property is not set, from PATH, building the name of the qemu binary from the triple in the target

This will allow a user to load a target and run without setting properties,
if qemu is on the PATH and named qemu-<ArchName>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155117

Files:
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp


Index: lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
===================================================================
--- lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
+++ lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
@@ -162,9 +162,18 @@
                                                Target &target, Status &error) {
   Log *log = GetLog(LLDBLog::Platform);
 
+  // If platform.plugin.qemu-user.emulator-path is set, use it.
   FileSpec qemu = GetGlobalProperties().GetEmulatorPath();
-  if (!qemu)
-    qemu.SetPath(("qemu-" + GetGlobalProperties().GetArchitecture()).str());
+  // If platform.plugin.qemu-user.emulator-path is not set, build the
+  // executable name from platform.plugin.qemu-user.architecture.
+  if (!qemu) {
+    llvm::StringRef arch = GetGlobalProperties().GetArchitecture();
+    // If platform.plugin.qemu-user.architecture is not set, build the
+    // executable name from the target Triple's ArchName
+    if (arch.empty())
+      arch = target.GetArchitecture().GetTriple().getArchName();
+    qemu.SetPath(("qemu-" + arch).str());
+  }
   FileSystem::Instance().ResolveExecutableLocation(qemu);
 
   llvm::SmallString<0> socket_model, socket_path;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155117.539723.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230712/17343a9a/attachment.bin>


More information about the lldb-commits mailing list