mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, jingham.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.
Introduce the initial support for handling multiple ContinueDelegates
in GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(). This
is the first step towards moving to a shared asynchronous thread serving
multiple ProcessGDBRemote instances.
The final goal is that every stop response will be passed through all
ContinueDelegates, and every delegate will decide whether it is
applicable to its process. The additional `handled` parameter is used
to indicate that the correct delegate has been found and no further
delegates need to be invoked.
The next step is going to involve decoupling the async thread from
ProcessGDBRemote itself, and moving all the logic responsible for
updating the process status into ContinueDelegate API.
Sponsored by: The FreeBSD Foundation
https://reviews.llvm.org/D131837
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
Index: lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
@@ -29,12 +29,23 @@
unsigned stop_reply_called = 0;
std::vector structured_data_packets;
- void HandleAsyncStdout(llvm::StringRef out) override { output += out; }
- void HandleAsyncMisc(llvm::StringRef data) override { misc_data += data; }
- void HandleStopReply() override { ++stop_reply_called; }
+ void HandleAsyncStdout(llvm::StringRef out, bool ) override {
+output += out;
+handled = true;
+ }
+ void HandleAsyncMisc(llvm::StringRef data, bool ) override {
+misc_data += data;
+handled = true;
+ }
+ void HandleStopReply(bool ) override {
+++stop_reply_called;
+handled = true;
+ }
- void HandleAsyncStructuredDataPacket(llvm::StringRef data) override {
+ void HandleAsyncStructuredDataPacket(llvm::StringRef data,
+ bool ) override {
structured_data_packets.push_back(std::string(data));
+handled = true;
}
};
@@ -63,9 +74,8 @@
ListenerSP listener_sp = Listener::MakeListener("listener");
StateType SendCPacket(StringExtractorGDBRemote ) {
-return client.SendContinuePacketAndWaitForResponse(delegate, LinuxSignals(),
- "c", g_timeout,
- response);
+return client.SendContinuePacketAndWaitForResponse(
+{}, LinuxSignals(), "c", g_timeout, response);
}
void WaitForRunEvent() {
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
@@ -425,10 +425,11 @@
lldb::user_id_t break_loc_id);
// ContinueDelegate interface
- void HandleAsyncStdout(llvm::StringRef out) override;
- void HandleAsyncMisc(llvm::StringRef data) override;
- void HandleStopReply() override;
- void HandleAsyncStructuredDataPacket(llvm::StringRef data) override;
+ void HandleAsyncStdout(llvm::StringRef out, bool ) override;
+ void HandleAsyncMisc(llvm::StringRef data, bool ) override;
+ void HandleStopReply(bool ) override;
+ void HandleAsyncStructuredDataPacket(llvm::StringRef data,
+ bool ) override;
void SetThreadPc(const lldb::ThreadSP _sp, uint64_t index);
using ModuleCacheKey = std::pair;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3484,7 +3484,7 @@
StateType stop_state =
GetGDBRemote().SendContinuePacketAndWaitForResponse(
-*this, *GetUnixSignals(),
+{this}, *GetUnixSignals(),
llvm::StringRef(continue_cstr, continue_cstr_len),
GetInterruptTimeout(), response);
@@ -4642,14 +4642,15 @@
m_gdb_comm.ServeSymbolLookups(this);
}
-void ProcessGDBRemote::HandleAsyncStdout(llvm::StringRef out) {
+void ProcessGDBRemote::HandleAsyncStdout(llvm::StringRef out, bool ) {
AppendSTDOUT(out.data(), out.size());
+ handled = true;
}
static const char *end_delimiter = "--end--;";
static const int