From 6611103cfe7a8c08554816fc08abef2e2960e799 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 23 Jun 2010 01:19:29 +0000 Subject: 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 --- lldb/source/Interpreter/CommandObject.cpp | 68 ++++++++++++------------------- 1 file changed, 25 insertions(+), 43 deletions(-) (limited to 'lldb/source/Interpreter/CommandObject.cpp') diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index eb8cdd2260d..384c03acfa2 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -133,21 +133,20 @@ CommandObject::GetFlags() const bool CommandObject::ExecuteCommandString ( + CommandInterpreter &interpreter, const char *command_line, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { Args command_args(command_line); - return ExecuteWithOptions (command_args, context, interpreter, result); + return ExecuteWithOptions (interpreter, command_args, result); } bool CommandObject::ParseOptions ( + CommandInterpreter &interpreter, Args& args, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -189,9 +188,8 @@ CommandObject::ParseOptions bool CommandObject::ExecuteWithOptions ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -199,10 +197,10 @@ CommandObject::ExecuteWithOptions { const char *tmp_str = args.GetArgumentAtIndex (i); if (tmp_str[0] == '`') // back-quote - args.ReplaceArgumentAtIndex (i, interpreter->ProcessEmbeddedScriptCommands (tmp_str)); + args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str)); } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) @@ -248,11 +246,11 @@ CommandObject::ExecuteWithOptions } } - if (!ParseOptions (args, interpreter, result)) + if (!ParseOptions (interpreter, args, result)) return false; // Call the command-specific version of 'Execute', passing it the already processed arguments. - return Execute (args, context, interpreter, result); + return Execute (interpreter, args, result); } class CommandDictCommandPartialMatch @@ -300,12 +298,12 @@ CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, int CommandObject::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { @@ -340,46 +338,30 @@ CommandObject::HandleCompletion input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); bool handled_by_options; - handled_by_options = cur_options->HandleOptionCompletion(input, - opt_element_vector, - cursor_index, - cursor_char_position, - match_start_point, - max_return_elements, - interpreter, - matches); + handled_by_options = cur_options->HandleOptionCompletion (interpreter, + input, + opt_element_vector, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); if (handled_by_options) return matches.GetSize(); } // If we got here, the last word is not an option or an option argument. - return HandleArgumentCompletion(input, - cursor_index, - cursor_char_position, - opt_element_vector, - match_start_point, - max_return_elements, - interpreter, - matches); + return HandleArgumentCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + opt_element_vector, + match_start_point, + max_return_elements, + matches); } } -int -CommandObject::HandleArgumentCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches -) -{ - return 0; -} - // Case insensitive version of ::strstr() // Returns true if s2 is contained within s1. -- cgit v1.2.3