summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Platform')
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp4
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp8
-rw-r--r--lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp4
-rw-r--r--lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp157
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h13
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp96
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h14
10 files changed, 104 insertions, 219 deletions
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 261f44c230f9..97c2f22b505f 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformFreeBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformFreeBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -36,6 +36,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_freebsd;
+LLDB_PLUGIN_DEFINE(PlatformFreeBSD)
+
static uint32_t g_initialize_count = 0;
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index e3a3aa7145f0..56f2f2771d12 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformFreeBSD_h_
-#define liblldb_PlatformFreeBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -62,10 +62,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformFreeBSD);
+ PlatformFreeBSD(const PlatformFreeBSD &) = delete;
+ const PlatformFreeBSD &operator=(const PlatformFreeBSD &) = delete;
};
} // namespace platform_freebsd
} // namespace lldb_private
-#endif // liblldb_PlatformFreeBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index 53f819e6a272..caebd79c853e 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformNetBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformNetBSD.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,6 +34,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_netbsd;
+LLDB_PLUGIN_DEFINE(PlatformNetBSD)
+
static uint32_t g_initialize_count = 0;
@@ -329,14 +331,14 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Hook up process PTY if we have one (which we should for local debugging
// with llgs).
- int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
LLDB_LOG(log, "hooked up STDIO pty to process");
} else
LLDB_LOG(log, "not using process STDIO pty");
} else {
- LLDB_LOG(log, "process launch failed: {0}", error);
+ LLDB_LOG(log, "{0}", error);
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
// we delete the process? Does our caller do that?
}
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index 0584d92d6c99..d53e58418884 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformNetBSD_h_
-#define liblldb_PlatformNetBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -60,10 +60,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD);
+ PlatformNetBSD(const PlatformNetBSD &) = delete;
+ const PlatformNetBSD &operator=(const PlatformNetBSD &) = delete;
};
} // namespace platform_netbsd
} // namespace lldb_private
-#endif // liblldb_PlatformNetBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
index 1b63e2da0a4f..a743970990a6 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformOpenBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformOpenBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,6 +34,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_openbsd;
+LLDB_PLUGIN_DEFINE(PlatformOpenBSD)
+
static uint32_t g_initialize_count = 0;
diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
index 3cb724f30325..9cfe32c3720c 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformOpenBSD_h_
-#define liblldb_PlatformOpenBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -54,10 +54,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformOpenBSD);
+ PlatformOpenBSD(const PlatformOpenBSD &) = delete;
+ const PlatformOpenBSD &operator=(const PlatformOpenBSD &) = delete;
};
} // namespace platform_openbsd
} // namespace lldb_private
-#endif // liblldb_PlatformOpenBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 2b64be63a623..180ea1d2cfd1 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformPOSIX.cpp ---------------------------------------*- C++ -*-===//
+//===-- PlatformPOSIX.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,9 @@
#include "PlatformPOSIX.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -22,7 +22,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ProcessLaunchInfo.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -64,148 +63,6 @@ lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
return m_options.at(&interpreter).get();
}
-Status
-PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Status error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost()) {
- // If we have "ls" as the exe_file, resolve the executable location based
- // on the current path variables
- if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path,
- FileSpec::Style::native);
- FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
- }
-
- if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- FileSystem::Instance().ResolveExecutableLocation(
- resolved_module_spec.GetFileSpec());
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- error.Clear();
- else {
- const uint32_t permissions = FileSystem::Instance().GetPermissions(
- resolved_module_spec.GetFileSpec());
- if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
- error.SetErrorStringWithFormat(
- "executable '%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- else
- error.SetErrorStringWithFormat(
- "unable to find executable for '%s'",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- } else {
- if (m_remote_platform_sp) {
- error =
- GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, *m_remote_platform_sp);
- } else {
- // We may connect to a process and use the provided executable (Don't use
- // local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently "
- "connected, and '%s' doesn't exist in "
- "the system root.",
- exe_path);
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, nullptr, nullptr);
- if (error.Fail()) {
- // If we failed, it may be because the vendor and os aren't known. If
- // that is the case, try setting them to the host architecture and give
- // it another try.
- llvm::Triple &module_triple =
- resolved_module_spec.GetArchitecture().GetTriple();
- bool is_vendor_specified =
- (module_triple.getVendor() != llvm::Triple::UnknownVendor);
- bool is_os_specified =
- (module_triple.getOS() != llvm::Triple::UnknownOS);
- if (!is_vendor_specified || !is_os_specified) {
- const llvm::Triple &host_triple =
- HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
-
- if (!is_vendor_specified)
- module_triple.setVendorName(host_triple.getVendorName());
- if (!is_os_specified)
- module_triple.setOSName(host_triple.getOSName());
-
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp, module_search_paths_ptr, nullptr, nullptr);
- }
- }
-
- // TODO find out why exe_module_sp might be NULL
- if (error.Fail() || !exe_module_sp || !exe_module_sp->GetObjectFile()) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for the
- // architectures that we should be using (in the correct order) and see
- // if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, nullptr, nullptr);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (FileSystem::Instance().Readable(
- resolved_module_spec.GetFileSpec())) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
-}
-
static uint32_t chown_file(Platform *platform, const char *path,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) {
@@ -429,7 +286,7 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
stream.Printf("cache dir: %s", GetLocalCacheDirectory());
if (stream.GetSize())
- return stream.GetString();
+ return std::string(stream.GetString());
else
return "";
}
@@ -679,7 +536,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
static const char *dlopen_wrapper_name = "__lldb_dlopen_wrapper";
Process *process = exe_ctx.GetProcessSP().get();
// Insert the dlopen shim defines into our generic expression:
- std::string expr(GetLibdlFunctionDeclarations(process));
+ std::string expr(std::string(GetLibdlFunctionDeclarations(process)));
expr.append(dlopen_wrapper_code);
Status utility_error;
DiagnosticManager diagnostics;
@@ -706,7 +563,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
FunctionCaller *do_dlopen_function = nullptr;
// Fetch the clang types we will need:
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast)
return nullptr;
@@ -950,9 +807,9 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
Value return_value;
// Fetch the clang types we will need:
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast) {
- error.SetErrorString("dlopen error: Unable to get ClangASTContext");
+ error.SetErrorString("dlopen error: Unable to get TypeSystemClang");
return LLDB_INVALID_IMAGE_TOKEN;
}
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 5858f99088e6..72c54f4147c2 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformPOSIX_h_
-#define liblldb_PlatformPOSIX_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
#include <map>
#include <memory>
@@ -37,10 +37,6 @@ public:
const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
- lldb_private::Status ResolveExecutable(
- const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be nullptr, if
@@ -105,7 +101,8 @@ protected:
llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
+ PlatformPOSIX(const PlatformPOSIX &) = delete;
+ const PlatformPOSIX &operator=(const PlatformPOSIX &) = delete;
};
-#endif // liblldb_PlatformPOSIX_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 1e62ddfe94fd..21bf7f4ac46d 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformRemoteGDBServer.cpp -----------------------------*- C++ -*-===//
+//===-- PlatformRemoteGDBServer.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,6 +35,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_gdb_server;
+LLDB_PLUGIN_DEFINE_ADV(PlatformRemoteGDBServer, PlatformGDB)
+
static bool g_initialized = false;
void PlatformRemoteGDBServer::Initialize() {
@@ -286,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(new 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 = scheme;
- m_platform_hostname = hostname;
- path = 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;
}
@@ -486,10 +503,10 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
"gdb-remote", nullptr);
if (process_sp) {
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
// Retry the connect remote one time...
if (error.Fail())
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
if (error.Success())
error = process_sp->Launch(launch_info);
else if (debugserver_pid != LLDB_INVALID_PROCESS_ID) {
@@ -572,7 +589,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
"gdb-remote", nullptr);
if (process_sp) {
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
if (error.Success()) {
ListenerSP listener_sp = attach_info.GetHijackListener();
if (listener_sp)
@@ -725,7 +742,8 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
response.GetResponseType() != response.eResponse)
return m_remote_signals_sp;
- auto object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ auto object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!object_sp || !object_sp->IsValid())
return m_remote_signals_sp;
@@ -772,7 +790,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
std::string description{""};
object_sp = dict->GetValueForKey("description");
if (object_sp && object_sp->IsValid())
- description = object_sp->GetStringValue();
+ description = std::string(object_sp->GetStringValue());
remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop,
notify, description.c_str());
@@ -811,7 +829,7 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
result.Printf(":%u", port);
if (path)
result.Write(path, strlen(path));
- return result.GetString();
+ return std::string(result.GetString());
}
lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 13edcbab9f59..0602be1fa377 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformRemoteGDBServer_h_
-#define liblldb_PlatformRemoteGDBServer_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H
#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 @@ public:
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
@@ -192,10 +194,12 @@ private:
llvm::Optional<std::string> DoGetUserName(UserIDResolver::id_t uid) override;
llvm::Optional<std::string> DoGetGroupName(UserIDResolver::id_t uid) override;
- DISALLOW_COPY_AND_ASSIGN(PlatformRemoteGDBServer);
+ PlatformRemoteGDBServer(const PlatformRemoteGDBServer &) = delete;
+ const PlatformRemoteGDBServer &
+ operator=(const PlatformRemoteGDBServer &) = delete;
};
} // namespace platform_gdb_server
} // namespace lldb_private
-#endif // liblldb_PlatformRemoteGDBServer_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H