summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-06-23 01:19:29 +0000
committerGreg Clayton <gclayton@apple.com>2010-06-23 01:19:29 +0000
commit6611103cfe7a8c08554816fc08abef2e2960e799 (patch)
treeb940bb129b59af3cf6923f8d69f095d2d9fc8dca /lldb/source/Commands/CommandObjectProcess.cpp
parentef5a4383ad679e58743c540c25d6a1bab0c77423 (diff)
downloadbcm5719-llvm-6611103cfe7a8c08554816fc08abef2e2960e799.tar.gz
bcm5719-llvm-6611103cfe7a8c08554816fc08abef2e2960e799.zip
Very large changes that were needed in order to allow multiple connections
to the debugger from GUI windows. Previously there was one global debugger instance that could be accessed that had its own command interpreter and current state (current target/process/thread/frame). When a GUI debugger was attached, if it opened more than one window that each had a console window, there were issues where the last one to setup the global debugger object won and got control of the debugger. To avoid this we now create instances of the lldb_private::Debugger that each has its own state: - target list for targets the debugger instance owns - current process/thread/frame - its own command interpreter - its own input, output and error file handles to avoid conflicts - its own input reader stack So now clients should call: SBDebugger::Initialize(); // (static function) SBDebugger debugger (SBDebugger::Create()); // Use which ever file handles you wish debugger.SetErrorFileHandle (stderr, false); debugger.SetOutputFileHandle (stdout, false); debugger.SetInputFileHandle (stdin, true); // main loop SBDebugger::Terminate(); // (static function) SBDebugger::Initialize() and SBDebugger::Terminate() are ref counted to ensure nothing gets destroyed too early when multiple clients might be attached. Cleaned up the command interpreter and the CommandObject and all subclasses to take more appropriate arguments. llvm-svn: 106615
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp108
1 files changed, 43 insertions, 65 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 0a8487155d3..84deb2fc593 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -120,13 +120,12 @@ public:
}
bool
- Execute (Args& launch_args,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& launch_args,
CommandReturnObject &result)
{
- Target *target = context->GetTarget();
- bool synchronous_execution = interpreter->GetSynchronous ();
+ Target *target = interpreter.GetDebugger().GetCurrentTarget().get();
+ bool synchronous_execution = interpreter.GetSynchronous ();
// bool launched = false;
// bool stopped_after_launch = false;
@@ -138,19 +137,11 @@ public:
}
// If our listener is NULL, users aren't allows to launch
- Listener *listener = interpreter->GetListener();
- if (listener == NULL)
- {
- result.AppendError ("operation not allowed through the command interpreter");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
char filename[PATH_MAX];
Module *exe_module = target->GetExecutableModule().get();
exe_module->GetFileSpec().GetPath(filename, sizeof(filename));
- Process *process = context->GetExecutionContext().process;
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process)
{
if (process->IsAlive())
@@ -168,10 +159,10 @@ public:
else
plugin_name = NULL;
- process = target->CreateProcess (*listener, plugin_name).get();
+ process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get();
- const Args *environment = interpreter->GetEnvironmentVariables();
- const Args *run_args = interpreter->GetProgramArguments();
+ const Args *environment = interpreter.GetEnvironmentVariables();
+ const Args *run_args = interpreter.GetProgramArguments();
// There are two possible sources of args to be passed to the process upon launching: Those the user
// typed at the run command (launch_args); or those the user pre-set in the run-args variable (run_args).
@@ -185,7 +176,7 @@ public:
else
{
// launch-args was not empty; use that, AND re-set run-args to contains launch-args values.
- StateVariable *run_args_var = interpreter->GetStateVariable ("run-args");
+ StateVariable *run_args_var = interpreter.GetStateVariable ("run-args");
if (run_args_var != NULL)
{
run_args_var->ArrayClearValues();
@@ -229,7 +220,7 @@ public:
{
// Call continue_command.
CommandReturnObject continue_result;
- interpreter->HandleCommand("process continue", false, continue_result);
+ interpreter.HandleCommand("process continue", false, continue_result);
}
if (synchronous_execution)
@@ -296,12 +287,11 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Target *target = context->GetTarget();
+ Target *target = interpreter.GetDebugger().GetCurrentTarget().get();
if (target == NULL)
{
result.AppendError ("invalid target, set executable file using 'file' command");
@@ -310,14 +300,8 @@ public:
}
// If our listener is NULL, users aren't allows to launch
- Listener *listener = interpreter->GetListener();
- if (listener == NULL)
- {
- result.AppendError ("operation not allowed through the command interpreter");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- Process *process = context->GetExecutionContext().process;
+
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process)
{
if (process->IsAlive())
@@ -340,7 +324,7 @@ public:
if (!m_options.plugin_name.empty())
plugin_name = m_options.plugin_name.c_str();
- process = target->CreateProcess (*listener, plugin_name).get();
+ process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get();
if (process)
{
@@ -508,13 +492,12 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Process *process = context->GetExecutionContext().process;
- bool synchronous_execution = interpreter->GetSynchronous ();
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
+ bool synchronous_execution = interpreter.GetSynchronous ();
if (process == NULL)
{
@@ -595,12 +578,11 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Process *process = context->GetExecutionContext().process;
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("must have a valid process in order to detach");
@@ -643,12 +625,11 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Process *process = context->GetExecutionContext().process;
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to signal");
@@ -711,12 +692,11 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Process *process = context->GetExecutionContext().process;
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to halt");
@@ -773,12 +753,11 @@ public:
}
bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
+ Execute (CommandInterpreter &interpreter,
+ Args& command,
CommandReturnObject &result)
{
- Process *process = context->GetExecutionContext().process;
+ Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process == NULL)
{
result.AppendError ("no process to kill");
@@ -832,15 +811,14 @@ public:
bool
Execute
(
+ CommandInterpreter &interpreter,
Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
CommandReturnObject &result
)
{
StreamString &output_stream = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- ExecutionContext exe_ctx(context->GetExecutionContext());
+ ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext());
if (exe_ctx.process)
{
const StateType state = exe_ctx.process->GetState();
@@ -891,19 +869,19 @@ public:
// CommandObjectMultiwordProcess
//-------------------------------------------------------------------------
-CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter *interpreter) :
+CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
CommandObjectMultiword ("process",
"A set of commands for operating on a process.",
"process <subcommand> [<subcommand-options>]")
{
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessAttach ()), "attach", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessLaunch ()), "launch", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessContinue ()), "continue", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessDetach ()), "detach", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessSignal ()), "signal", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessStatus ()), "status", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessInterrupt ()), "interrupt", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectProcessKill ()), "kill", interpreter);
+ LoadSubCommand (interpreter, "attach", CommandObjectSP (new CommandObjectProcessAttach ()));
+ LoadSubCommand (interpreter, "launch", CommandObjectSP (new CommandObjectProcessLaunch ()));
+ LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectProcessContinue ()));
+ LoadSubCommand (interpreter, "detach", CommandObjectSP (new CommandObjectProcessDetach ()));
+ LoadSubCommand (interpreter, "signal", CommandObjectSP (new CommandObjectProcessSignal ()));
+ LoadSubCommand (interpreter, "status", CommandObjectSP (new CommandObjectProcessStatus ()));
+ LoadSubCommand (interpreter, "interrupt", CommandObjectSP (new CommandObjectProcessInterrupt ()));
+ LoadSubCommand (interpreter, "kill", CommandObjectSP (new CommandObjectProcessKill ()));
}
CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()
OpenPOWER on IntegriCloud