Author: Michał Górny Date: 2021-04-27T19:34:00+02:00 New Revision: ca7824c2a8dbf3e37734e10e77003acd34d0868a
URL: https://github.com/llvm/llvm-project/commit/ca7824c2a8dbf3e37734e10e77003acd34d0868a DIFF: https://github.com/llvm/llvm-project/commit/ca7824c2a8dbf3e37734e10e77003acd34d0868a.diff LOG: [lldb] [gdb-remote] Report QPassSignals and qXfer via extensions API Remove hardcoded platform list for QPassSignals, qXfer:auxv:read and qXfer:libraries-svr4:read and instead query the process plugin via the GetSupportedExtensions() API. Differential Revision: https://reviews.llvm.org/D101241 Added: Modified: 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 Removed: ################################################################################ diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h index 8054bcba8a720..a8ec6306e1d5a 100644 --- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h +++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h @@ -240,8 +240,11 @@ class NativeProcessProtocol { multiprocess = (1u << 0), fork = (1u << 1), vfork = (1u << 2), + pass_signals = (1u << 3), + auxv = (1u << 4), + libraries_svr4 = (1u << 5), - LLVM_MARK_AS_BITMASK_ENUM(vfork) + LLVM_MARK_AS_BITMASK_ENUM(libraries_svr4) }; class Factory { diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp index 6d9a7d7f0d9c1..d6426b3d23675 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp @@ -130,7 +130,8 @@ NativeProcessFreeBSD::Factory::Attach( 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 diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 86c5a093b6430..963b4b84595f5 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -283,7 +283,8 @@ NativeProcessLinux::Factory::Attach( 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 diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 7d860e30774cf..9ea1a16b87858 100644 --- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -135,7 +135,8 @@ NativeProcessNetBSD::Factory::Attach( 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 diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 15908c785ad63..1825bc8fa9e71 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -3594,15 +3594,22 @@ std::vector<std::string> GDBRemoteCommunicationServerLLGS::HandleFeatures( 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+", + }); - // check for client features + // report server-only features using Extension = NativeProcessProtocol::Extension; + Extension plugin_features = m_process_factory.GetSupportedExtensions(); + if (bool(plugin_features & Extension::pass_signals)) + ret.push_back("QPassSignals+"); + if (bool(plugin_features & Extension::auxv)) + ret.push_back("qXfer:auxv:read+"); + if (bool(plugin_features & Extension::libraries_svr4)) + ret.push_back("qXfer:libraries-svr4:read+"); + + // check for client features m_extensions_supported = {}; for (llvm::StringRef x : client_features) m_extensions_supported |= @@ -3611,7 +3618,8 @@ std::vector<std::string> GDBRemoteCommunicationServerLLGS::HandleFeatures( .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)) diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py index 83593164daabb..93e9ec61a0432 100644 --- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py +++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py @@ -17,7 +17,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test.lldbdwarf import * -from lldbsuite.test import lldbutil +from lldbsuite.test import lldbutil, lldbplatformutil class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcodeParser): @@ -974,6 +974,25 @@ def test_qSupported_returns_known_stub_features(self): self.assertIsNotNone(supported_dict) self.assertTrue(len(supported_dict) > 0) + def test_qSupported_auvx(self): + expected = ('+' if lldbplatformutil.getPlatform() + in ["freebsd", "linux", "netbsd"] else '-') + supported_dict = self.get_qSupported_dict() + self.assertEqual(supported_dict.get('qXfer:auxv:read', '-'), expected) + + def test_qSupported_libraries_svr4(self): + expected = ('+' if lldbplatformutil.getPlatform() + in ["freebsd", "linux", "netbsd"] else '-') + supported_dict = self.get_qSupported_dict() + self.assertEqual(supported_dict.get('qXfer:libraries-svr4:read', '-'), + expected) + + def test_qSupported_QPassSignals(self): + expected = ('+' if lldbplatformutil.getPlatform() + in ["freebsd", "linux", "netbsd"] else '-') + supported_dict = self.get_qSupported_dict() + self.assertEqual(supported_dict.get('QPassSignals', '-'), expected) + @add_test_categories(["fork"]) def test_qSupported_fork_events(self): supported_dict = ( diff --git a/lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py b/lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py index 8d4f464b8dee0..ccdfb9b44482d 100644 --- a/lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py +++ b/lldb/test/API/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py @@ -88,21 +88,3 @@ def test_default_signals_behavior(self): 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"], "+") _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits