From 9ddda78c403a1bd2f18fd3f68e7b89126b5ef1f3 Mon Sep 17 00:00:00 2001 From: Nikolai Kholiavin Date: Mon, 16 Jan 2023 05:12:04 +0000 Subject: [PATCH] [lldb] Send QPassSignals packet on attach and on process init for remote server Change-Id: Ife520d860a6b205b5669acb26682a023940c6062 Signed-off-by: Nikolai Kholiavin --- .../Process/gdb-remote/ProcessGDBRemote.h | 2 +- lldb/source/Target/Process.cpp | 6 +++- .../TestGDBRemoteSignalFiltering.py | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteSignalFiltering.py diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 0921bf17c4e4..97b53199c733 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -414,7 +414,7 @@ private: // For ProcessGDBRemote only std::string m_partial_profile_data; std::map m_thread_id_to_used_usec_map; - uint64_t m_last_signals_version = 0; + uint64_t m_last_signals_version = UINT64_MAX; static bool NewThreadNotifyBreakpointHit(void *baton, StoppointCallbackContext *context, diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 518a6934059e..79d541d2a52c 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2502,7 +2502,7 @@ Status Process::Launch(ProcessLaunchInfo &launch_info) { if (!m_os_up) LoadOperatingSystemPlugin(false); - // We successfully launched the process and stopped, now it the + // We successfully launched the process and stopped, now it is the // right time to set up signal filters before resuming. UpdateAutomaticSignalFiltering(); @@ -2934,6 +2934,10 @@ void Process::CompleteAttach() { : ""); } } + + // We successfully attached to the process and stopped, now it is the + // right time to set up signal filters before resuming. + UpdateAutomaticSignalFiltering(); } Status Process::ConnectRemote(llvm::StringRef remote_url) { diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteSignalFiltering.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteSignalFiltering.py new file mode 100644 index 000000000000..9447adc51fcf --- /dev/null +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteSignalFiltering.py @@ -0,0 +1,31 @@ +"""Test that GDBRemoteProcess sends default signal filtering info when necessary""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestGDBRemoteSignalFiltering(GDBRemoteTestBase): + + @skipIfReproducer # Packet log is not populated during replay. + def test_signals_sent_on_connect(self): + """Test that signal filtering info is sent on connect""" + class Responder(MockGDBServerResponder): + def qSupported(self, client_supported): + return "PacketSize=3fff;QStartNoAckMode+;QPassSignals+" + + def respond(self, packet): + if packet == "QPassSignals": + return self.QPassSignals() + return MockGDBServerResponder.respond(self, packet) + + def QPassSignals(self): + return "OK" + + self.server.responder = Responder() + target = self.createTarget("a.yaml") + process = self.connect(target) + self.assertGreater( + len([p for p in self.server.responder.packetLog if p.startswith("QPassSignals:")]), + 0) -- Gitee