mgorny created this revision.
mgorny added reviewers: krytarowski, emaste, labath.
mgorny requested review of this revision.

Remove hardcoded platform list for QPassSignals, qXfer:auxv:read
and qXfer:libraries-svr4:read and instead query the process plugin
via the GetSupportedExtensions() API.


https://reviews.llvm.org/D101241

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
  lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py

Index: lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
===================================================================
--- lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
+++ lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
@@ -88,21 +88,3 @@
             signo = lldbutil.get_signal_number(signal_name)
             self.expect_signal(signo)
         self.expect_exit_code(0)
-
-
-    @skipUnlessPlatform(["linux", "android"])
-    def test_support_q_pass_signals(self):
-        self.build()
-
-        # Start up the stub and start/prep the inferior.
-        self.set_inferior_startup_launch()
-        procs = self.prep_debug_monitor_and_inferior()
-        self.add_qSupported_packets()
-
-        # Run the packet stream.
-        context = self.expect_gdbremote_sequence()
-        self.assertIsNotNone(context)
-
-        # Retrieve the qSupported features and check QPassSignals+
-        supported_dict = self.parse_qSupported_response(context)
-        self.assertEqual(supported_dict["QPassSignals"], "+")
Index: lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -974,6 +974,22 @@
         self.assertIsNotNone(supported_dict)
         self.assertTrue(len(supported_dict) > 0)
 
+    @skipUnlessPlatform(["freebsd", "linux", "netbsd"])
+    def test_qSupported_auvx(self):
+        supported_dict = self.get_qSupported_dict()
+        self.assertEqual(supported_dict.get('qXfer:auxv:read', '-'), '+')
+
+    @skipUnlessPlatform(["freebsd", "linux", "netbsd"])
+    def test_qSupported_libraries_svr4(self):
+        supported_dict = self.get_qSupported_dict()
+        self.assertEqual(supported_dict.get('qXfer:libraries-svr4:read', '-'),
+                         '+')
+
+    @skipUnlessPlatform(["freebsd", "linux", "netbsd", "android"])
+    def test_qSupported_qpasssignals(self):
+        supported_dict = self.get_qSupported_dict()
+        self.assertEqual(supported_dict.get('QPassSignals', '-'), '+')
+
     @add_test_categories(["fork"])
     def test_qSupported_fork_events(self):
         supported_dict = (
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3602,12 +3602,19 @@
   std::vector<std::string> ret =
       GDBRemoteCommunicationServerCommon::HandleFeatures(client_features);
   ret.insert(ret.end(), {
-    "QThreadSuffixSupported+", "QListThreadsInStopReply+",
-        "qXfer:features:read+",
-#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
-        "QPassSignals+", "qXfer:auxv:read+", "qXfer:libraries-svr4:read+",
-#endif
-  });
+                            "QThreadSuffixSupported+",
+                            "QListThreadsInStopReply+",
+                            "qXfer:features:read+",
+                        });
+
+  // report server-only features
+  Extension plugin_features = m_process_factory.GetSupportedExtensions();
+  if (bool(plugin_features & Extension::pass_signals))
+    ret.push_back("QPassSignals+");
+  if (bool(plugin_features & Extension::auvx))
+    ret.push_back("qXfer:auxv:read+");
+  if (bool(plugin_features & Extension::libraries_svr4))
+    ret.push_back("qXfer:libraries-svr4+");
 
   // check for client features
   using Extension = NativeProcessProtocol::Extension;
@@ -3619,7 +3626,8 @@
             .Case("fork-events+", Extension::fork)
             .Case("vfork-events+", Extension::vfork)
             .Default({});
-  m_extensions_supported &= m_process_factory.GetSupportedExtensions();
+
+  m_extensions_supported &= plugin_features;
 
   // fork & vfork require multiprocess
   if (!bool(m_extensions_supported & Extension::multiprocess))
Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===================================================================
--- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -135,7 +135,8 @@
 
 NativeProcessNetBSD::Extension
 NativeProcessNetBSD::Factory::GetSupportedExtensions() const {
-  return Extension::multiprocess | Extension::fork | Extension::vfork;
+  return Extension::multiprocess | Extension::fork | Extension::vfork |
+         Extension::pass_signals | Extension::auxv | Extension::libraries_svr4;
 }
 
 // Public Instance Methods
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -283,7 +283,8 @@
 
 NativeProcessLinux::Extension
 NativeProcessLinux::Factory::GetSupportedExtensions() const {
-  return Extension::multiprocess | Extension::fork | Extension::vfork;
+  return Extension::multiprocess | Extension::fork | Extension::vfork |
+         Extension::pass_signals | Extension::auxv | Extension::libraries_svr4;
 }
 
 // Public Instance Methods
Index: lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
===================================================================
--- lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
@@ -130,7 +130,8 @@
 
 NativeProcessFreeBSD::Extension
 NativeProcessFreeBSD::Factory::GetSupportedExtensions() const {
-  return Extension::multiprocess | Extension::fork | Extension::vfork;
+  return Extension::multiprocess | Extension::fork | Extension::vfork |
+         Extension::pass_signals | Extension::auxv | Extension::libraries_svr4;
 }
 
 // Public Instance Methods
Index: lldb/include/lldb/Host/common/NativeProcessProtocol.h
===================================================================
--- lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -240,8 +240,11 @@
     multiprocess = (1u << 0),
     fork = (1u << 1),
     vfork = (1u << 2),
+    pass_signals = (1u << 3),
+    auvx = (1u << 4),
+    libraries_svr4 = (1u << 5),
 
-    LLVM_MARK_AS_BITMASK_ENUM(vfork)
+    LLVM_MARK_AS_BITMASK_ENUM(libraries_svr4)
   };
 
   class Factory {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to