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/2] [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/2] [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 &&

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to