summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-03-08 22:40:15 +0000
committerGreg Clayton <gclayton@apple.com>2011-03-08 22:40:15 +0000
commite996fd30be59b65b0607607aa907af7178568994 (patch)
treebe26b775d619b8375f6c874826fc14ef493fe76d /lldb/source/Commands/CommandObjectProcess.cpp
parent6111db9e9cde94262624891fd29d8225f4bc9de1 (diff)
downloadbcm5719-llvm-e996fd30be59b65b0607607aa907af7178568994.tar.gz
bcm5719-llvm-e996fd30be59b65b0607607aa907af7178568994.zip
LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS that supports LLDB should be registering a "default" platform that will be used unless a new platform is selected. Platforms are responsible for things such as: - getting process information by name or by processs ID - finding platform files. This is useful for remote debugging where there is an SDK with files that might already or need to be cached for debug access. - getting a list of platform supported architectures in the exact order they should be selected. This helps the native x86 platform on MacOSX select the correct x86_64/i386 slice from universal binaries. - Connect to remote platforms for remote debugging - Resolving an executable including finding an executable inside platform specific bundles (macosx uses .app bundles that contain files) and also selecting the appropriate slice of universal files for a given platform. So by default there is always a local platform, but remote platforms can be connected to. I will soon be adding a new "platform" command that will support the following commands: (lldb) platform connect --name machine1 macosx connect://host:port Connected to "machine1" platform. (lldb) platform disconnect macosx This allows LLDB to be well setup to do remote debugging and also once connected process listing and finding for things like: (lldb) process attach --name x<TAB> The currently selected platform plug-in can now auto complete any available processes that start with "x". The responsibilities for the platform plug-in will soon grow and expand. llvm-svn: 127286
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp64
1 files changed, 25 insertions, 39 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 9b2b2a4246d..0dbc9b82873 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -18,8 +18,9 @@
#include "lldb/Core/State.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "./CommandObjectThread.h"
+#include "CommandObjectThread.h"
#include "lldb/Host/Host.h"
+#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
@@ -518,38 +519,24 @@ public:
// Look to see if there is a -P argument provided, and if so use that plugin, otherwise
// use the default plugin.
- Process *process = interpeter.GetDebugger().GetExecutionContext().process;
- bool need_to_delete_process = false;
const char *partial_name = NULL;
partial_name = input.GetArgumentAtIndex(opt_arg_pos);
-
- if (process && process->IsAlive())
- return true;
-
- Target *target = interpeter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
- {
- // No target has been set yet, for now do host completion. Otherwise I don't know how we would
- // figure out what the right target to use is...
- std::vector<lldb::pid_t> pids;
- Host::ListProcessesMatchingName (partial_name, matches, pids);
- return true;
- }
- if (!process)
- {
- process = target->CreateProcess (interpeter.GetDebugger().GetListener(), partial_name).get();
- need_to_delete_process = true;
- }
-
- if (process)
+
+ PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+ if (platform_sp)
{
- matches.Clear();
- std::vector<lldb::pid_t> pids;
- process->ListProcessesMatchingName (NULL, matches, pids);
- if (need_to_delete_process)
- target->DeleteCurrentProcess();
- return true;
+ ProcessInfoList process_infos;
+ platform_sp->FindProcessesByName (partial_name, partial_name ? lldb::eNameMatchStartsWith : lldb::eNameMatchIgnore, process_infos);
+ const uint32_t num_matches = process_infos.GetSize();
+ if (num_matches > 0)
+ {
+ for (uint32_t i=0; i<num_matches; ++i)
+ {
+ matches.AppendString (process_infos.GetProcessNameAtIndex(i),
+ process_infos.GetProcessNameLengthAtIndex(i));
+ }
+ }
}
}
@@ -612,7 +599,6 @@ public:
error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
emptyFileSpec,
emptyArchSpec,
- NULL,
false,
new_target_sp);
target = new_target_sp.get();
@@ -716,17 +702,19 @@ public:
if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL)
{
- std::vector<lldb::pid_t> pids;
- StringList matches;
-
- process->ListProcessesMatchingName(wait_name, matches, pids);
- if (matches.GetSize() > 1)
+ ProcessInfoList process_infos;
+ PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+ if (platform_sp)
+ {
+ platform_sp->FindProcessesByName (wait_name, eNameMatchEquals, process_infos);
+ }
+ if (process_infos.GetSize() > 1)
{
result.AppendErrorWithFormat("More than one process named %s\n", wait_name);
result.SetStatus (eReturnStatusFailed);
return false;
}
- else if (matches.GetSize() == 0)
+ else if (process_infos.GetSize() == 0)
{
result.AppendErrorWithFormat("Could not find a process named %s\n", wait_name);
result.SetStatus (eReturnStatusFailed);
@@ -734,9 +722,8 @@ public:
}
else
{
- attach_pid = pids[0];
+ attach_pid = process_infos.GetProcessIDAtIndex (0);
}
-
}
if (attach_pid != LLDB_INVALID_PROCESS_ID)
@@ -1085,7 +1072,6 @@ public:
error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
emptyFileSpec,
emptyArchSpec,
- NULL,
false,
target_sp);
if (!target_sp || error.Fail())
OpenPOWER on IntegriCloud