diff options
Diffstat (limited to 'source/Commands/CommandObjectWatchpointCommand.cpp')
-rw-r--r-- | source/Commands/CommandObjectWatchpointCommand.cpp | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp index 2be0b5b154e0..5683381efc85 100644 --- a/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/source/Commands/CommandObjectWatchpointCommand.cpp @@ -24,28 +24,33 @@ using namespace lldb; using namespace lldb_private; -// CommandObjectWatchpointCommandAdd - // FIXME: "script-type" needs to have its contents determined dynamically, so -// somebody can add a new scripting -// language to lldb and have it pickable here without having to change this -// enumeration by hand and rebuild lldb proper. - +// somebody can add a new scripting language to lldb and have it pickable here +// without having to change this enumeration by hand and rebuild lldb proper. static constexpr OptionEnumValueElement g_script_option_enumeration[] = { - {eScriptLanguageNone, "command", - "Commands are in the lldb command interpreter language"}, - {eScriptLanguagePython, "python", "Commands are in the Python language."}, - {eSortOrderByName, "default-script", - "Commands are in the default scripting language."} }; + { + eScriptLanguageNone, + "command", + "Commands are in the lldb command interpreter language", + }, + { + eScriptLanguagePython, + "python", + "Commands are in the Python language.", + }, + { + eSortOrderByName, + "default-script", + "Commands are in the default scripting language.", + }, +}; static constexpr OptionEnumValues ScriptOptionEnum() { return OptionEnumValues(g_script_option_enumeration); } -static constexpr OptionDefinition g_watchpoint_command_add_options[] = { #define LLDB_OPTIONS_watchpoint_command_add #include "CommandOptions.inc" -}; class CommandObjectWatchpointCommandAdd : public CommandObjectParsed, public IOHandlerDelegateMultiline { @@ -54,7 +59,7 @@ public: : CommandObjectParsed(interpreter, "add", "Add a set of LLDB commands to a watchpoint, to be " "executed whenever the watchpoint is hit.", - nullptr), + nullptr, eCommandRequiresTarget), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), m_options() { @@ -202,7 +207,7 @@ are no syntax errors may indicate that a function was declared but never called. Options *GetOptions() override { return &m_options; } void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { - StreamFileSP output_sp(io_handler.GetOutputStreamFile()); + StreamFileSP output_sp(io_handler.GetOutputStreamFileSP()); if (output_sp && interactive) { output_sp->PutCString( "Enter your debugger command(s). Type 'DONE' to end.\n"); @@ -349,7 +354,7 @@ are no syntax errors may indicate that a function was declared but never called. break; default: - break; + llvm_unreachable("Unimplemented option"); } return error; } @@ -384,14 +389,7 @@ are no syntax errors may indicate that a function was declared but never called. protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = GetDebugger().GetSelectedTarget().get(); - - if (target == nullptr) { - result.AppendError("There is not a current executable; there are no " - "watchpoints to which to add commands"); - result.SetStatus(eReturnStatusFailed); - return false; - } + Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -481,7 +479,7 @@ public: CommandObjectWatchpointCommandDelete(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "delete", "Delete the set of commands from a watchpoint.", - nullptr) { + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandArgumentData wp_id_arg; @@ -501,14 +499,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = GetDebugger().GetSelectedTarget().get(); - - if (target == nullptr) { - result.AppendError("There is not a current executable; there are no " - "watchpoints from which to delete commands"); - result.SetStatus(eReturnStatusFailed); - return false; - } + Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -557,10 +548,10 @@ protected: class CommandObjectWatchpointCommandList : public CommandObjectParsed { public: CommandObjectWatchpointCommandList(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "list", "List the script or set of " - "commands to be executed when " - "the watchpoint is hit.", - nullptr) { + : CommandObjectParsed(interpreter, "list", + "List the script or set of commands to be executed " + "when the watchpoint is hit.", + nullptr, eCommandRequiresTarget) { CommandArgumentEntry arg; CommandArgumentData wp_id_arg; @@ -580,14 +571,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = GetDebugger().GetSelectedTarget().get(); - - if (target == nullptr) { - result.AppendError("There is not a current executable; there are no " - "watchpoints for which to list commands"); - result.SetStatus(eReturnStatusFailed); - return false; - } + Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); |