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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@106615 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 1762f5d..3f8581c 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -18,7 +18,7 @@
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/CommandContext.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Process.h"
@@ -46,12 +46,11 @@
}
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)
{
uint32_t argc = command.GetArgumentCount();
@@ -70,9 +69,9 @@
if (from[0] && to[0])
{
bool last_pair = ((argc - i) == 2);
- target->GetImageSearchPathList().Append(ConstString(from),
- ConstString(to),
- last_pair); // Notify if this is the last pair
+ target->GetImageSearchPathList().Append (ConstString(from),
+ ConstString(to),
+ last_pair); // Notify if this is the last pair
}
else
{
@@ -110,12 +109,11 @@
}
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)
{
bool notify = true;
@@ -146,12 +144,11 @@
}
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)
{
uint32_t argc = command.GetArgumentCount();
@@ -230,12 +227,11 @@
}
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)
{
if (command.GetArgumentCount() != 0)
@@ -272,12 +268,11 @@
}
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)
{
if (command.GetArgumentCount() != 1)
@@ -327,8 +322,8 @@
//
// bool
// Execute (Args& command,
-// CommandContext *context,
-// CommandInterpreter *interpreter,
+// Debugger *context,
+// CommandInterpreter &interpreter,
// CommandReturnObject &result)
// {
// ExecutionContext exe_ctx (context->GetExecutionContext());
@@ -392,16 +387,16 @@
{
public:
- CommandObjectMultiwordImageSearchPaths (CommandInterpreter *interpreter) :
+ CommandObjectMultiwordImageSearchPaths (CommandInterpreter &interpreter) :
CommandObjectMultiword ("target image-search-paths",
"A set of commands for operating on debugger target image search paths.",
"target image-search-paths <subcommand> [<subcommand-options>]")
{
- LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ()), "add", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ()), "clear", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ()), "insert", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsList ()), "list", interpreter);
- LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ()), "query", interpreter);
+ LoadSubCommand (interpreter, "add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ()));
+ LoadSubCommand (interpreter, "clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ()));
+ LoadSubCommand (interpreter, "insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ()));
+ LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList ()));
+ LoadSubCommand (interpreter, "query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ()));
}
~CommandObjectMultiwordImageSearchPaths()
@@ -416,12 +411,12 @@
// CommandObjectMultiwordTarget
//-------------------------------------------------------------------------
-CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter *interpreter) :
+CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) :
CommandObjectMultiword ("target",
"A set of commands for operating on debugger targets.",
"target <subcommand> [<subcommand-options>]")
{
- LoadSubCommand (CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter)), "image-search-paths", interpreter);
+ LoadSubCommand (interpreter, "image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter)));
}
CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget ()