[Lldb-commits] [lldb] 4b485fc - [lldb] [llgs] Introduce an AppendThreadIDToResponse() helper
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 24 08:20:49 PDT 2022
Author: Michał Górny
Date: 2022-06-24T17:20:24+02:00
New Revision: 4b485fc0ea4acf065c7992a5c9a1223f5565544e
URL: https://github.com/llvm/llvm-project/commit/4b485fc0ea4acf065c7992a5c9a1223f5565544e
DIFF: https://github.com/llvm/llvm-project/commit/4b485fc0ea4acf065c7992a5c9a1223f5565544e.diff
LOG: [lldb] [llgs] Introduce an AppendThreadIDToResponse() helper
Introduce a helper function to append GDB Remote Serial Protocol "thread
IDs", with optional PID in multiprocess mode.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128324
Added:
Modified:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index f5c66496d765..9356b01a6ce8 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -826,10 +826,8 @@ GDBRemoteCommunicationServerLLGS::PrepareStopReplyPacketForThread(
// Include the (pid and) tid.
response.PutCString("thread:");
- if (bool(m_extensions_supported &
- NativeProcessProtocol::Extension::multiprocess))
- response.Format("p{0:x-}.", process.GetID());
- response.Format("{0:x-};", thread.GetID());
+ AppendThreadIDToResponse(response, process.GetID(), thread.GetID());
+ response.PutChar(';');
// Include the thread name if there is one.
const std::string thread_name = thread.GetName();
@@ -1425,9 +1423,8 @@ GDBRemoteCommunicationServerLLGS::Handle_qC(StringExtractorGDBRemote &packet) {
StreamString response;
response.PutCString("QC");
- if (bool(m_extensions_supported & NativeProcessProtocol::Extension::multiprocess))
- response.Format("p{0:x-}.", m_current_process->GetID());
- response.Format("{0:x-}", thread->GetID());
+ AppendThreadIDToResponse(response, m_current_process->GetID(),
+ thread->GetID());
return SendPacketNoLock(response.GetString());
}
@@ -1996,10 +1993,7 @@ void GDBRemoteCommunicationServerLLGS::AddProcessThreads(
LLDB_LOG(log, "iterated thread {0} (tid={1})", thread_index,
thread->GetID());
response.PutChar(had_any ? ',' : 'm');
- if (bool(m_extensions_supported &
- NativeProcessProtocol::Extension::multiprocess))
- response.Format("p{0:x-}.", pid);
- response.Format("{0:x-}", thread->GetID());
+ AppendThreadIDToResponse(response, pid, thread->GetID());
had_any = true;
}
}
@@ -4143,6 +4137,14 @@ GDBRemoteCommunicationServerLLGS::SendContinueSuccessResponse() {
return m_non_stop ? SendOKResponse() : PacketResult::Success;
}
+void GDBRemoteCommunicationServerLLGS::AppendThreadIDToResponse(
+ Stream &response, lldb::pid_t pid, lldb::tid_t tid) {
+ if (bool(m_extensions_supported &
+ NativeProcessProtocol::Extension::multiprocess))
+ response.Format("p{0:x-}.", pid);
+ response.Format("{0:x-}", tid);
+}
+
std::string
lldb_private::process_gdb_remote::LLGSArgToURL(llvm::StringRef url_arg,
bool reverse_connect) {
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index abb7f10f4830..5187a953f957 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -273,6 +273,9 @@ class GDBRemoteCommunicationServerLLGS
// in non-stop mode, no response otherwise.
PacketResult SendContinueSuccessResponse();
+ void AppendThreadIDToResponse(Stream &response, lldb::pid_t pid,
+ lldb::tid_t tid);
+
private:
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> BuildTargetXml();
More information about the lldb-commits
mailing list