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 | |
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')
65 files changed, 841 insertions, 1305 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index f2bf7da63aa..5d42229917b 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -33,13 +33,16 @@ CommandCompletions::g_common_completions[] = }; bool -CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, - const char *completion_str, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::InvokeCommonCompletionCallbacks +( + CommandInterpreter &interpreter, + uint32_t completion_mask, + const char *completion_str, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { bool handled = false; @@ -54,10 +57,10 @@ CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, && g_common_completions[i].callback != NULL) { handled = true; - g_common_completions[i].callback (completion_str, + g_common_completions[i].callback (interpreter, + completion_str, match_start_point, max_return_elements, - interpreter, searcher, matches); } @@ -66,20 +69,27 @@ CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, } int -CommandCompletions::SourceFiles (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::SourceFiles +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { // Find some way to switch "include support files..." - SourceFileCompleter completer (false, partial_file_name, match_start_point, max_return_elements, interpreter, + SourceFileCompleter completer (interpreter, + false, + partial_file_name, + match_start_point, + max_return_elements, matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -91,18 +101,25 @@ CommandCompletions::SourceFiles (const char *partial_file_name, } int -CommandCompletions::Modules (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Modules +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { - ModuleCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); - + ModuleCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); + if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -114,18 +131,24 @@ CommandCompletions::Modules (const char *partial_file_name, } int -CommandCompletions::Symbols (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Symbols +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches) { - SymbolCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); + SymbolCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -136,17 +159,18 @@ CommandCompletions::Symbols (const char *partial_file_name, return matches.GetSize(); } -CommandCompletions::Completer::Completer ( +CommandCompletions::Completer::Completer +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : + m_interpreter (interpreter), m_completion_str (completion_str), m_match_start_point (match_start_point), m_max_return_elements (max_return_elements), - m_interpreter (interpreter), m_matches (matches) { } @@ -160,15 +184,16 @@ CommandCompletions::Completer::~Completer () // SourceFileCompleter //---------------------------------------------------------------------- -CommandCompletions::SourceFileCompleter::SourceFileCompleter ( +CommandCompletions::SourceFileCompleter::SourceFileCompleter +( + CommandInterpreter &interpreter, bool include_support_files, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches), + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches), m_include_support_files (include_support_files), m_matching_files() { @@ -264,14 +289,15 @@ regex_chars (const char comp) else return false; } -CommandCompletions::SymbolCompleter::SymbolCompleter ( +CommandCompletions::SymbolCompleter::SymbolCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { std::string regex_str ("^"); regex_str.append(completion_str); @@ -353,14 +379,15 @@ CommandCompletions::SymbolCompleter::DoCompletion (SearchFilter *filter) //---------------------------------------------------------------------- // ModuleCompleter //---------------------------------------------------------------------- -CommandCompletions::ModuleCompleter::ModuleCompleter ( +CommandCompletions::ModuleCompleter::ModuleCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { FileSpec partial_spec (m_completion_str.c_str()); m_file_name = partial_spec.GetFilename().GetCString(); diff --git a/lldb/source/Commands/CommandObjectAdd.cpp b/lldb/source/Commands/CommandObjectAdd.cpp deleted file mode 100644 index 1bd5fe4518d..00000000000 --- a/lldb/source/Commands/CommandObjectAdd.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===-- CommandObjectAdd.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectAdd.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -CommandObjectAdd::CommandObjectAdd () : - CommandObject ("add", - "Allows the user to add a new command/function pair to the debugger's dictionary.", - "add <new-command-name> <script-function-name>") -{ -} - -CommandObjectAdd::~CommandObjectAdd() -{ -} - - -bool -CommandObjectAdd::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - result.AppendMessage ("This function has not been implemented yet."); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); -} diff --git a/lldb/source/Commands/CommandObjectAdd.h b/lldb/source/Commands/CommandObjectAdd.h deleted file mode 100644 index 9aa59b61a7a..00000000000 --- a/lldb/source/Commands/CommandObjectAdd.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CommandObjectAdd.h --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectAdd_h_ -#define liblldb_CommandObjectAdd_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -class CommandObjectAdd : public CommandObject -{ -public: - - CommandObjectAdd (); - - virtual - ~CommandObjectAdd (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectAdd_h_ diff --git a/lldb/source/Commands/CommandObjectAlias.cpp b/lldb/source/Commands/CommandObjectAlias.cpp index 5ab7db62bb8..62ffbf4915e 100644 --- a/lldb/source/Commands/CommandObjectAlias.cpp +++ b/lldb/source/Commands/CommandObjectAlias.cpp @@ -89,8 +89,12 @@ CommandObjectAlias::~CommandObjectAlias () bool -CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectAlias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { const int argc = args.GetArgumentCount(); @@ -109,7 +113,7 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr // Verify that the command is alias'able, and get the appropriate command object. - if (interpreter->CommandExists (alias_command.c_str())) + if (interpreter.CommandExists (alias_command.c_str())) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -117,7 +121,7 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr } else { - CommandObjectSP command_obj_sp(interpreter->GetCommandSP (actual_command.c_str())); + CommandObjectSP command_obj_sp(interpreter.GetCommandSP (actual_command.c_str())); CommandObjectSP subcommand_obj_sp; bool use_subcommand = false; if (command_obj_sp.get()) @@ -193,24 +197,24 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr // Create the alias. - if (interpreter->AliasExists (alias_command.c_str()) - || interpreter->UserCommandExists (alias_command.c_str())) + if (interpreter.AliasExists (alias_command.c_str()) + || interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (interpreter->GetAliasOptions (alias_command.c_str())); + OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); if (tmp_option_arg_sp.get()) { if (option_arg_vector->size() == 0) - interpreter->RemoveAliasOptions (alias_command.c_str()); + interpreter.RemoveAliasOptions (alias_command.c_str()); } result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (use_subcommand) - interpreter->AddAlias (alias_command.c_str(), subcommand_obj_sp); + interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); else - interpreter->AddAlias (alias_command.c_str(), command_obj_sp); + interpreter.AddAlias (alias_command.c_str(), command_obj_sp); if (option_arg_vector->size() > 0) - interpreter->AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else diff --git a/lldb/source/Commands/CommandObjectAlias.h b/lldb/source/Commands/CommandObjectAlias.h index 859b7cea049..da3334643de 100644 --- a/lldb/source/Commands/CommandObjectAlias.h +++ b/lldb/source/Commands/CommandObjectAlias.h @@ -32,9 +32,8 @@ public: ~CommandObjectAlias (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectAppend.cpp b/lldb/source/Commands/CommandObjectAppend.cpp index 613b85b4be9..6bdbc36572e 100644 --- a/lldb/source/Commands/CommandObjectAppend.cpp +++ b/lldb/source/Commands/CommandObjectAppend.cpp @@ -37,9 +37,8 @@ CommandObjectAppend::~CommandObjectAppend () bool CommandObjectAppend::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -64,7 +63,7 @@ CommandObjectAppend::Execute } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); diff --git a/lldb/source/Commands/CommandObjectAppend.h b/lldb/source/Commands/CommandObjectAppend.h index 436283730fb..6b2ab9d3888 100644 --- a/lldb/source/Commands/CommandObjectAppend.h +++ b/lldb/source/Commands/CommandObjectAppend.h @@ -30,9 +30,8 @@ public: ~CommandObjectAppend (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index bdb70df1a32..0f10b3ec780 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -40,14 +40,18 @@ CommandObjectApropos::~CommandObjectApropos() bool -CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectApropos::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - const int argc = command.GetArgumentCount (); + const int argc = args.GetArgumentCount (); if (argc == 1) { - const char *search_word = command.GetArgumentAtIndex(0); + const char *search_word = args.GetArgumentAtIndex(0); if ((search_word != NULL) && (strlen (search_word) > 0)) { @@ -55,7 +59,7 @@ CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandIn // is private. StringList commands_found; StringList commands_help; - interpreter->FindCommandsForApropos (search_word, commands_found, commands_help); + interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); @@ -74,8 +78,11 @@ CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandIn } for (int i = 0; i < commands_found.GetSize(); ++i) - interpreter->OutputFormattedHelpText (result.GetOutputStream(), commands_found.GetStringAtIndex(i), - "--", commands_help.GetStringAtIndex(i), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + commands_found.GetStringAtIndex(i), + "--", commands_help. + GetStringAtIndex(i), + max_len); } result.SetStatus (eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectApropos.h b/lldb/source/Commands/CommandObjectApropos.h index a079a3fc4ac..cf5cabe3ade 100644 --- a/lldb/source/Commands/CommandObjectApropos.h +++ b/lldb/source/Commands/CommandObjectApropos.h @@ -32,9 +32,8 @@ public: ~CommandObjectApropos (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index e1cb9825c88..74a7d2b04de 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -95,14 +95,17 @@ CommandObjectArgs::GetOptions () } bool -CommandObjectArgs::Execute(Args &command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectArgs::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { ConstString target_triple; - Process *process = context->GetExecutionContext().process; + + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -118,7 +121,7 @@ CommandObjectArgs::Execute(Args &command, return false; } - int num_args = command.GetArgumentCount (); + int num_args = args.GetArgumentCount (); int arg_index; if (!num_args) @@ -128,7 +131,7 @@ CommandObjectArgs::Execute(Args &command, return false; } - Thread *thread = context->GetExecutionContext ().thread; + Thread *thread = interpreter.GetDebugger().GetExecutionContext ().thread; if (!thread) { @@ -167,7 +170,7 @@ CommandObjectArgs::Execute(Args &command, for (arg_index = 0; arg_index < num_args; ++arg_index) { - const char *arg_type_cstr = command.GetArgumentAtIndex(arg_index); + const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index); Value value; value.SetValueType(Value::eValueTypeScalar); void *type; @@ -262,7 +265,7 @@ CommandObjectArgs::Execute(Args &command, for (arg_index = 0; arg_index < num_args; ++arg_index) { - result.GetOutputStream ().Printf ("%d (%s): ", arg_index, command.GetArgumentAtIndex (arg_index)); + result.GetOutputStream ().Printf ("%d (%s): ", arg_index, args.GetArgumentAtIndex (arg_index)); value_list.GetValueAtIndex (arg_index)->Dump (&result.GetOutputStream ()); result.GetOutputStream ().Printf("\n"); } diff --git a/lldb/source/Commands/CommandObjectArgs.h b/lldb/source/Commands/CommandObjectArgs.h index 997d289c1d3..5a73460e361 100644 --- a/lldb/source/Commands/CommandObjectArgs.h +++ b/lldb/source/Commands/CommandObjectArgs.h @@ -58,9 +58,8 @@ namespace lldb_private { virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 044ff40c74b..01d29fbd81b 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -32,7 +32,7 @@ using namespace lldb; using namespace lldb_private; static void -AddBreakpointDescription (CommandContext *context, StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) +AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) { s->IndentMore(); bp->GetDescription (s, level, true); @@ -240,13 +240,12 @@ CommandObjectBreakpointSet::GetOptions () bool CommandObjectBreakpointSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, 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."); @@ -287,7 +286,7 @@ CommandObjectBreakpointSet::Execute FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = context->GetExecutionContext().frame; + StackFrame *cur_frame = interpreter.GetDebugger().GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); @@ -458,7 +457,7 @@ CommandObjectBreakpointSet::Execute //------------------------------------------------------------------------- #pragma mark MultiwordBreakpoint -CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter) : +CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : CommandObjectMultiword ("breakpoint", "A set of commands for operating on breakpoints.", "breakpoint <command> [<command-options>]") @@ -480,13 +479,13 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter modify_command_object->SetCommandName ("breakpoint modify"); set_command_object->SetCommandName("breakpoint set"); - status = LoadSubCommand (list_command_object, "list", interpreter); - status = LoadSubCommand (enable_command_object, "enable", interpreter); - status = LoadSubCommand (disable_command_object, "disable", interpreter); - status = LoadSubCommand (delete_command_object, "delete", interpreter); - status = LoadSubCommand (set_command_object, "set", interpreter); - status = LoadSubCommand (command_command_object, "command", interpreter); - status = LoadSubCommand (modify_command_object, "modify", interpreter); + status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand (interpreter, "enable", enable_command_object); + status = LoadSubCommand (interpreter, "disable", disable_command_object); + status = LoadSubCommand (interpreter, "delete", delete_command_object); + status = LoadSubCommand (interpreter, "set", set_command_object); + status = LoadSubCommand (interpreter, "command", command_command_object); + status = LoadSubCommand (interpreter, "modify", modify_command_object); } CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () @@ -653,13 +652,12 @@ CommandObjectBreakpointList::GetOptions () bool CommandObjectBreakpointList::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, 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."); @@ -689,7 +687,7 @@ CommandObjectBreakpointList::Execute for (int i = 0; i < num_breakpoints; ++i) { Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (i).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -705,7 +703,7 @@ CommandObjectBreakpointList::Execute { BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -743,10 +741,14 @@ CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () bool -CommandObjectBreakpointEnable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointEnable::Execute +( + CommandInterpreter &interpreter, + Args& args, + 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."); @@ -838,10 +840,14 @@ CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () } bool -CommandObjectBreakpointDisable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDisable::Execute +( + CommandInterpreter &interpreter, + Args& args, + 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."); @@ -929,10 +935,14 @@ CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () } bool -CommandObjectBreakpointDelete::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDelete::Execute +( + CommandInterpreter &interpreter, + Args& args, + 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."); @@ -1163,9 +1173,8 @@ CommandObjectBreakpointModify::GetOptions () bool CommandObjectBreakpointModify::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -1176,7 +1185,7 @@ CommandObjectBreakpointModify::Execute return false; } - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); diff --git a/lldb/source/Commands/CommandObjectBreakpoint.h b/lldb/source/Commands/CommandObjectBreakpoint.h index 053e036c0c8..92bea698847 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.h +++ b/lldb/source/Commands/CommandObjectBreakpoint.h @@ -32,7 +32,7 @@ namespace lldb_private { class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword { public: - CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter); + CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordBreakpoint (); @@ -66,9 +66,8 @@ public: ~CommandObjectBreakpointSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -133,9 +132,8 @@ public: ~CommandObjectBreakpointModify (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -194,9 +192,8 @@ public: ~CommandObjectBreakpointEnable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -215,9 +212,8 @@ public: ~CommandObjectBreakpointDisable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -236,9 +232,8 @@ public: ~CommandObjectBreakpointList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -290,9 +285,8 @@ public: ~CommandObjectBreakpointDelete (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index e080450710d..547192dc68a 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -208,13 +208,12 @@ CommandObjectBreakpointCommandAdd::~CommandObjectBreakpointCommandAdd () bool CommandObjectBreakpointCommandAdd::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -258,12 +257,12 @@ CommandObjectBreakpointCommandAdd::Execute { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp_loc_sp->GetLocationOptions(), result); } } } @@ -271,12 +270,12 @@ CommandObjectBreakpointCommandAdd::Execute { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp->GetOptions(), result); } } } @@ -297,11 +296,12 @@ const char *g_reader_instructions = "Enter your debugger command(s). Type 'DONE void CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback ( + CommandInterpreter &interpreter, BreakpointOptions *bp_options, CommandReturnObject &result ) { - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData()); if (reader_sp && data_ap.get()) { @@ -316,7 +316,7 @@ CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -337,13 +337,13 @@ size_t CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); switch (notification) { @@ -351,8 +351,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback if (out_fh) { ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } break; @@ -360,8 +360,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback break; case eInputReaderReactivate: - if (out_fh && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderGotToken: @@ -375,8 +375,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); } } - if (out_fh && !reader->IsDone() && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderDone: @@ -403,12 +403,14 @@ CommandObjectBreakpointCommandRemove::~CommandObjectBreakpointCommandRemove () } bool -CommandObjectBreakpointCommandRemove::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandRemove::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -486,12 +488,14 @@ CommandObjectBreakpointCommandList::~CommandObjectBreakpointCommandList () } bool -CommandObjectBreakpointCommandList::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandList::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -587,7 +591,7 @@ CommandObjectBreakpointCommandList::Execute (Args& command, // CommandObjectBreakpointCommand //------------------------------------------------------------------------- -CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter *interpreter) : +CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) : CommandObjectMultiword ("command", "A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commmands').", "command <sub-command> [<sub-command-options>] <breakpoint-id>") @@ -601,9 +605,9 @@ CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpret remove_command_object->SetCommandName ("breakpoint command remove"); list_command_object->SetCommandName ("breakpoint command list"); - status = LoadSubCommand (add_command_object, "add", interpreter); - status = LoadSubCommand (remove_command_object, "remove", interpreter); - status = LoadSubCommand (list_command_object, "list", interpreter); + status = LoadSubCommand (interpreter, "add", add_command_object); + status = LoadSubCommand (interpreter, "remove", remove_command_object); + status = LoadSubCommand (interpreter, "list", list_command_object); } @@ -631,63 +635,61 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction if (commands.GetSize() > 0) { uint32_t num_commands = commands.GetSize(); - CommandInterpreter &interpreter = Debugger::GetSharedInstance().GetCommandInterpreter(); CommandReturnObject result; - ExecutionContext exe_ctx = context->context; - - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetErrorFileHandle(); - - - uint32_t i; - for (i = 0; i < num_commands; ++i) + if (context->exe_ctx.target) { - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - - if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &exe_ctx)) - break; + + Debugger &debugger = context->exe_ctx.target->GetDebugger(); + CommandInterpreter &interpreter = debugger.GetCommandInterpreter(); + + FILE *out_fh = debugger.GetOutputFileHandle(); + FILE *err_fh = debugger.GetErrorFileHandle(); - // FIXME: This isn't really the right way to do this. We should be able to peek at the public - // to see if there is any new events, but that is racey, since the internal process thread has to run and - // deliver the event to the public queue before a run will show up. So for now we check - // the internal thread state. - - lldb::StateType internal_state = exe_ctx.process->GetPrivateState(); - if (internal_state != eStateStopped) + uint32_t i; + for (i = 0; i < num_commands; ++i) { - if (i < num_commands - 1) + + // First time through we use the context from the stoppoint, after that we use whatever + // has been set by the previous command. + + if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &context->exe_ctx)) + break; + + // FIXME: This isn't really the right way to do this. We should be able to peek at the public + // to see if there is any new events, but that is racey, since the internal process thread has to run and + // deliver the event to the public queue before a run will show up. So for now we check + // the internal thread state. + + lldb::StateType internal_state = context->exe_ctx.process->GetPrivateState(); + if (internal_state != eStateStopped) { - if (out_fh) - ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." - " last command: \"%s\"\n", StateAsCString(internal_state), - commands.GetStringAtIndex(i)); + if (i < num_commands - 1) + { + if (out_fh) + ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." + " last command: \"%s\"\n", StateAsCString(internal_state), + commands.GetStringAtIndex(i)); + } + break; } - break; + + if (out_fh) + ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); + result.Clear(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); } - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - exe_ctx = Debugger::GetSharedInstance().GetCurrentExecutionContext(); - + if (err_fh && !result.Succeeded() && i < num_commands) + ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); + if (out_fh) ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); - result.Clear(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } - - if (err_fh && !result.Succeeded() && i < num_commands) - ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); - - if (out_fh) - ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); - - if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } return ret_value; } diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.h b/lldb/source/Commands/CommandObjectBreakpointCommand.h index 344eccea2ef..fc59c7714da 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.h +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.h @@ -34,7 +34,7 @@ namespace lldb_private { class CommandObjectBreakpointCommand : public CommandObjectMultiword { public: - CommandObjectBreakpointCommand (CommandInterpreter *interpreter); + CommandObjectBreakpointCommand (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommand (); @@ -62,21 +62,21 @@ public: ~CommandObjectBreakpointCommandAdd (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * GetOptions (); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result); static size_t GenerateBreakpointCommandCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); @@ -134,9 +134,8 @@ public: ~CommandObjectBreakpointCommandRemove (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -155,9 +154,8 @@ public: ~CommandObjectBreakpointCommandList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectCall.cpp b/lldb/source/Commands/CommandObjectCall.cpp index 516ea036806..a2cbc05ce13 100644 --- a/lldb/source/Commands/CommandObjectCall.cpp +++ b/lldb/source/Commands/CommandObjectCall.cpp @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -128,23 +128,21 @@ CommandObjectCall::GetOptions () bool CommandObjectCall::Execute ( + CommandInterpreter &interpreter, Args &command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; int num_args = command.GetArgumentCount(); - Target *target = context->GetTarget (); - if (target) - target->GetTargetTriple(target_triple); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.target) + exe_ctx.target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); if (exe_ctx.thread == NULL || exe_ctx.frame == NULL) { result.AppendError ("No currently selected thread and frame."); @@ -215,7 +213,7 @@ CommandObjectCall::Execute val.SetValueType (Value::eValueTypeHostAddress); - void *cstr_type = target->GetScratchClangASTContext()->GetCStringType(true); + void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true); val.SetContext (Value::eContextTypeOpaqueClangQualType, cstr_type); value_list.PushValue(val); @@ -233,7 +231,7 @@ CommandObjectCall::Execute // run it: StreamString errors; - ClangFunction clang_fun (target_triple.GetCString(), *target_fn, target->GetScratchClangASTContext(), value_list); + ClangFunction clang_fun (target_triple.GetCString(), *target_fn, exe_ctx.target->GetScratchClangASTContext(), value_list); if (m_options.noexecute) { // Now write down the argument values for this call. diff --git a/lldb/source/Commands/CommandObjectCall.h b/lldb/source/Commands/CommandObjectCall.h index 6cd09c4465e..1a5ae1db1e2 100644 --- a/lldb/source/Commands/CommandObjectCall.h +++ b/lldb/source/Commands/CommandObjectCall.h @@ -66,9 +66,8 @@ public: virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectCrossref.cpp b/lldb/source/Commands/CommandObjectCrossref.cpp index 27b66379e87..0d11369c6e7 100644 --- a/lldb/source/Commands/CommandObjectCrossref.cpp +++ b/lldb/source/Commands/CommandObjectCrossref.cpp @@ -40,9 +40,8 @@ CommandObjectCrossref::~CommandObjectCrossref () bool CommandObjectCrossref::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 0716ff30778..c2abeee702c 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -155,8 +155,7 @@ CommandObjectDisassemble::~CommandObjectDisassemble() void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list @@ -171,11 +170,11 @@ CommandObjectDisassemble::Disassemble break; if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range)) { - lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); if (addr != LLDB_INVALID_ADDRESS) { lldb::addr_t end_addr = addr + range.GetByteSize(); - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } } } @@ -184,8 +183,7 @@ CommandObjectDisassemble::Disassemble void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, @@ -198,7 +196,7 @@ CommandObjectDisassemble::Disassemble if (end_addr == LLDB_INVALID_ADDRESS || addr >= end_addr) end_addr = addr + DEFAULT_DISASM_BYTE_SIZE; - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); DataExtractor data; size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, eAddressTypeLoad, addr, end_addr - addr, data); if (bytes_disassembled == 0) @@ -225,7 +223,7 @@ CommandObjectDisassemble::Disassemble lldb::addr_t curr_addr = addr + offset; if (m_options.show_mixed) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!sc_range.ContainsLoadAddress (curr_addr, process)) { prev_sc = sc; @@ -248,7 +246,7 @@ CommandObjectDisassemble::Disassemble output_stream.EOL(); if (sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, m_options.num_lines_context, @@ -286,13 +284,12 @@ CommandObjectDisassemble::Disassemble bool CommandObjectDisassemble::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, 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"); @@ -353,7 +350,7 @@ CommandObjectDisassemble::Execute } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); @@ -394,11 +391,11 @@ CommandObjectDisassemble::Execute if (target->GetImages().FindFunctions(name, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else if (target->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else { @@ -409,7 +406,7 @@ CommandObjectDisassemble::Execute } else { - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } return result.Succeeded(); diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h index 6fca74824e1..830b102017e 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.h +++ b/lldb/source/Commands/CommandObjectDisassemble.h @@ -67,25 +67,22 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); protected: CommandOptions m_options; void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, lldb::addr_t end_addr); void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list); diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 6e4efbf1cef..38534f03730 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -21,7 +21,8 @@ #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -124,9 +125,8 @@ CommandObjectExpression::GetOptions () bool CommandObjectExpression::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -138,24 +138,22 @@ size_t CommandObjectExpression::MultiLineExpressionCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); CommandObjectExpression *cmd_object_expr = (CommandObjectExpression *) baton; switch (notification) { case eInputReaderActivate: - if (out_fh) - ::fprintf (out_fh, "%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); + reader.GetDebugger().GetOutputStream().Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); // Fall through case eInputReaderReactivate: //if (out_fh) - // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); + // reader.GetDebugger().GetOutputStream().Printf ("%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDeactivate: @@ -169,20 +167,18 @@ CommandObjectExpression::MultiLineExpressionCallback } if (bytes_len == 0) - reader->SetIsDone(true); + reader.SetIsDone(true); //else if (out_fh && !reader->IsDone()) // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDone: { - StreamFile out_stream(Debugger::GetSharedInstance().GetOutputFileHandle()); - StreamFile err_stream(Debugger::GetSharedInstance().GetErrorFileHandle()); bool bare = false; cmd_object_expr->EvaluateExpression (cmd_object_expr->m_expr_lines.c_str(), bare, - out_stream, - err_stream); + reader.GetDebugger().GetOutputStream(), + reader.GetDebugger().GetErrorStream()); } break; } @@ -329,21 +325,20 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream bool CommandObjectExpression::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; - Target *target = context->GetTarget (); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); Stream &output_stream = result.GetOutputStream(); @@ -356,18 +351,18 @@ CommandObjectExpression::ExecuteRawCommandString m_expr_lines.clear(); m_expr_line_count = 0; - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); if (reader_sp) { Error err (reader_sp->Initialize (CommandObjectExpression::MultiLineExpressionCallback, this, // baton eInputReaderGranularityLine, // token size, to pass to callback function - NULL, // end token + NULL, // end token NULL, // prompt true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -408,8 +403,8 @@ CommandObjectExpression::ExecuteRawCommandString if (end_options) { - Args args(command, end_options - command); - if (!ParseOptions(args, interpreter, result)) + Args args (command, end_options - command); + if (!ParseOptions (interpreter, args, result)) return false; } } diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index 084a87b2cdb..1959ecbc1e8 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -65,25 +65,23 @@ public: virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); protected: static size_t MultiLineExpressionCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp index af7e2fed943..bdaf67cc814 100644 --- a/lldb/source/Commands/CommandObjectFile.cpp +++ b/lldb/source/Commands/CommandObjectFile.cpp @@ -16,7 +16,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" @@ -104,9 +104,8 @@ CommandObjectFile::GetOptions () bool CommandObjectFile::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -135,8 +134,8 @@ CommandObjectFile::Execute if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; } - - Error error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + Debugger &debugger = interpreter.GetDebugger(); + Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); if (error.Fail() && !m_options.m_arch.IsValid()) { @@ -144,12 +143,12 @@ CommandObjectFile::Execute arch = LLDB_ARCH_DEFAULT_64BIT; else arch = LLDB_ARCH_DEFAULT_32BIT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); } if (target_sp) { - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget(target_sp.get()); + debugger.GetTargetList().SetCurrentTarget(target_sp.get()); result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, arch.AsCString()); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectFile.h b/lldb/source/Commands/CommandObjectFile.h index 527dc2112ee..23f4761983d 100644 --- a/lldb/source/Commands/CommandObjectFile.h +++ b/lldb/source/Commands/CommandObjectFile.h @@ -34,9 +34,8 @@ public: ~CommandObjectFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 7eab3fe3a68..e2c52a61d59 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -16,7 +16,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" @@ -51,12 +51,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->Dump (&result.GetOutputStream(), true); @@ -95,12 +94,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (command.GetArgumentCount() == 1) @@ -156,13 +154,13 @@ public: // CommandObjectMultiwordFrame //------------------------------------------------------------------------- -CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter *interpreter) : +CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : CommandObjectMultiword ("frame", "A set of commands for operating on the current thread's frames.", "frame <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectFrameInfo ()), "info", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectFrameSelect ()), "select", interpreter); + LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectFrameInfo ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectFrameSelect ())); } CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () diff --git a/lldb/source/Commands/CommandObjectFrame.h b/lldb/source/Commands/CommandObjectFrame.h index f7077af4ac0..ea7c808e84b 100644 --- a/lldb/source/Commands/CommandObjectFrame.h +++ b/lldb/source/Commands/CommandObjectFrame.h @@ -28,7 +28,7 @@ class CommandObjectMultiwordFrame : public CommandObjectMultiword { public: - CommandObjectMultiwordFrame (CommandInterpreter *interpreter); + CommandObjectMultiwordFrame (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordFrame (); diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index ac1046e1e93..8a037e94816 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -38,133 +38,29 @@ CommandObjectHelp::~CommandObjectHelp() bool -CommandObjectHelp::OldExecute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - const int argc = command.GetArgumentCount(); - if (argc > 0) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), false, false); - if (cmd_obj == NULL) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), true, false); - if (cmd_obj != NULL) - { - StreamString alias_help_str; - interpreter->GetAliasHelp (command.GetArgumentAtIndex(0), cmd_obj->GetCommandName(), alias_help_str); - result.AppendMessageWithFormat ("'%s' is an alias for %s.\n", command.GetArgumentAtIndex (0), - alias_help_str.GetData()); - } - } - - if (cmd_obj) - { - Stream &output_strm = result.GetOutputStream(); - if (cmd_obj->GetOptions() != NULL) - { - const char * long_help = cmd_obj->GetHelpLong(); - if ((long_help!= NULL) - && strlen (long_help) > 0) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, cmd_obj); - } - else if (cmd_obj->IsMultiwordObject()) - { - bool done = false; - if (argc > 1) - { - CommandObject::CommandMap::iterator pos; - std::string sub_command = command.GetArgumentAtIndex(1); - pos = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.find(sub_command); - if (pos != ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.end()) - { - CommandObject *sub_cmd_obj = pos->second.get(); - if (sub_cmd_obj->GetOptions() != NULL) - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj); - done = true; - } - else - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - done = true; - } - } - } - if (!done) - { - output_strm.Printf ("%s\n", cmd_obj->GetHelp()); - ((CommandObjectMultiword *) cmd_obj)->GenerateHelpText (result, interpreter); - } - } - else - { - const char *long_help = cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - } - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp(result); - } - return result.Succeeded(); -} - -bool -CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; const int argc = command.GetArgumentCount (); - + // 'help' doesn't take any options or arguments, other than command names. If argc is 0, we show the user // all commands and aliases. Otherwise every argument must be the name of a command or a sub-command. - if (argc == 0) { result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp (result); // General help, for ALL commands. + interpreter.GetHelp (result); // General help, for ALL commands. } else { // Get command object for the first command argument. Only search built-in command dictionary. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), false, false); + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), false, false); if (cmd_obj == NULL) - { + { // That failed, so now search in the aliases dictionary, too. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), true, false); - } - + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), true, false); + } + if (cmd_obj != NULL) { bool all_okay = true; @@ -182,19 +78,19 @@ CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInter { pos = ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.find (sub_command); if (pos != ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.end()) - sub_cmd_obj = pos->second.get(); + sub_cmd_obj = pos->second.get(); else - all_okay = false; + all_okay = false; } } - + if (!all_okay || (sub_cmd_obj == NULL)) { std::string cmd_string; command.GetCommandString (cmd_string); result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - cmd_string.c_str()); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + cmd_string.c_str()); result.SetStatus (eReturnStatusFailed); } else @@ -208,59 +104,59 @@ CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInter const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", long_help); + output_strm.Printf ("\n%s", long_help); } else if (sub_cmd_obj->IsMultiwordObject()) { output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result, interpreter); + ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); } else { - const char *long_help = sub_cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("%s", long_help); - else - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); + const char *long_help = sub_cmd_obj->GetHelpLong(); + if ((long_help != NULL) + && (strlen (long_help) > 0)) + output_strm.Printf ("%s", long_help); + else + output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } } else { result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + command.GetArgumentAtIndex(0)); result.SetStatus (eReturnStatusFailed); } } - + return result.Succeeded(); } int CommandObjectHelp::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { // Return the completions of the commands in the help system: if (cursor_index == 0) { - return interpreter->HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); + return interpreter.HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); } else { - CommandObject *cmd_obj = interpreter->GetCommandObject (input.GetArgumentAtIndex(0), true, false); + CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0), true, false); input.Shift(); cursor_index--; - 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); } } diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h index a8084aa704d..881b67d7141 100644 --- a/lldb/source/Commands/CommandObjectHelp.h +++ b/lldb/source/Commands/CommandObjectHelp.h @@ -31,25 +31,18 @@ public: virtual ~CommandObjectHelp (); - bool - OldExecute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); }; diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp index d9c40e5b67a..38a04ecf5f0 100644 --- a/lldb/source/Commands/CommandObjectImage.cpp +++ b/lldb/source/Commands/CommandObjectImage.cpp @@ -13,21 +13,22 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FileSpec.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/RegularExpression.h" +#include "lldb/Core/Stream.h" #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Core/FileSpec.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Core/Module.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Interpreter/CommandCompletions.h" using namespace lldb; using namespace lldb_private; @@ -56,7 +57,7 @@ DumpModuleUUID (Stream &strm, Module *module) static uint32_t DumpCompileUnitLineTable ( - CommandContext *context, + CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, @@ -85,7 +86,9 @@ DumpCompileUnitLineTable << module->GetFileSpec().GetFilename() << "\n"; LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) - line_table->GetDescription (&strm, context->GetExecutionContext().process, lldb::eDescriptionLevelBrief); + line_table->GetDescription (&strm, + interpreter.GetDebugger().GetExecutionContext().process, + lldb::eDescriptionLevelBrief); else strm << "No line table"; } @@ -153,7 +156,7 @@ DumpBasename (Stream &strm, const FileSpec *file_spec_ptr, uint32_t width) static void -DumpModuleSymtab (CommandContext *context, Stream &strm, Module *module) +DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -162,13 +165,13 @@ DumpModuleSymtab (CommandContext *context, Stream &strm, Module *module) { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, context->GetExecutionContext().process); + symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process); } } } static void -DumpModuleSections (CommandContext *context, Stream &strm, Module *module) +DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -177,7 +180,7 @@ DumpModuleSections (CommandContext *context, Stream &strm, Module *module) { SectionList *section_list = objfile->GetSectionList(); if (section_list) - section_list->Dump(&strm, context->GetExecutionContext().process, true); + section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process, true); } } } @@ -198,14 +201,14 @@ DumpModuleSymbolVendor (Stream &strm, Module *module) } static bool -LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) +LookupAddressInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) { if (module) { lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process && process->IsAlive()) { if (!process->ResolveLoadAddress (addr, so_addr)) @@ -223,7 +226,7 @@ LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, ui if (offset) strm.Printf("0x%llx: ", addr); - ExecutionContextScope *exe_scope = context->GetExecutionContext().GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope(); if (so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset)) strm.PutCString(": "); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); @@ -234,7 +237,7 @@ LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, ui } static uint32_t -LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module) { @@ -275,7 +278,7 @@ LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, con { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, context->GetExecutionContext().process, i); + symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().process, i); } strm.IndentLess (); return num_matches; @@ -288,7 +291,7 @@ LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, con static void -DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) +DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) { strm.IndentMore (); uint32_t i; @@ -305,9 +308,9 @@ DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList if (sc.line_entry.range.GetBaseAddress().IsValid()) { lldb::addr_t vm_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); int addr_size = sizeof (addr_t); - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) addr_size = process->GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) @@ -318,14 +321,14 @@ DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList strm.PutCString(" in "); } } - sc.DumpStopContext(&strm, context->GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); + sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); } } strm.IndentLess (); } static uint32_t -LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupFunctionInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module && name && name[0]) { @@ -353,7 +356,7 @@ LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, c strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : ""); DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); } return num_matches; } @@ -362,7 +365,7 @@ LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, c } static uint32_t -LookupFileAndLineInModule (CommandContext *context, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) +LookupFileAndLineInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) { if (module && file_spec) { @@ -379,7 +382,7 @@ LookupFileAndLineInModule (CommandContext *context, Stream &strm, Module *module strm << " in "; DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); return num_matches; } } @@ -397,8 +400,8 @@ class CommandObjectImageDumpModuleList : public CommandObject public: CommandObjectImageDumpModuleList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -409,26 +412,26 @@ public: } virtual int - 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) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard module completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eModuleCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eModuleCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -438,8 +441,8 @@ class CommandObjectImageDumpSourceFileList : public CommandObject public: CommandObjectImageDumpSourceFileList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -450,26 +453,26 @@ public: } virtual int - 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) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eSourceFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSourceFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -491,12 +494,11 @@ public: } virtual 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"); @@ -521,7 +523,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSymtab (context, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -549,7 +551,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSymtab (context, result.GetOutputStream(), image_module); + DumpModuleSymtab (interpreter, result.GetOutputStream(), image_module); } } } @@ -578,10 +580,9 @@ class CommandObjectImageDumpSections : public CommandObjectImageDumpModuleList { public: CommandObjectImageDumpSections () : - CommandObjectImageDumpModuleList ( - "image dump sections", - "Dump the sections from one or more executable images.", - "image dump sections [<file1> ...]") + CommandObjectImageDumpModuleList ("image dump sections", + "Dump the sections from one or more executable images.", + "image dump sections [<file1> ...]") { } @@ -591,12 +592,11 @@ public: } virtual 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"); @@ -621,7 +621,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSections (context, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSections (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -649,7 +649,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSections (context, result.GetOutputStream(), image_module); + DumpModuleSections (interpreter, result.GetOutputStream(), image_module); } } } @@ -689,12 +689,11 @@ public: } virtual 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"); @@ -787,12 +786,11 @@ public: } virtual 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"); @@ -801,7 +799,7 @@ public: } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -826,7 +824,7 @@ public: uint32_t num_dumped = 0; for (uint32_t i = 0; i<num_modules; ++i) { - if (DumpCompileUnitLineTable (context, + if (DumpCompileUnitLineTable (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(i), file_spec, @@ -863,15 +861,15 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImageDump(CommandInterpreter *interpreter) : + CommandObjectImageDump(CommandInterpreter &interpreter) : CommandObjectMultiword ("image dump", - "Dumps information in one or more executable images; 'line-table' expects a source file name", - "image dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") + "Dumps information in one or more executable images; 'line-table' expects a source file name", + "image dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymtab ()), "symtab", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSections ()), "sections", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymfile ()), "symfile", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpLineTable ()), "line-table", interpreter); + LoadSubCommand (interpreter, "symtab", CommandObjectSP (new CommandObjectImageDumpSymtab ())); + LoadSubCommand (interpreter, "sections", CommandObjectSP (new CommandObjectImageDumpSections ())); + LoadSubCommand (interpreter, "symfile", CommandObjectSP (new CommandObjectImageDumpSymfile ())); + LoadSubCommand (interpreter, "line-table", CommandObjectSP (new CommandObjectImageDumpLineTable ())); } virtual @@ -957,12 +955,11 @@ public: } virtual 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"); @@ -1223,14 +1220,14 @@ public: bool - LookupInModule (CommandContext *context, Module *module, CommandReturnObject &result, bool &syntax_error) + LookupInModule (CommandInterpreter &interpreter, Module *module, CommandReturnObject &result, bool &syntax_error) { switch (m_options.m_type) { case eLookupTypeAddress: if (m_options.m_addr != LLDB_INVALID_ADDRESS) { - if (LookupAddressInModule (context, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) + if (LookupAddressInModule (interpreter, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1241,7 +1238,7 @@ public: case eLookupTypeSymbol: if (!m_options.m_str.empty()) { - if (LookupSymbolInModule (context, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) + if (LookupSymbolInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1253,7 +1250,7 @@ public: if (m_options.m_file) { - if (LookupFileAndLineInModule (context, + if (LookupFileAndLineInModule (interpreter, result.GetOutputStream(), module, m_options.m_file, @@ -1269,7 +1266,7 @@ public: case eLookupTypeFunction: if (!m_options.m_str.empty()) { - if (LookupFunctionInModule (context, + if (LookupFunctionInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1292,12 +1289,11 @@ public: } virtual 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"); @@ -1322,7 +1318,7 @@ public: { for (i = 0; i<num_modules && syntax_error == false; ++i) { - if (LookupInModule (context, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) + if (LookupInModule (interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1353,7 +1349,7 @@ public: Module * image_module = matching_modules.GetModulePointerAtIndex(i); if (image_module) { - if (LookupInModule (context, image_module, result, syntax_error)) + if (LookupInModule (interpreter, image_module, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1399,14 +1395,14 @@ CommandObjectImageLookup::CommandOptions::g_option_table[] = //---------------------------------------------------------------------- // CommandObjectImage constructor //---------------------------------------------------------------------- -CommandObjectImage::CommandObjectImage(CommandInterpreter *interpreter) : +CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : CommandObjectMultiword ("image", - "Access information for one or more executable images.", - "image [dump|list] ...") + "Access information for one or more executable images.", + "image [dump|list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDump (interpreter)), "dump", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageLookup ()), "lookup", interpreter); + LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); + LoadSubCommand (interpreter, "lookup", CommandObjectSP (new CommandObjectImageLookup ())); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectImage.h b/lldb/source/Commands/CommandObjectImage.h index 8863a3649a3..9394aeb10d1 100644 --- a/lldb/source/Commands/CommandObjectImage.h +++ b/lldb/source/Commands/CommandObjectImage.h @@ -28,7 +28,8 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImage(CommandInterpreter *interpreter); + CommandObjectImage(CommandInterpreter &interpreter); + virtual ~CommandObjectImage(); diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index c68ecce3d73..5616fb1a064 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -26,7 +26,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/LineTable.h" @@ -76,9 +76,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() < 1) @@ -256,9 +255,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -318,9 +316,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -382,9 +379,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -429,15 +425,15 @@ public: //---------------------------------------------------------------------- // CommandObjectLog constructor //---------------------------------------------------------------------- -CommandObjectLog::CommandObjectLog(CommandInterpreter *interpreter) : +CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : CommandObjectMultiword ("log", "A set of commands for operating on logs.", "log <command> [<command-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectLogEnable), "enable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogDisable), "disable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogList), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogTimer), "timers", interpreter); + LoadSubCommand (interpreter, "enable", CommandObjectSP (new CommandObjectLogEnable)); + LoadSubCommand (interpreter, "disable", CommandObjectSP (new CommandObjectLogDisable)); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectLogList)); + LoadSubCommand (interpreter, "timers", CommandObjectSP (new CommandObjectLogTimer)); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectLog.h b/lldb/source/Commands/CommandObjectLog.h index a1ba258ea33..3e731fa1d18 100644 --- a/lldb/source/Commands/CommandObjectLog.h +++ b/lldb/source/Commands/CommandObjectLog.h @@ -31,7 +31,7 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLog(CommandInterpreter *interpreter); + CommandObjectLog(CommandInterpreter &interpreter); virtual ~CommandObjectLog(); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index da845f0d155..9400200070a 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -13,13 +13,14 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Interpreter/Options.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/Options.h" #include "lldb/Target/Process.h" using namespace lldb; @@ -195,12 +196,11 @@ public: } virtual 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("need a process to read memory"); @@ -441,12 +441,11 @@ public: } virtual 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("need a process to read memory"); @@ -666,13 +665,13 @@ CommandObjectMemoryWrite::CommandOptions::g_option_table[] = // CommandObjectMemory //------------------------------------------------------------------------- -CommandObjectMemory::CommandObjectMemory (CommandInterpreter *interpreter) : +CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : CommandObjectMultiword ("memory", "A set of commands for operating on a memory.", "memory <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectMemoryWrite ())); } CommandObjectMemory::~CommandObjectMemory () diff --git a/lldb/source/Commands/CommandObjectMemory.h b/lldb/source/Commands/CommandObjectMemory.h index a4665401510..b044921ae07 100644 --- a/lldb/source/Commands/CommandObjectMemory.h +++ b/lldb/source/Commands/CommandObjectMemory.h @@ -21,7 +21,7 @@ namespace lldb_private { class CommandObjectMemory : public CommandObjectMultiword { public: - CommandObjectMemory (CommandInterpreter *interpreter); + CommandObjectMemory (CommandInterpreter &interpreter); virtual ~CommandObjectMemory (); 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); } } 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 () diff --git a/lldb/source/Commands/CommandObjectProcess.h b/lldb/source/Commands/CommandObjectProcess.h index 9a8d59e70e6..0aaa74d28a0 100644 --- a/lldb/source/Commands/CommandObjectProcess.h +++ b/lldb/source/Commands/CommandObjectProcess.h @@ -25,7 +25,7 @@ namespace lldb_private { class CommandObjectMultiwordProcess : public CommandObjectMultiword { public: - CommandObjectMultiwordProcess (CommandInterpreter *interpreter); + CommandObjectMultiwordProcess (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordProcess (); diff --git a/lldb/source/Commands/CommandObjectQuit.cpp b/lldb/source/Commands/CommandObjectQuit.cpp index 23aee3bb6f3..1d85555d195 100644 --- a/lldb/source/Commands/CommandObjectQuit.cpp +++ b/lldb/source/Commands/CommandObjectQuit.cpp @@ -35,13 +35,12 @@ CommandObjectQuit::~CommandObjectQuit () bool CommandObjectQuit::Execute ( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result ) { - interpreter->BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); + interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); result.SetStatus (eReturnStatusQuit); return true; } diff --git a/lldb/source/Commands/CommandObjectQuit.h b/lldb/source/Commands/CommandObjectQuit.h index a45d8a4b51b..f696828237b 100644 --- a/lldb/source/Commands/CommandObjectQuit.h +++ b/lldb/source/Commands/CommandObjectQuit.h @@ -39,9 +39,8 @@ public: ~CommandObjectQuit (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index cd7708489ae..2aded26d2b4 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -13,10 +13,11 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Scalar.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/RegisterContext.h" @@ -44,14 +45,16 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { StreamString &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -150,13 +153,15 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -213,13 +218,13 @@ public: //---------------------------------------------------------------------- // CommandObjectRegister constructor //---------------------------------------------------------------------- -CommandObjectRegister::CommandObjectRegister(CommandInterpreter *interpreter) : +CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : CommandObjectMultiword ("register", "Access thread registers.", "register [read|write] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectRegisterWrite ())); } diff --git a/lldb/source/Commands/CommandObjectRegister.h b/lldb/source/Commands/CommandObjectRegister.h index 740bc5424e4..7f856c2de52 100644 --- a/lldb/source/Commands/CommandObjectRegister.h +++ b/lldb/source/Commands/CommandObjectRegister.h @@ -28,7 +28,8 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectRegister(CommandInterpreter *interpreter); + CommandObjectRegister(CommandInterpreter &interpreter); + virtual ~CommandObjectRegister(); diff --git a/lldb/source/Commands/CommandObjectRemove.cpp b/lldb/source/Commands/CommandObjectRemove.cpp deleted file mode 100644 index 28736cd16ec..00000000000 --- a/lldb/source/Commands/CommandObjectRemove.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===-- CommandObjectRemove.cpp ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectRemove.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -CommandObjectRemove::CommandObjectRemove () : - CommandObject ("remove", - "Allows the user to remove/delete user-defined command functions (script functions).", - "remove <command-name-to-be-removed>") -{ -} - -CommandObjectRemove::~CommandObjectRemove() -{ -} - - -bool -CommandObjectRemove::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - if (args.GetArgumentCount() != 0) - { - const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter->GetCommandObject(command_name); - if (cmd_obj) - { - if (interpreter->CommandExists (command_name)) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - else - { - - if (interpreter->RemoveUser (command_name) == false) - { - if (interpreter->UserCommandExists (command_name)) - result.AppendErrorWithFormat ("Unknown error occurred; unable to remove command '%s'.\n", - command_name); - else - result.AppendErrorWithFormat ("'%s' is not a user-defined command/function name.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - else - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - } - else - { - result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call remove with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectRemove.h b/lldb/source/Commands/CommandObjectRemove.h deleted file mode 100644 index 4b017a4fbb1..00000000000 --- a/lldb/source/Commands/CommandObjectRemove.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- CommandObjectRemove.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectRemove_h_ -#define liblldb_CommandObjectRemove_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -class CommandObjectRemove : public CommandObject -{ -public: - - CommandObjectRemove (); - - virtual - ~CommandObjectRemove (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectRemove_h_ diff --git a/lldb/source/Commands/CommandObjectSet.cpp b/lldb/source/Commands/CommandObjectSet.cpp index 46ad049fd1b..89f154a083e 100644 --- a/lldb/source/Commands/CommandObjectSet.cpp +++ b/lldb/source/Commands/CommandObjectSet.cpp @@ -38,9 +38,8 @@ CommandObjectSet::~CommandObjectSet() bool CommandObjectSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -66,7 +65,7 @@ CommandObjectSet::Execute else if (var_value == NULL || var_value[0] == '\0') { // No value given: Check to see if we're trying to clear an array. - StateVariable *var = interpreter->GetStateVariable (var_name); + StateVariable *var = interpreter.GetStateVariable (var_name); if (var != NULL && var->GetType() == StateVariable::eTypeStringArray) { @@ -81,7 +80,7 @@ CommandObjectSet::Execute } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); @@ -98,7 +97,7 @@ CommandObjectSet::Execute if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetBoolValue (new_value); } else @@ -115,7 +114,7 @@ CommandObjectSet::Execute if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetIntValue (new_value); } else @@ -126,7 +125,7 @@ CommandObjectSet::Execute } else if (var->GetType() == StateVariable::eTypeString) { - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) var_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) var_value, result)) var->SetStringValue (var_value); } else if (var->GetType() == StateVariable::eTypeStringArray) diff --git a/lldb/source/Commands/CommandObjectSet.h b/lldb/source/Commands/CommandObjectSet.h index 1a3c3dfd1bc..8e4d81f8d42 100644 --- a/lldb/source/Commands/CommandObjectSet.h +++ b/lldb/source/Commands/CommandObjectSet.h @@ -32,9 +32,8 @@ public: ~CommandObjectSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 078b699ffdb..3b75c870a34 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -38,9 +38,8 @@ CommandObjectSettings::~CommandObjectSettings() bool CommandObjectSettings::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -53,7 +52,7 @@ CommandObjectSettings::Execute } else { - interpreter->ShowVariableHelp (result); + interpreter.ShowVariableHelp (result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h index 674a98b8ca8..4159b8b03b6 100644 --- a/lldb/source/Commands/CommandObjectSettings.h +++ b/lldb/source/Commands/CommandObjectSettings.h @@ -32,9 +32,8 @@ public: ~CommandObjectSettings (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectShow.cpp b/lldb/source/Commands/CommandObjectShow.cpp index be6f6888a99..4acbf66d548 100644 --- a/lldb/source/Commands/CommandObjectShow.cpp +++ b/lldb/source/Commands/CommandObjectShow.cpp @@ -38,9 +38,8 @@ CommandObjectShow::~CommandObjectShow() bool CommandObjectShow::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -51,7 +50,7 @@ CommandObjectShow::Execute // The user requested to see the value of a particular variable. const char *var_name = command.GetArgumentAtIndex(0); - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var) { var->AppendVariableInformation (result); @@ -66,7 +65,7 @@ CommandObjectShow::Execute else { // The user didn't specify a particular variable, so show the values of all of them. - interpreter->ShowVariableValues(result); + interpreter.ShowVariableValues(result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectShow.h b/lldb/source/Commands/CommandObjectShow.h index 460280a3c55..a51cd4d6516 100644 --- a/lldb/source/Commands/CommandObjectShow.h +++ b/lldb/source/Commands/CommandObjectShow.h @@ -32,9 +32,8 @@ public: ~CommandObjectShow (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 97c04a71654..9be4dccc8d9 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.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" @@ -43,9 +43,8 @@ CommandObjectSource::~CommandObjectSource () bool CommandObjectSource::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -88,8 +87,8 @@ CommandObjectSource::Execute size_t i; for (i = 0; i<num_commands; ++i) { - result.GetOutputStream().Printf("%s %s\n", interpreter->GetPrompt(), commands[i].c_str()); - if (!interpreter->HandleCommand(commands[i].c_str(), false, result)) + result.GetOutputStream().Printf("%s %s\n", interpreter.GetPrompt(), commands[i].c_str()); + if (!interpreter.HandleCommand(commands[i].c_str(), false, result)) break; } diff --git a/lldb/source/Commands/CommandObjectSource.h b/lldb/source/Commands/CommandObjectSource.h index 416e3c02b2c..8bc1ae58b3d 100644 --- a/lldb/source/Commands/CommandObjectSource.h +++ b/lldb/source/Commands/CommandObjectSource.h @@ -36,9 +36,8 @@ public: GetCommands (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSourceFile.cpp b/lldb/source/Commands/CommandObjectSourceFile.cpp index 6e6082c81c2..cfb53e0ad34 100644 --- a/lldb/source/Commands/CommandObjectSourceFile.cpp +++ b/lldb/source/Commands/CommandObjectSourceFile.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.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" @@ -119,9 +119,8 @@ CommandObjectSourceFile::GetOptions () bool CommandObjectSourceFile::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -133,7 +132,7 @@ CommandObjectSourceFile::Execute result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (m_options.file_name.empty()) { // Last valid source manager context, or the current frame if no @@ -142,14 +141,14 @@ CommandObjectSourceFile::Execute // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (interpreter->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) + if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } } else { - if (interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( m_options.start_line, // Line to display 0, // Lines before line to display m_options.num_lines, // Lines after line to display @@ -164,7 +163,7 @@ CommandObjectSourceFile::Execute else { const char *filename = m_options.file_name.c_str(); - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -187,13 +186,13 @@ CommandObjectSourceFile::Execute { if (sc.comp_unit) { - interpreter->GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit, - m_options.start_line, // Line to display - 0, // Lines before line to display - m_options.num_lines, // Lines after line to display - "", // Don't mark "line" - &result.GetOutputStream()); - + interpreter.GetDebugger().GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, // Line to display + 0, // Lines before line to display + m_options.num_lines, // Lines after line to display + "", // Don't mark "line" + &result.GetOutputStream()); + result.SetStatus (eReturnStatusSuccessFinishResult); } diff --git a/lldb/source/Commands/CommandObjectSourceFile.h b/lldb/source/Commands/CommandObjectSourceFile.h index f25fcc0eff9..9d15b198d53 100644 --- a/lldb/source/Commands/CommandObjectSourceFile.h +++ b/lldb/source/Commands/CommandObjectSourceFile.h @@ -62,9 +62,8 @@ public: ~CommandObjectSourceFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual diff --git a/lldb/source/Commands/CommandObjectSyntax.cpp b/lldb/source/Commands/CommandObjectSyntax.cpp index 092a9fce3f1..3279da2c1d6 100644 --- a/lldb/source/Commands/CommandObjectSyntax.cpp +++ b/lldb/source/Commands/CommandObjectSyntax.cpp @@ -43,7 +43,7 @@ bool CommandObjectSyntax::OldExecute ( Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result ) @@ -86,7 +86,7 @@ CommandObjectSyntax::OldExecute } bool -CommandObjectSyntax::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, +CommandObjectSyntax::Execute (Args &command, Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; diff --git a/lldb/source/Commands/CommandObjectSyntax.h b/lldb/source/Commands/CommandObjectSyntax.h index e5f5f4e544d..3caf533fed8 100644 --- a/lldb/source/Commands/CommandObjectSyntax.h +++ b/lldb/source/Commands/CommandObjectSyntax.h @@ -33,13 +33,13 @@ public: bool OldExecute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); virtual bool Execute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1762f5d9977..3f8581c80fa 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/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 @@ 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) { uint32_t argc = command.GetArgumentCount(); @@ -70,9 +69,9 @@ public: 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 @@ 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) { bool notify = true; @@ -146,12 +144,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) { uint32_t argc = command.GetArgumentCount(); @@ -230,12 +227,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) { if (command.GetArgumentCount() != 0) @@ -272,12 +268,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) { if (command.GetArgumentCount() != 1) @@ -327,8 +322,8 @@ public: // // bool // Execute (Args& command, -// CommandContext *context, -// CommandInterpreter *interpreter, +// Debugger *context, +// CommandInterpreter &interpreter, // CommandReturnObject &result) // { // ExecutionContext exe_ctx (context->GetExecutionContext()); @@ -392,16 +387,16 @@ class CommandObjectMultiwordImageSearchPaths : public CommandObjectMultiword { 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 @@ public: // 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 () diff --git a/lldb/source/Commands/CommandObjectTarget.h b/lldb/source/Commands/CommandObjectTarget.h index 06c89dc7a51..7b6637812c4 100644 --- a/lldb/source/Commands/CommandObjectTarget.h +++ b/lldb/source/Commands/CommandObjectTarget.h @@ -28,7 +28,7 @@ class CommandObjectMultiwordTarget : public CommandObjectMultiword { public: - CommandObjectMultiwordTarget (CommandInterpreter *interpreter); + CommandObjectMultiwordTarget (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordTarget (); diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index ef529f0e70b..bf4843da67f 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -39,7 +39,7 @@ using namespace lldb_private; bool lldb_private::DisplayThreadInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, @@ -96,7 +96,7 @@ lldb_private::DisplayThreadInfo size_t lldb_private::DisplayThreadsInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -145,7 +145,7 @@ size_t lldb_private::DisplayFramesForExecutionContext ( Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -226,7 +226,7 @@ lldb_private::DisplayFrameForExecutionContext ( Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, @@ -248,7 +248,7 @@ lldb_private::DisplayFrameForExecutionContext if (show_source && sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, 3, @@ -285,18 +285,17 @@ public: } - bool + virtual bool Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { bool show_frame_info = true; @@ -441,13 +440,15 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + 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) { @@ -647,21 +648,23 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -897,21 +900,23 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1085,12 +1090,14 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + 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"); @@ -1132,128 +1139,130 @@ public: // CommandObjectThreadList //------------------------------------------------------------------------- -CommandObjectThreadList::CommandObjectThreadList (): - CommandObject ("thread list", - "Shows a summary of all current threads in a process.", - "thread list", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) +class CommandObjectThreadList : public CommandObject { -} +public: -CommandObjectThreadList::~CommandObjectThreadList() -{ -} -bool -CommandObjectThreadList::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - StreamString &strm = result.GetOutputStream(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(context->GetExecutionContext()); - if (exe_ctx.process) + CommandObjectThreadList (): + CommandObject ("thread list", + "Shows a summary of all current threads in a process.", + "thread list", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + { + } + + ~CommandObjectThreadList() { - const StateType state = exe_ctx.process->GetState(); + } - if (StateIsStoppedState(state)) + bool + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) + { + StreamString &strm = result.GetOutputStream(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.process) { - if (state == eStateExited) - { - int exit_status = exe_ctx.process->GetExitStatus(); - const char *exit_description = exe_ctx.process->GetExitDescription(); - strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", - exe_ctx.process->GetID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else + const StateType state = exe_ctx.process->GetState(); + + if (StateIsStoppedState(state)) { - strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (exe_ctx.thread != NULL) + if (state == eStateExited) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + int exit_status = exe_ctx.process->GetExitStatus(); + const char *exit_description = exe_ctx.process->GetExitDescription(); + strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + exe_ctx.process->GetID(), + exit_status, + exit_status, + exit_description ? exit_description : ""); } else { - result.AppendError ("no valid thread found in current process"); - result.SetStatus (eReturnStatusFailed); + strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); + if (exe_ctx.thread == NULL) + exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (exe_ctx.thread != NULL) + { + DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + } + else + { + result.AppendError ("no valid thread found in current process"); + result.SetStatus (eReturnStatusFailed); + } } } + else + { + result.AppendError ("process is currently running"); + result.SetStatus (eReturnStatusFailed); + } } else { - result.AppendError ("process is currently running"); + result.AppendError ("no current location or status available"); result.SetStatus (eReturnStatusFailed); } + return result.Succeeded(); } - else - { - result.AppendError ("no current location or status available"); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); -} +}; //------------------------------------------------------------------------- // CommandObjectMultiwordThread //------------------------------------------------------------------------- -CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter *interpreter) : +CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : CommandObjectMultiword ("thread", "A set of commands for operating on one or more thread within a running process.", "thread <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectThreadBacktrace ()), "backtrace", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadContinue ()), "continue", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadSelect ()), "select", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadUntil ()), "until", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-in", - "Source level single step in in specified thread (current thread, if none specified).", - "thread step-in [<thread-id>]", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeInto, - eStepScopeSource)), - "step-in", interpreter); - - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", + LoadSubCommand (interpreter, "backtrace", CommandObjectSP (new CommandObjectThreadBacktrace ())); + LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectThreadContinue ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectThreadList ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectThreadSelect ())); + LoadSubCommand (interpreter, "until", CommandObjectSP (new CommandObjectThreadUntil ())); + LoadSubCommand (interpreter, "step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + "thread step-in", + "Source level single step in in specified thread (current thread, if none specified).", + "thread step-in [<thread-id>]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeInto, + eStepScopeSource))); + + LoadSubCommand (interpreter, "step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", "Source level single step out in specified thread (current thread, if none specified).", "thread step-out [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, - eStepScopeSource)), - "step-out", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", + LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", "Source level single step over in specified thread (current thread, if none specified).", "thread step-over [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOver, - eStepScopeSource)), - "step-over", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", + LoadSubCommand (interpreter, "step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", "Single step one instruction in specified thread (current thread, if none specified).", "thread step-inst [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTrace, - eStepScopeInstruction)), - "step-inst", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", + eStepScopeInstruction))); + + LoadSubCommand (interpreter, "step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", "thread step-inst-over [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTraceOver, - eStepScopeInstruction)), - "step-inst-over", interpreter); + eStepScopeInstruction))); } CommandObjectMultiwordThread::~CommandObjectMultiwordThread () diff --git a/lldb/source/Commands/CommandObjectThread.h b/lldb/source/Commands/CommandObjectThread.h index 21bba714626..1a913eb73ad 100644 --- a/lldb/source/Commands/CommandObjectThread.h +++ b/lldb/source/Commands/CommandObjectThread.h @@ -18,27 +18,11 @@ namespace lldb_private { -class CommandObjectThreadList : public CommandObject -{ -public: - - CommandObjectThreadList (); - - ~CommandObjectThreadList (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); -}; - - class CommandObjectMultiwordThread : public CommandObjectMultiword { public: - CommandObjectMultiwordThread (CommandInterpreter *interpreter); + CommandObjectMultiwordThread (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordThread (); @@ -47,14 +31,14 @@ public: bool -DisplayThreadInfo (CommandInterpreter *interpreter, +DisplayThreadInfo (CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, bool show_source); size_t -DisplayThreadsInfo (CommandInterpreter *interpreter, +DisplayThreadsInfo (CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -62,7 +46,7 @@ DisplayThreadsInfo (CommandInterpreter *interpreter, size_t DisplayFramesForExecutionContext (Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -75,7 +59,7 @@ DisplayFramesForExecutionContext (Thread *thread, bool DisplayFrameForExecutionContext (Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, diff --git a/lldb/source/Commands/CommandObjectTranslate.cpp b/lldb/source/Commands/CommandObjectTranslate.cpp deleted file mode 100644 index ef899159043..00000000000 --- a/lldb/source/Commands/CommandObjectTranslate.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===-- CommandObjectTranslate.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectTranslate.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/Options.h" - -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -CommandObjectTranslate::CommandObjectTranslate () : - CommandObject ("translate", - "Shows the actual function called for a given debugger command.", - "translate <command>") -{ -} - -CommandObjectTranslate::~CommandObjectTranslate() -{ -} - - -bool -CommandObjectTranslate::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject *cmd_obj; - - if (command.GetArgumentCount() != 0) - { - cmd_obj = interpreter->GetCommandObject(command.GetArgumentAtIndex(0)); - if (cmd_obj) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - result.AppendMessageWithFormat ("%s\n", cmd_obj->Translate()); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call translate with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} diff --git a/lldb/source/Commands/CommandObjectTranslate.h b/lldb/source/Commands/CommandObjectTranslate.h deleted file mode 100644 index efc3c8b4092..00000000000 --- a/lldb/source/Commands/CommandObjectTranslate.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- CommandObjectTranslate.h --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectTranslate_h_ -#define liblldb_CommandObjectTranslate_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -class CommandObjectTranslate : public CommandObject -{ -public: - - CommandObjectTranslate (); - - virtual - ~CommandObjectTranslate (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectTranslate_h_ diff --git a/lldb/source/Commands/CommandObjectUnalias.cpp b/lldb/source/Commands/CommandObjectUnalias.cpp index 6c2f5085cf8..253414c4305 100644 --- a/lldb/source/Commands/CommandObjectUnalias.cpp +++ b/lldb/source/Commands/CommandObjectUnalias.cpp @@ -25,8 +25,8 @@ using namespace lldb_private; CommandObjectUnalias::CommandObjectUnalias () : CommandObject ("unalias", - "Allows the user to remove/delete a user-defined command abbreviation.", - "unalias <alias-name-to-be-removed>") + "Allows the user to remove/delete a user-defined command abbreviation.", + "unalias <alias-name-to-be-removed>") { } @@ -36,8 +36,12 @@ CommandObjectUnalias::~CommandObjectUnalias() bool -CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectUnalias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -45,10 +49,10 @@ CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInter if (args.GetArgumentCount() != 0) { const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter->GetCommandObject(command_name); + cmd_obj = interpreter.GetCommandObject(command_name); if (cmd_obj) { - if (interpreter->CommandExists (command_name)) + if (interpreter.CommandExists (command_name)) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", command_name); @@ -57,9 +61,9 @@ CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInter else { - if (interpreter->RemoveAlias (command_name) == false) + if (interpreter.RemoveAlias (command_name) == false) { - if (interpreter->AliasExists (command_name)) + if (interpreter.AliasExists (command_name)) result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name); else result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name); diff --git a/lldb/source/Commands/CommandObjectUnalias.h b/lldb/source/Commands/CommandObjectUnalias.h index 5d1cafbcc71..29ce9a408a4 100644 --- a/lldb/source/Commands/CommandObjectUnalias.h +++ b/lldb/source/Commands/CommandObjectUnalias.h @@ -32,9 +32,8 @@ public: ~CommandObjectUnalias (); virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectVariable.cpp b/lldb/source/Commands/CommandObjectVariable.cpp index 398273461b9..a14fa510d5c 100644 --- a/lldb/source/Commands/CommandObjectVariable.cpp +++ b/lldb/source/Commands/CommandObjectVariable.cpp @@ -465,12 +465,14 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("invalid frame"); @@ -492,14 +494,13 @@ public: if (!m_options.globals.empty()) { uint32_t fail_count = 0; - Target *target = context->GetTarget(); - if (target) + if (exe_ctx.target) { const size_t num_globals = m_options.globals.size(); for (idx = 0; idx < num_globals; ++idx) { VariableList global_var_list; - const uint32_t num_matching_globals = target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); + const uint32_t num_matching_globals = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); if (num_matching_globals == 0) { @@ -781,12 +782,12 @@ CommandObjectVariableList::CommandOptions::g_option_table[] = //---------------------------------------------------------------------- // CommandObjectVariable constructor //---------------------------------------------------------------------- -CommandObjectVariable::CommandObjectVariable(CommandInterpreter *interpreter) : +CommandObjectVariable::CommandObjectVariable(CommandInterpreter &interpreter) : CommandObjectMultiword ("variable", - "Access program arguments, locals, static and global variables.", - "variable [list] ...") + "Access program arguments, locals, static and global variables.", + "variable [list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectVariableList ()), "list", interpreter); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectVariableList ())); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectVariable.h b/lldb/source/Commands/CommandObjectVariable.h index 65869c73d72..c13b4b709fd 100644 --- a/lldb/source/Commands/CommandObjectVariable.h +++ b/lldb/source/Commands/CommandObjectVariable.h @@ -26,7 +26,7 @@ class CommandObjectVariable : public CommandObjectMultiword { public: - CommandObjectVariable (CommandInterpreter *iterpreter); + CommandObjectVariable (CommandInterpreter &interpreter); virtual ~CommandObjectVariable (); |