[Lldb-commits] [lldb] 18e4272 - [lldb] Prevent 'process connect' from using local-only plugins
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 23 00:49:21 PST 2020
Author: Michał Górny
Date: 2020-11-23T09:48:55+01:00
New Revision: 18e4272a4fe4667a44f4d323140645a83ddfd864
URL: https://github.com/llvm/llvm-project/commit/18e4272a4fe4667a44f4d323140645a83ddfd864
DIFF: https://github.com/llvm/llvm-project/commit/18e4272a4fe4667a44f4d323140645a83ddfd864.diff
LOG: [lldb] Prevent 'process connect' from using local-only plugins
Add a 'can_connect' parameter to Process plugin initialization, and use
it to filter plugins to these capable of remote connections. This is
used to prevent 'process connect' from picking up a plugin that can only
be used locally, e.g. the legacy FreeBSD plugin.
Differential Revision: https://reviews.llvm.org/D91810
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/ProcessTrace.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/ProcessTrace.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TraceSessionFileParser.cpp
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
lldb/test/Shell/Commands/command-process-connect.test
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 7f1e1e8765568..744deab276c49 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -537,7 +537,8 @@ class Process : public std::enable_shared_from_this<Process>,
static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
llvm::StringRef plugin_name,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
+ const FileSpec *crash_file_path,
+ bool can_connect);
/// Static function that can be used with the \b host function
/// Host::StartMonitoringChildProcess ().
diff --git a/lldb/include/lldb/Target/ProcessTrace.h b/lldb/include/lldb/Target/ProcessTrace.h
index f947fbe8cdb42..53b3e704c17b0 100644
--- a/lldb/include/lldb/Target/ProcessTrace.h
+++ b/lldb/include/lldb/Target/ProcessTrace.h
@@ -77,7 +77,8 @@ class ProcessTrace : public PostMortemProcess {
private:
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
+ const FileSpec *crash_file_path,
+ bool can_connect);
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index f77917a8812f7..47568c9e44299 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -573,7 +573,8 @@ class Target : public std::enable_shared_from_this<Target>,
// used.
const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
llvm::StringRef plugin_name,
- const FileSpec *crash_file);
+ const FileSpec *crash_file,
+ bool can_connect);
const lldb::ProcessSP &GetProcessSP() const;
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 1a4eaba7cc5e7..df33f8af0e142 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -76,7 +76,7 @@ typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force,
const ArchSpec *arch);
typedef lldb::ProcessSP (*ProcessCreateInstance)(
lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
+ const FileSpec *crash_file_path, bool can_connect);
typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(
Debugger &debugger);
typedef SymbolFile *(*SymbolFileCreateInstance)(lldb::ObjectFileSP objfile_sp);
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 34cab6217565c..2a305159bbb58 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -267,7 +267,7 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
FileSpec filespec(core_file);
FileSystem::Instance().Resolve(filespec);
ProcessSP process_sp(target_sp->CreateProcess(
- target_sp->GetDebugger().GetListener(), "", &filespec));
+ target_sp->GetDebugger().GetListener(), "", &filespec, false));
if (process_sp) {
error.SetError(process_sp->LoadCore());
if (error.Success())
@@ -567,10 +567,11 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (listener.IsValid())
process_sp =
- target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
+ target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr,
+ true);
else
process_sp = target_sp->CreateProcess(
- target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
+ target_sp->GetDebugger().GetListener(), plugin_name, nullptr, true);
if (process_sp) {
sb_process.SetSP(process_sp);
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 98285289e3a98..eba129c461b39 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -401,7 +401,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed {
target_sp->AppendExecutableSearchPaths(core_file_dir);
ProcessSP process_sp(target_sp->CreateProcess(
- GetDebugger().GetListener(), llvm::StringRef(), &core_file));
+ GetDebugger().GetListener(), llvm::StringRef(), &core_file,
+ false));
if (process_sp) {
// Seems weird that we Launch a core file, but that is what we
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 7f6cbd7fab587..47f62a9ca04fc 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -388,7 +388,8 @@ lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
process_sp =
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
- attach_info.GetProcessPluginName(), nullptr);
+ attach_info.GetProcessPluginName(), nullptr,
+ false);
if (process_sp) {
ListenerSP listener_sp = attach_info.GetHijackListener();
@@ -468,7 +469,8 @@ PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Now create the gdb-remote process.
LLDB_LOG(log, "having target create process with gdb-remote plugin");
process_sp =
- target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
+ target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr,
+ true);
if (!process_sp) {
error.SetErrorString("CreateProcess() failed for gdb-remote process");
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 167a92118fdad..0ef4dcb7b9f64 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -233,7 +233,8 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info,
return Attach(attach_info, debugger, target, error);
} else {
ProcessSP process_sp = target->CreateProcess(
- launch_info.GetListener(), launch_info.GetProcessPluginName(), nullptr);
+ launch_info.GetListener(), launch_info.GetProcessPluginName(), nullptr,
+ false);
// We need to launch and attach to the process.
launch_info.GetFlags().Set(eLaunchFlagDebug);
@@ -275,7 +276,7 @@ lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info,
const char *plugin_name = attach_info.GetProcessPluginName();
process_sp = target->CreateProcess(
- attach_info.GetListenerForProcess(debugger), plugin_name, nullptr);
+ attach_info.GetListenerForProcess(debugger), plugin_name, nullptr, false);
process_sp->HijackProcessEvents(attach_info.GetHijackListener());
if (process_sp)
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index e8bfbd889299f..b3774b9c226c2 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -500,7 +500,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
process_sp = target->CreateProcess(launch_info.GetListener(),
- "gdb-remote", nullptr);
+ "gdb-remote", nullptr, true);
if (process_sp) {
error = process_sp->ConnectRemote(connect_url.c_str());
@@ -587,7 +587,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
// so even when debugging locally we are debugging remotely!
process_sp =
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
- "gdb-remote", nullptr);
+ "gdb-remote", nullptr, true);
if (process_sp) {
error = process_sp->ConnectRemote(connect_url.c_str());
if (error.Success()) {
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index 67a18bd8de13b..ed134d8f2a369 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -70,9 +70,10 @@ UnixSignalsSP &GetFreeBSDSignals() {
lldb::ProcessSP
ProcessFreeBSD::CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path) {
+ const FileSpec *crash_file_path,
+ bool can_connect) {
lldb::ProcessSP process_sp;
- if (crash_file_path == NULL)
+ if (crash_file_path == NULL && !can_connect)
process_sp.reset(
new ProcessFreeBSD(target_sp, listener_sp, GetFreeBSDSignals()));
return process_sp;
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
index 536da0c0aa70e..dbb2acb1cd3f7 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -26,7 +26,8 @@ class ProcessFreeBSD : public lldb_private::Process {
// Static functions.
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *crash_file_path);
+ const lldb_private::FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 6e394eac6f9e6..c3f1d019d66cd 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -111,7 +111,8 @@ void ProcessKDP::Terminate() {
lldb::ProcessSP ProcessKDP::CreateInstance(TargetSP target_sp,
ListenerSP listener_sp,
- const FileSpec *crash_file_path) {
+ const FileSpec *crash_file_path,
+ bool can_connect) {
lldb::ProcessSP process_sp;
if (crash_file_path == NULL)
process_sp = std::make_shared<ProcessKDP>(target_sp, listener_sp);
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
index 52af56134404c..137b67809a632 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
@@ -32,7 +32,8 @@ class ProcessKDP : public lldb_private::Process {
// Constructors and Destructors
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *crash_file_path);
+ const lldb_private::FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 96e2603b993ea..11bfc7c897d54 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -79,7 +79,8 @@ namespace lldb_private {
ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *) {
+ const FileSpec *,
+ bool can_connect) {
return ProcessSP(new ProcessWindows(target_sp, listener_sp));
}
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
index a1085df022c91..7d1443176d3b5 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
@@ -25,7 +25,8 @@ class ProcessWindows : public Process, public ProcessDebugger {
// Static functions.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *);
+ const FileSpec *,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index dbc1a01814322..3bcf560c4f07e 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -52,9 +52,10 @@ void ProcessElfCore::Terminate() {
lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file) {
+ const FileSpec *crash_file,
+ bool can_connect) {
lldb::ProcessSP process_sp;
- if (crash_file) {
+ if (crash_file && !can_connect) {
// Read enough data for a ELF32 header or ELF64 header Note: Here we care
// about e_type field only, so it is safe to ignore possible presence of
// the header extension.
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 9f796d69b90b2..793f3cda126f6 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -33,7 +33,8 @@ class ProcessElfCore : public lldb_private::PostMortemProcess {
// Constructors and Destructors
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *crash_file_path);
+ const lldb_private::FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 0cd97abc3f4ff..4c00e9a4c6733 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -205,7 +205,8 @@ void ProcessGDBRemote::Terminate() {
lldb::ProcessSP
ProcessGDBRemote::CreateInstance(lldb::TargetSP target_sp,
ListenerSP listener_sp,
- const FileSpec *crash_file_path) {
+ const FileSpec *crash_file_path,
+ bool can_connect) {
lldb::ProcessSP process_sp;
if (crash_file_path == nullptr)
process_sp = std::make_shared<ProcessGDBRemote>(target_sp, listener_sp);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index e47300fac2d0a..5efe8b757af82 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -55,7 +55,8 @@ class ProcessGDBRemote : public Process,
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
+ const FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index c1a8d167be356..6f03825cd6cdd 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -61,9 +61,10 @@ void ProcessMachCore::Terminate() {
lldb::ProcessSP ProcessMachCore::CreateInstance(lldb::TargetSP target_sp,
ListenerSP listener_sp,
- const FileSpec *crash_file) {
+ const FileSpec *crash_file,
+ bool can_connect) {
lldb::ProcessSP process_sp;
- if (crash_file) {
+ if (crash_file && !can_connect) {
const size_t header_size = sizeof(llvm::MachO::mach_header);
auto data_sp = FileSystem::Instance().CreateDataBuffer(
crash_file->GetPath(), header_size, 0);
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index 9c85139c78464..60463bc44d417 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -28,7 +28,8 @@ class ProcessMachCore : public lldb_private::PostMortemProcess {
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener,
- const lldb_private::FileSpec *crash_file_path);
+ const lldb_private::FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 1850a36f27723..c001547eefd63 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -200,8 +200,9 @@ const char *ProcessMinidump::GetPluginDescriptionStatic() {
lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file) {
- if (!crash_file)
+ const FileSpec *crash_file,
+ bool can_connect) {
+ if (!crash_file || can_connect)
return nullptr;
lldb::ProcessSP process_sp;
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
index 1d4d535d697a4..9a68bd43551aa 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -30,7 +30,8 @@ class ProcessMinidump : public PostMortemProcess {
public:
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path);
+ const FileSpec *crash_file_path,
+ bool can_connect);
static void Initialize();
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 685dd9515e1bf..b5b673a33e44b 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1834,7 +1834,7 @@ lldb::ProcessSP Platform::DoConnectProcess(llvm::StringRef connect_url,
debugger.GetTargetList().SetSelectedTarget(target);
lldb::ProcessSP process_sp =
- target->CreateProcess(debugger.GetListener(), plugin_name, nullptr);
+ target->CreateProcess(debugger.GetListener(), plugin_name, nullptr, true);
if (!process_sp)
return nullptr;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index c2effda3bdcb7..14f8326cfcec4 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -479,7 +479,8 @@ llvm::ArrayRef<OptionDefinition> ProcessLaunchCommandOptions::GetDefinitions() {
ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
llvm::StringRef plugin_name,
ListenerSP listener_sp,
- const FileSpec *crash_file_path) {
+ const FileSpec *crash_file_path,
+ bool can_connect) {
static uint32_t g_process_unique_id = 0;
ProcessSP process_sp;
@@ -489,7 +490,8 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
create_callback =
PluginManager::GetProcessCreateCallbackForPluginName(const_plugin_name);
if (create_callback) {
- process_sp = create_callback(target_sp, listener_sp, crash_file_path);
+ process_sp = create_callback(target_sp, listener_sp, crash_file_path,
+ can_connect);
if (process_sp) {
if (process_sp->CanDebug(target_sp, true)) {
process_sp->m_process_unique_id = ++g_process_unique_id;
@@ -502,7 +504,8 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
(create_callback =
PluginManager::GetProcessCreateCallbackAtIndex(idx)) != nullptr;
++idx) {
- process_sp = create_callback(target_sp, listener_sp, crash_file_path);
+ process_sp = create_callback(target_sp, listener_sp, crash_file_path,
+ can_connect);
if (process_sp) {
if (process_sp->CanDebug(target_sp, false)) {
process_sp->m_process_unique_id = ++g_process_unique_id;
diff --git a/lldb/source/Target/ProcessTrace.cpp b/lldb/source/Target/ProcessTrace.cpp
index 85e5380fe70b8..4f7a5766c35dd 100644
--- a/lldb/source/Target/ProcessTrace.cpp
+++ b/lldb/source/Target/ProcessTrace.cpp
@@ -34,7 +34,10 @@ void ProcessTrace::Terminate() {
ProcessSP ProcessTrace::CreateInstance(TargetSP target_sp,
ListenerSP listener_sp,
- const FileSpec *crash_file) {
+ const FileSpec *crash_file,
+ bool can_connect) {
+ if (can_connect)
+ return nullptr;
return std::make_shared<ProcessTrace>(target_sp, listener_sp);
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 9bed2035bf854..c6bb989c132e1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -199,12 +199,13 @@ void Target::DeleteCurrentProcess() {
const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp,
llvm::StringRef plugin_name,
- const FileSpec *crash_file) {
+ const FileSpec *crash_file,
+ bool can_connect) {
if (!listener_sp)
listener_sp = GetDebugger().GetListener();
DeleteCurrentProcess();
m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name,
- listener_sp, crash_file);
+ listener_sp, crash_file, can_connect);
return m_process_sp;
}
@@ -2975,7 +2976,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
} else {
// Use a Process plugin to construct the process.
const char *plugin_name = launch_info.GetProcessPluginName();
- CreateProcess(launch_info.GetListener(), plugin_name, nullptr);
+ CreateProcess(launch_info.GetListener(), plugin_name, nullptr, false);
}
// Since we didn't have a platform launch the process, launch it here.
@@ -3103,7 +3104,7 @@ Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
const char *plugin_name = attach_info.GetProcessPluginName();
process_sp =
CreateProcess(attach_info.GetListenerForProcess(GetDebugger()),
- plugin_name, nullptr);
+ plugin_name, nullptr, false);
if (process_sp == nullptr) {
error.SetErrorStringWithFormat(
"failed to create process using plugin %s",
diff --git a/lldb/source/Target/TraceSessionFileParser.cpp b/lldb/source/Target/TraceSessionFileParser.cpp
index bf6b6204e1e0b..1cef818309893 100644
--- a/lldb/source/Target/TraceSessionFileParser.cpp
+++ b/lldb/source/Target/TraceSessionFileParser.cpp
@@ -127,7 +127,8 @@ TraceSessionFileParser::ParseProcess(const JSONProcess &process) {
ProcessSP process_sp = target_sp->CreateProcess(
/*listener*/ nullptr, "trace",
- /*crash_file*/ nullptr);
+ /*crash_file*/ nullptr,
+ /*can_connect*/ false);
process_sp->SetID(static_cast<lldb::pid_t>(process.pid));
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
index 5e98e3b028d03..e9152f02a15ed 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
@@ -11,7 +11,6 @@ class TestProcessConnect(GDBRemoteTestBase):
NO_DEBUG_INFO_TESTCASE = True
- @skipIfWindows
def test_gdb_remote_sync(self):
"""Test the gdb-remote command in synchronous mode"""
try:
@@ -21,7 +20,6 @@ def test_gdb_remote_sync(self):
finally:
self.dbg.GetSelectedPlatform().DisconnectRemote()
- @skipIfWindows
@skipIfReproducer # Reproducer don't support async.
def test_gdb_remote_async(self):
"""Test the gdb-remote command in asynchronous mode"""
@@ -35,8 +33,6 @@ def test_gdb_remote_async(self):
finally:
self.dbg.GetSelectedPlatform().DisconnectRemote()
- @skipIfWindows
- @expectedFailureAll(oslist=["freebsd"])
def test_process_connect_sync(self):
"""Test the gdb-remote command in synchronous mode"""
try:
@@ -47,8 +43,6 @@ def test_process_connect_sync(self):
finally:
self.dbg.GetSelectedPlatform().DisconnectRemote()
- @skipIfWindows
- @expectedFailureAll(oslist=["freebsd"])
@skipIfReproducer # Reproducer don't support async.
def test_process_connect_async(self):
"""Test the gdb-remote command in asynchronous mode"""
diff --git a/lldb/test/Shell/Commands/command-process-connect.test b/lldb/test/Shell/Commands/command-process-connect.test
index 415cda123b358..c4761360d5411 100644
--- a/lldb/test/Shell/Commands/command-process-connect.test
+++ b/lldb/test/Shell/Commands/command-process-connect.test
@@ -1,6 +1,3 @@
-# UNSUPPORTED: system-windows
-# XFAIL: system-freebsd
-
# Synchronous
# RUN: %lldb -o 'platform select remote-gdb-server' -o 'process connect connect://localhost:4321' 2>&1 | FileCheck %s
More information about the lldb-commits
mailing list