[Lldb-commits] [PATCH] D144390: [lldb] Send QPassSignals packet on attach, and at start for remote platforms

Pavel Kosov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 20 06:01:45 PST 2023

kpdev42 created this revision.
kpdev42 added reviewers: clayborg, davide, k8stone, DavidSpickett.
kpdev42 added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
kpdev42 requested review of this revision.
Herald added a subscriber: lldb-commits.

Before this patch, lldb did not send signal filtering information (QPassSignals packet) to lldb-server on remote platforms until signal settings were explicitly changed. Patch changes last sent signals version to be initialized with an invalid value instead of 0, so that the signal filtering information is sent to the server when the version is actually 0, which happens on remote platforms when the signal structure is copied and the version is reset. Also changes Process so that the information is sent not only right after launch, but right after attach too to be more consistent.

  rG LLVM Github Monorepo



Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteSignalFiltering.py
--- /dev/null
+++ 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 lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+class TestGDBRemoteSignalFiltering(GDBRemoteTestBase):
+    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)
Index: lldb/source/Target/Process.cpp
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2592,7 +2592,7 @@
     if (!m_os_up)
-    // 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.
     return Status();
@@ -3026,6 +3026,10 @@
                         : "<none>");
+  // 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) {
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -420,7 +420,7 @@
   // For ProcessGDBRemote only
   std::string m_partial_profile_data;
   std::map<uint64_t, uint32_t> 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,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144390.498817.patch
Type: text/x-patch
Size: 2930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230220/b29b3100/attachment.bin>

More information about the lldb-commits mailing list