diff options
author | Greg Clayton <gclayton@apple.com> | 2010-06-23 01:19:29 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-06-23 01:19:29 +0000 |
commit | 6611103cfe7a8c08554816fc08abef2e2960e799 (patch) | |
tree | b940bb129b59af3cf6923f8d69f095d2d9fc8dca /lldb/source/Commands/CommandObjectMultiword.cpp | |
parent | ef5a4383ad679e58743c540c25d6a1bab0c77423 (diff) | |
download | bcm5719-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/CommandObjectMultiword.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectMultiword.cpp | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index b5553d65b80..d8e8f546a53 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -12,7 +12,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -80,8 +80,12 @@ CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *ma } bool -CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *name, - CommandInterpreter *interpreter) +CommandObjectMultiword::LoadSubCommand +( + CommandInterpreter &interpreter, + const char *name, + const CommandObjectSP& cmd_obj +) { CommandMap::iterator pos; bool success = true; @@ -90,7 +94,7 @@ CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *nam if (pos == m_subcommand_dict.end()) { m_subcommand_dict[name] = cmd_obj; - interpreter->CrossRegisterCommand (name, GetCommandName()); + interpreter.CrossRegisterCommand (name, GetCommandName()); } else success = false; @@ -101,16 +105,15 @@ CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *nam bool CommandObjectMultiword::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { const size_t argc = args.GetArgumentCount(); if (argc == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else { @@ -120,7 +123,7 @@ CommandObjectMultiword::Execute { if (::strcasecmp (sub_command, "help") == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else if (!m_subcommand_dict.empty()) { @@ -133,7 +136,7 @@ CommandObjectMultiword::Execute args.Shift(); - sub_cmd_obj->ExecuteWithOptions (args, context, interpreter, result); + sub_cmd_obj->ExecuteWithOptions (interpreter, args, result); } else { @@ -176,7 +179,7 @@ CommandObjectMultiword::Execute } void -CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter) +CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result) { // First time through here, generate the help text for the object and // push it to the return result object as well @@ -185,7 +188,7 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; - std::string longest_word = interpreter->FindLongestCommandWord (m_subcommand_dict); + std::string longest_word = interpreter.FindLongestCommandWord (m_subcommand_dict); uint32_t max_len = 0; if (! longest_word.empty()) @@ -195,8 +198,11 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn { std::string indented_command (" "); indented_command.append (pos->first); - interpreter->OutputFormattedHelpText (result.GetOutputStream(), indented_command.c_str(), "--", - pos->second->GetHelp(), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + pos->second->GetHelp(), + max_len); } output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help <command> <subcommand>'.\n"); @@ -207,33 +213,40 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn int CommandObjectMultiword::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { if (cursor_index == 0) { - CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, input.GetArgumentAtIndex(0), matches); + CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, + input.GetArgumentAtIndex(0), + matches); if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != NULL && strcmp (input.GetArgumentAtIndex(0), matches.GetStringAtIndex(0)) == 0) { StringList temp_matches; - CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), &temp_matches); + CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), + &temp_matches); if (cmd_obj != NULL) { matches.DeleteStringAtIndex (0); input.Shift(); cursor_char_position = 0; input.AppendArgument (""); - return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return cmd_obj->HandleCompletion (interpreter, + input, cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } else return matches.GetSize(); @@ -243,7 +256,8 @@ CommandObjectMultiword::HandleCompletion } else { - CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), &matches); + CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), + &matches); if (sub_command_object == NULL) { return matches.GetSize(); @@ -254,8 +268,13 @@ CommandObjectMultiword::HandleCompletion matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; - return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return sub_command_object->HandleCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } } |