[Lldb-commits] [lldb] d57b80e - [lldb/Reproducers] Support reproducers for PlatformRemoteGDBServer
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed May 20 09:19:14 PDT 2020
Author: Jonas Devlieghere
Date: 2020-05-20T09:18:57-07:00
New Revision: d57b80e13ebd140f0b9acefa02423e1bc4a835d4
URL: https://github.com/llvm/llvm-project/commit/d57b80e13ebd140f0b9acefa02423e1bc4a835d4
DIFF: https://github.com/llvm/llvm-project/commit/d57b80e13ebd140f0b9acefa02423e1bc4a835d4.diff
LOG: [lldb/Reproducers] Support reproducers for PlatformRemoteGDBServer
Add reproducer support to PlatformRemoteGDBServer. The logic is
essentially the same as for ProcessGDBRemote. During capture we record
the GDB packets and during replay we connect to a replay server.
This fixes TestPlatformClient.py when run form a reproducer.
Differential Revision: https://reviews.llvm.org/D80224
Added:
Modified:
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 657b8fdc729a..18631a0c5315 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -288,40 +288,55 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) {
"execute 'platform disconnect' to close the "
"current connection",
GetHostname());
+ return error;
+ }
+
+ if (args.GetArgumentCount() != 1) {
+ error.SetErrorString(
+ "\"platform connect\" takes a single argument: <connect-url>");
+ return error;
+ }
+
+ const char *url = args.GetArgumentAtIndex(0);
+ if (!url)
+ return Status("URL is null.");
+
+ int port;
+ llvm::StringRef scheme, hostname, pathname;
+ if (!UriParser::Parse(url, scheme, hostname, port, pathname))
+ return Status("Invalid URL: %s", url);
+
+ // We're going to reuse the hostname when we connect to the debugserver.
+ m_platform_scheme = std::string(scheme);
+ m_platform_hostname = std::string(hostname);
+
+ m_gdb_client.SetConnection(std::make_unique<ConnectionFileDescriptor>());
+ if (repro::Reproducer::Instance().IsReplaying()) {
+ error = m_gdb_replay_server.Connect(m_gdb_client);
+ if (error.Success())
+ m_gdb_replay_server.StartAsyncThread();
} else {
- if (args.GetArgumentCount() == 1) {
- m_gdb_client.SetConnection(std::make_unique<ConnectionFileDescriptor>());
- // we're going to reuse the hostname when we connect to the debugserver
- int port;
- std::string path;
- const char *url = args.GetArgumentAtIndex(0);
- if (!url)
- return Status("URL is null.");
- llvm::StringRef scheme, hostname, pathname;
- if (!UriParser::Parse(url, scheme, hostname, port, pathname))
- return Status("Invalid URL: %s", url);
- m_platform_scheme = std::string(scheme);
- m_platform_hostname = std::string(hostname);
- path = std::string(pathname);
-
- const ConnectionStatus status = m_gdb_client.Connect(url, &error);
- if (status == eConnectionStatusSuccess) {
- if (m_gdb_client.HandshakeWithServer(&error)) {
- m_gdb_client.GetHostInfo();
- // If a working directory was set prior to connecting, send it down
- // now
- if (m_working_dir)
- m_gdb_client.SetWorkingDir(m_working_dir);
- } else {
- m_gdb_client.Disconnect();
- if (error.Success())
- error.SetErrorString("handshake failed");
- }
- }
- } else {
- error.SetErrorString(
- "\"platform connect\" takes a single argument: <connect-url>");
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+ repro::GDBRemoteProvider &provider =
+ g->GetOrCreate<repro::GDBRemoteProvider>();
+ m_gdb_client.SetPacketRecorder(provider.GetNewPacketRecorder());
}
+ m_gdb_client.Connect(url, &error);
+ }
+
+ if (error.Fail())
+ return error;
+
+ if (m_gdb_client.HandshakeWithServer(&error)) {
+ m_gdb_client.GetHostInfo();
+ // If a working directory was set prior to connecting, send it down
+ // now.
+ if (m_working_dir)
+ m_gdb_client.SetWorkingDir(m_working_dir);
+ } else {
+ m_gdb_client.Disconnect();
+ if (error.Success())
+ error.SetErrorString("handshake failed");
}
return error;
}
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index ee195d90ee3b..b06eafacc802 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -12,8 +12,9 @@
#include <string>
-#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h"
#include "lldb/Target/Platform.h"
namespace lldb_private {
@@ -164,6 +165,7 @@ class PlatformRemoteGDBServer : public Platform, private UserIDResolver {
protected:
process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
+ process_gdb_remote::GDBRemoteCommunicationReplayServer m_gdb_replay_server;
std::string m_platform_description; // After we connect we can get a more
// complete description of what we are
// connected to
More information about the lldb-commits
mailing list