This revision was automatically updated to reflect the committed changes.
Closed by commit rG611fdde4c765: [lldb/qemu] Add emulator-args setting 
(authored by labath).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115151/new/

https://reviews.llvm.org/D115151

Files:
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td
  lldb/test/API/qemu/TestQemuLaunch.py
  lldb/test/API/qemu/qemu.py

Index: lldb/test/API/qemu/qemu.py
===================================================================
--- lldb/test/API/qemu/qemu.py
+++ lldb/test/API/qemu/qemu.py
@@ -53,6 +53,7 @@
     parser = argparse.ArgumentParser(description=_description,
             formatter_class=argparse.RawDescriptionHelpFormatter)
     parser.add_argument('-g', metavar="unix-socket", required=True)
+    parser.add_argument('-fake-arg', dest="fake-arg")
     parser.add_argument('program', help="The program to 'emulate'.")
     parser.add_argument("args", nargs=argparse.REMAINDER)
     args = parser.parse_args()
Index: lldb/test/API/qemu/TestQemuLaunch.py
===================================================================
--- lldb/test/API/qemu/TestQemuLaunch.py
+++ lldb/test/API/qemu/TestQemuLaunch.py
@@ -20,7 +20,7 @@
     NO_DEBUG_INFO_TESTCASE = True
 
     def set_emulator_setting(self, name, value):
-        self.runCmd("settings set platform.plugin.qemu-user.%s %s" %
+        self.runCmd("settings set -- platform.plugin.qemu-user.%s %s" %
                 (name, value))
 
     def setUp(self):
@@ -43,7 +43,7 @@
         self.set_emulator_setting("architecture", self.getArchitecture())
         self.set_emulator_setting("emulator-path", emulator)
 
-    def test_basic_launch(self):
+    def _run_and_get_state(self):
         self.build()
         exe = self.getBuildArtifact()
 
@@ -63,7 +63,11 @@
 
         # Verify the qemu invocation parameters.
         with open(self.getBuildArtifact("state.log")) as s:
-            state = json.load(s)
+            return json.load(s)
+
+    def test_basic_launch(self):
+        state = self._run_and_get_state()
+
         self.assertEqual(state["program"], self.getBuildArtifact())
         self.assertEqual(state["args"],
                 ["dump:" + self.getBuildArtifact("state.log")])
@@ -159,3 +163,9 @@
         target.Launch(info, error)
         self.assertTrue(error.Fail())
         self.assertIn("doesn't exist", error.GetCString())
+
+    def test_extra_args(self):
+        self.set_emulator_setting("emulator-args", "-fake-arg fake-value")
+        state = self._run_and_get_state()
+
+        self.assertEqual(state["fake-arg"], "fake-value")
Index: lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td
===================================================================
--- lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td
+++ lldb/source/Plugins/Platform/QemuUser/PlatformQemuUserProperties.td
@@ -9,4 +9,8 @@
     Global,
     DefaultStringValue<"">,
     Desc<"Path to the emulator binary.">;
+  def EmulatorArgs: Property<"emulator-args", "Args">,
+    Global,
+    DefaultStringValue<"">,
+    Desc<"Extra arguments to pass to the emulator.">;
 }
Index: lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
===================================================================
--- lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
+++ lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
@@ -47,6 +47,13 @@
     return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr,
                                                          ePropertyEmulatorPath);
   }
+
+  Args GetEmulatorArgs() {
+    Args result;
+    m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, ePropertyEmulatorArgs,
+                                              result);
+    return result;
+  }
 };
 
 static PluginProperties &GetGlobalProperties() {
@@ -112,8 +119,10 @@
     llvm::sys::fs::createUniquePath(socket_model, socket_path, false);
   } while (FileSystem::Instance().Exists(socket_path));
 
-  Args args(
-      {qemu, "-g", socket_path, launch_info.GetExecutableFile().GetPath()});
+  Args args({qemu, "-g", socket_path});
+  args.AppendArguments(GetGlobalProperties().GetEmulatorArgs());
+  args.AppendArgument("--");
+  args.AppendArgument(launch_info.GetExecutableFile().GetPath());
   for (size_t i = 1; i < launch_info.GetArguments().size(); ++i)
     args.AppendArgument(launch_info.GetArguments()[i].ref());
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to