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;


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;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to