diff options
Diffstat (limited to 'lldb/source/Commands')
36 files changed, 881 insertions, 929 deletions
diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index 36494708b75..a0184646de7 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -26,10 +26,11 @@ using namespace lldb_private; // CommandObjectApropos //------------------------------------------------------------------------- -CommandObjectApropos::CommandObjectApropos () : - CommandObject ("apropos", - "Find a list of debugger commands related to a particular word/subject.", - "apropos <search-word>") +CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "apropos", + "Find a list of debugger commands related to a particular word/subject.", + "apropos <search-word>") { } @@ -41,7 +42,6 @@ CommandObjectApropos::~CommandObjectApropos() bool CommandObjectApropos::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -58,7 +58,7 @@ CommandObjectApropos::Execute // is private. StringList commands_found; StringList commands_help; - interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); + m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); @@ -77,12 +77,12 @@ CommandObjectApropos::Execute } for (size_t i = 0; i < commands_found.GetSize(); ++i) - interpreter.OutputFormattedHelpText (result.GetOutputStream(), - commands_found.GetStringAtIndex(i), - "--", commands_help. - GetStringAtIndex(i), - max_len); - + m_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 cf5cabe3ade..5a3949e4ba1 100644 --- a/lldb/source/Commands/CommandObjectApropos.h +++ b/lldb/source/Commands/CommandObjectApropos.h @@ -26,14 +26,13 @@ class CommandObjectApropos : public CommandObject { public: - CommandObjectApropos (); + CommandObjectApropos (CommandInterpreter &interpreter); virtual ~CommandObjectApropos (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index 0c8b8b6d270..d6ad9011f57 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -77,8 +77,9 @@ CommandObjectArgs::CommandOptions::GetDefinitions () return g_option_table; } -CommandObjectArgs::CommandObjectArgs () : - CommandObject ("args", +CommandObjectArgs::CommandObjectArgs (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "args", "When stopped at the start of a function, reads function arguments of type (u?)int(8|16|32|64)_t, (void|char)*", "args") { @@ -97,7 +98,6 @@ CommandObjectArgs::GetOptions () bool CommandObjectArgs::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -105,7 +105,7 @@ CommandObjectArgs::Execute ConstString target_triple; - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -131,7 +131,7 @@ CommandObjectArgs::Execute return false; } - Thread *thread = interpreter.GetDebugger().GetExecutionContext ().thread; + Thread *thread = m_interpreter.GetDebugger().GetExecutionContext ().thread; if (!thread) { diff --git a/lldb/source/Commands/CommandObjectArgs.h b/lldb/source/Commands/CommandObjectArgs.h index 5a73460e361..70f73f041d8 100644 --- a/lldb/source/Commands/CommandObjectArgs.h +++ b/lldb/source/Commands/CommandObjectArgs.h @@ -47,7 +47,7 @@ namespace lldb_private { static lldb::OptionDefinition g_option_table[]; }; - CommandObjectArgs (); + CommandObjectArgs (CommandInterpreter &interpreter); virtual ~CommandObjectArgs (); @@ -58,8 +58,7 @@ namespace lldb_private { virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute ( Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 40284824d85..a4ad58ce1d5 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -247,8 +247,10 @@ CommandObjectBreakpointSet::CommandOptions::ResetOptionValues () //------------------------------------------------------------------------- #pragma mark Set -CommandObjectBreakpointSet::CommandObjectBreakpointSet () : - CommandObject ("breakpoint set", "Sets a breakpoint or set of breakpoints in the executable.", +CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint set", + "Sets a breakpoint or set of breakpoints in the executable.", "breakpoint set <cmd-options>") { } @@ -266,12 +268,11 @@ CommandObjectBreakpointSet::GetOptions () bool CommandObjectBreakpointSet::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -312,7 +313,7 @@ CommandObjectBreakpointSet::Execute FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = interpreter.GetDebugger().GetExecutionContext().frame; + StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); @@ -503,19 +504,20 @@ CommandObjectBreakpointSet::Execute #pragma mark MultiwordBreakpoint CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : - CommandObjectMultiword ("breakpoint", - "A set of commands for operating on breakpoints. Also see regexp-break.", - "breakpoint <command> [<command-options>]") + CommandObjectMultiword (interpreter, + "breakpoint", + "A set of commands for operating on breakpoints. Also see regexp-break.", + "breakpoint <command> [<command-options>]") { bool status; - CommandObjectSP list_command_object (new CommandObjectBreakpointList ()); - CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete ()); - CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable ()); - CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable ()); - CommandObjectSP set_command_object (new CommandObjectBreakpointSet ()); + CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); + CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); + CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); + CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); + CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); - CommandObjectSP modify_command_object (new CommandObjectBreakpointModify()); + CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); command_command_object->SetCommandName ("breakpoint command"); enable_command_object->SetCommandName("breakpoint enable"); @@ -524,13 +526,13 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter modify_command_object->SetCommandName ("breakpoint modify"); set_command_object->SetCommandName("breakpoint set"); - 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); + status = LoadSubCommand ("list", list_command_object); + status = LoadSubCommand ("enable", enable_command_object); + status = LoadSubCommand ("disable", disable_command_object); + status = LoadSubCommand ("delete", delete_command_object); + status = LoadSubCommand ("set", set_command_object); + status = LoadSubCommand ("command", command_command_object); + status = LoadSubCommand ("modify", modify_command_object); } CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () @@ -679,10 +681,11 @@ CommandObjectBreakpointList::CommandOptions::ResetOptionValues () //------------------------------------------------------------------------- #pragma mark List -CommandObjectBreakpointList::CommandObjectBreakpointList () : - CommandObject ("breakpoint list", - "List some or all breakpoints at configurable levels of detail.", - "breakpoint list [<breakpoint-id>]") +CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint list", + "List some or all breakpoints at configurable levels of detail.", + "breakpoint list [<breakpoint-id>]") { } @@ -699,12 +702,11 @@ CommandObjectBreakpointList::GetOptions () bool CommandObjectBreakpointList::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -769,10 +771,11 @@ CommandObjectBreakpointList::Execute //------------------------------------------------------------------------- #pragma mark Enable -CommandObjectBreakpointEnable::CommandObjectBreakpointEnable () : - CommandObject ("enable", - "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", - "breakpoint enable [<breakpoint-id> | <breakpoint-id-list>]") +CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "enable", + "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", + "breakpoint enable [<breakpoint-id> | <breakpoint-id-list>]") { // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different // potential invocation methods, we need to be a little tricky about generating the syntax string. @@ -790,12 +793,11 @@ CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () bool CommandObjectBreakpointEnable::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -871,8 +873,9 @@ CommandObjectBreakpointEnable::Execute //------------------------------------------------------------------------- #pragma mark Disable -CommandObjectBreakpointDisable::CommandObjectBreakpointDisable () : - CommandObject ("disable", +CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "disable", "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", "disable [<breakpoint-id> | <breakpoint-id-list>]") { @@ -890,12 +893,11 @@ CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () bool CommandObjectBreakpointDisable::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -971,8 +973,9 @@ CommandObjectBreakpointDisable::Execute //------------------------------------------------------------------------- #pragma mark Delete -CommandObjectBreakpointDelete::CommandObjectBreakpointDelete() : - CommandObject ("breakpoint delete", +CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint delete", "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", "breakpoint delete [<breakpoint-id> | <breakpoint-id-list>]") { @@ -986,12 +989,11 @@ CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () bool CommandObjectBreakpointDelete::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -1207,8 +1209,10 @@ CommandObjectBreakpointModify::CommandOptions::ResetOptionValues () //------------------------------------------------------------------------- #pragma mark Modify -CommandObjectBreakpointModify::CommandObjectBreakpointModify () : - CommandObject ("breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable.", +CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint modify", + "Modify the options on a breakpoint or set of breakpoints in the executable.", "breakpoint modify <cmd-options> <breakpoint-id> [<breakpoint-id> ...]") { } @@ -1226,7 +1230,6 @@ CommandObjectBreakpointModify::GetOptions () bool CommandObjectBreakpointModify::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -1238,7 +1241,7 @@ CommandObjectBreakpointModify::Execute return false; } - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().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 b998e3d07c3..cdff75a0b48 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.h +++ b/lldb/source/Commands/CommandObjectBreakpoint.h @@ -60,14 +60,13 @@ public: eSetTypeFunctionRegexp } BreakpointSetType; - CommandObjectBreakpointSet (); + CommandObjectBreakpointSet (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointSet (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -127,14 +126,13 @@ class CommandObjectBreakpointModify : public CommandObject { public: - CommandObjectBreakpointModify (); + CommandObjectBreakpointModify (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointModify (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -187,14 +185,13 @@ private: class CommandObjectBreakpointEnable : public CommandObject { public: - CommandObjectBreakpointEnable (); + CommandObjectBreakpointEnable (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointEnable (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -207,14 +204,13 @@ private: class CommandObjectBreakpointDisable : public CommandObject { public: - CommandObjectBreakpointDisable (); + CommandObjectBreakpointDisable (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointDisable (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -227,14 +223,13 @@ private: class CommandObjectBreakpointList : public CommandObject { public: - CommandObjectBreakpointList (); + CommandObjectBreakpointList (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -280,14 +275,13 @@ private: class CommandObjectBreakpointDelete : public CommandObject { public: - CommandObjectBreakpointDelete (); + CommandObjectBreakpointDelete (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointDelete (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 84f402cbf90..ca39084c3b1 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -125,8 +125,9 @@ CommandObjectBreakpointCommandAdd::CommandOptions::ResetOptionValues () //------------------------------------------------------------------------- -CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd () : - CommandObject ("add", +CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "add", "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.", "breakpoint command add <cmd-options> <breakpoint-id>") { @@ -239,12 +240,11 @@ CommandObjectBreakpointCommandAdd::~CommandObjectBreakpointCommandAdd () bool CommandObjectBreakpointCommandAdd::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -307,24 +307,20 @@ CommandObjectBreakpointCommandAdd::Execute { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) - interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, - bp_options, - m_options.m_one_liner.c_str()); + m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, + m_options.m_one_liner.c_str()); else - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp_options, - result); + m_interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_options, + result); } else { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) - SetBreakpointCommandCallback (interpreter, - bp_options, + SetBreakpointCommandCallback (bp_options, m_options.m_one_liner.c_str()); else - CollectDataForBreakpointCommandCallback (interpreter, - bp_options, + CollectDataForBreakpointCommandCallback (bp_options, result); } } @@ -345,12 +341,11 @@ 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(interpreter.GetDebugger())); + InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger())); std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData()); if (reader_sp && data_ap.get()) { @@ -365,7 +360,7 @@ CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback true)); // echo input if (err.Success()) { - interpreter.GetDebugger().PushInputReader (reader_sp); + m_interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -384,8 +379,7 @@ CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback // Set a one-liner as the callback for the breakpoint. void -CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, +CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner) { std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData()); @@ -460,8 +454,9 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback // CommandObjectBreakpointCommandRemove //------------------------------------------------------------------------- -CommandObjectBreakpointCommandRemove::CommandObjectBreakpointCommandRemove () : - CommandObject ("remove", +CommandObjectBreakpointCommandRemove::CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "remove", "Remove the set of commands from a breakpoint.", "breakpoint command remove <breakpoint-id>") { @@ -474,12 +469,11 @@ CommandObjectBreakpointCommandRemove::~CommandObjectBreakpointCommandRemove () bool CommandObjectBreakpointCommandRemove::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -546,8 +540,9 @@ CommandObjectBreakpointCommandRemove::Execute // CommandObjectBreakpointCommandList //------------------------------------------------------------------------- -CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList () : - CommandObject ("List", +CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "list", "List the script or set of commands to be executed when the breakpoint is hit.", "breakpoint command list <breakpoint-id>") { @@ -560,12 +555,11 @@ CommandObjectBreakpointCommandList::~CommandObjectBreakpointCommandList () bool CommandObjectBreakpointCommandList::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -663,22 +657,23 @@ CommandObjectBreakpointCommandList::Execute //------------------------------------------------------------------------- CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) : - CommandObjectMultiword ("command", + CommandObjectMultiword (interpreter, + "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>") { bool status; - CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd ()); - CommandObjectSP remove_command_object (new CommandObjectBreakpointCommandRemove ()); - CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList ()); + CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd (interpreter)); + CommandObjectSP remove_command_object (new CommandObjectBreakpointCommandRemove (interpreter)); + CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList (interpreter)); add_command_object->SetCommandName ("breakpoint command add"); remove_command_object->SetCommandName ("breakpoint command remove"); list_command_object->SetCommandName ("breakpoint command list"); - status = LoadSubCommand (interpreter, "add", add_command_object); - status = LoadSubCommand (interpreter, "remove", remove_command_object); - status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand ("add", add_command_object); + status = LoadSubCommand ("remove", remove_command_object); + status = LoadSubCommand ("list", list_command_object); } diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.h b/lldb/source/Commands/CommandObjectBreakpointCommand.h index e315515a28c..034a0e80727 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.h +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.h @@ -56,28 +56,25 @@ class CommandObjectBreakpointCommandAdd : public CommandObject { public: - CommandObjectBreakpointCommandAdd (); + CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandAdd (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * GetOptions (); void - CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, CommandReturnObject &result); /// Set a one-liner as the callback for the breakpoint. void - SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner); static size_t @@ -138,14 +135,13 @@ private: class CommandObjectBreakpointCommandRemove : public CommandObject { public: - CommandObjectBreakpointCommandRemove (); + CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandRemove (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -158,14 +154,13 @@ private: class CommandObjectBreakpointCommandList : public CommandObject { public: - CommandObjectBreakpointCommandList (); + CommandObjectBreakpointCommandList (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectCall.cpp b/lldb/source/Commands/CommandObjectCall.cpp index fe0ee534437..cedbd7a2ce1 100644 --- a/lldb/source/Commands/CommandObjectCall.cpp +++ b/lldb/source/Commands/CommandObjectCall.cpp @@ -128,7 +128,6 @@ CommandObjectCall::GetOptions () bool CommandObjectCall::Execute ( - CommandInterpreter &interpreter, Args &command, CommandReturnObject &result ) diff --git a/lldb/source/Commands/CommandObjectCall.h b/lldb/source/Commands/CommandObjectCall.h index 1a5ae1db1e2..33c6f56b257 100644 --- a/lldb/source/Commands/CommandObjectCall.h +++ b/lldb/source/Commands/CommandObjectCall.h @@ -66,8 +66,7 @@ public: virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index b301d8f3bf1..fc761587c82 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -31,10 +31,11 @@ const char *k_space_characters = "\t\n\v\f\r "; class CommandObjectCommandsSource : public CommandObject { public: - CommandObjectCommandsSource() : - CommandObject ("commands source", - "Read in debugger commands from the file <filename> and execute them.", - "command source <filename>") + CommandObjectCommandsSource(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "commands source", + "Read in debugger commands from the file <filename> and execute them.", + "command source <filename>") { } @@ -45,7 +46,6 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -89,8 +89,10 @@ public: 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", + m_interpreter.GetPrompt(), + commands[i].c_str()); + if (!m_interpreter.HandleCommand(commands[i].c_str(), false, result)) break; } @@ -137,8 +139,9 @@ public: class CommandObjectCommandsAlias : public CommandObject { public: - CommandObjectCommandsAlias () : - CommandObject ("commands alias", + CommandObjectCommandsAlias (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "commands alias", "Allow users to define their own debugger command abbreviations.", "commands alias <new_command> <old_command> [<options-for-aliased-command>]") { @@ -200,7 +203,6 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -222,7 +224,7 @@ public: // Verify that the command is alias'able, and get the appropriate command object. - if (interpreter.CommandExists (alias_command.c_str())) + if (m_interpreter.CommandExists (alias_command.c_str())) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -230,7 +232,7 @@ public: } else { - CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true)); + CommandObjectSP command_obj_sp(m_interpreter.GetCommandSPExact (actual_command.c_str(), true)); CommandObjectSP subcommand_obj_sp; bool use_subcommand = false; if (command_obj_sp.get()) @@ -307,25 +309,25 @@ public: // Create the alias. - if (interpreter.AliasExists (alias_command.c_str()) - || interpreter.UserCommandExists (alias_command.c_str())) + if (m_interpreter.AliasExists (alias_command.c_str()) + || m_interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); + OptionArgVectorSP tmp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str())); if (tmp_option_arg_sp.get()) { if (option_arg_vector->size() == 0) - interpreter.RemoveAliasOptions (alias_command.c_str()); + m_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); + m_interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); else - interpreter.AddAlias (alias_command.c_str(), command_obj_sp); + m_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); + m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -347,8 +349,9 @@ public: class CommandObjectCommandsUnalias : public CommandObject { public: - CommandObjectCommandsUnalias () : - CommandObject ("commands unalias", + CommandObjectCommandsUnalias (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "commands unalias", "Allow the user to remove/delete a user-defined command abbreviation.", "unalias <alias-name-to-be-removed>") { @@ -362,7 +365,6 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -373,10 +375,10 @@ public: if (args.GetArgumentCount() != 0) { const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter.GetCommandObject(command_name); + cmd_obj = m_interpreter.GetCommandObject(command_name); if (cmd_obj) { - if (interpreter.CommandExists (command_name)) + if (m_interpreter.CommandExists (command_name)) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", command_name); @@ -385,9 +387,9 @@ public: else { - if (interpreter.RemoveAlias (command_name) == false) + if (m_interpreter.RemoveAlias (command_name) == false) { - if (interpreter.AliasExists (command_name)) + if (m_interpreter.AliasExists (command_name)) result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name); else @@ -423,13 +425,14 @@ public: //------------------------------------------------------------------------- CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) : - CommandObjectMultiword ("commands", + CommandObjectMultiword (interpreter, + "commands", "A set of commands for managing or customizing the debugger commands.", "commands <subcommand> [<subcommand-options>]") { - LoadSubCommand (interpreter, "source", CommandObjectSP (new CommandObjectCommandsSource ())); - LoadSubCommand (interpreter, "alias", CommandObjectSP (new CommandObjectCommandsAlias ())); - LoadSubCommand (interpreter, "unalias", CommandObjectSP (new CommandObjectCommandsUnalias ())); + LoadSubCommand ("source", CommandObjectSP (new CommandObjectCommandsSource (interpreter))); + LoadSubCommand ("alias", CommandObjectSP (new CommandObjectCommandsAlias (interpreter))); + LoadSubCommand ("unalias", CommandObjectSP (new CommandObjectCommandsUnalias (interpreter))); } CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands () diff --git a/lldb/source/Commands/CommandObjectCrossref.cpp b/lldb/source/Commands/CommandObjectCrossref.cpp index a9e833e3a4d..461c7e85de8 100644 --- a/lldb/source/Commands/CommandObjectCrossref.cpp +++ b/lldb/source/Commands/CommandObjectCrossref.cpp @@ -24,11 +24,12 @@ using namespace lldb_private; CommandObjectCrossref::CommandObjectCrossref ( + CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax ) : - CommandObject (name, help, syntax), + CommandObject (interpreter, name, help, syntax), m_crossref_object_types() { } @@ -40,7 +41,6 @@ CommandObjectCrossref::~CommandObjectCrossref () bool CommandObjectCrossref::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index a5fc7f6cfab..5e135376813 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -141,10 +141,11 @@ CommandObjectDisassemble::CommandOptions::g_option_table[] = // CommandObjectDisassemble //------------------------------------------------------------------------- -CommandObjectDisassemble::CommandObjectDisassemble () : - CommandObject ("disassemble", - "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.", - "disassemble [<cmd-options>]") +CommandObjectDisassemble::CommandObjectDisassemble (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "disassemble", + "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.", + "disassemble [<cmd-options>]") { } @@ -155,12 +156,11 @@ CommandObjectDisassemble::~CommandObjectDisassemble() bool CommandObjectDisassemble::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -189,11 +189,15 @@ CommandObjectDisassemble::Execute if (command.GetArgumentCount() != 0) { - result.AppendErrorWithFormat ("\"disassemble\" doesn't take any arguments.\n"); + result.AppendErrorWithFormat ("\"disassemble\" arguments are specified as options.\n"); + GetOptions()->GenerateOptionUsage (m_interpreter, + result.GetErrorStream(), + this); + result.SetStatus (eReturnStatusFailed); return false; } - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (m_options.show_mixed && m_options.num_lines_context == 0) m_options.num_lines_context = 1; @@ -202,7 +206,7 @@ CommandObjectDisassemble::Execute { ConstString name(m_options.m_func_name.c_str()); - if (Disassembler::Disassemble (interpreter.GetDebugger(), + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), arch, exe_ctx, name, @@ -260,7 +264,7 @@ CommandObjectDisassemble::Execute if (range.GetByteSize() == 0) range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE); - if (Disassembler::Disassemble (interpreter.GetDebugger(), + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), arch, exe_ctx, range, diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h index 8ea992707f6..9b0e0ab2afe 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.h +++ b/lldb/source/Commands/CommandObjectDisassemble.h @@ -54,7 +54,7 @@ public: static lldb::OptionDefinition g_option_table[]; }; - CommandObjectDisassemble (); + CommandObjectDisassemble (CommandInterpreter &interpreter); virtual ~CommandObjectDisassemble (); @@ -67,8 +67,7 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); protected: diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 61ada69e48f..1e2d0235598 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -95,12 +95,12 @@ CommandObjectExpression::CommandOptions::GetDefinitions () return g_option_table; } -CommandObjectExpression::CommandObjectExpression () : - CommandObject ( - "expression", - "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", - "expression [<cmd-options>] <expr>"), - m_expr_line_count (0), +CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "expression", + "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", + "expression [<cmd-options>] <expr>"), +m_expr_line_count (0), m_expr_lines () { SetHelpLong( @@ -125,7 +125,6 @@ CommandObjectExpression::GetOptions () bool CommandObjectExpression::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -259,12 +258,11 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream bool CommandObjectExpression::ExecuteRawCommandString ( - CommandInterpreter &interpreter, const char *command, CommandReturnObject &result ) { - m_exe_ctx = interpreter.GetDebugger().GetExecutionContext(); + m_exe_ctx = m_interpreter.GetDebugger().GetExecutionContext(); m_options.ResetOptionValues(); @@ -275,7 +273,7 @@ CommandObjectExpression::ExecuteRawCommandString m_expr_lines.clear(); m_expr_line_count = 0; - InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); + InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger())); if (reader_sp) { Error err (reader_sp->Initialize (CommandObjectExpression::MultiLineExpressionCallback, @@ -286,7 +284,7 @@ CommandObjectExpression::ExecuteRawCommandString true)); // echo input if (err.Success()) { - interpreter.GetDebugger().PushInputReader (reader_sp); + m_interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -328,7 +326,7 @@ CommandObjectExpression::ExecuteRawCommandString if (end_options) { Args args (command, end_options - command); - if (!ParseOptions (interpreter, args, result)) + if (!ParseOptions (args, result)) return false; } } diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index f4805634c4b..4aed304a793 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -54,7 +54,7 @@ public: bool show_summary; }; - CommandObjectExpression (); + CommandObjectExpression (CommandInterpreter &interpreter); virtual ~CommandObjectExpression (); @@ -65,16 +65,14 @@ public: virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteRawCommandString (const char *command, CommandReturnObject &result); protected: diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp index 54bd975a07e..4a560ab558e 100644 --- a/lldb/source/Commands/CommandObjectFile.cpp +++ b/lldb/source/Commands/CommandObjectFile.cpp @@ -85,8 +85,9 @@ CommandObjectFile::CommandOptions::ResetOptionValues () // CommandObjectFile //------------------------------------------------------------------------- -CommandObjectFile::CommandObjectFile() : - CommandObject ("file", +CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "file", "Set the file to be used as the main executable by the debugger.", "file [<cmd-options>] <filename>") { @@ -105,7 +106,6 @@ CommandObjectFile::GetOptions () bool CommandObjectFile::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -127,7 +127,7 @@ CommandObjectFile::Execute TargetSP target_sp; ArchSpec arch = m_options.m_arch; - Debugger &debugger = interpreter.GetDebugger(); + Debugger &debugger = m_interpreter.GetDebugger(); Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_options.m_arch, NULL, true, target_sp); if (target_sp) @@ -152,27 +152,28 @@ CommandObjectFile::Execute } int -CommandObjectFile::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) +CommandObjectFile::HandleArgumentCompletion +( + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches +) { - std::string completion_str (input.GetArgumentAtIndex(cursor_index)); - completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, - CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); - return matches.GetSize(); - + std::string completion_str (input.GetArgumentAtIndex(cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, + CommandCompletions::eDiskFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); } diff --git a/lldb/source/Commands/CommandObjectFile.h b/lldb/source/Commands/CommandObjectFile.h index b42f753ada1..4820b20a12b 100644 --- a/lldb/source/Commands/CommandObjectFile.h +++ b/lldb/source/Commands/CommandObjectFile.h @@ -28,14 +28,13 @@ class CommandObjectFile : public CommandObject { public: - CommandObjectFile (); + CommandObjectFile (CommandInterpreter &interpreter); virtual ~CommandObjectFile (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -69,8 +68,7 @@ public: }; virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 1593488f4c1..04136642f15 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -51,11 +51,12 @@ class CommandObjectFrameInfo : public CommandObject { public: - CommandObjectFrameInfo () : - CommandObject ("frame info", - "List information about the currently selected frame in the current thread.", - "frame info", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectFrameInfo (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame info", + "List information about the currently selected frame in the current thread.", + "frame info", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -64,11 +65,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->Dump (&result.GetOutputStream(), true, false); @@ -94,12 +94,12 @@ class CommandObjectFrameSelect : public CommandObject { public: - CommandObjectFrameSelect () : - CommandObject ("frame select", - //"Select the current frame by index in the current thread.", - "Select a frame by index from within the current thread and make it the current frame.", - "frame select <frame-index>", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectFrameSelect (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame select", + "Select a frame by index from within the current thread and make it the current frame.", + "frame select <frame-index>", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -108,11 +108,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (command.GetArgumentCount() == 1) @@ -130,14 +129,14 @@ public: { bool already_shown = false; SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); - if (interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) + if (m_interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); } if (DisplayFrameForExecutionContext (exe_ctx.thread, exe_ctx.frame, - interpreter, + m_interpreter, result.GetOutputStream(), true, !already_shown, @@ -288,11 +287,11 @@ public: // Instance variables to hold the values for command options. }; - CommandObjectFrameVariable () : - CommandObject ( - "frame variable", - "Show specified argument, local variable, static variable or global variable for the current frame. If none specified, list them all.", - "frame variable [<cmd-options>] [<var-name1> [<var-name2>...]]") + CommandObjectFrameVariable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame variable", + "Show specified argument, local variable, static variable or global variable for the current frame. If none specified, list them all.", + "frame variable [<cmd-options>] [<var-name1> [<var-name2>...]]") { } @@ -431,12 +430,11 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("invalid frame"); @@ -789,13 +787,14 @@ CommandObjectFrameVariable::CommandOptions::g_option_table[] = //------------------------------------------------------------------------- CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : - CommandObjectMultiword ("frame", + CommandObjectMultiword (interpreter, + "frame", "A set of commands for operating on the current thread's frames.", "frame <subcommand> [<subcommand-options>]") { - LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectFrameInfo ())); - LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectFrameSelect ())); - LoadSubCommand (interpreter, "variable", CommandObjectSP (new CommandObjectFrameVariable ())); + LoadSubCommand ("info", CommandObjectSP (new CommandObjectFrameInfo (interpreter))); + LoadSubCommand ("select", CommandObjectSP (new CommandObjectFrameSelect (interpreter))); + LoadSubCommand ("variable", CommandObjectSP (new CommandObjectFrameVariable (interpreter))); } CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 9541d368d03..2d4b9f28482 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -25,8 +25,9 @@ using namespace lldb_private; // CommandObjectHelp //------------------------------------------------------------------------- -CommandObjectHelp::CommandObjectHelp () : - CommandObject ("help", +CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "help", "Show a list of all debugger commands, or give details about specific commands.", "help [<cmd-name>]") { @@ -38,7 +39,7 @@ CommandObjectHelp::~CommandObjectHelp() bool -CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result) +CommandObjectHelp::Execute (Args& command, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -49,13 +50,13 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm if (argc == 0) { result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter.GetHelp (result); // General help, for ALL commands. + m_interpreter.GetHelp (result); // General help, for ALL commands. } else { // Get command object for the first command argument. Only search built-in command dictionary. StringList matches; - cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches); + cmd_obj = m_interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches); if (cmd_obj != NULL) { @@ -94,10 +95,9 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm Stream &output_strm = result.GetOutputStream(); if (sub_cmd_obj->GetOptions() != NULL) { - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj, - interpreter.GetDebugger().GetInstanceName().AsCString()); + sub_cmd_obj->GetOptions()->GenerateOptionUsage (m_interpreter, output_strm, sub_cmd_obj); const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) @@ -105,8 +105,8 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm } else if (sub_cmd_obj->IsMultiwordObject()) { - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); - ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result); } else { @@ -115,7 +115,7 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm && (strlen (long_help) > 0)) output_strm.Printf ("\n%s", long_help); else - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } @@ -145,7 +145,6 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm int CommandObjectHelp::HandleCompletion ( - CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, @@ -158,15 +157,25 @@ CommandObjectHelp::HandleCompletion // 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, word_complete, matches); + return m_interpreter.HandleCompletionMatches (input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); } else { - CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0)); + CommandObject *cmd_obj = m_interpreter.GetCommandObject (input.GetArgumentAtIndex(0)); input.Shift(); cursor_index--; - return cmd_obj->HandleCompletion (interpreter, input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); + return cmd_obj->HandleCompletion (input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); } } diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h index cf16e5d35a2..9e6c90b5e87 100644 --- a/lldb/source/Commands/CommandObjectHelp.h +++ b/lldb/source/Commands/CommandObjectHelp.h @@ -26,19 +26,17 @@ class CommandObjectHelp : public CommandObject { public: - CommandObjectHelp (); + CommandObjectHelp (CommandInterpreter &interpreter); virtual ~CommandObjectHelp (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleCompletion (CommandInterpreter &interpreter, - Args &input, + HandleCompletion (Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp index 414e0315fde..8c17221b9a7 100644 --- a/lldb/source/Commands/CommandObjectImage.cpp +++ b/lldb/source/Commands/CommandObjectImage.cpp @@ -476,10 +476,11 @@ class CommandObjectImageDumpModuleList : public CommandObject { public: - CommandObjectImageDumpModuleList (const char *name, + CommandObjectImageDumpModuleList (CommandInterpreter &interpreter, + const char *name, const char *help, const char *syntax) : - CommandObject (name, help, syntax) + CommandObject (interpreter, name, help, syntax) { } @@ -489,8 +490,7 @@ public: } virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -503,7 +503,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eModuleCompletion, completion_str.c_str(), match_start_point, @@ -519,10 +519,11 @@ class CommandObjectImageDumpSourceFileList : public CommandObject { public: - CommandObjectImageDumpSourceFileList (const char *name, + CommandObjectImageDumpSourceFileList (CommandInterpreter &interpreter, + const char *name, const char *help, const char *syntax) : - CommandObject (name, help, syntax) + CommandObject (interpreter, name, help, syntax) { } @@ -532,8 +533,7 @@ public: } virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -546,7 +546,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSourceFileCompletion, completion_str.c_str(), match_start_point, @@ -562,10 +562,11 @@ public: class CommandObjectImageDumpSymtab : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSymtab () : - CommandObjectImageDumpModuleList ("image dump symtab", - "Dump the symbol table from one or more executable images.", - "image dump symtab [<file1> ...]") + CommandObjectImageDumpSymtab (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump symtab", + "Dump the symbol table from one or more executable images.", + "image dump symtab [<file1> ...]") { } @@ -575,11 +576,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -604,7 +604,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSymtab (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -642,7 +642,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSymtab (interpreter, result.GetOutputStream(), image_module); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), image_module); } } } @@ -670,8 +670,9 @@ public: class CommandObjectImageDumpSections : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSections () : - CommandObjectImageDumpModuleList ("image dump sections", + CommandObjectImageDumpSections (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump sections", "Dump the sections from one or more executable images.", "image dump sections [<file1> ...]") { @@ -683,11 +684,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -712,7 +712,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSections (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSections (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -750,7 +750,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSections (interpreter, result.GetOutputStream(), image_module); + DumpModuleSections (m_interpreter, result.GetOutputStream(), image_module); } } } @@ -777,10 +777,11 @@ public: class CommandObjectImageDumpSymfile : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSymfile () : - CommandObjectImageDumpModuleList ("image dump symfile", - "Dump the debug symbol file for one or more executable images.", - "image dump symfile [<file1> ...]") + CommandObjectImageDumpSymfile (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump symfile", + "Dump the debug symbol file for one or more executable images.", + "image dump symfile [<file1> ...]") { } @@ -790,11 +791,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -884,10 +884,11 @@ public: class CommandObjectImageDumpLineTable : public CommandObjectImageDumpSourceFileList { public: - CommandObjectImageDumpLineTable () : - CommandObjectImageDumpSourceFileList ("image dump line-table", - "Dump the debug symbol file for one or more executable images.", - "image dump line-table <source-file1> [<source-file2> ...]") + CommandObjectImageDumpLineTable (CommandInterpreter &interpreter) : + CommandObjectImageDumpSourceFileList (interpreter, + "image dump line-table", + "Dump the debug symbol file for one or more executable images.", + "image dump line-table <source-file1> [<source-file2> ...]") { } @@ -897,11 +898,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -910,7 +910,7 @@ public: } else { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -935,7 +935,7 @@ public: uint32_t num_dumped = 0; for (uint32_t i = 0; i<num_modules; ++i) { - if (DumpCompileUnitLineTable (interpreter, + if (DumpCompileUnitLineTable (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(i), file_spec, @@ -973,14 +973,15 @@ public: // Constructors and Destructors //------------------------------------------------------------------ CommandObjectImageDump(CommandInterpreter &interpreter) : - CommandObjectMultiword ("image dump", + CommandObjectMultiword (interpreter, + "image dump", "A set of commands for dumping information about one or more executable images; 'line-table' expects a source file name", "image dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") { - 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 ())); + LoadSubCommand ("symtab", CommandObjectSP (new CommandObjectImageDumpSymtab (interpreter))); + LoadSubCommand ("sections", CommandObjectSP (new CommandObjectImageDumpSections (interpreter))); + LoadSubCommand ("symfile", CommandObjectSP (new CommandObjectImageDumpSymfile (interpreter))); + LoadSubCommand ("line-table", CommandObjectSP (new CommandObjectImageDumpLineTable (interpreter))); } virtual @@ -1045,11 +1046,11 @@ public: FormatWidthCollection m_format_array; }; - CommandObjectImageList () : - CommandObject ( - "image list", - "List current executable and dependent shared library images.", - "image list [<cmd-options>]") + CommandObjectImageList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "image list", + "List current executable and dependent shared library images.", + "image list [<cmd-options>]") { } @@ -1066,11 +1067,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1322,11 +1322,11 @@ public: }; - CommandObjectImageLookup () : - CommandObject ( - "image lookup", - "Look up information within executable and dependent shared library images.", - "image lookup [<cmd-options>] [<file1>...]") + CommandObjectImageLookup (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "image lookup", + "Look up information within executable and dependent shared library images.", + "image lookup [<cmd-options>] [<file1>...]") { } @@ -1351,7 +1351,7 @@ public: case eLookupTypeAddress: if (m_options.m_addr != LLDB_INVALID_ADDRESS) { - if (LookupAddressInModule (interpreter, + if (LookupAddressInModule (m_interpreter, result.GetOutputStream(), module, eSymbolContextEverything, @@ -1368,7 +1368,7 @@ public: case eLookupTypeSymbol: if (!m_options.m_str.empty()) { - if (LookupSymbolInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) + if (LookupSymbolInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1380,7 +1380,7 @@ public: if (m_options.m_file) { - if (LookupFileAndLineInModule (interpreter, + if (LookupFileAndLineInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_file, @@ -1396,7 +1396,7 @@ public: case eLookupTypeFunction: if (!m_options.m_str.empty()) { - if (LookupFunctionInModule (interpreter, + if (LookupFunctionInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1411,7 +1411,7 @@ public: case eLookupTypeType: if (!m_options.m_str.empty()) { - if (LookupTypeInModule (interpreter, + if (LookupTypeInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1424,7 +1424,7 @@ public: break; default: - m_options.GenerateOptionUsage (result.GetErrorStream(), this, interpreter.GetDebugger().GetInstanceName().AsCString()); + m_options.GenerateOptionUsage (m_interpreter, result.GetErrorStream(), this); syntax_error = true; break; } @@ -1434,11 +1434,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1463,7 +1462,7 @@ public: { for (i = 0; i<num_modules && syntax_error == false; ++i) { - if (LookupInModule (interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) + if (LookupInModule (m_interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1504,7 +1503,7 @@ public: Module * image_module = matching_modules.GetModulePointerAtIndex(j); if (image_module) { - if (LookupInModule (interpreter, image_module, result, syntax_error)) + if (LookupInModule (m_interpreter, image_module, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1553,13 +1552,14 @@ CommandObjectImageLookup::CommandOptions::g_option_table[] = // CommandObjectImage constructor //---------------------------------------------------------------------- CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : - CommandObjectMultiword ("image", + CommandObjectMultiword (interpreter, + "image", "A set of commands for accessing information for one or more executable images.", "image <sub-command> ...") { - LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); - LoadSubCommand (interpreter, "lookup", CommandObjectSP (new CommandObjectImageLookup ())); + LoadSubCommand ("dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectImageList (interpreter))); + LoadSubCommand ("lookup", CommandObjectSP (new CommandObjectImageLookup (interpreter))); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index f5ad33d5df5..d2e0652639a 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -58,8 +58,9 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogEnable() : - CommandObject ("log enable", + CommandObjectLogEnable(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log enable", "Enable logging for a single log channel.", "log enable [<cmd-options>] <channel>") { @@ -77,8 +78,7 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() < 1) @@ -95,7 +95,7 @@ public: if (m_options.log_file.empty()) { - log_stream_sp.reset(new StreamFile(interpreter.GetDebugger().GetOutputFileHandle())); + log_stream_sp.reset(new StreamFile(m_interpreter.GetDebugger().GetOutputFileHandle())); } else { @@ -234,10 +234,11 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogDisable() : - CommandObject ("log disable", - "Disable one or more log channels.", - "log disable <channel> [<channel> ...]") + CommandObjectLogDisable(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log disable", + "Disable one or more log channels.", + "log disable <channel> [<channel> ...]") { } @@ -247,8 +248,7 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -295,8 +295,9 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogList() : - CommandObject ("log list", + CommandObjectLogList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log list", "List the log categories for one or more log channels.", "log list <channel> [<channel> ...]") { @@ -308,8 +309,7 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -358,8 +358,9 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogTimer() : - CommandObject ("log timers", + CommandObjectLogTimer(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log timers", "Enable, disable, dump, and reset LLDB internal performance timers.", "log timers < enable | disable | dump | reset >") { @@ -371,8 +372,7 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -418,14 +418,15 @@ public: // CommandObjectLog constructor //---------------------------------------------------------------------- CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : - CommandObjectMultiword ("log", + CommandObjectMultiword (interpreter, + "log", "A set of commands for operating on logs.", "log <command> [<command-options>]") { - LoadSubCommand (interpreter, "enable", CommandObjectSP (new CommandObjectLogEnable)); - LoadSubCommand (interpreter, "disable", CommandObjectSP (new CommandObjectLogDisable)); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectLogList)); - LoadSubCommand (interpreter, "timers", CommandObjectSP (new CommandObjectLogTimer)); + LoadSubCommand ("enable", CommandObjectSP (new CommandObjectLogEnable (interpreter))); + LoadSubCommand ("disable", CommandObjectSP (new CommandObjectLogDisable (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectLogList (interpreter))); + LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter))); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index f5fe0ec62c2..22eccca9015 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -176,8 +176,9 @@ public: uint32_t m_num_per_line; }; - CommandObjectMemoryRead () : - CommandObject ("memory read", + CommandObjectMemoryRead (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "memory read", "Read from the memory of the process being debugged.", "memory read [<cmd-options>] <start-addr> [<end-addr>]", eFlagProcessMustBeLaunched) @@ -196,11 +197,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -394,8 +394,9 @@ public: uint32_t m_byte_size; }; - CommandObjectMemoryWrite () : - CommandObject ("memory write", + CommandObjectMemoryWrite (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "memory write", "Write to the memory of the process being debugged.", "memory write [<cmd-options>] <addr> [value1 value2 ...]", eFlagProcessMustBeLaunched) @@ -441,11 +442,10 @@ public: } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -677,12 +677,13 @@ CommandObjectMemoryWrite::CommandOptions::g_option_table[] = //------------------------------------------------------------------------- CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : - CommandObjectMultiword ("memory", + CommandObjectMultiword (interpreter, + "memory", "A set of commands for operating on memory.", "memory <subcommand> [<subcommand-options>]") { - LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); - LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectMemoryWrite ())); + LoadSubCommand ("read", CommandObjectSP (new CommandObjectMemoryRead (interpreter))); + LoadSubCommand ("write", CommandObjectSP (new CommandObjectMemoryWrite (interpreter))); } CommandObjectMemory::~CommandObjectMemory () diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 0a2987cf380..9530adf8668 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -26,12 +26,13 @@ using namespace lldb_private; CommandObjectMultiword::CommandObjectMultiword ( + CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags ) : - CommandObject (name, help, syntax, flags) + CommandObject (interpreter, name, help, syntax, flags) { } @@ -82,7 +83,6 @@ CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *ma bool CommandObjectMultiword::LoadSubCommand ( - CommandInterpreter &interpreter, const char *name, const CommandObjectSP& cmd_obj ) @@ -94,7 +94,7 @@ CommandObjectMultiword::LoadSubCommand if (pos == m_subcommand_dict.end()) { m_subcommand_dict[name] = cmd_obj; - interpreter.CrossRegisterCommand (name, GetCommandName()); + m_interpreter.CrossRegisterCommand (name, GetCommandName()); } else success = false; @@ -105,7 +105,6 @@ CommandObjectMultiword::LoadSubCommand bool CommandObjectMultiword::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -113,7 +112,7 @@ CommandObjectMultiword::Execute const size_t argc = args.GetArgumentCount(); if (argc == 0) { - GenerateHelpText (interpreter, result); + GenerateHelpText (result); } else { @@ -123,7 +122,7 @@ CommandObjectMultiword::Execute { if (::strcasecmp (sub_command, "help") == 0) { - GenerateHelpText (interpreter, result); + GenerateHelpText (result); } else if (!m_subcommand_dict.empty()) { @@ -136,7 +135,7 @@ CommandObjectMultiword::Execute args.Shift(); - sub_cmd_obj->ExecuteWithOptions (interpreter, args, result); + sub_cmd_obj->ExecuteWithOptions (args, result); } else { @@ -179,7 +178,7 @@ CommandObjectMultiword::Execute } void -CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result) +CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result) { // First time through here, generate the help text for the object and // push it to the return result object as well @@ -188,7 +187,7 @@ CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, Comma output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; - uint32_t max_len = interpreter.FindLongestCommandWord (m_subcommand_dict); + uint32_t max_len = m_interpreter.FindLongestCommandWord (m_subcommand_dict); if (max_len) max_len += 4; // Indent the output by 4 spaces. @@ -197,11 +196,11 @@ CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, Comma { std::string indented_command (" "); indented_command.append (pos->first); - interpreter.OutputFormattedHelpText (result.GetOutputStream(), - indented_command.c_str(), - "--", - pos->second->GetHelp(), - max_len); + m_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"); @@ -212,7 +211,6 @@ CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, Comma int CommandObjectMultiword::HandleCompletion ( - CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, @@ -245,8 +243,8 @@ CommandObjectMultiword::HandleCompletion input.Shift(); cursor_char_position = 0; input.AppendArgument (""); - return cmd_obj->HandleCompletion (interpreter, - input, cursor_index, + return cmd_obj->HandleCompletion (input, + cursor_index, cursor_char_position, match_start_point, max_return_elements, @@ -273,8 +271,7 @@ CommandObjectMultiword::HandleCompletion matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; - return sub_command_object->HandleCompletion (interpreter, - input, + return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index cd1e013b671..f04f1fa48ff 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -101,8 +101,9 @@ public: }; - CommandObjectProcessLaunch () : - CommandObject ("process launch", + CommandObjectProcessLaunch (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process launch", "Launch the executable in the debugger.", "process launch [<cmd-options>] [<arguments-for-running-the-program>]") { @@ -120,12 +121,11 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& launch_args, + Execute (Args& launch_args, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); - bool synchronous_execution = interpreter.GetSynchronous (); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + bool synchronous_execution = m_interpreter.GetSynchronous (); // bool launched = false; // bool stopped_after_launch = false; @@ -141,16 +141,13 @@ public: Module *exe_module = target->GetExecutableModule().get(); exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - if (process) + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + if (process && process->IsAlive()) { - if (process->IsAlive()) - { - result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before running again.\n", - process->GetID()); - result.SetStatus (eReturnStatusFailed); - return false; - } + result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before running again.\n", + process->GetID()); + result.SetStatus (eReturnStatusFailed); + return false; } const char *plugin_name; @@ -159,130 +156,91 @@ public: else plugin_name = NULL; - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); - - const char *process_name = process->GetInstanceName().AsCString(); - const char *debugger_instance_name = interpreter.GetDebugger().GetInstanceName().AsCString(); - StreamString run_args_var_name; - StreamString env_vars_var_name; - StreamString disable_aslr_var_name; - lldb::SettableVariableType var_type; - - Args *run_args = NULL; - run_args_var_name.Printf ("process.[%s].run-args", process_name); - StringList run_args_value = Debugger::GetSettingsController()->GetVariable (run_args_var_name.GetData(), - var_type, debugger_instance_name); + process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get(); - if (run_args_value.GetSize() > 0) + if (process == NULL) { - run_args = new Args; - for (unsigned i = 0, e = run_args_value.GetSize(); i != e; ++i) - run_args->AppendArgument(run_args_value.GetStringAtIndex(i)); + result.AppendErrorWithFormat ("Failed to find a process plugin for executable"); + result.SetStatus (eReturnStatusFailed); + return false; } - - Args *environment = NULL; - env_vars_var_name.Printf ("process.[%s].env-vars", process_name); - StringList env_vars_value = Debugger::GetSettingsController()->GetVariable (env_vars_var_name.GetData(), - var_type, debugger_instance_name); - if (env_vars_value.GetSize() > 0) + // If no launch args were given on the command line, then use any that + // might have been set using the "run-args" set variable. + if (launch_args.GetArgumentCount() == 0) { - environment = new Args; - for (unsigned i = 0, e = env_vars_value.GetSize(); i != e; ++i) - environment->AppendArgument (env_vars_value.GetStringAtIndex (i)); + if (process->GetRunArguments().GetArgumentCount() > 0) + launch_args = process->GetRunArguments(); } - + + Args environment; + + process->GetEnvironmentAsArgs (environment); + uint32_t launch_flags = eLaunchFlagNone; - disable_aslr_var_name.Printf ("process.[%s].disable-aslr", process_name); - StringList disable_aslr_value = Debugger::GetSettingsController()->GetVariable(disable_aslr_var_name.GetData(), - var_type, - debugger_instance_name); - - if (disable_aslr_value.GetSize() > 0) - { - if (strcmp (disable_aslr_value.GetStringAtIndex(0), "true") == 0) - launch_flags |= eLaunchFlagDisableASLR; + + if (process->GetDisableASLR()) + launch_flags |= eLaunchFlagDisableASLR; - } + const char *archname = exe_module->GetArchitecture().AsCString(); - // 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). + const char * stdin_path = NULL; + const char * stdout_path = NULL; + const char * stderr_path = NULL; - // If launch_args is empty, use run_args. - if (launch_args.GetArgumentCount() == 0) + // Were any standard input/output/error paths given on the command line? + if (m_options.stdin_path.empty() && + m_options.stdout_path.empty() && + m_options.stderr_path.empty()) { - if (run_args != NULL) - launch_args.AppendArguments (*run_args); + // No standard file handles were given on the command line, check + // with the process object in case they were give using "set settings" + stdin_path = process->GetStandardInputPath(); + stdout_path = process->GetStandardOutputPath(); + stderr_path = process->GetStandardErrorPath(); } else { - // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. - std::string new_run_args; - launch_args.GetCommandString (new_run_args); - Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), - lldb::eVarSetOperationAssign, false, - interpreter.GetDebugger().GetInstanceName().AsCString()); + stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); + stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); + stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); } - - if (process) + if (stdin_path == NULL) + stdin_path = "/dev/null"; + if (stdout_path == NULL) + stdout_path = "/dev/null"; + if (stderr_path == NULL) + stderr_path = "/dev/null"; + + Error error (process->Launch (launch_args.GetArgumentCount() ? launch_args.GetConstArgumentVector() : NULL, + environment.GetArgumentCount() ? environment.GetConstArgumentVector() : NULL, + launch_flags, + stdin_path, + stdout_path, + stderr_path)); + + if (error.Success()) { - const char *archname = exe_module->GetArchitecture().AsCString(); - - const char * stdin_path = NULL; - const char * stdout_path = NULL; - const char * stderr_path = NULL; - - if (!(m_options.stdin_path.empty() && - m_options.stdout_path.empty() && - m_options.stderr_path.empty())) + result.AppendMessageWithFormat ("Launching '%s' (%s)\n", filename, archname); + result.SetStatus (eReturnStatusSuccessContinuingNoResult); + if (m_options.stop_at_entry == false) { - stdin_path = m_options.stdin_path.empty() ? "/dev/null" : m_options.stdin_path.c_str(); - stdout_path = m_options.stdout_path.empty() ? "/dev/null" : m_options.stdout_path.c_str(); - stderr_path = m_options.stderr_path.empty() ? "/dev/null" : m_options.stderr_path.c_str(); - } + StateType state = process->WaitForProcessToStop (NULL); - Error error (process->Launch (launch_args.GetConstArgumentVector(), - environment ? environment->GetConstArgumentVector() : NULL, - launch_flags, - stdin_path, - stdout_path, - stderr_path)); - - if (error.Success()) - { - result.AppendMessageWithFormat ("Launching '%s' (%s)\n", filename, archname); - result.SetStatus (eReturnStatusSuccessContinuingNoResult); - if (m_options.stop_at_entry == false) + if (state == eStateStopped) { - StateType state = process->WaitForProcessToStop (NULL); - - if (state == eStateStopped) - { - // Call continue_command. - CommandReturnObject continue_result; - interpreter.HandleCommand("process continue", false, continue_result); - } + // Call continue_command. + CommandReturnObject continue_result; + m_interpreter.HandleCommand("process continue", false, continue_result); + } - if (synchronous_execution) - { - result.SetDidChangeProcessState (true); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } + if (synchronous_execution) + { + result.SetDidChangeProcessState (true); + result.SetStatus (eReturnStatusSuccessFinishNoResult); } } - else - { - result.AppendErrorWithFormat ("Process launch failed: %s", - error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendErrorWithFormat ("Process launch failed: unable to create a process object.\n"); - result.SetStatus (eReturnStatusFailed); - return false; } return result.Succeeded(); @@ -386,7 +344,7 @@ public: } virtual bool - HandleOptionArgumentCompletion (CommandInterpreter &interpreter, + HandleOptionArgumentCompletion (CommandInterpreter &interpeter, Args &input, int cursor_index, int char_pos, @@ -409,7 +367,7 @@ public: // Look to see if there is a -P argument provided, and if so use that plugin, otherwise // use the default plugin. - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = interpeter.GetDebugger().GetExecutionContext().process; bool need_to_delete_process = false; const char *partial_name = NULL; @@ -418,7 +376,7 @@ public: if (process && process->IsAlive()) return true; - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = interpeter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { // No target has been set yet, for now do host completion. Otherwise I don't know how we would @@ -429,7 +387,7 @@ public: } if (!process) { - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), partial_name).get(); + process = target->CreateProcess (interpeter.GetDebugger().GetListener(), partial_name).get(); need_to_delete_process = true; } @@ -459,8 +417,9 @@ public: bool waitfor; }; - CommandObjectProcessAttach () : - CommandObject ("process attach", + CommandObjectProcessAttach (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process attach", "Attach to a process.", "process attach <cmd-options>") { @@ -471,13 +430,12 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -497,19 +455,19 @@ public: ArchSpec emptyArchSpec; Error error; - error = interpreter.GetDebugger().GetTargetList().CreateTarget(interpreter.GetDebugger(), - emptyFileSpec, - emptyArchSpec, - NULL, - false, - new_target_sp); + error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), + emptyFileSpec, + emptyArchSpec, + NULL, + false, + new_target_sp); target = new_target_sp.get(); if (target == NULL || error.Fail()) { result.AppendError(error.AsCString("Error creating empty target")); return false; } - interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); + m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); } // Record the old executable module, we want to issue a warning if the process of attaching changed the @@ -530,7 +488,7 @@ public: if (!m_options.plugin_name.empty()) plugin_name = m_options.plugin_name.c_str(); - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); + process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get(); if (process) { @@ -562,7 +520,7 @@ public: return false; } - interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name); + m_interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name); error = process->Attach (wait_name, m_options.waitfor); if (error.Success()) { @@ -700,8 +658,9 @@ class CommandObjectProcessContinue : public CommandObject { public: - CommandObjectProcessContinue () : - CommandObject ("process continue", + CommandObjectProcessContinue (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process continue", "Continue execution of all threads in the current process.", "process continue", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -714,12 +673,11 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - bool synchronous_execution = interpreter.GetSynchronous (); + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = m_interpreter.GetSynchronous (); if (process == NULL) { @@ -787,8 +745,9 @@ class CommandObjectProcessDetach : public CommandObject { public: - CommandObjectProcessDetach () : - CommandObject ("process detach", + CommandObjectProcessDetach (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process detach", "Detach from the current process being debugged.", "process detach", eFlagProcessMustBeLaunched) @@ -800,11 +759,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -835,8 +793,9 @@ class CommandObjectProcessSignal : public CommandObject { public: - CommandObjectProcessSignal () : - CommandObject ("process signal", + CommandObjectProcessSignal (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process signal", "Send a UNIX signal to the current process being debugged.", "process signal <unix-signal-number>") { @@ -847,11 +806,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -901,8 +859,9 @@ class CommandObjectProcessInterrupt : public CommandObject public: - CommandObjectProcessInterrupt () : - CommandObject ("process interrupt", + CommandObjectProcessInterrupt (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process interrupt", "Interrupt the current process being debugged.", "process interrupt", eFlagProcessMustBeLaunched) @@ -914,11 +873,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -962,8 +920,9 @@ class CommandObjectProcessKill : public CommandObject { public: - CommandObjectProcessKill () : - CommandObject ("process kill", + CommandObjectProcessKill (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process kill", "Terminate the current process being debugged.", "process kill", eFlagProcessMustBeLaunched) @@ -975,11 +934,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -1017,8 +975,9 @@ public: class CommandObjectProcessStatus : public CommandObject { public: - CommandObjectProcessStatus () : - CommandObject ("process status", + CommandObjectProcessStatus (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process status", "Show the current status and location of executing process.", "process status", 0) @@ -1033,14 +992,13 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -1063,7 +1021,7 @@ public: exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); if (exe_ctx.thread != NULL) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, true, true); + DisplayThreadsInfo (m_interpreter, &exe_ctx, result, true, true); } else { @@ -1092,18 +1050,19 @@ public: //------------------------------------------------------------------------- CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) : - CommandObjectMultiword ("process", - "A set of commands for operating on a process.", - "process <subcommand> [<subcommand-options>]") + CommandObjectMultiword (interpreter, + "process", + "A set of commands for operating on a process.", + "process <subcommand> [<subcommand-options>]") { - 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 ())); + LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter))); + LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter))); + LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter))); + LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter))); + LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter))); + LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter))); + LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter))); + LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter))); } CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () diff --git a/lldb/source/Commands/CommandObjectQuit.cpp b/lldb/source/Commands/CommandObjectQuit.cpp index f1d32361e30..36fdf32e3a7 100644 --- a/lldb/source/Commands/CommandObjectQuit.cpp +++ b/lldb/source/Commands/CommandObjectQuit.cpp @@ -23,8 +23,8 @@ using namespace lldb_private; // CommandObjectQuit //------------------------------------------------------------------------- -CommandObjectQuit::CommandObjectQuit () : - CommandObject ("quit", "Quit out of the LLDB debugger.", "quit") +CommandObjectQuit::CommandObjectQuit (CommandInterpreter &interpreter) : + CommandObject (interpreter, "quit", "Quit out of the LLDB debugger.", "quit") { } @@ -35,12 +35,11 @@ CommandObjectQuit::~CommandObjectQuit () bool CommandObjectQuit::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); + m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); result.SetStatus (eReturnStatusQuit); return true; } diff --git a/lldb/source/Commands/CommandObjectQuit.h b/lldb/source/Commands/CommandObjectQuit.h index f696828237b..0609aedc8c8 100644 --- a/lldb/source/Commands/CommandObjectQuit.h +++ b/lldb/source/Commands/CommandObjectQuit.h @@ -22,25 +22,17 @@ namespace lldb_private { // CommandObjectQuit //------------------------------------------------------------------------- -// SPECIAL NOTE!! The CommandObjectQuit is special, because the actual function to execute -// when the user types 'quit' is passed (via function pointer) to the Command Interpreter when it -// is constructed. The function pointer is then stored in this CommandObjectQuit, and is invoked -// via the CommandObjectQuit::Execute function. This is the only command object that works this -// way; it was done this way because different Command Interpreter callers may want or need different things -// to be done in order to shut down properly. - class CommandObjectQuit : public CommandObject { public: - CommandObjectQuit (); + CommandObjectQuit (CommandInterpreter &interpreter); virtual ~CommandObjectQuit (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 7d11a6e93db..6182509ee80 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -31,8 +31,9 @@ using namespace lldb_private; class CommandObjectRegisterRead : public CommandObject { public: - CommandObjectRegisterRead () : - CommandObject ("register read", + CommandObjectRegisterRead (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "register read", "Dump the contents of one or more register values from the current frame.", "register read [<reg-name1> [<reg-name2> [...]]]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -47,14 +48,13 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -139,8 +139,9 @@ public: class CommandObjectRegisterWrite : public CommandObject { public: - CommandObjectRegisterWrite () : - CommandObject ("register write", + CommandObjectRegisterWrite (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "register write", "Modify a single register value.", "register write <reg-name> <value>", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -155,13 +156,12 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { DataExtractor reg_data; - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -219,12 +219,13 @@ public: // CommandObjectRegister constructor //---------------------------------------------------------------------- CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : - CommandObjectMultiword ("register", + CommandObjectMultiword (interpreter, + "register", "A set of commands to access thread registers.", "register [read|write] ...") { - LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); - LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectRegisterWrite ())); + LoadSubCommand ("read", CommandObjectSP (new CommandObjectRegisterRead (interpreter))); + LoadSubCommand ("write", CommandObjectSP (new CommandObjectRegisterWrite (interpreter))); } diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 8e6a5b1184c..ceb5d47579e 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -25,31 +25,32 @@ using namespace lldb_private; //------------------------------------------------------------------------- CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) : - CommandObjectMultiword ("settings", + CommandObjectMultiword (interpreter, + "settings", "A set of commands for manipulating internal settable debugger variables.", "settings <command> [<command-options>]") { bool status; - CommandObjectSP set_command_object (new CommandObjectSettingsSet ()); - CommandObjectSP show_command_object (new CommandObjectSettingsShow ()); - CommandObjectSP list_command_object (new CommandObjectSettingsList ()); - CommandObjectSP remove_command_object (new CommandObjectSettingsRemove ()); - CommandObjectSP replace_command_object (new CommandObjectSettingsReplace ()); - CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore ()); - CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter()); - CommandObjectSP append_command_object (new CommandObjectSettingsAppend()); - CommandObjectSP clear_command_object (new CommandObjectSettingsClear()); - - status = LoadSubCommand (interpreter, "set", set_command_object); - status = LoadSubCommand (interpreter, "show", show_command_object); - status = LoadSubCommand (interpreter, "list", list_command_object); - status = LoadSubCommand (interpreter, "remove", remove_command_object); - status = LoadSubCommand (interpreter, "replace", replace_command_object); - status = LoadSubCommand (interpreter, "insert-before", insert_before_command_object); - status = LoadSubCommand (interpreter, "insert-after", insert_after_command_object); - status = LoadSubCommand (interpreter, "append", append_command_object); - status = LoadSubCommand (interpreter, "clear", clear_command_object); + CommandObjectSP set_command_object (new CommandObjectSettingsSet (interpreter)); + CommandObjectSP show_command_object (new CommandObjectSettingsShow (interpreter)); + CommandObjectSP list_command_object (new CommandObjectSettingsList (interpreter)); + CommandObjectSP remove_command_object (new CommandObjectSettingsRemove (interpreter)); + CommandObjectSP replace_command_object (new CommandObjectSettingsReplace (interpreter)); + CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore (interpreter)); + CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter(interpreter)); + CommandObjectSP append_command_object (new CommandObjectSettingsAppend(interpreter)); + CommandObjectSP clear_command_object (new CommandObjectSettingsClear(interpreter)); + + status = LoadSubCommand ("set", set_command_object); + status = LoadSubCommand ("show", show_command_object); + status = LoadSubCommand ("list", list_command_object); + status = LoadSubCommand ("remove", remove_command_object); + status = LoadSubCommand ("replace", replace_command_object); + status = LoadSubCommand ("insert-before", insert_before_command_object); + status = LoadSubCommand ("insert-after", insert_after_command_object); + status = LoadSubCommand ("append", append_command_object); + status = LoadSubCommand ("clear", clear_command_object); } CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () @@ -60,8 +61,9 @@ CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () // CommandObjectSettingsSet //------------------------------------------------------------------------- -CommandObjectSettingsSet::CommandObjectSettingsSet () : - CommandObject ("settings set", +CommandObjectSettingsSet::CommandObjectSettingsSet (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings set", "Set or change the value of a single debugger setting variable.", "settings set [<cmd-options>] <setting-variable-name> <value>"), m_options () @@ -74,9 +76,7 @@ CommandObjectSettingsSet::~CommandObjectSettingsSet() bool -CommandObjectSettingsSet::Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result) +CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -116,9 +116,11 @@ CommandObjectSettingsSet::Execute (CommandInterpreter &interpreter, } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAssign, + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationAssign, m_options.m_override, - interpreter.GetDebugger().GetInstanceName().AsCString()); + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -132,8 +134,7 @@ CommandObjectSettingsSet::Execute (CommandInterpreter &interpreter, } int -CommandObjectSettingsSet::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsSet::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -147,7 +148,7 @@ CommandObjectSettingsSet::HandleArgumentCompletion (CommandInterpreter &interpre // Attempting to complete variable name if (cursor_index == 1) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -258,10 +259,11 @@ CommandObjectSettingsSet::GetOptions () // CommandObjectSettingsShow -- Show current values //------------------------------------------------------------------------- -CommandObjectSettingsShow::CommandObjectSettingsShow () : - CommandObject ("settings show", - "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", - "settings show [<setting-variable-name>]") +CommandObjectSettingsShow::CommandObjectSettingsShow (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings show", + "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", + "settings show [<setting-variable-name>]") { } @@ -271,8 +273,7 @@ CommandObjectSettingsShow::~CommandObjectSettingsShow() bool -CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsShow::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -286,7 +287,7 @@ CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, lldb::SettableVariableType var_type; const char *variable_name = command.GetArgumentAtIndex (0); StringList value = root_settings->GetVariable (variable_name, var_type, - interpreter.GetDebugger().GetInstanceName().AsCString()); + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (value.GetSize() == 0) { @@ -320,8 +321,11 @@ CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, } else { - UserSettingsController::GetAllVariableValues (interpreter, root_settings, current_prefix, - result.GetOutputStream(), err); + UserSettingsController::GetAllVariableValues (m_interpreter, + root_settings, + current_prefix, + result.GetOutputStream(), + err); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -337,8 +341,7 @@ CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, } int -CommandObjectSettingsShow::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsShow::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -350,7 +353,7 @@ CommandObjectSettingsShow::HandleArgumentCompletion (CommandInterpreter &interpr std::string completion_str (input.GetArgumentAtIndex (cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -365,8 +368,9 @@ CommandObjectSettingsShow::HandleArgumentCompletion (CommandInterpreter &interpr // CommandObjectSettingsList //------------------------------------------------------------------------- -CommandObjectSettingsList::CommandObjectSettingsList () : - CommandObject ("settings list", +CommandObjectSettingsList::CommandObjectSettingsList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings list", "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", "settings list [<setting-name> | <setting-name-prefix>]") { @@ -378,8 +382,7 @@ CommandObjectSettingsList::~CommandObjectSettingsList() bool -CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsList::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -389,14 +392,21 @@ CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, if (command.GetArgumentCount() == 0) { - UserSettingsController::FindAllSettingsDescriptions (interpreter, root_settings, current_prefix, - result.GetOutputStream(), err); + UserSettingsController::FindAllSettingsDescriptions (m_interpreter, + root_settings, + current_prefix, + result.GetOutputStream(), + err); } else if (command.GetArgumentCount() == 1) { const char *search_name = command.GetArgumentAtIndex (0); - UserSettingsController::FindSettingsDescriptions (interpreter, root_settings, current_prefix, - search_name, result.GetOutputStream(), err); + UserSettingsController::FindSettingsDescriptions (m_interpreter, + root_settings, + current_prefix, + search_name, + result.GetOutputStream(), + err); } else { @@ -419,8 +429,7 @@ CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, } int -CommandObjectSettingsList::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsList::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -432,7 +441,7 @@ CommandObjectSettingsList::HandleArgumentCompletion (CommandInterpreter &interpr std::string completion_str (input.GetArgumentAtIndex (cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -447,8 +456,9 @@ CommandObjectSettingsList::HandleArgumentCompletion (CommandInterpreter &interpr // CommandObjectSettingsRemove //------------------------------------------------------------------------- -CommandObjectSettingsRemove::CommandObjectSettingsRemove () : - CommandObject ("settings remove", +CommandObjectSettingsRemove::CommandObjectSettingsRemove (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings remove", "Remove the specified element from an internal debugger settings array or dictionary variable.", "settings remove <setting-variable-name> [<index>|\"key\"]") { @@ -459,8 +469,7 @@ CommandObjectSettingsRemove::~CommandObjectSettingsRemove () } bool -CommandObjectSettingsRemove::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsRemove::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -497,8 +506,11 @@ CommandObjectSettingsRemove::Execute (CommandInterpreter &interpreter, index_value_string = index_value; - Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + NULL, + lldb::eVarSetOperationRemove, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -512,8 +524,7 @@ CommandObjectSettingsRemove::Execute (CommandInterpreter &interpreter, } int -CommandObjectSettingsRemove::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsRemove::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -527,7 +538,7 @@ CommandObjectSettingsRemove::HandleArgumentCompletion (CommandInterpreter &inter // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -543,8 +554,9 @@ CommandObjectSettingsRemove::HandleArgumentCompletion (CommandInterpreter &inter // CommandObjectSettingsReplace //------------------------------------------------------------------------- -CommandObjectSettingsReplace::CommandObjectSettingsReplace () : - CommandObject ("settings replace", +CommandObjectSettingsReplace::CommandObjectSettingsReplace (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings replace", "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", "settings replace <setting-variable-name> [<index>|\"<key>\"] <new-value>") { @@ -555,8 +567,7 @@ CommandObjectSettingsReplace::~CommandObjectSettingsReplace () } bool -CommandObjectSettingsReplace::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsReplace::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -607,8 +618,11 @@ CommandObjectSettingsReplace::Execute (CommandInterpreter &interpreter, } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationReplace, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -623,8 +637,7 @@ CommandObjectSettingsReplace::Execute (CommandInterpreter &interpreter, } int -CommandObjectSettingsReplace::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsReplace::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -638,7 +651,7 @@ CommandObjectSettingsReplace::HandleArgumentCompletion (CommandInterpreter &inte // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -654,8 +667,9 @@ CommandObjectSettingsReplace::HandleArgumentCompletion (CommandInterpreter &inte // CommandObjectSettingsInsertBefore //------------------------------------------------------------------------- -CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore () : - CommandObject ("settings insert-before", +CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings insert-before", "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", "settings insert-before <setting-variable-name> [<index>] <new-value>") { @@ -666,8 +680,7 @@ CommandObjectSettingsInsertBefore::~CommandObjectSettingsInsertBefore () } bool -CommandObjectSettingsInsertBefore::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsInsertBefore::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -719,8 +732,11 @@ CommandObjectSettingsInsertBefore::Execute (CommandInterpreter &interpreter, } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationInsertBefore, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -736,8 +752,7 @@ CommandObjectSettingsInsertBefore::Execute (CommandInterpreter &interpreter, int -CommandObjectSettingsInsertBefore::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsInsertBefore::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -751,7 +766,7 @@ CommandObjectSettingsInsertBefore::HandleArgumentCompletion (CommandInterpreter // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -767,8 +782,9 @@ CommandObjectSettingsInsertBefore::HandleArgumentCompletion (CommandInterpreter // CommandObjectSettingInsertAfter //------------------------------------------------------------------------- -CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter () : - CommandObject ("settings insert-after", +CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings insert-after", "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", "settings insert-after <setting-variable-name> [<index>] <new-value>") { @@ -779,8 +795,7 @@ CommandObjectSettingsInsertAfter::~CommandObjectSettingsInsertAfter () } bool -CommandObjectSettingsInsertAfter::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsInsertAfter::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -832,8 +847,11 @@ CommandObjectSettingsInsertAfter::Execute (CommandInterpreter &interpreter, } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationInsertAfter, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -849,8 +867,7 @@ CommandObjectSettingsInsertAfter::Execute (CommandInterpreter &interpreter, int -CommandObjectSettingsInsertAfter::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsInsertAfter::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -864,7 +881,7 @@ CommandObjectSettingsInsertAfter::HandleArgumentCompletion (CommandInterpreter & // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -880,8 +897,9 @@ CommandObjectSettingsInsertAfter::HandleArgumentCompletion (CommandInterpreter & // CommandObjectSettingsAppend //------------------------------------------------------------------------- -CommandObjectSettingsAppend::CommandObjectSettingsAppend () : - CommandObject ("settings append", +CommandObjectSettingsAppend::CommandObjectSettingsAppend (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings append", "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", "settings append <setting-variable-name> <new-value>") { @@ -892,8 +910,7 @@ CommandObjectSettingsAppend::~CommandObjectSettingsAppend () } bool -CommandObjectSettingsAppend::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsAppend::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -933,8 +950,11 @@ CommandObjectSettingsAppend::Execute (CommandInterpreter &interpreter, } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, - false, interpreter.GetDebugger().GetInstanceName().AsCString()); + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationAppend, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -949,8 +969,7 @@ CommandObjectSettingsAppend::Execute (CommandInterpreter &interpreter, int -CommandObjectSettingsAppend::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsAppend::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -964,7 +983,7 @@ CommandObjectSettingsAppend::HandleArgumentCompletion (CommandInterpreter &inter // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -980,8 +999,9 @@ CommandObjectSettingsAppend::HandleArgumentCompletion (CommandInterpreter &inter // CommandObjectSettingsClear //------------------------------------------------------------------------- -CommandObjectSettingsClear::CommandObjectSettingsClear () : - CommandObject ("settings clear", +CommandObjectSettingsClear::CommandObjectSettingsClear (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings clear", "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", "settings clear") { @@ -992,8 +1012,7 @@ CommandObjectSettingsClear::~CommandObjectSettingsClear () } bool -CommandObjectSettingsClear::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsClear::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -1015,8 +1034,11 @@ CommandObjectSettingsClear::Execute (CommandInterpreter &interpreter, return false; } - Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false, - interpreter.GetDebugger().GetInstanceName().AsCString()); + Error err = root_settings->SetVariable (var_name, + NULL, + lldb::eVarSetOperationClear, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { @@ -1031,8 +1053,7 @@ CommandObjectSettingsClear::Execute (CommandInterpreter &interpreter, int -CommandObjectSettingsClear::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsClear::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -1046,7 +1067,7 @@ CommandObjectSettingsClear::HandleArgumentCompletion (CommandInterpreter &interp // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h index 13b51442d0b..9f369642b51 100644 --- a/lldb/source/Commands/CommandObjectSettings.h +++ b/lldb/source/Commands/CommandObjectSettings.h @@ -43,14 +43,13 @@ public: class CommandObjectSettingsSet : public CommandObject { public: - CommandObjectSettingsSet (); + CommandObjectSettingsSet (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsSet (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -86,8 +85,7 @@ public: }; virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -107,20 +105,18 @@ private: class CommandObjectSettingsShow : public CommandObject { public: - CommandObjectSettingsShow (); + CommandObjectSettingsShow (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsShow (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -139,19 +135,17 @@ private: class CommandObjectSettingsList : public CommandObject { public: - CommandObjectSettingsList (); + CommandObjectSettingsList (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -170,19 +164,17 @@ private: class CommandObjectSettingsRemove : public CommandObject { public: - CommandObjectSettingsRemove (); + CommandObjectSettingsRemove (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsRemove (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -201,19 +193,17 @@ private: class CommandObjectSettingsReplace : public CommandObject { public: - CommandObjectSettingsReplace (); + CommandObjectSettingsReplace (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsReplace (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -232,19 +222,17 @@ private: class CommandObjectSettingsInsertBefore : public CommandObject { public: - CommandObjectSettingsInsertBefore (); + CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsInsertBefore (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -263,19 +251,17 @@ private: class CommandObjectSettingsInsertAfter : public CommandObject { public: - CommandObjectSettingsInsertAfter (); + CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsInsertAfter (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -294,19 +280,17 @@ private: class CommandObjectSettingsAppend : public CommandObject { public: - CommandObjectSettingsAppend (); + CommandObjectSettingsAppend (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsAppend (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -325,19 +309,17 @@ private: class CommandObjectSettingsClear : public CommandObject { public: - CommandObjectSettingsClear (); + CommandObjectSettingsClear (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsClear (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 996eb79fc1c..0ca222d772c 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -96,10 +96,11 @@ class CommandObjectSourceInfo : public CommandObject }; public: - CommandObjectSourceInfo() : - CommandObject ("source info", - "Display information about the source lines from the current executable's debug info.", - "source info [<cmd-options>]") + CommandObjectSourceInfo(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source info", + "Display information about the source lines from the current executable's debug info.", + "source info [<cmd-options>]") { } @@ -118,7 +119,6 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -227,10 +227,11 @@ class CommandObjectSourceList : public CommandObject }; public: - CommandObjectSourceList() : - CommandObject ("source list", - "Display source code (as specified) based on the current executable's debug info.", - "source list [<cmd-options>] [<filename>]") + CommandObjectSourceList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source list", + "Display source code (as specified) based on the current executable's debug info.", + "source list [<cmd-options>] [<filename>]") { } @@ -249,7 +250,6 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -262,12 +262,12 @@ public: result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (!m_options.symbol_name.empty()) { // Displaying the source for a symbol: - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -400,12 +400,12 @@ public: char path_buf[PATH_MAX+1]; start_file.GetPath(path_buf, PATH_MAX); result.AppendMessageWithFormat("File: %s.\n", path_buf); - interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file, - line_no, - 0, - m_options.num_lines, - "", - &result.GetOutputStream()); + m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file, + line_no, + 0, + m_options.num_lines, + "", + &result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); return true; @@ -419,14 +419,14 @@ public: // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) + if (m_interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } } else { - if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + if (m_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 @@ -441,7 +441,7 @@ public: else { const char *filename = m_options.file_name.c_str(); - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -524,12 +524,12 @@ public: { if (sc.comp_unit) { - interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, - m_options.start_line, - 0, - m_options.num_lines, - "", - &result.GetOutputStream()); + m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, + 0, + m_options.num_lines, + "", + &result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -574,12 +574,13 @@ CommandObjectSourceList::CommandOptions::g_option_table[] = //------------------------------------------------------------------------- CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) : - CommandObjectMultiword ("source", + CommandObjectMultiword (interpreter, + "source", "A set of commands for accessing source file information", "source <subcommand> [<subcommand-options>]") { - LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectSourceInfo ())); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectSourceList ())); + LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter))); } CommandObjectMultiwordSource::~CommandObjectMultiwordSource () diff --git a/lldb/source/Commands/CommandObjectSyntax.cpp b/lldb/source/Commands/CommandObjectSyntax.cpp index 6574692e8bf..8bc49a723e5 100644 --- a/lldb/source/Commands/CommandObjectSyntax.cpp +++ b/lldb/source/Commands/CommandObjectSyntax.cpp @@ -27,10 +27,11 @@ using namespace lldb_private; // CommandObjectSyntax //------------------------------------------------------------------------- -CommandObjectSyntax::CommandObjectSyntax () : - CommandObject ("syntax", - "Shows the correct syntax for a given debugger command.", - "syntax <command>") +CommandObjectSyntax::CommandObjectSyntax (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "syntax", + "Shows the correct syntax for a given debugger command.", + "syntax <command>") { } @@ -42,7 +43,6 @@ CommandObjectSyntax::~CommandObjectSyntax() bool CommandObjectSyntax::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -53,7 +53,7 @@ CommandObjectSyntax::Execute if (argc > 0) { - cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex(0)); + cmd_obj = m_interpreter.GetCommandObject (command.GetArgumentAtIndex(0)); bool all_okay = true; for (int i = 1; i < argc; ++i) { diff --git a/lldb/source/Commands/CommandObjectSyntax.h b/lldb/source/Commands/CommandObjectSyntax.h index 47b3e8e1033..24ae876e25d 100644 --- a/lldb/source/Commands/CommandObjectSyntax.h +++ b/lldb/source/Commands/CommandObjectSyntax.h @@ -26,14 +26,13 @@ class CommandObjectSyntax : public CommandObject { public: - CommandObjectSyntax (); + CommandObjectSyntax (CommandInterpreter &interpreter); virtual ~CommandObjectSyntax (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1410d5b46d6..8708d4427ea 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -34,8 +34,9 @@ class CommandObjectTargetImageSearchPathsAdd : public CommandObject { public: - CommandObjectTargetImageSearchPathsAdd () : - CommandObject ("target image-search-paths add", + CommandObjectTargetImageSearchPathsAdd (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths add", "Add new image search paths substitution pairs to the current target.", "target image-search-paths add <path-prefix> <new-path-prefix> [<path-prefix> <new-path-prefix>] ...") { @@ -46,11 +47,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -97,8 +97,9 @@ class CommandObjectTargetImageSearchPathsClear : public CommandObject { public: - CommandObjectTargetImageSearchPathsClear () : - CommandObject ("target image-search-paths clear", + CommandObjectTargetImageSearchPathsClear (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths clear", "Clear all current image search path substitution pairs from the current target.", "target image-search-paths clear") { @@ -109,11 +110,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { bool notify = true; @@ -132,8 +132,9 @@ class CommandObjectTargetImageSearchPathsInsert : public CommandObject { public: - CommandObjectTargetImageSearchPathsInsert () : - CommandObject ("target image-search-paths insert", + CommandObjectTargetImageSearchPathsInsert (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths insert", "Insert a new image search path substitution pair into the current target at the specified index.", "target image-search-paths insert <index> <path-prefix> <new-path-prefix> [<path-prefix> <new-path-prefix>] ...") { @@ -144,11 +145,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -215,8 +215,9 @@ class CommandObjectTargetImageSearchPathsList : public CommandObject { public: - CommandObjectTargetImageSearchPathsList () : - CommandObject ("target image-search-paths list", + CommandObjectTargetImageSearchPathsList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths list", "List all current image search path substitution pairs in the current target.", "target image-search-paths list") { @@ -227,11 +228,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 0) @@ -256,8 +256,9 @@ class CommandObjectTargetImageSearchPathsQuery : public CommandObject { public: - CommandObjectTargetImageSearchPathsQuery () : - CommandObject ("target image-search-paths query", + CommandObjectTargetImageSearchPathsQuery (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths query", "Transform a path using the first applicable image search path.", "target image-search-paths query <path>") { @@ -268,11 +269,10 @@ public: } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 1) @@ -310,7 +310,8 @@ public: //public: // // CommandObjectTargetSelect () : -// CommandObject ("frame select", +// CommandObject (interpreter, +// frame select", // "Select the current frame by index in the current thread.", // "frame select <frame-index>") // { @@ -323,7 +324,7 @@ public: // bool // Execute (Args& command, // Debugger *context, -// CommandInterpreter &interpreter, +// CommandInterpreter &m_interpreter, // CommandReturnObject &result) // { // ExecutionContext exe_ctx (context->GetExecutionContext()); @@ -344,7 +345,7 @@ public: // { // if (DisplayFrameForExecutionContext (exe_ctx.thread, // exe_ctx.frame, -// interpreter, +// m_interpreter, // result.GetOutputStream(), // true, // true, @@ -388,15 +389,16 @@ class CommandObjectMultiwordImageSearchPaths : public CommandObjectMultiword public: CommandObjectMultiwordImageSearchPaths (CommandInterpreter &interpreter) : - CommandObjectMultiword ("target image-search-paths", + CommandObjectMultiword (interpreter, + "target image-search-paths", "A set of commands for operating on debugger target image search paths.", "target image-search-paths <subcommand> [<subcommand-options>]") { - 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 ())); + LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd (interpreter))); + LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear (interpreter))); + LoadSubCommand ("insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList (interpreter))); + LoadSubCommand ("query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery (interpreter))); } ~CommandObjectMultiwordImageSearchPaths() @@ -412,11 +414,12 @@ public: //------------------------------------------------------------------------- CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) : - CommandObjectMultiword ("target", + CommandObjectMultiword (interpreter, + "target", "A set of commands for operating on debugger targets.", "target <subcommand> [<subcommand-options>]") { - LoadSubCommand (interpreter, "image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); + LoadSubCommand ("image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); } CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 8c5e968a67a..bfb32c7f9f2 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -330,8 +330,9 @@ public: uint32_t m_start; }; - CommandObjectThreadBacktrace () : - CommandObject ("thread backtrace", + CommandObjectThreadBacktrace (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread backtrace", "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", "thread backtrace [<thread-index>] ...", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), @@ -350,12 +351,7 @@ public: } virtual bool - Execute - ( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result - ) + Execute (Args& command, CommandReturnObject &result) { bool show_frame_info = true; @@ -365,11 +361,11 @@ public: if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (DisplayFramesForExecutionContext (exe_ctx.thread, - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -389,13 +385,13 @@ public: } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; uint32_t num_threads = process->GetThreadList().GetSize(); for (uint32_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = process->GetThreadList().GetThreadAtIndex(i); if (!DisplayFramesForExecutionContext (thread_sp.get(), - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -415,7 +411,7 @@ public: else { uint32_t num_args = command.GetArgumentCount(); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; std::vector<ThreadSP> thread_sps; for (uint32_t i = 0; i < num_args; i++) @@ -444,7 +440,7 @@ public: for (uint32_t i = 0; i < num_args; i++) { if (!DisplayFramesForExecutionContext (thread_sps[i].get(), - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -566,13 +562,14 @@ public: std::string m_avoid_regexp; }; - CommandObjectThreadStepWithTypeAndScope (const char *name, - const char *help, - const char *syntax, - uint32_t flags, - StepType step_type, - StepScope step_scope) : - CommandObject (name, help, syntax, flags), + CommandObjectThreadStepWithTypeAndScope (CommandInterpreter &interpreter, + const char *name, + const char *help, + const char *syntax, + uint32_t flags, + StepType step_type, + StepScope step_scope) : + CommandObject (interpreter, name, help, syntax, flags), m_step_type (step_type), m_step_scope (step_scope), m_options () @@ -594,13 +591,12 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - bool synchronous_execution = interpreter.GetSynchronous(); + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = m_interpreter.GetSynchronous(); if (process == NULL) { @@ -791,8 +787,9 @@ class CommandObjectThreadContinue : public CommandObject { public: - CommandObjectThreadContinue () : - CommandObject ("thread continue", + CommandObjectThreadContinue (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread continue", "Continue execution of one or more threads in an active process.", "thread continue <thread-index> [<thread-index> ...]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -808,21 +805,20 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - bool synchronous_execution = interpreter.GetSynchronous (); + bool synchronous_execution = m_interpreter.GetSynchronous (); - if (!interpreter.GetDebugger().GetSelectedTarget().get()) + if (!m_interpreter.GetDebugger().GetSelectedTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -1035,8 +1031,9 @@ public: // Instance variables to hold the values for command options. }; - CommandObjectThreadUntil () : - CommandObject ("thread until", + CommandObjectThreadUntil (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread until", "Run the current or specified thread until it reaches a given line number or leaves the current function.", "thread until [<cmd-options>] <line-number>", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), @@ -1060,14 +1057,13 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - bool synchronous_execution = interpreter.GetSynchronous (); + bool synchronous_execution = m_interpreter.GetSynchronous (); - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1075,7 +1071,7 @@ public: return false; } - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1234,11 +1230,12 @@ class CommandObjectThreadSelect : public CommandObject { public: - CommandObjectThreadSelect () : - CommandObject ("thread select", - "Select a thread as the currently active thread.", - "thread select <thread-index>", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectThreadSelect (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread select", + "Select a thread as the currently active thread.", + "thread select <thread-index>", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -1251,12 +1248,11 @@ public: virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1283,7 +1279,7 @@ public: process->GetThreadList().SetSelectedThreadByID(new_thread->GetID()); result.SetStatus (eReturnStatusSuccessFinishNoResult); - DisplayThreadInfo (interpreter, + DisplayThreadInfo (m_interpreter, result.GetOutputStream(), new_thread, false, @@ -1304,8 +1300,9 @@ class CommandObjectThreadList : public CommandObject public: - CommandObjectThreadList (): - CommandObject ("thread list", + CommandObjectThreadList (CommandInterpreter &interpreter): + CommandObject (interpreter, + "thread list", "Show a summary of all current threads in a process.", "thread list", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -1319,14 +1316,13 @@ public: bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -1350,7 +1346,7 @@ public: exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); if (exe_ctx.thread != NULL) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + DisplayThreadsInfo (m_interpreter, &exe_ctx, result, false, false); } else { @@ -1379,50 +1375,60 @@ public: //------------------------------------------------------------------------- CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : - CommandObjectMultiword ("thread", + CommandObjectMultiword (interpreter, + "thread", "A set of commands for operating on one or more threads within a running process.", "thread <subcommand> [<subcommand-options>]") { - 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 ( + LoadSubCommand ("backtrace", CommandObjectSP (new CommandObjectThreadBacktrace (interpreter))); + LoadSubCommand ("continue", CommandObjectSP (new CommandObjectThreadContinue (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectThreadList (interpreter))); + LoadSubCommand ("select", CommandObjectSP (new CommandObjectThreadSelect (interpreter))); + LoadSubCommand ("until", CommandObjectSP (new CommandObjectThreadUntil (interpreter))); + LoadSubCommand ("step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, "thread step-in", - "Source level single step in specified thread (current thread, if none specified).", - "thread step-in [<thread-id>]", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeInto, - eStepScopeSource))); + "Source level single step 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", - "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", - "thread step-out [<thread-id>]", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeOut, - eStepScopeSource))); - - LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", - "Source level single step in specified thread (current thread, if none specified), stepping over calls.", - "thread step-over [<thread-id>]", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeOver, - eStepScopeSource))); - - 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))); - - 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))); + LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-out", + "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", + "thread step-out [<thread-id>]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeOut, + eStepScopeSource))); + + LoadSubCommand ("step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-over", + "Source level single step in specified thread (current thread, if none specified), stepping over calls.", + "thread step-over [<thread-id>]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeOver, + eStepScopeSource))); + + LoadSubCommand ("step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-inst", + "Single step one instruction in specified thread (current thread, if none specified).", + "thread step-inst [<thread-id>]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeTrace, + eStepScopeInstruction))); + + LoadSubCommand ("step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "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))); } CommandObjectMultiwordThread::~CommandObjectMultiwordThread () |