summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandObjectScript.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/Interpreter/CommandObjectScript.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/Interpreter/CommandObjectScript.cpp')
-rw-r--r--lldb/source/Interpreter/CommandObjectScript.cpp70
1 files changed, 12 insertions, 58 deletions
diff --git a/lldb/source/Interpreter/CommandObjectScript.cpp b/lldb/source/Interpreter/CommandObjectScript.cpp
index 2cbca117bfc..3a7362de075 100644
--- a/lldb/source/Interpreter/CommandObjectScript.cpp
+++ b/lldb/source/Interpreter/CommandObjectScript.cpp
@@ -43,15 +43,12 @@ CommandObjectScript::~CommandObjectScript ()
bool
CommandObjectScript::ExecuteRawCommandString
(
+ CommandInterpreter &interpreter,
const char *command,
- CommandContext *context,
- CommandInterpreter *interpreter,
CommandReturnObject &result
)
{
- std::string arg_str (command);
-
- ScriptInterpreter *script_interpreter = GetInterpreter ();
+ ScriptInterpreter *script_interpreter = GetInterpreter (interpreter);
if (script_interpreter == NULL)
{
@@ -59,23 +56,11 @@ CommandObjectScript::ExecuteRawCommandString
result.SetStatus (eReturnStatusFailed);
}
- FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- if (out_fh && err_fh)
- {
- if (arg_str.empty())
- script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh);
- else
- script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
+ if (command == NULL || command[0] == '\0')
+ script_interpreter->ExecuteInterpreterLoop (interpreter);
else
- {
- if (out_fh == NULL)
- result.AppendError("invalid output file handle");
- else
- result.AppendError("invalid error file handle");
- }
+ script_interpreter->ExecuteOneLine (interpreter, command);
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
@@ -88,60 +73,29 @@ CommandObjectScript::WantsRawCommandString()
bool
CommandObjectScript::Execute
(
+ CommandInterpreter &interpreter,
Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
CommandReturnObject &result
)
{
- std::string arg_str;
- ScriptInterpreter *script_interpreter = GetInterpreter ();
-
- if (script_interpreter == NULL)
- {
- result.AppendError("no script interpeter");
- result.SetStatus (eReturnStatusFailed);
- }
-
- const int argc = command.GetArgumentCount();
- for (int i = 0; i < argc; ++i)
- arg_str.append(command.GetArgumentAtIndex(i));
-
-
- FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- if (out_fh && err_fh)
- {
- if (arg_str.empty())
- script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh);
- else
- script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else
- {
- if (out_fh == NULL)
- result.AppendError("invalid output file handle");
- else
- result.AppendError("invalid error file handle");
- }
- return result.Succeeded();
+ // everything should be handled in ExecuteRawCommandString
+ return false;
}
ScriptInterpreter *
-CommandObjectScript::GetInterpreter ()
+CommandObjectScript::GetInterpreter (CommandInterpreter &interpreter)
{
if (m_interpreter_ap.get() == NULL)
{
switch (m_script_lang)
{
case eScriptLanguagePython:
- m_interpreter_ap.reset (new ScriptInterpreterPython ());
+ m_interpreter_ap.reset (new ScriptInterpreterPython (interpreter));
break;
case eScriptLanguageNone:
- m_interpreter_ap.reset (new ScriptInterpreterNone ());
+ m_interpreter_ap.reset (new ScriptInterpreterNone (interpreter));
break;
}
}
OpenPOWER on IntegriCloud