[Lldb-commits] [PATCH] D135030: [lldb] [gdb-remote] Abstract sending ^c packet into SendCtrlC() method

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Oct 2 03:49:48 PDT 2022


mgorny created this revision.
mgorny added reviewers: labath, emaste, jingham, krytarowski.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Abstract sending ^c packet into a dedicated
GDBRemoteClientBase::SendCtrlC() method. This makes it possible to avoid
exposing the complete Write() method in the API.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D135030

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
@@ -106,8 +106,7 @@
 
   size_t SendAck();
 
-  size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
-               Status *error_ptr);
+  bool SendCtrlC();
 
   bool IsConnected() const;
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -374,10 +374,7 @@
     if (m_comm.m_async_count == 1) {
       // The sender has sent the continue packet and we are the first async
       // packet. Let's interrupt it.
-      const char ctrl_c = '\x03';
-      ConnectionStatus status = eConnectionStatusSuccess;
-      size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, nullptr);
-      if (bytes_written == 0) {
+      if (!m_comm.SendCtrlC()) {
         --m_comm.m_async_count;
         LLDB_LOGF(log, "GDBRemoteClientBase::Lock::Lock failed to send "
                        "interrupt packet");
@@ -417,9 +414,11 @@
 
 size_t GDBRemoteClientBase::SendAck() { return m_comm.SendAck(); }
 
-size_t GDBRemoteClientBase::Write(const void *src, size_t src_len,
-                                  ConnectionStatus &status, Status *error_ptr) {
-  return m_comm.Write(src, src_len, status, error_ptr);
+bool GDBRemoteClientBase::SendCtrlC() {
+  const char ctrl_c = '\x03';
+  ConnectionStatus status = eConnectionStatusSuccess;
+  size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, nullptr);
+  return bytes_written != 0;
 }
 
 bool GDBRemoteClientBase::IsConnected() const { return m_comm.IsConnected(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135030.464546.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221002/30c8562b/attachment.bin>


More information about the lldb-commits mailing list