https://github.com/sedymrak updated https://github.com/llvm/llvm-project/pull/182287
From 741a94d7782b56b42a32eb19a3ad04e24ec188d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Thu, 19 Feb 2026 13:35:03 +0100 Subject: [PATCH 1/9] [lldb] generalize the GDBRemoteCommunicationClient::GetVContSupported method so that it is able to process multi-character capabilities --- .../GDBRemoteCommunicationClient.cpp | 40 ++++++++----------- .../gdb-remote/GDBRemoteCommunicationClient.h | 6 +-- .../Process/gdb-remote/ProcessGDBRemote.cpp | 10 ++--- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 11f164c2426ce..f05bb43c46ab7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -480,7 +480,9 @@ bool GDBRemoteCommunicationClient::GetThreadSuffixSupported() { } return m_supports_thread_suffix; } -bool GDBRemoteCommunicationClient::GetVContSupported(char flavor) { + +bool GDBRemoteCommunicationClient::GetVContSupported(llvm::StringRef flavor) { + assert(flavor.size() > 0); if (m_supports_vCont_c == eLazyBoolCalculate) { StringExtractorGDBRemote response; m_supports_vCont_any = eLazyBoolNo; @@ -491,17 +493,18 @@ bool GDBRemoteCommunicationClient::GetVContSupported(char flavor) { m_supports_vCont_S = eLazyBoolNo; if (SendPacketAndWaitForResponse("vCont?", response) == PacketResult::Success) { - const char *response_cstr = response.GetStringRef().data(); - if (::strstr(response_cstr, ";c")) + std::string response_str(response.GetStringRef()); + response_str += ';'; + if (response_str.find(";c;") != std::string::npos) m_supports_vCont_c = eLazyBoolYes; - if (::strstr(response_cstr, ";C")) + if (response_str.find(";C;") != std::string::npos) m_supports_vCont_C = eLazyBoolYes; - if (::strstr(response_cstr, ";s")) + if (response_str.find(";s;") != std::string::npos) m_supports_vCont_s = eLazyBoolYes; - if (::strstr(response_cstr, ";S")) + if (response_str.find(";S;") != std::string::npos) m_supports_vCont_S = eLazyBoolYes; if (m_supports_vCont_c == eLazyBoolYes && @@ -520,23 +523,14 @@ bool GDBRemoteCommunicationClient::GetVContSupported(char flavor) { } } - switch (flavor) { - case 'a': - return m_supports_vCont_any; - case 'A': - return m_supports_vCont_all; - case 'c': - return m_supports_vCont_c; - case 'C': - return m_supports_vCont_C; - case 's': - return m_supports_vCont_s; - case 'S': - return m_supports_vCont_S; - default: - break; - } - return false; + return llvm::StringSwitch<bool>(flavor) + .Case("a", m_supports_vCont_any) + .Case("A", m_supports_vCont_all) + .Case("c", m_supports_vCont_c) + .Case("C", m_supports_vCont_C) + .Case("s", m_supports_vCont_s) + .Case("S", m_supports_vCont_S) + .Default(false); } GDBRemoteCommunication::PacketResult diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index ad590a25d0f16..d04f6370bb6ae 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -214,7 +214,7 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { void GetRemoteQSupported(); - bool GetVContSupported(char flavor); + bool GetVContSupported(llvm::StringRef flavor); bool GetpPacketSupported(lldb::tid_t tid); @@ -262,9 +262,9 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { bool GetGroupName(uint32_t gid, std::string &name); - bool HasFullVContSupport() { return GetVContSupported('A'); } + bool HasFullVContSupport() { return GetVContSupported("A"); } - bool HasAnyVContSupport() { return GetVContSupported('a'); } + bool HasAnyVContSupport() { return GetVContSupported("a"); } bool GetStopReply(StringExtractorGDBRemote &response); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 57d86ef71eecc..75b28f90d08b8 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -925,7 +925,7 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) { m_gdb_comm.GetThreadSuffixSupported(); m_gdb_comm.GetListThreadsInStopReplySupported(); m_gdb_comm.GetHostInfo(); - m_gdb_comm.GetVContSupported('c'); + m_gdb_comm.GetVContSupported("c"); m_gdb_comm.GetVAttachOrWaitSupported(); m_gdb_comm.EnableErrorStringInPacket(); @@ -1305,7 +1305,7 @@ Status ProcessGDBRemote::DoResume(RunDirection direction) { continue_packet.PutCString("vCont"); if (!m_continue_c_tids.empty()) { - if (m_gdb_comm.GetVContSupported('c')) { + if (m_gdb_comm.GetVContSupported("c")) { for (tid_collection::const_iterator t_pos = m_continue_c_tids.begin(), t_end = m_continue_c_tids.end(); @@ -1316,7 +1316,7 @@ Status ProcessGDBRemote::DoResume(RunDirection direction) { } if (!continue_packet_error && !m_continue_C_tids.empty()) { - if (m_gdb_comm.GetVContSupported('C')) { + if (m_gdb_comm.GetVContSupported("C")) { for (tid_sig_collection::const_iterator s_pos = m_continue_C_tids.begin(), s_end = m_continue_C_tids.end(); @@ -1328,7 +1328,7 @@ Status ProcessGDBRemote::DoResume(RunDirection direction) { } if (!continue_packet_error && !m_continue_s_tids.empty()) { - if (m_gdb_comm.GetVContSupported('s')) { + if (m_gdb_comm.GetVContSupported("s")) { for (tid_collection::const_iterator t_pos = m_continue_s_tids.begin(), t_end = m_continue_s_tids.end(); @@ -1339,7 +1339,7 @@ Status ProcessGDBRemote::DoResume(RunDirection direction) { } if (!continue_packet_error && !m_continue_S_tids.empty()) { - if (m_gdb_comm.GetVContSupported('S')) { + if (m_gdb_comm.GetVContSupported("S")) { for (tid_sig_collection::const_iterator s_pos = m_continue_S_tids.begin(), s_end = m_continue_S_tids.end(); From f570b6add2c08e4440ed98f9e2c2e06591d9d14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Thu, 19 Feb 2026 21:51:40 +0100 Subject: [PATCH 2/9] [lldb] rewrite the code so that we do not need to copy and modify the received packet --- .../GDBRemoteCommunicationClient.cpp | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index f05bb43c46ab7..c350a1a0f3651 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -493,19 +493,18 @@ bool GDBRemoteCommunicationClient::GetVContSupported(llvm::StringRef flavor) { m_supports_vCont_S = eLazyBoolNo; if (SendPacketAndWaitForResponse("vCont?", response) == PacketResult::Success) { - std::string response_str(response.GetStringRef()); - response_str += ';'; - if (response_str.find(";c;") != std::string::npos) - m_supports_vCont_c = eLazyBoolYes; - - if (response_str.find(";C;") != std::string::npos) - m_supports_vCont_C = eLazyBoolYes; - - if (response_str.find(";s;") != std::string::npos) - m_supports_vCont_s = eLazyBoolYes; - - if (response_str.find(";S;") != std::string::npos) - m_supports_vCont_S = eLazyBoolYes; + llvm::SmallVector<llvm::StringRef> flavors; + response.GetStringRef().split(";").second.split(flavors, ';'); + for (llvm::StringRef flavor : flavors) { + if (flavor == "c") + m_supports_vCont_c = eLazyBoolYes; + if (flavor == "C") + m_supports_vCont_C = eLazyBoolYes; + if (flavor == "s") + m_supports_vCont_s = eLazyBoolYes; + if (flavor == "S") + m_supports_vCont_S = eLazyBoolYes; + } if (m_supports_vCont_c == eLazyBoolYes && m_supports_vCont_C == eLazyBoolYes && From 606c561012c20061b718f0fedf8f6608571a5d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Fri, 20 Feb 2026 08:22:10 +0100 Subject: [PATCH 3/9] [lldb] simplify the code --- .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index c350a1a0f3651..c84ca60d63c84 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -493,9 +493,7 @@ bool GDBRemoteCommunicationClient::GetVContSupported(llvm::StringRef flavor) { m_supports_vCont_S = eLazyBoolNo; if (SendPacketAndWaitForResponse("vCont?", response) == PacketResult::Success) { - llvm::SmallVector<llvm::StringRef> flavors; - response.GetStringRef().split(";").second.split(flavors, ';'); - for (llvm::StringRef flavor : flavors) { + for (llvm::StringRef flavor : llvm::split(response.GetStringRef(), ';')) { if (flavor == "c") m_supports_vCont_c = eLazyBoolYes; if (flavor == "C") From a9f7defc4dd4b27fd6d00c463edc1d0a79d5ce98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Mon, 23 Feb 2026 17:53:28 +0100 Subject: [PATCH 4/9] [lldb] add some unit-tests for the GDBRemoteCommunicationClient::GetVContSupported method --- .../GDBRemoteCommunicationClientTest.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 966b37e09ee55..1603a1a43520c 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -77,6 +77,48 @@ class GDBRemoteCommunicationClientTest : public GDBRemoteTest { MockServer server; }; +TEST_F(GDBRemoteCommunicationClientTest, vCont_c) { + std::future<bool> write_result = std::async(std::launch::async, [&] { + return client.GetVContSupported("c"); + }); + HandlePacket(server, "vCont?", "$vCont;c#16"); + ASSERT_TRUE(write_result.get()); + ASSERT_FALSE(client.GetVContSupported("C")); + ASSERT_FALSE(client.GetVContSupported("s")); + ASSERT_FALSE(client.GetVContSupported("S")); + ASSERT_TRUE(client.GetVContSupported("a")); + ASSERT_FALSE(client.GetVContSupported("A")); + return; +} + +TEST_F(GDBRemoteCommunicationClientTest, vCont_C) { + std::future<bool> write_result = std::async(std::launch::async, [&] { + return client.GetVContSupported("c"); + }); + HandlePacket(server, "vCont?", "$vCont;C#16"); + ASSERT_FALSE(write_result.get()); + ASSERT_TRUE(client.GetVContSupported("C")); + ASSERT_FALSE(client.GetVContSupported("s")); + ASSERT_FALSE(client.GetVContSupported("S")); + ASSERT_TRUE(client.GetVContSupported("a")); + ASSERT_FALSE(client.GetVContSupported("A")); + return; +} + +TEST_F(GDBRemoteCommunicationClientTest, vCont_cC) { + std::future<bool> write_result = std::async(std::launch::async, [&] { + return client.GetVContSupported("c"); + }); + HandlePacket(server, "vCont?", "$vCont;c;C#16"); + ASSERT_TRUE(write_result.get()); + ASSERT_TRUE(client.GetVContSupported("C")); + ASSERT_FALSE(client.GetVContSupported("s")); + ASSERT_FALSE(client.GetVContSupported("S")); + ASSERT_TRUE(client.GetVContSupported("a")); + ASSERT_FALSE(client.GetVContSupported("A")); + return; +} + TEST_F(GDBRemoteCommunicationClientTest, WriteRegister) { const lldb::tid_t tid = 0x47; const uint32_t reg_num = 4; From ed92bf13cbff4241138b23f77898b7442d7735cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Mon, 23 Feb 2026 18:23:50 +0100 Subject: [PATCH 5/9] [lldb] code formatting --- .../GDBRemoteCommunicationClientTest.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 1603a1a43520c..962926520eec1 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -78,9 +78,8 @@ class GDBRemoteCommunicationClientTest : public GDBRemoteTest { }; TEST_F(GDBRemoteCommunicationClientTest, vCont_c) { - std::future<bool> write_result = std::async(std::launch::async, [&] { - return client.GetVContSupported("c"); - }); + std::future<bool> write_result = std::async( + std::launch::async, [&] { return client.GetVContSupported("c"); }); HandlePacket(server, "vCont?", "$vCont;c#16"); ASSERT_TRUE(write_result.get()); ASSERT_FALSE(client.GetVContSupported("C")); @@ -92,9 +91,8 @@ TEST_F(GDBRemoteCommunicationClientTest, vCont_c) { } TEST_F(GDBRemoteCommunicationClientTest, vCont_C) { - std::future<bool> write_result = std::async(std::launch::async, [&] { - return client.GetVContSupported("c"); - }); + std::future<bool> write_result = std::async( + std::launch::async, [&] { return client.GetVContSupported("c"); }); HandlePacket(server, "vCont?", "$vCont;C#16"); ASSERT_FALSE(write_result.get()); ASSERT_TRUE(client.GetVContSupported("C")); @@ -106,9 +104,8 @@ TEST_F(GDBRemoteCommunicationClientTest, vCont_C) { } TEST_F(GDBRemoteCommunicationClientTest, vCont_cC) { - std::future<bool> write_result = std::async(std::launch::async, [&] { - return client.GetVContSupported("c"); - }); + std::future<bool> write_result = std::async( + std::launch::async, [&] { return client.GetVContSupported("c"); }); HandlePacket(server, "vCont?", "$vCont;c;C#16"); ASSERT_TRUE(write_result.get()); ASSERT_TRUE(client.GetVContSupported("C")); From 58d01b3060bdd4a06363019167ba3c18f465cfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Tue, 24 Feb 2026 08:44:25 +0100 Subject: [PATCH 6/9] [lldb] remove a superfluous return command Co-authored-by: Jonas Devlieghere <[email protected]> --- .../Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 962926520eec1..3e4eec94b8825 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -113,7 +113,6 @@ TEST_F(GDBRemoteCommunicationClientTest, vCont_cC) { ASSERT_FALSE(client.GetVContSupported("S")); ASSERT_TRUE(client.GetVContSupported("a")); ASSERT_FALSE(client.GetVContSupported("A")); - return; } TEST_F(GDBRemoteCommunicationClientTest, WriteRegister) { From 55881f264edbab7b7fba8b40af0a23990d0649a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Tue, 24 Feb 2026 08:47:49 +0100 Subject: [PATCH 7/9] [lldb] remove the rest of superfluous return commands --- .../Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 3e4eec94b8825..72b88e7201a75 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -87,7 +87,6 @@ TEST_F(GDBRemoteCommunicationClientTest, vCont_c) { ASSERT_FALSE(client.GetVContSupported("S")); ASSERT_TRUE(client.GetVContSupported("a")); ASSERT_FALSE(client.GetVContSupported("A")); - return; } TEST_F(GDBRemoteCommunicationClientTest, vCont_C) { @@ -100,7 +99,6 @@ TEST_F(GDBRemoteCommunicationClientTest, vCont_C) { ASSERT_FALSE(client.GetVContSupported("S")); ASSERT_TRUE(client.GetVContSupported("a")); ASSERT_FALSE(client.GetVContSupported("A")); - return; } TEST_F(GDBRemoteCommunicationClientTest, vCont_cC) { From 9b0f0a858e3a28a5ace66cb76fbaaba7d406a397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Tue, 24 Feb 2026 08:57:57 +0100 Subject: [PATCH 8/9] [lldb] change the name of the shadowed variable --- .../gdb-remote/GDBRemoteCommunicationClient.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index c84ca60d63c84..19fb768bb8e94 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -493,14 +493,14 @@ bool GDBRemoteCommunicationClient::GetVContSupported(llvm::StringRef flavor) { m_supports_vCont_S = eLazyBoolNo; if (SendPacketAndWaitForResponse("vCont?", response) == PacketResult::Success) { - for (llvm::StringRef flavor : llvm::split(response.GetStringRef(), ';')) { - if (flavor == "c") + for (llvm::StringRef token : llvm::split(response.GetStringRef(), ';')) { + if (token == "c") m_supports_vCont_c = eLazyBoolYes; - if (flavor == "C") + if (token == "C") m_supports_vCont_C = eLazyBoolYes; - if (flavor == "s") + if (token == "s") m_supports_vCont_s = eLazyBoolYes; - if (flavor == "S") + if (token == "S") m_supports_vCont_S = eLazyBoolYes; } From 7b5f84c4ec2e8a8a7f2fd37e05d64e4ae638373a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Tue, 24 Feb 2026 09:07:11 +0100 Subject: [PATCH 9/9] [lldb] simplify the code --- .../Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 19fb768bb8e94..738e4013b6154 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -482,7 +482,7 @@ bool GDBRemoteCommunicationClient::GetThreadSuffixSupported() { } bool GDBRemoteCommunicationClient::GetVContSupported(llvm::StringRef flavor) { - assert(flavor.size() > 0); + assert(!flavor.empty()); if (m_supports_vCont_c == eLazyBoolCalculate) { StringExtractorGDBRemote response; m_supports_vCont_any = eLazyBoolNo; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
