diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
| commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
| tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Commands/CommandObjectWatchpointCommand.cpp | |
| parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) | |
Notes
Diffstat (limited to 'source/Commands/CommandObjectWatchpointCommand.cpp')
| -rw-r--r-- | source/Commands/CommandObjectWatchpointCommand.cpp | 121 | 
1 files changed, 49 insertions, 72 deletions
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp index 2fa849f97674..0ae1850b5e28 100644 --- a/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/source/Commands/CommandObjectWatchpointCommand.cpp @@ -9,11 +9,12 @@  // C Includes  // C++ Includes +#include <vector> - +// Other libraries and framework includes +// Project includes  #include "CommandObjectWatchpointCommand.h"  #include "CommandObjectWatchpoint.h" -  #include "lldb/Core/IOHandler.h"  #include "lldb/Interpreter/CommandInterpreter.h"  #include "lldb/Interpreter/CommandReturnObject.h" @@ -23,8 +24,6 @@  #include "lldb/Breakpoint/StoppointCallbackContext.h"  #include "lldb/Core/State.h" -#include <vector> -  using namespace lldb;  using namespace lldb_private; @@ -32,20 +31,17 @@ using namespace lldb_private;  // CommandObjectWatchpointCommandAdd  //------------------------------------------------------------------------- -  class CommandObjectWatchpointCommandAdd :      public CommandObjectParsed,      public IOHandlerDelegateMultiline  {  public: - -    CommandObjectWatchpointCommandAdd (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "add", -                             "Add a set of commands to a watchpoint, to be executed whenever the watchpoint is hit.", -                             NULL), -        IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), -        m_options (interpreter) +    CommandObjectWatchpointCommandAdd(CommandInterpreter &interpreter) +        : CommandObjectParsed( +              interpreter, "add", +              "Add a set of LLDB commands to a watchpoint, to be executed whenever the watchpoint is hit.", nullptr), +          IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), +          m_options(interpreter)      {          SetHelpLong (  R"( @@ -169,7 +165,7 @@ are no syntax errors may indicate that a function was declared but never called.          m_arguments.push_back (arg);      } -    ~CommandObjectWatchpointCommandAdd () override {} +    ~CommandObjectWatchpointCommandAdd() override = default;      Options *      GetOptions () override @@ -187,8 +183,7 @@ are no syntax errors may indicate that a function was declared but never called.              output_sp->Flush();          }      } -     -     +      void      IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override      { @@ -199,7 +194,7 @@ are no syntax errors may indicate that a function was declared but never called.          if (wp_options)          {              std::unique_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData()); -            if (data_ap.get()) +            if (data_ap)              {                  data_ap->user_source.SplitIntoLines(line);                  BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release())); @@ -234,8 +229,6 @@ are no syntax errors may indicate that a function was declared but never called.          BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release()));          wp_options->SetCallback (WatchpointOptionsCallbackFunction, baton_sp); - -        return;      }      static bool @@ -244,10 +237,9 @@ are no syntax errors may indicate that a function was declared but never called.                                         lldb::user_id_t watch_id)      {          bool ret_value = true; -        if (baton == NULL) +        if (baton == nullptr)              return true; -         -         +          WatchpointOptions::CommandData *data = (WatchpointOptions::CommandData *) baton;          StringList &commands = data->user_source; @@ -288,7 +280,6 @@ are no syntax errors may indicate that a function was declared but never called.      class CommandOptions : public Options      {      public: -          CommandOptions (CommandInterpreter &interpreter) :              Options (interpreter),              m_use_commands (false), @@ -300,7 +291,7 @@ are no syntax errors may indicate that a function was declared but never called.          {          } -        ~CommandOptions () override {} +        ~CommandOptions() override = default;          Error          SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -321,14 +312,8 @@ are no syntax errors may indicate that a function was declared but never called.                                                                                       eScriptLanguageNone,                                                                                       error); -                if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) -                { -                    m_use_script_language = true; -                } -                else -                { -                    m_use_script_language = false; -                }           +                m_use_script_language = +                    (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault);                  break;              case 'e': @@ -341,11 +326,9 @@ are no syntax errors may indicate that a function was declared but never called.                  break;              case 'F': -                { -                    m_use_one_liner = false; -                    m_use_script_language = true; -                    m_function_name.assign(option_arg); -                } +                m_use_one_liner = false; +                m_use_script_language = true; +                m_function_name.assign(option_arg);                  break;              default: @@ -353,6 +336,7 @@ are no syntax errors may indicate that a function was declared but never called.              }              return error;          } +          void          OptionParsingStarting () override          { @@ -395,7 +379,7 @@ protected:      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("There is not a current executable; there are no watchpoints to which to add commands");              result.SetStatus (eReturnStatusFailed); @@ -412,7 +396,7 @@ protected:              return false;          } -        if (m_options.m_use_script_language == false && m_options.m_function_name.size()) +        if (!m_options.m_use_script_language && !m_options.m_function_name.empty())          {              result.AppendError ("need to enable scripting to have a function run as a watchpoint command");              result.SetStatus (eReturnStatusFailed); @@ -436,11 +420,11 @@ protected:              {                  Watchpoint *wp = target->GetWatchpointList().FindByID (cur_wp_id).get();                  // Sanity check wp first. -                if (wp == NULL) continue; +                if (wp == nullptr) continue;                  WatchpointOptions *wp_options = wp->GetOptions();                  // Skip this watchpoint if wp_options is not good. -                if (wp_options == NULL) continue; +                if (wp_options == nullptr) continue;                  // If we are using script language, get the script interpreter                  // in order to set or collect command callback.  Otherwise, call @@ -456,7 +440,7 @@ protected:                      // Special handling for using a Python function by name                      // instead of extending the watchpoint callback data structures, we just automatize                      // what the user would do manually: make their watchpoint command be a function call -                    else if (m_options.m_function_name.size()) +                    else if (!m_options.m_function_name.empty())                      {                          std::string oneliner(m_options.m_function_name);                          oneliner += "(frame, wp, internal_dict)"; @@ -489,7 +473,6 @@ private:      CommandOptions m_options;  }; -  // 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. @@ -499,25 +482,25 @@ g_script_option_enumeration[4] =      { 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."}, -    { 0,                      NULL,              NULL } +    { 0,                      nullptr,           nullptr }  };  OptionDefinition  CommandObjectWatchpointCommandAdd::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_1,   false, "one-liner",       'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner, +    { LLDB_OPT_SET_1,   false, "one-liner",       'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner,          "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." }, -    { LLDB_OPT_SET_ALL, false, "stop-on-error",   'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, +    { LLDB_OPT_SET_ALL, false, "stop-on-error",   'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,          "Specify whether watchpoint command execution should terminate on error." }, -    { LLDB_OPT_SET_ALL, false, "script-type",     's', OptionParser::eRequiredArgument, NULL, g_script_option_enumeration, 0, eArgTypeNone, +    { LLDB_OPT_SET_ALL, false, "script-type",     's', OptionParser::eRequiredArgument, nullptr, g_script_option_enumeration, 0, eArgTypeNone,          "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."}, -    { LLDB_OPT_SET_2,   false, "python-function", 'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePythonFunction, +    { LLDB_OPT_SET_2,   false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePythonFunction,          "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate."}, -    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +    { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }  };  //------------------------------------------------------------------------- @@ -528,10 +511,10 @@ class CommandObjectWatchpointCommandDelete : public CommandObjectParsed  {  public:      CommandObjectWatchpointCommandDelete (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter,  -                             "delete", -                             "Delete the set of commands from a watchpoint.", -                             NULL) +        CommandObjectParsed(interpreter, +                            "delete", +                            "Delete the set of commands from a watchpoint.", +                            nullptr)      {          CommandArgumentEntry arg;          CommandArgumentData wp_id_arg; @@ -547,8 +530,7 @@ public:          m_arguments.push_back (arg);      } - -    ~CommandObjectWatchpointCommandDelete () override {} +    ~CommandObjectWatchpointCommandDelete() override = default;  protected:      bool @@ -556,7 +538,7 @@ protected:      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("There is not a current executable; there are no watchpoints from which to delete commands");              result.SetStatus (eReturnStatusFailed); @@ -619,10 +601,10 @@ 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.", -                              NULL) +        CommandObjectParsed(interpreter, +                            "list", +                            "List the script or set of commands to be executed when the watchpoint is hit.", +                            nullptr)      {          CommandArgumentEntry arg;          CommandArgumentData wp_id_arg; @@ -638,7 +620,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectWatchpointCommandList () override {} +    ~CommandObjectWatchpointCommandList() override = default;  protected:      bool @@ -646,7 +628,7 @@ protected:      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("There is not a current executable; there are no watchpoints for which to list commands");              result.SetStatus (eReturnStatusFailed); @@ -725,11 +707,10 @@ protected:  // CommandObjectWatchpointCommand  //------------------------------------------------------------------------- -CommandObjectWatchpointCommand::CommandObjectWatchpointCommand (CommandInterpreter &interpreter) : -    CommandObjectMultiword (interpreter, -                            "command", -                            "A set of commands for adding, removing and examining bits of code to be executed when the watchpoint is hit (watchpoint 'commmands').", -                            "command <sub-command> [<sub-command-options>] <watchpoint-id>") +CommandObjectWatchpointCommand::CommandObjectWatchpointCommand(CommandInterpreter &interpreter) +    : CommandObjectMultiword(interpreter, "command", "Commands for adding, removing and examining LLDB commands " +                                                     "executed when the watchpoint is hit (watchpoint 'commmands').", +                             "command <sub-command> [<sub-command-options>] <watchpoint-id>")  {      CommandObjectSP add_command_object (new CommandObjectWatchpointCommandAdd (interpreter));      CommandObjectSP delete_command_object (new CommandObjectWatchpointCommandDelete (interpreter)); @@ -744,8 +725,4 @@ CommandObjectWatchpointCommand::CommandObjectWatchpointCommand (CommandInterpret      LoadSubCommand ("list",   list_command_object);  } -CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand () -{ -} - - +CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand() = default;  | 
