aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-04-12 05:54:46 +0000
committerGreg Clayton <gclayton@apple.com>2011-04-12 05:54:46 +0000
commit8b82f087a0499319640f5d06498f965fa0214c72 (patch)
tree561c493dbe3e1a176d4c1b4ddd0c0afb396d3bea /lldb/source/Commands/CommandObjectProcess.cpp
parentf52718899fa93f19403336355bca8117321ee834 (diff)
downloadllvm-8b82f087a0499319640f5d06498f965fa0214c72.zip
llvm-8b82f087a0499319640f5d06498f965fa0214c72.tar.gz
llvm-8b82f087a0499319640f5d06498f965fa0214c72.tar.bz2
Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used. Make sure that Modules can track their object file offsets correctly to allow opening of sub object files (like the "__commpage" on darwin). Modified the Platforms to be able to launch processes. The first part of this move is the platform soon will become the entity that launches your program and when it does, it uses a new ProcessLaunchInfo class which encapsulates all process launching settings. This simplifies the internal APIs needed for launching. I want to slowly phase out process launching from the process classes, so for now we can still launch just as we used to, but eventually the platform is the object that should do the launching. Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able to launch processes with all of the new eLaunchFlag settings. Modified any code that was manually launching processes to use the Host::LaunchProcess functions. Fixed an issue where lldb_private::Args had implicitly defined copy constructors that could do the wrong thing. This has now been fixed by adding an appropriate copy constructor and assignment operator. Make sure we don't add empty ModuleSP entries to a module list. Fixed the commpage module creation on MacOSX, but we still need to train the MacOSX dynamic loader to not get rid of it when it doesn't have an entry in the all image infos. Abstracted many more calls from in ProcessGDBRemote down into the GDBRemoteCommunicationClient subclass to make the classes cleaner and more efficient. Fixed the default iOS ARM register context to be correct and also added support for targets that don't support the qThreadStopInfo packet by selecting the current thread (only if needed) and then sending a stop reply packet. Debugserver can now start up with a --unix-socket (-u for short) and can then bind to port zero and send the port it bound to to a listening process on the other end. This allows the GDB remote platform to spawn new GDB server instances (debugserver) to allow platform debugging. llvm-svn: 129351
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp104
1 files changed, 45 insertions, 59 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 116309d..1fc573b 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -175,7 +175,7 @@ public:
exe_module->GetFileSpec().GetPath(filename, sizeof(filename));
StateType state = eStateInvalid;
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process)
{
state = process->GetState();
@@ -266,7 +266,10 @@ public:
if (process->GetDisableASLR())
launch_flags |= eLaunchFlagDisableASLR;
-
+
+ if (m_options.in_new_tty)
+ launch_flags |= eLaunchFlagLaunchInTTY;
+
if (m_options.no_stdio)
launch_flags |= eLaunchFlagDisableSTDIO;
else if (!m_options.in_new_tty
@@ -287,52 +290,35 @@ public:
if (!m_options.working_dir.empty())
working_dir = m_options.working_dir.c_str();
- if (m_options.in_new_tty)
+ const char * stdin_path = NULL;
+ const char * stdout_path = NULL;
+ const char * stderr_path = NULL;
+
+ // Were any standard input/output/error paths given on the command line?
+ if (m_options.stdin_path.empty() &&
+ m_options.stdout_path.empty() &&
+ m_options.stderr_path.empty())
{
-
- lldb::pid_t pid = Host::LaunchInNewTerminal (m_options.tty_name.c_str(),
- inferior_argv,
- inferior_envp,
- working_dir,
- &exe_module->GetArchitecture(),
- true,
- process->GetDisableASLR());
-
- if (pid != LLDB_INVALID_PROCESS_ID)
- error = process->Attach (pid);
+ // No standard file handles were given on the command line, check
+ // with the process object in case they were give using "set settings"
+ stdin_path = process->GetStandardInputPath();
+ stdout_path = process->GetStandardOutputPath();
+ stderr_path = process->GetStandardErrorPath();
}
else
{
- const char * stdin_path = NULL;
- const char * stdout_path = NULL;
- const char * stderr_path = NULL;
-
- // Were any standard input/output/error paths given on the command line?
- if (m_options.stdin_path.empty() &&
- m_options.stdout_path.empty() &&
- m_options.stderr_path.empty())
- {
- // No standard file handles were given on the command line, check
- // with the process object in case they were give using "set settings"
- stdin_path = process->GetStandardInputPath();
- stdout_path = process->GetStandardOutputPath();
- stderr_path = process->GetStandardErrorPath();
- }
- else
- {
- stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str();
- stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str();
- stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str();
- }
-
- error = process->Launch (inferior_argv,
- inferior_envp,
- launch_flags,
- stdin_path,
- stdout_path,
- stderr_path,
- working_dir);
+ stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str();
+ stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str();
+ stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str();
}
+
+ error = process->Launch (inferior_argv,
+ inferior_envp,
+ launch_flags,
+ stdin_path,
+ stdout_path,
+ stderr_path,
+ working_dir);
if (error.Success())
{
@@ -521,11 +507,11 @@ public:
const char *partial_name = NULL;
partial_name = input.GetArgumentAtIndex(opt_arg_pos);
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
+ PlatformSP platform_sp (m_interpreter.GetPlatform (true));
if (platform_sp)
{
- ProcessInfoList process_infos;
- ProcessInfoMatch match_info;
+ ProcessInstanceInfoList process_infos;
+ ProcessInstanceInfoMatch match_info;
if (partial_name)
{
match_info.GetProcessInfo().SetName(partial_name);
@@ -579,7 +565,7 @@ public:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
bool synchronous_execution = m_interpreter.GetSynchronous ();
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
StateType state = eStateInvalid;
if (process)
{
@@ -707,11 +693,11 @@ public:
if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL)
{
- ProcessInfoList process_infos;
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
+ ProcessInstanceInfoList process_infos;
+ PlatformSP platform_sp (m_interpreter.GetPlatform (true));
if (platform_sp)
{
- ProcessInfoMatch match_info (wait_name, eNameMatchEquals);
+ ProcessInstanceInfoMatch match_info (wait_name, eNameMatchEquals);
platform_sp->FindProcesses (match_info, process_infos);
}
if (process_infos.GetSize() > 1)
@@ -860,7 +846,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
bool synchronous_execution = m_interpreter.GetSynchronous ();
if (process == NULL)
@@ -947,7 +933,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("must have a valid process in order to detach");
@@ -1057,7 +1043,7 @@ public:
TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
Error error;
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process)
{
if (process->IsAlive())
@@ -1172,7 +1158,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("must have a valid process in order to load a shared library");
@@ -1230,7 +1216,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("must have a valid process in order to load a shared library");
@@ -1307,7 +1293,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to signal");
@@ -1382,7 +1368,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to halt");
@@ -1444,7 +1430,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to kill");
@@ -1507,7 +1493,7 @@ public:
{
Stream &output_stream = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
+ ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
if (exe_ctx.process)
{
const StateType state = exe_ctx.process->GetState();