diff options
Diffstat (limited to 'source/Commands/CommandObjectTarget.cpp')
| -rw-r--r-- | source/Commands/CommandObjectTarget.cpp | 925 | 
1 files changed, 455 insertions, 470 deletions
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp index 57ec1c953fcf..9e535ba8ebd8 100644 --- a/source/Commands/CommandObjectTarget.cpp +++ b/source/Commands/CommandObjectTarget.cpp @@ -10,9 +10,9 @@  #include "CommandObjectTarget.h"  // C Includes -#include <errno.h> -  // C++ Includes +#include <cerrno> +  // Other libraries and framework includes  // Project includes  #include "lldb/Interpreter/Args.h" @@ -58,8 +58,6 @@  using namespace lldb;  using namespace lldb_private; - -  static void  DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bool show_stopped_process_status, Stream &strm)  { @@ -128,7 +126,7 @@ DumpTargetList (TargetList &target_list, bool show_stopped_process_status, Strea      {          TargetSP selected_target_sp (target_list.GetSelectedTarget());          strm.PutCString ("Current targets:\n"); -        for (uint32_t i=0; i<num_targets; ++i) +        for (uint32_t i = 0; i < num_targets; ++i)          {              TargetSP target_sp (target_list.GetTargetAtIndex (i));              if (target_sp) @@ -144,6 +142,7 @@ DumpTargetList (TargetList &target_list, bool show_stopped_process_status, Strea      }      return num_targets;  } +  #pragma mark CommandObjectTargetCreate  //------------------------------------------------------------------------- @@ -154,10 +153,10 @@ class CommandObjectTargetCreate : public CommandObjectParsed  {  public:      CommandObjectTargetCreate(CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target create", -                             "Create a target using the argument as the main executable.", -                             NULL), +        CommandObjectParsed(interpreter, +                            "target create", +                            "Create a target using the argument as the main executable.", +                            nullptr),          m_option_group (interpreter),          m_arch_option (),          m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."), @@ -188,9 +187,7 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetCreate () override -    { -    } +    ~CommandObjectTargetCreate() override = default;      Options *      GetOptions () override @@ -211,14 +208,14 @@ public:          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); +        CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, +                                                            CommandCompletions::eDiskFileCompletion, +                                                            completion_str.c_str(), +                                                            match_start_point, +                                                            max_return_elements, +                                                            nullptr, +                                                            word_complete, +                                                            matches);          return matches.GetSize();      } @@ -285,12 +282,12 @@ protected:              TargetSP target_sp;              const char *arch_cstr = m_arch_option.GetArchitectureName();              const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue(); -            Error error (debugger.GetTargetList().CreateTarget (debugger, -                                                                file_path, -                                                                arch_cstr, -                                                                get_dependent_files, -                                                                NULL, -                                                                target_sp)); +            Error error(debugger.GetTargetList().CreateTarget(debugger, +                                                              file_path, +                                                              arch_cstr, +                                                              get_dependent_files, +                                                              nullptr, +                                                              target_sp));              if (target_sp)              { @@ -398,7 +395,7 @@ protected:                          core_file_dir.GetDirectory() = core_file.GetDirectory();                          target_sp->GetExecutableSearchPaths ().Append (core_file_dir); -                        ProcessSP process_sp (target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), NULL, &core_file)); +                        ProcessSP process_sp(target_sp->CreateProcess(m_interpreter.GetDebugger().GetListener(), nullptr, &core_file));                          if (process_sp)                          { @@ -470,17 +467,14 @@ class CommandObjectTargetList : public CommandObjectParsed  {  public:      CommandObjectTargetList (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target list", -                             "List all current targets in the current debug session.", -                             NULL, -                             0) +        CommandObjectParsed(interpreter, +                            "target list", +                            "List all current targets in the current debug session.", +                            nullptr)      {      } -    ~CommandObjectTargetList () override -    { -    } +    ~CommandObjectTargetList() override = default;  protected:      bool @@ -506,7 +500,6 @@ protected:      }  }; -  #pragma mark CommandObjectTargetSelect  //---------------------------------------------------------------------- @@ -517,17 +510,14 @@ class CommandObjectTargetSelect : public CommandObjectParsed  {  public:      CommandObjectTargetSelect (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target select", -                             "Select a target as the current target by target index.", -                             NULL, -                             0) +        CommandObjectParsed(interpreter, +                            "target select", +                            "Select a target as the current target by target index.", +                            nullptr)      {      } -    ~CommandObjectTargetSelect () override -    { -    } +    ~CommandObjectTargetSelect() override = default;  protected:      bool @@ -566,7 +556,8 @@ protected:                          result.AppendErrorWithFormat ("index %u is out of range, valid target indexes are 0 - %u\n",                                                        target_idx,                                                        num_targets - 1); -                    } else +                    } +                    else                      {                          result.AppendErrorWithFormat ("index %u is out of range since there are no active targets\n",                                                        target_idx); @@ -599,11 +590,10 @@ class CommandObjectTargetDelete : public CommandObjectParsed  {  public:      CommandObjectTargetDelete (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target delete", -                             "Delete one or more targets by target index.", -                             NULL, -                             0), +        CommandObjectParsed(interpreter, +                            "target delete", +                            "Delete one or more targets by target index.", +                            nullptr),          m_option_group(interpreter),          m_all_option(LLDB_OPT_SET_1, false, "all", 'a', "Delete all targets.", false, true),          m_cleanup_option( @@ -621,9 +611,7 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetDelete () override -    { -    } +    ~CommandObjectTargetDelete() override = default;      Options *      GetOptions () override @@ -724,7 +712,6 @@ protected:      OptionGroupBoolean m_cleanup_option;  }; -  #pragma mark CommandObjectTargetVariable  //---------------------------------------------------------------------- @@ -737,22 +724,20 @@ class CommandObjectTargetVariable : public CommandObjectParsed      static const uint32_t SHORT_OPTION_SHLB = 0x73686c62;   // 'shlb'  public: -    CommandObjectTargetVariable (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target variable", -                             "Read global variable(s) prior to, or while running your binary.", -                             NULL, -                             eCommandRequiresTarget), -        m_option_group (interpreter), -        m_option_variable (false), // Don't include frame options -        m_option_format (eFormatDefault), -        m_option_compile_units    (LLDB_OPT_SET_1, false, "file", -                                   SHORT_OPTION_FILE, 0, eArgTypeFilename, -                                   "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."), -        m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib", -                                   SHORT_OPTION_SHLB, 0, eArgTypeFilename, -                                   "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."), -        m_varobj_options() +    CommandObjectTargetVariable(CommandInterpreter &interpreter) +        : CommandObjectParsed(interpreter, "target variable", +                              "Read global variables for the current target, before or while running a process.", +                              nullptr, eCommandRequiresTarget), +          m_option_group(interpreter), +          m_option_variable(false), // Don't include frame options +          m_option_format(eFormatDefault), +          m_option_compile_units(LLDB_OPT_SET_1, false, "file", SHORT_OPTION_FILE, 0, eArgTypeFilename, +                                 "A basename or fullpath to a file that contains global variables. This option can be " +                                 "specified multiple times."), +          m_option_shared_libraries(LLDB_OPT_SET_1, false, "shlib", SHORT_OPTION_SHLB, 0, eArgTypeFilename, +                                    "A basename or fullpath to a shared library to use in the search for global " +                                    "variables. This option can be specified multiple times."), +          m_varobj_options()      {          CommandArgumentEntry arg;          CommandArgumentData var_name_arg; @@ -775,17 +760,15 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetVariable () override -    { -    } +    ~CommandObjectTargetVariable() override = default;      void      DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)      {          DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions()); -        if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && -            true == valobj_sp->IsRuntimeSupportValue()) +        if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && +            valobj_sp->IsRuntimeSupportValue())              return;          switch (var_sp->GetScope()) @@ -810,6 +793,11 @@ public:                      s.PutCString(" LOCAL: ");                  break; +            case eValueTypeVariableThreadLocal: +                if (m_option_variable.show_scope) +                    s.PutCString("THREAD: "); +                break; +              default:                  break;          } @@ -879,7 +867,7 @@ protected:                            sc.comp_unit->GetPath().c_str());              } -            for (uint32_t i=0; i<count; ++i) +            for (uint32_t i = 0; i < count; ++i)              {                  VariableSP var_sp (variable_list.GetVariableAtIndex(i));                  if (var_sp) @@ -891,8 +879,8 @@ protected:                  }              }          } -      } +      bool      DoExecute (Args& args, CommandReturnObject &result) override      { @@ -972,7 +960,7 @@ protected:              {                  bool success = false;                  StackFrame *frame = m_exe_ctx.GetFramePtr(); -                CompileUnit *comp_unit = NULL; +                CompileUnit *comp_unit = nullptr;                  if (frame)                  {                      SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit); @@ -1093,21 +1081,18 @@ protected:      OptionGroupFileList m_option_compile_units;      OptionGroupFileList m_option_shared_libraries;      OptionGroupValueObjectDisplay m_varobj_options; -  }; -  #pragma mark CommandObjectTargetModulesSearchPathsAdd  class CommandObjectTargetModulesSearchPathsAdd : public CommandObjectParsed  {  public: -      CommandObjectTargetModulesSearchPathsAdd (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target modules search-paths add", -                             "Add new image search paths substitution pairs to the current target.", -                             NULL) +        CommandObjectParsed(interpreter, +                            "target modules search-paths add", +                            "Add new image search paths substitution pairs to the current target.", +                            nullptr)      {          CommandArgumentEntry arg;          CommandArgumentData old_prefix_arg; @@ -1131,9 +1116,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectTargetModulesSearchPathsAdd () override -    { -    } +    ~CommandObjectTargetModulesSearchPathsAdd() override = default;  protected:      bool @@ -1150,7 +1133,7 @@ protected:              }              else              { -                for (size_t i=0; i<argc; i+=2) +                for (size_t i = 0; i < argc; i+=2)                  {                      const char *from = command.GetArgumentAtIndex(i);                      const char *to = command.GetArgumentAtIndex(i+1); @@ -1194,7 +1177,6 @@ protected:  class CommandObjectTargetModulesSearchPathsClear : public CommandObjectParsed  {  public: -      CommandObjectTargetModulesSearchPathsClear (CommandInterpreter &interpreter) :          CommandObjectParsed (interpreter,                               "target modules search-paths clear", @@ -1203,9 +1185,7 @@ public:      {      } -    ~CommandObjectTargetModulesSearchPathsClear () override -    { -    } +    ~CommandObjectTargetModulesSearchPathsClear() override = default;  protected:      bool @@ -1232,12 +1212,11 @@ protected:  class CommandObjectTargetModulesSearchPathsInsert : public CommandObjectParsed  {  public: -      CommandObjectTargetModulesSearchPathsInsert (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target modules search-paths insert", -                             "Insert a new image search path substitution pair into the current target at the specified index.", -                             NULL) +        CommandObjectParsed(interpreter, +                            "target modules search-paths insert", +                            "Insert a new image search path substitution pair into the current target at the specified index.", +                            nullptr)      {          CommandArgumentEntry arg1;          CommandArgumentEntry arg2; @@ -1272,9 +1251,7 @@ public:          m_arguments.push_back (arg2);      } -    ~CommandObjectTargetModulesSearchPathsInsert () override -    { -    } +    ~CommandObjectTargetModulesSearchPathsInsert() override = default;  protected:      bool @@ -1302,7 +1279,7 @@ protected:                  command.Shift();                  argc = command.GetArgumentCount(); -                for (uint32_t i=0; i<argc; i+=2, ++insert_idx) +                for (uint32_t i = 0; i < argc; i += 2, ++insert_idx)                  {                      const char *from = command.GetArgumentAtIndex(i);                      const char *to = command.GetArgumentAtIndex(i+1); @@ -1344,14 +1321,11 @@ protected:      }  }; -  #pragma mark CommandObjectTargetModulesSearchPathsList -  class CommandObjectTargetModulesSearchPathsList : public CommandObjectParsed  {  public: -      CommandObjectTargetModulesSearchPathsList (CommandInterpreter &interpreter) :          CommandObjectParsed (interpreter,                               "target modules search-paths list", @@ -1360,9 +1334,7 @@ public:      {      } -    ~CommandObjectTargetModulesSearchPathsList () override -    { -    } +    ~CommandObjectTargetModulesSearchPathsList() override = default;  protected:      bool @@ -1395,12 +1367,11 @@ protected:  class CommandObjectTargetModulesSearchPathsQuery : public CommandObjectParsed  {  public: -      CommandObjectTargetModulesSearchPathsQuery (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target modules search-paths query", -                             "Transform a path using the first applicable image search path.", -                             NULL) +        CommandObjectParsed(interpreter, +                            "target modules search-paths query", +                            "Transform a path using the first applicable image search path.", +                            nullptr)      {          CommandArgumentEntry arg;          CommandArgumentData path_arg; @@ -1416,9 +1387,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectTargetModulesSearchPathsQuery () override -    { -    } +    ~CommandObjectTargetModulesSearchPathsQuery() override = default;  protected:      bool @@ -1501,7 +1470,7 @@ DumpCompileUnitLineTable (CommandInterpreter &interpreter,                                                                  eSymbolContextCompUnit,                                                                  sc_list); -        for (uint32_t i=0; i<num_matches; ++i) +        for (uint32_t i = 0; i < num_matches; ++i)          {              SymbolContext sc;              if (sc_list.GetContextAtIndex(i, sc)) @@ -1578,6 +1547,34 @@ DumpBasename (Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)          strm.Printf("%-*s", width, "");  } +static size_t +DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list) +{ +    size_t num_dumped = 0; +    std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex()); +    const size_t num_modules = module_list.GetSize(); +    if (num_modules > 0) +    { +        strm.Printf("Dumping headers for %" PRIu64 " module(s).\n", static_cast<uint64_t>(num_modules)); +        strm.IndentMore(); +        for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) +        { +            Module *module = module_list.GetModulePointerAtIndexUnlocked(image_idx); +            if (module) +            { +                if (num_dumped++ > 0) +                { +                    strm.EOL(); +                    strm.EOL(); +                } +                ObjectFile *objfile = module->GetObjectFile(); +                objfile->Dump(&strm); +            } +        } +        strm.IndentLess(); +    } +    return num_dumped; +}  static void  DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module, SortOrder sort_order) @@ -1717,7 +1714,6 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod              Symtab *symtab = sym_vendor->GetSymtab();              if (symtab)              { -                uint32_t i;                  std::vector<uint32_t> match_indexes;                  ConstString symbol_name (name);                  uint32_t num_matches = 0; @@ -1741,7 +1737,7 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod                      DumpFullpath (strm, &module->GetFileSpec(), 0);                      strm.PutCString(":\n");                      strm.IndentMore (); -                    for (i=0; i < num_matches; ++i) +                    for (uint32_t i = 0; i < num_matches; ++i)                      {                          Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]);                          if (symbol && symbol->ValueIsAddress()) @@ -1761,15 +1757,14 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod      return 0;  } -  static void  DumpSymbolContextList (ExecutionContextScope *exe_scope, Stream &strm, SymbolContextList &sc_list, bool verbose)  {      strm.IndentMore (); -    uint32_t i; +      const uint32_t num_matches = sc_list.GetSize(); -    for (i=0; i<num_matches; ++i) +    for (uint32_t i = 0; i < num_matches; ++i)      {          SymbolContext sc;          if (sc_list.GetContextAtIndex(i, sc)) @@ -1814,13 +1809,13 @@ LookupFunctionInModule (CommandInterpreter &interpreter,          else          {              ConstString function_name (name); -            num_matches = module->FindFunctions (function_name, -                                                 NULL, -                                                 eFunctionNameTypeAuto, -                                                 include_symbols, -                                                 include_inlines,  -                                                 append,  -                                                 sc_list); +            num_matches = module->FindFunctions(function_name, +                                                nullptr, +                                                eFunctionNameTypeAuto, +                                                include_symbols, +                                                include_inlines, +                                                append,  +                                                sc_list);          }          if (num_matches) @@ -1852,7 +1847,8 @@ LookupTypeInModule (CommandInterpreter &interpreter,          SymbolContext sc;          ConstString name(name_cstr); -        num_matches = module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, type_list); +        llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; +        num_matches = module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list);          if (num_matches)          { @@ -1905,7 +1901,8 @@ LookupTypeHere (CommandInterpreter &interpreter,      bool name_is_fully_qualified = false;      ConstString name(name_cstr); -    num_matches = sym_ctx.module_sp->FindTypes(sym_ctx, name, name_is_fully_qualified, max_num_matches, type_list); +    llvm::DenseSet<SymbolFile *> searched_symbol_files; +    num_matches = sym_ctx.module_sp->FindTypes(sym_ctx, name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list);      if (num_matches)      { @@ -1970,14 +1967,12 @@ LookupFileAndLineInModule (CommandInterpreter &interpreter,      return 0;  } -  static size_t  FindModulesByName (Target *target,                      const char *module_name,                      ModuleList &module_list,                      bool check_global_list)  { -// Dump specified images (by basename or fullpath)      FileSpec module_file_spec(module_name, false);      ModuleSpec module_spec (module_file_spec); @@ -1986,7 +1981,7 @@ FindModulesByName (Target *target,      if (check_global_list)      {          // Check the global list -        Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); +        std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());          const size_t num_modules = Module::GetNumberAllocatedModules();          ModuleSP module_sp;          for (size_t image_idx = 0; image_idx<num_modules; ++image_idx) @@ -2057,9 +2052,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectTargetModulesModuleAutoComplete () override -    { -    } +    ~CommandObjectTargetModulesModuleAutoComplete() override = default;      int      HandleArgumentCompletion (Args &input, @@ -2075,14 +2068,14 @@ public:          std::string completion_str (input.GetArgumentAtIndex(cursor_index));          completion_str.erase (cursor_char_position); -        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, -                                                             CommandCompletions::eModuleCompletion, -                                                             completion_str.c_str(), -                                                             match_start_point, -                                                             max_return_elements, -                                                             NULL, -                                                             word_complete, -                                                             matches); +        CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, +                                                            CommandCompletions::eModuleCompletion, +                                                            completion_str.c_str(), +                                                            match_start_point, +                                                            max_return_elements, +                                                            nullptr, +                                                            word_complete, +                                                            matches);          return matches.GetSize();      }  }; @@ -2118,9 +2111,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectTargetModulesSourceFileAutoComplete () override -    { -    } +    ~CommandObjectTargetModulesSourceFileAutoComplete() override = default;      int      HandleArgumentCompletion (Args &input, @@ -2136,37 +2127,104 @@ public:          std::string completion_str (input.GetArgumentAtIndex(cursor_index));          completion_str.erase (cursor_char_position); -        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,  -                                                             CommandCompletions::eSourceFileCompletion, -                                                             completion_str.c_str(), -                                                             match_start_point, -                                                             max_return_elements, -                                                             NULL, -                                                             word_complete, -                                                             matches); +        CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, +                                                            CommandCompletions::eSourceFileCompletion, +                                                            completion_str.c_str(), +                                                            match_start_point, +                                                            max_return_elements, +                                                            nullptr, +                                                            word_complete, +                                                            matches);          return matches.GetSize();      }  }; +#pragma mark CommandObjectTargetModulesDumpObjfile -#pragma mark CommandObjectTargetModulesDumpSymtab +class CommandObjectTargetModulesDumpObjfile : public CommandObjectTargetModulesModuleAutoComplete +{ +public: +    CommandObjectTargetModulesDumpObjfile(CommandInterpreter &interpreter) +        : CommandObjectTargetModulesModuleAutoComplete(interpreter, "target modules dump objfile", +                                                       "Dump the object file headers from one or more target modules.", +                                                       nullptr) +    { +    } +    ~CommandObjectTargetModulesDumpObjfile() override = default; + +protected: +    bool +    DoExecute(Args &command, CommandReturnObject &result) override +    { +        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); +        if (target == nullptr) +        { +            result.AppendError("invalid target, create a debug target using the 'target create' command"); +            result.SetStatus(eReturnStatusFailed); +            return false; +        } + +        uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); +        result.GetOutputStream().SetAddressByteSize(addr_byte_size); +        result.GetErrorStream().SetAddressByteSize(addr_byte_size); + +        size_t num_dumped = 0; +        if (command.GetArgumentCount() == 0) +        { +            // Dump all headers for all modules images +            num_dumped = DumpModuleObjfileHeaders(result.GetOutputStream(), target->GetImages()); +            if (num_dumped == 0) +            { +                result.AppendError("the target has no associated executable images"); +                result.SetStatus(eReturnStatusFailed); +            } +        } +        else +        { +            // Find the modules that match the basename or full path. +            ModuleList module_list; +            const char *arg_cstr; +            for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx) +            { +                size_t num_matched = FindModulesByName(target, arg_cstr, module_list, true); +                if (num_matched == 0) +                { +                    result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr); +                } +            } +            // Dump all the modules we found. +            num_dumped = DumpModuleObjfileHeaders(result.GetOutputStream(), module_list); +        } + +        if (num_dumped > 0) +        { +            result.SetStatus(eReturnStatusSuccessFinishResult); +        } +        else +        { +            result.AppendError("no matching executable images found"); +            result.SetStatus(eReturnStatusFailed); +        } +        return result.Succeeded(); +    } +}; + +#pragma mark CommandObjectTargetModulesDumpSymtab  class CommandObjectTargetModulesDumpSymtab : public CommandObjectTargetModulesModuleAutoComplete  {  public:      CommandObjectTargetModulesDumpSymtab (CommandInterpreter &interpreter) : -    CommandObjectTargetModulesModuleAutoComplete (interpreter, -                                      "target modules dump symtab", -                                      "Dump the symbol table from one or more target modules.", -                                      NULL), -    m_options (interpreter) +        CommandObjectTargetModulesModuleAutoComplete(interpreter, +                                                     "target modules dump symtab", +                                                     "Dump the symbol table from one or more target modules.", +                                                     nullptr), +        m_options(interpreter)      {      } -    ~CommandObjectTargetModulesDumpSymtab () override -    { -    } +    ~CommandObjectTargetModulesDumpSymtab() override = default;      Options *      GetOptions () override @@ -2183,9 +2241,7 @@ public:          {          } -        ~CommandOptions () override -        { -        } +        ~CommandOptions() override = default;          Error          SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -2205,7 +2261,6 @@ public:                  default:                      error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);                      break; -              }              return error;          } @@ -2233,7 +2288,7 @@ protected:      DoExecute (Args& command, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -2250,7 +2305,7 @@ protected:              if (command.GetArgumentCount() == 0)              {                  // Dump all sections for all modules images -                Mutex::Locker modules_locker(target->GetImages().GetMutex()); +                std::lock_guard<std::recursive_mutex> guard(target->GetImages().GetMutex());                  const size_t num_modules = target->GetImages().GetSize();                  if (num_modules > 0)                  { @@ -2280,13 +2335,13 @@ protected:              {                  // Dump specified images (by basename or fullpath)                  const char *arg_cstr; -                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) +                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)                  {                      ModuleList module_list;                      const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);                      if (num_matches > 0)                      { -                        for (size_t i=0; i<num_matches; ++i) +                        for (size_t i = 0; i < num_matches; ++i)                          {                              Module *module = module_list.GetModulePointerAtIndex(i);                              if (module) @@ -2326,15 +2381,14 @@ g_sort_option_enumeration[4] =      { eSortOrderNone,       "none",     "No sorting, use the original symbol table order."},      { eSortOrderByAddress,  "address",  "Sort output by symbol address."},      { eSortOrderByName,     "name",     "Sort output by symbol name."}, -    { 0,                    NULL,       NULL } +    { 0,                    nullptr,    nullptr }  }; -  OptionDefinition  CommandObjectTargetModulesDumpSymtab::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, NULL, g_sort_option_enumeration, 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table."}, -    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +    { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, g_sort_option_enumeration, 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table."}, +    { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }  };  #pragma mark CommandObjectTargetModulesDumpSections @@ -2347,24 +2401,22 @@ class CommandObjectTargetModulesDumpSections : public CommandObjectTargetModules  {  public:      CommandObjectTargetModulesDumpSections (CommandInterpreter &interpreter) : -    CommandObjectTargetModulesModuleAutoComplete (interpreter, -                                      "target modules dump sections", -                                      "Dump the sections from one or more target modules.", -                                      //"target modules dump sections [<file1> ...]") -                                      NULL) +        CommandObjectTargetModulesModuleAutoComplete(interpreter, +                                                     "target modules dump sections", +                                                     "Dump the sections from one or more target modules.", +                                                     //"target modules dump sections [<file1> ...]") +                                                     nullptr)      {      } -    ~CommandObjectTargetModulesDumpSections () override -    { -    } +    ~CommandObjectTargetModulesDumpSections() override = default;  protected:      bool      DoExecute (Args& command, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -2402,13 +2454,13 @@ protected:              {                  // Dump specified images (by basename or fullpath)                  const char *arg_cstr; -                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) +                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)                  {                      ModuleList module_list;                      const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);                      if (num_matches > 0)                      { -                        for (size_t i=0; i<num_matches; ++i) +                        for (size_t i = 0; i < num_matches; ++i)                          {                              Module *module = module_list.GetModulePointerAtIndex(i);                              if (module) @@ -2421,7 +2473,7 @@ protected:                      else                      {                          // Check the global list -                        Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); +                        std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());                          result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr);                      } @@ -2440,7 +2492,6 @@ protected:      }  }; -  #pragma mark CommandObjectTargetModulesDumpSymfile  //---------------------------------------------------------------------- @@ -2451,24 +2502,22 @@ class CommandObjectTargetModulesDumpSymfile : public CommandObjectTargetModulesM  {  public:      CommandObjectTargetModulesDumpSymfile (CommandInterpreter &interpreter) : -    CommandObjectTargetModulesModuleAutoComplete (interpreter, -                                      "target modules dump symfile", -                                      "Dump the debug symbol file for one or more target modules.", -                                      //"target modules dump symfile [<file1> ...]") -                                      NULL) +        CommandObjectTargetModulesModuleAutoComplete(interpreter, +                                                     "target modules dump symfile", +                                                     "Dump the debug symbol file for one or more target modules.", +                                                     //"target modules dump symfile [<file1> ...]") +                                                     nullptr)      {      } -    ~CommandObjectTargetModulesDumpSymfile () override -    { -    } +    ~CommandObjectTargetModulesDumpSymfile() override = default;  protected:      bool      DoExecute (Args& command, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -2486,7 +2535,7 @@ protected:              {                  // Dump all sections for all modules images                  const ModuleList &target_modules = target->GetImages(); -                Mutex::Locker modules_locker (target_modules.GetMutex()); +                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());                  const size_t num_modules = target_modules.GetSize();                  if (num_modules > 0)                  { @@ -2508,13 +2557,13 @@ protected:              {                  // Dump specified images (by basename or fullpath)                  const char *arg_cstr; -                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) +                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)                  {                      ModuleList module_list;                      const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, true);                      if (num_matches > 0)                      { -                        for (size_t i=0; i<num_matches; ++i) +                        for (size_t i = 0; i < num_matches; ++i)                          {                              Module *module = module_list.GetModulePointerAtIndex(i);                              if (module) @@ -2541,7 +2590,6 @@ protected:      }  }; -  #pragma mark CommandObjectTargetModulesDumpLineTable  //---------------------------------------------------------------------- @@ -2552,17 +2600,15 @@ class CommandObjectTargetModulesDumpLineTable : public CommandObjectTargetModule  {  public:      CommandObjectTargetModulesDumpLineTable (CommandInterpreter &interpreter) : -    CommandObjectTargetModulesSourceFileAutoComplete (interpreter, -                                                      "target modules dump line-table", -                                                      "Dump the line table for one or more compilation units.", -                                                      NULL, -                                                      eCommandRequiresTarget) +        CommandObjectTargetModulesSourceFileAutoComplete(interpreter, +                                                         "target modules dump line-table", +                                                         "Dump the line table for one or more compilation units.", +                                                         nullptr, +                                                         eCommandRequiresTarget)      {      } -    ~CommandObjectTargetModulesDumpLineTable () override -    { -    } +    ~CommandObjectTargetModulesDumpLineTable() override = default;  protected:      bool @@ -2585,12 +2631,12 @@ protected:          {              // Dump specified images (by basename or fullpath)              const char *arg_cstr; -            for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) +            for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx)              {                  FileSpec file_spec(arg_cstr, false);                  const ModuleList &target_modules = target->GetImages(); -                Mutex::Locker modules_locker(target_modules.GetMutex()); +                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());                  const size_t num_modules = target_modules.GetSize();                  if (num_modules > 0)                  { @@ -2623,7 +2669,6 @@ protected:      }  }; -  #pragma mark CommandObjectTargetModulesDump  //---------------------------------------------------------------------- @@ -2636,21 +2681,19 @@ public:      //------------------------------------------------------------------      // Constructors and Destructors      //------------------------------------------------------------------ -    CommandObjectTargetModulesDump(CommandInterpreter &interpreter) : -    CommandObjectMultiword (interpreter,  -                            "target modules dump", -                            "A set of commands for dumping information about one or more target modules.", -                            "target modules dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") +    CommandObjectTargetModulesDump(CommandInterpreter &interpreter) +        : CommandObjectMultiword( +              interpreter, "target modules dump", "Commands for dumping information about one or more target modules.", +              "target modules dump [headers|symtab|sections|symfile|line-table] [<file1> <file2> ...]")      { +        LoadSubCommand("objfile", CommandObjectSP(new CommandObjectTargetModulesDumpObjfile(interpreter)));          LoadSubCommand ("symtab",      CommandObjectSP (new CommandObjectTargetModulesDumpSymtab (interpreter)));          LoadSubCommand ("sections",    CommandObjectSP (new CommandObjectTargetModulesDumpSections (interpreter)));          LoadSubCommand ("symfile",     CommandObjectSP (new CommandObjectTargetModulesDumpSymfile (interpreter)));          LoadSubCommand ("line-table",  CommandObjectSP (new CommandObjectTargetModulesDumpLineTable (interpreter)));      } -    ~CommandObjectTargetModulesDump() override -    { -    } +    ~CommandObjectTargetModulesDump() override = default;  };  class CommandObjectTargetModulesAdd : public CommandObjectParsed @@ -2669,9 +2712,7 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetModulesAdd () override -    { -    } +    ~CommandObjectTargetModulesAdd() override = default;      Options *      GetOptions () override @@ -2692,14 +2733,14 @@ public:          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); +        CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, +                                                            CommandCompletions::eDiskFileCompletion, +                                                            completion_str.c_str(), +                                                            match_start_point, +                                                            max_return_elements, +                                                            nullptr, +                                                            word_complete, +                                                            matches);          return matches.GetSize();      } @@ -2712,7 +2753,7 @@ protected:      DoExecute (Args& args, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -2787,7 +2828,7 @@ protected:              }              else              { -                for (size_t i=0; i<argc; ++i) +                for (size_t i = 0; i < argc; ++i)                  {                      const char *path = args.GetArgumentAtIndex(i);                      if (path) @@ -2849,7 +2890,6 @@ protected:          return result.Succeeded();      } -  };  class CommandObjectTargetModulesLoad : public CommandObjectTargetModulesModuleAutoComplete @@ -2870,9 +2910,7 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetModulesLoad () override -    { -    } +    ~CommandObjectTargetModulesLoad() override = default;      Options *      GetOptions () override @@ -2885,7 +2923,7 @@ protected:      DoExecute (Args& args, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -2969,7 +3007,7 @@ protected:                                          return false;                                      } -                                    for (size_t i=0; i<argc; i += 2) +                                    for (size_t i = 0; i < argc; i += 2)                                      {                                          const char *sect_name = args.GetArgumentAtIndex(i);                                          const char *load_addr_cstr = args.GetArgumentAtIndex(i+1); @@ -3075,7 +3113,7 @@ protected:                                                        path,                                                        !uuid_str.empty() ? " uuid=" : "",                                                         uuid_str.c_str()); -                        for (size_t i=0; i<num_matches; ++i) +                        for (size_t i = 0; i < num_matches; ++i)                          {                              if (matching_modules.GetModulePointerAtIndex(i)->GetFileSpec().GetPath (path, sizeof(path)))                                  result.AppendMessageWithFormat("%s\n", path); @@ -3125,9 +3163,7 @@ public:          {          } -        ~CommandOptions () override -        { -        } +        ~CommandOptions() override = default;          Error          SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -3148,7 +3184,7 @@ public:              {                  unsigned long width = 0;                  if (option_arg) -                    width = strtoul (option_arg, NULL, 0); +                    width = strtoul(option_arg, nullptr, 0);                  m_format_array.push_back(std::make_pair(short_option, width));              }              return error; @@ -3188,9 +3224,7 @@ public:      {      } -    ~CommandObjectTargetModulesList () override -    { -    } +    ~CommandObjectTargetModulesList() override = default;      Options *      GetOptions () override @@ -3208,7 +3242,7 @@ protected:          // object which might lock its contents below (through the "module_list_ptr"          // variable).          ModuleList module_list; -        if (target == NULL && use_global_module_list == false) +        if (target == nullptr && !use_global_module_list)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -3259,16 +3293,19 @@ protected:              }              size_t num_modules = 0; -            Mutex::Locker locker;      // This locker will be locked on the mutex in module_list_ptr if it is non-NULL. -                                       // Otherwise it will lock the AllocationModuleCollectionMutex when accessing -                                       // the global module list directly. -            const ModuleList *module_list_ptr = NULL; + +            // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr. +            // Otherwise it will lock the AllocationModuleCollectionMutex when accessing +            // the global module list directly. +            std::unique_lock<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock); + +            const ModuleList *module_list_ptr = nullptr;              const size_t argc = command.GetArgumentCount();              if (argc == 0)              {                  if (use_global_module_list)                  { -                    locker.Lock (Module::GetAllocationModuleCollectionMutex()); +                    guard.lock();                      num_modules = Module::GetNumberAllocatedModules();                  }                  else @@ -3278,7 +3315,7 @@ protected:              }              else              { -                for (size_t i=0; i<argc; ++i) +                for (size_t i = 0; i < argc; ++i)                  {                      // Dump specified images (by basename or fullpath)                      const char *arg_cstr = command.GetArgumentAtIndex(i); @@ -3297,9 +3334,11 @@ protected:                  module_list_ptr = &module_list;              } -            if (module_list_ptr != NULL) +            std::unique_lock<std::recursive_mutex> lock; +            if (module_list_ptr != nullptr)              { -                locker.Lock(module_list_ptr->GetMutex()); +                lock = std::unique_lock<std::recursive_mutex>(module_list_ptr->GetMutex()); +                  num_modules = module_list_ptr->GetSize();              } @@ -3352,8 +3391,7 @@ protected:      void      PrintModule (Target *target, Module *module, int indent, Stream &strm)      { - -        if (module == NULL) +        if (module == nullptr)          {              strm.PutCString("Null module");              return; @@ -3369,7 +3407,7 @@ protected:          }          const size_t num_entries = m_options.m_format_array.size();          bool print_space = false; -        for (size_t i=0; i<num_entries; ++i) +        for (size_t i = 0; i < num_entries; ++i)          {              if (print_space)                  strm.PutChar(' '); @@ -3442,6 +3480,7 @@ protected:                          strm.Printf ("%*s", addr_nibble_width + 2, "");                      }                      break; +                  case 'r':                      {                          size_t ref_count = 0; @@ -3499,7 +3538,6 @@ protected:                  default:                      break;              } -          }          if (dump_object_name)          { @@ -3516,22 +3554,22 @@ protected:  OptionDefinition  CommandObjectTargetModulesList::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_1, false, "address",    'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Display the image at this address."}, -    { LLDB_OPT_SET_1, false, "arch",       'A', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the architecture when listing images."}, -    { LLDB_OPT_SET_1, false, "triple",     't', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the triple when listing images."}, -    { LLDB_OPT_SET_1, false, "header",     'h', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,    "Display the image header address as a load address if debugging, a file address otherwise."}, -    { LLDB_OPT_SET_1, false, "offset",     'o', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,    "Display the image header address offset from the header file address (the slide amount)."}, -    { LLDB_OPT_SET_1, false, "uuid",       'u', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,    "Display the UUID when listing images."}, -    { LLDB_OPT_SET_1, false, "fullpath",   'f', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the fullpath to the image object file."}, -    { LLDB_OPT_SET_1, false, "directory",  'd', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the directory with optional width for the image object file."}, -    { LLDB_OPT_SET_1, false, "basename",   'b', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the basename with optional width for the image object file."}, -    { LLDB_OPT_SET_1, false, "symfile",    's', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the fullpath to the image symbol file with optional width."}, -    { LLDB_OPT_SET_1, false, "symfile-unique", 'S', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the symbol file with optional width only if it is different from the executable object file."}, -    { LLDB_OPT_SET_1, false, "mod-time",   'm', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the modification time with optional width of the module."}, -    { LLDB_OPT_SET_1, false, "ref-count",  'r', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeWidth,   "Display the reference count if the module is still in the shared module cache."}, -    { LLDB_OPT_SET_1, false, "pointer",    'p', OptionParser::eOptionalArgument, NULL, NULL, 0, eArgTypeNone,    "Display the module pointer."}, -    { LLDB_OPT_SET_1, false, "global",     'g', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,    "Display the modules from the global module list, not just the current target."}, -    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +    { LLDB_OPT_SET_1, false, "address",    'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Display the image at this address."}, +    { LLDB_OPT_SET_1, false, "arch",       'A', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the architecture when listing images."}, +    { LLDB_OPT_SET_1, false, "triple",     't', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the triple when listing images."}, +    { LLDB_OPT_SET_1, false, "header",     'h', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,    "Display the image header address as a load address if debugging, a file address otherwise."}, +    { LLDB_OPT_SET_1, false, "offset",     'o', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,    "Display the image header address offset from the header file address (the slide amount)."}, +    { LLDB_OPT_SET_1, false, "uuid",       'u', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,    "Display the UUID when listing images."}, +    { LLDB_OPT_SET_1, false, "fullpath",   'f', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the fullpath to the image object file."}, +    { LLDB_OPT_SET_1, false, "directory",  'd', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the directory with optional width for the image object file."}, +    { LLDB_OPT_SET_1, false, "basename",   'b', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the basename with optional width for the image object file."}, +    { LLDB_OPT_SET_1, false, "symfile",    's', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the fullpath to the image symbol file with optional width."}, +    { LLDB_OPT_SET_1, false, "symfile-unique", 'S', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the symbol file with optional width only if it is different from the executable object file."}, +    { LLDB_OPT_SET_1, false, "mod-time",   'm', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the modification time with optional width of the module."}, +    { LLDB_OPT_SET_1, false, "ref-count",  'r', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeWidth,   "Display the reference count if the module is still in the shared module cache."}, +    { LLDB_OPT_SET_1, false, "pointer",    'p', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeNone,    "Display the module pointer."}, +    { LLDB_OPT_SET_1, false, "global",     'g', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,    "Display the modules from the global module list, not just the current target."}, +    { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }  };  #pragma mark CommandObjectTargetModulesShowUnwind @@ -3543,7 +3581,6 @@ CommandObjectTargetModulesList::CommandOptions::g_option_table[] =  class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed  {  public: -      enum      {          eLookupTypeInvalid = -1, @@ -3557,7 +3594,6 @@ public:      class CommandOptions : public Options      {      public: -          CommandOptions (CommandInterpreter &interpreter) :              Options(interpreter),              m_type(eLookupTypeInvalid), @@ -3566,9 +3602,7 @@ public:          {          } -        ~CommandOptions () override -        { -        } +        ~CommandOptions() override = default;          Error          SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -3591,11 +3625,9 @@ public:                  }                  case 'n': -                {                      m_str = option_arg;                      m_type = eLookupTypeFunctionOrSymbol;                      break; -                }                  default:                      error.SetErrorStringWithFormat ("unrecognized option %c.", short_option); @@ -3631,21 +3663,19 @@ public:      };      CommandObjectTargetModulesShowUnwind (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target modules show-unwind", -                             "Show synthesized unwind instructions for a function.", -                             NULL, -                             eCommandRequiresTarget        | -                             eCommandRequiresProcess       | -                             eCommandProcessMustBeLaunched | -                             eCommandProcessMustBePaused   ), +        CommandObjectParsed(interpreter, +                            "target modules show-unwind", +                            "Show synthesized unwind instructions for a function.", +                            nullptr, +                            eCommandRequiresTarget        | +                            eCommandRequiresProcess       | +                            eCommandProcessMustBeLaunched | +                            eCommandProcessMustBePaused   ),          m_options (interpreter)      {      } -    ~CommandObjectTargetModulesShowUnwind () override -    { -    } +    ~CommandObjectTargetModulesShowUnwind() override = default;      Options *      GetOptions () override @@ -3659,11 +3689,11 @@ protected:      {          Target *target = m_exe_ctx.GetTargetPtr();          Process *process = m_exe_ctx.GetProcessPtr(); -        ABI *abi = NULL; +        ABI *abi = nullptr;          if (process)            abi = process->GetABI().get(); -        if (process == NULL) +        if (process == nullptr)          {              result.AppendError ("You must have a process running to use this command.");              result.SetStatus (eReturnStatusFailed); @@ -3679,7 +3709,7 @@ protected:          }          ThreadSP thread(threads.GetThreadAtIndex(0)); -        if (thread.get() == NULL) +        if (!thread)          {              result.AppendError ("The process must be paused to use this command.");              result.SetStatus (eReturnStatusFailed); @@ -3726,9 +3756,9 @@ protected:          {              SymbolContext sc;              sc_list.GetContextAtIndex(idx, sc); -            if (sc.symbol == NULL && sc.function == NULL) +            if (sc.symbol == nullptr && sc.function == nullptr)                  continue; -            if (sc.module_sp.get() == NULL || sc.module_sp->GetObjectFile() == NULL) +            if (!sc.module_sp || sc.module_sp->GetObjectFile() == nullptr)                  continue;              AddressRange range;              if (!sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range)) @@ -3743,37 +3773,36 @@ protected:                  start_addr = abi->FixCodeAddress(start_addr);              FuncUnwindersSP func_unwinders_sp (sc.module_sp->GetObjectFile()->GetUnwindTable().GetUncachedFuncUnwindersContainingAddress(start_addr, sc)); -            if (func_unwinders_sp.get() == NULL) +            if (!func_unwinders_sp)                  continue;              result.GetOutputStream().Printf("UNWIND PLANS for %s`%s (start addr 0x%" PRIx64 ")\n\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr); -            UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread.get(), -1); -            if (non_callsite_unwind_plan.get()) +            UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread, -1); +            if (non_callsite_unwind_plan)              {                  result.GetOutputStream().Printf("Asynchronous (not restricted to call-sites) UnwindPlan is '%s'\n", non_callsite_unwind_plan->GetSourceName().AsCString());              }              UnwindPlanSP callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(*target, -1); -            if (callsite_unwind_plan.get()) +            if (callsite_unwind_plan)              {                  result.GetOutputStream().Printf("Synchronous (restricted to call-sites) UnwindPlan is '%s'\n", callsite_unwind_plan->GetSourceName().AsCString());              } -            UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread.get()); -            if (fast_unwind_plan.get()) +            UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread); +            if (fast_unwind_plan)              {                  result.GetOutputStream().Printf("Fast UnwindPlan is '%s'\n", fast_unwind_plan->GetSourceName().AsCString());              }              result.GetOutputStream().Printf("\n"); -            UnwindPlanSP assembly_sp = func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread.get(), 0); +            UnwindPlanSP assembly_sp = func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread, 0);              if (assembly_sp)              {                  result.GetOutputStream().Printf("Assembly language inspection UnwindPlan:\n");                  assembly_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);                  result.GetOutputStream().Printf("\n");              } -                          UnwindPlanSP ehframe_sp = func_unwinders_sp->GetEHFrameUnwindPlan(*target, 0);              if (ehframe_sp) @@ -3783,7 +3812,7 @@ protected:                  result.GetOutputStream().Printf("\n");              } -            UnwindPlanSP ehframe_augmented_sp = func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread.get(), 0); +            UnwindPlanSP ehframe_augmented_sp = func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread, 0);              if (ehframe_augmented_sp)              {                  result.GetOutputStream().Printf("eh_frame augmented UnwindPlan:\n"); @@ -3845,9 +3874,9 @@ protected:  OptionDefinition  CommandObjectTargetModulesShowUnwind::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_1,   false,  "name",       'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."}, -    { LLDB_OPT_SET_2,   false,  "address",    'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"}, -    { 0,                false, NULL,           0, 0,                 NULL, NULL, 0, eArgTypeNone, NULL } +    { LLDB_OPT_SET_1,   false,  "name",       'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."}, +    { LLDB_OPT_SET_2,   false,  "address",    'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"}, +    { 0,                false, nullptr,           0, 0,                 nullptr, nullptr, 0, eArgTypeNone, nullptr }  };  //---------------------------------------------------------------------- @@ -3877,9 +3906,7 @@ public:              OptionParsingStarting();          } -        ~CommandOptions () override -        { -        } +        ~CommandOptions() override = default;          Error          SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -3995,11 +4022,11 @@ public:      };      CommandObjectTargetModulesLookup (CommandInterpreter &interpreter) : -        CommandObjectParsed (interpreter, -                             "target modules lookup", -                             "Look up information within executable and dependent shared library images.", -                             NULL, -                             eCommandRequiresTarget), +        CommandObjectParsed(interpreter, +                            "target modules lookup", +                            "Look up information within executable and dependent shared library images.", +                            nullptr, +                            eCommandRequiresTarget),          m_options (interpreter)      {          CommandArgumentEntry arg; @@ -4016,9 +4043,7 @@ public:          m_arguments.push_back (arg);      } -    ~CommandObjectTargetModulesLookup () override -    { -    } +    ~CommandObjectTargetModulesLookup() override = default;      Options *      GetOptions () override @@ -4083,11 +4108,11 @@ public:              case eLookupTypeAddress:                  if (m_options.m_addr != LLDB_INVALID_ADDRESS)                  { -                    if (LookupAddressInModule (m_interpreter,  -                                               result.GetOutputStream(),  -                                               module,  -                                               eSymbolContextEverything | (m_options.m_verbose ? eSymbolContextVariable : 0), -                                               m_options.m_addr,  +                    if (LookupAddressInModule (m_interpreter, +                                               result.GetOutputStream(), +                                               module, +                                               eSymbolContextEverything | (m_options.m_verbose ? static_cast<int>(eSymbolContextVariable) : 0), +                                               m_options.m_addr,                                                 m_options.m_offset,                                                 m_options.m_verbose))                      { @@ -4179,7 +4204,7 @@ protected:      DoExecute (Args& command, CommandReturnObject &result) override      {          Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); -        if (target == NULL) +        if (target == nullptr)          {              result.AppendError ("invalid target, create a debug target using the 'target create' command");              result.SetStatus (eReturnStatusFailed); @@ -4216,11 +4241,11 @@ protected:                  // Dump all sections for all other modules                  const ModuleList &target_modules = target->GetImages(); -                Mutex::Locker modules_locker(target_modules.GetMutex()); +                std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());                  const size_t num_modules = target_modules.GetSize();                  if (num_modules > 0)                  { -                    for (i = 0; i<num_modules && syntax_error == false; ++i) +                    for (i = 0; i < num_modules && !syntax_error; ++i)                      {                          Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i); @@ -4243,7 +4268,7 @@ protected:              {                  // Dump specified images (by basename or fullpath)                  const char *arg_cstr; -                for (i = 0; (arg_cstr = command.GetArgumentAtIndex(i)) != NULL && syntax_error == false; ++i) +                for (i = 0; (arg_cstr = command.GetArgumentAtIndex(i)) != nullptr && !syntax_error; ++i)                  {                      ModuleList module_list;                      const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, false); @@ -4281,25 +4306,24 @@ protected:  OptionDefinition  CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_1,   true,  "address",    'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."}, -    { LLDB_OPT_SET_1,   false, "offset",     'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset,           "When looking up an address subtract <offset> from any addresses before doing the lookup."}, +    { LLDB_OPT_SET_1,   true,  "address",    'a', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."}, +    { LLDB_OPT_SET_1,   false, "offset",     'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset,           "When looking up an address subtract <offset> from any addresses before doing the lookup."},      { LLDB_OPT_SET_2| LLDB_OPT_SET_4 | LLDB_OPT_SET_5        /* FIXME: re-enable this for types when the LookupTypeInModule actually uses the regex option: | LLDB_OPT_SET_6 */ , -                        false, "regex",      'r', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,             "The <name> argument for name lookups are regular expressions."}, -    { LLDB_OPT_SET_2,   true,  "symbol",     's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSymbol,           "Lookup a symbol by name in the symbol tables in one or more target modules."}, -    { LLDB_OPT_SET_3,   true,  "file",       'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename,         "Lookup a file by fullpath or basename in one or more target modules."}, -    { LLDB_OPT_SET_3,   false, "line",       'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum,          "Lookup a line number in a file (must be used in conjunction with --file)."}, +                        false, "regex",      'r', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,             "The <name> argument for name lookups are regular expressions."}, +    { LLDB_OPT_SET_2,   true,  "symbol",     's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeSymbol,           "Lookup a symbol by name in the symbol tables in one or more target modules."}, +    { LLDB_OPT_SET_3,   true,  "file",       'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename,         "Lookup a file by fullpath or basename in one or more target modules."}, +    { LLDB_OPT_SET_3,   false, "line",       'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,          "Lookup a line number in a file (must be used in conjunction with --file)."},      { LLDB_OPT_SET_FROM_TO(3,5), -                        false, "no-inlines", 'i', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,             "Ignore inline entries (must be used in conjunction with --file or --function)."}, -    { LLDB_OPT_SET_4,   true,  "function",   'F', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionName,     "Lookup a function by name in the debug symbols in one or more target modules."}, -    { LLDB_OPT_SET_5,   true,  "name",       'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFunctionOrSymbol, "Lookup a function or symbol by name in one or more target modules."}, -    { LLDB_OPT_SET_6,   true,  "type",       't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName,             "Lookup a type by name in the debug symbols in one or more target modules."}, -    { LLDB_OPT_SET_ALL, false, "verbose",    'v', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,             "Enable verbose lookup information."}, -    { LLDB_OPT_SET_ALL, false, "all",        'A', OptionParser::eNoArgument,       NULL, NULL, 0, eArgTypeNone,             "Print all matches, not just the best match, if a best match is available."}, -    { 0,                false, NULL,           0, 0,                 NULL, NULL, 0, eArgTypeNone,             NULL } +                        false, "no-inlines", 'i', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,             "Ignore inline entries (must be used in conjunction with --file or --function)."}, +    { LLDB_OPT_SET_4,   true,  "function",   'F', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionName,     "Lookup a function by name in the debug symbols in one or more target modules."}, +    { LLDB_OPT_SET_5,   true,  "name",       'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFunctionOrSymbol, "Lookup a function or symbol by name in one or more target modules."}, +    { LLDB_OPT_SET_6,   true,  "type",       't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName,             "Lookup a type by name in the debug symbols in one or more target modules."}, +    { LLDB_OPT_SET_ALL, false, "verbose",    'v', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,             "Enable verbose lookup information."}, +    { LLDB_OPT_SET_ALL, false, "all",        'A', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone,             "Print all matches, not just the best match, if a best match is available."}, +    { 0,                false, nullptr,           0, 0,                 nullptr, nullptr, 0, eArgTypeNone,             nullptr }  }; -  #pragma mark CommandObjectMultiwordImageSearchPaths  //------------------------------------------------------------------------- @@ -4309,11 +4333,10 @@ CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =  class CommandObjectTargetModulesImageSearchPaths : public CommandObjectMultiword  {  public: -    CommandObjectTargetModulesImageSearchPaths (CommandInterpreter &interpreter) : -    CommandObjectMultiword (interpreter,  -                            "target modules search-paths", -                            "A set of commands for operating on debugger target image search paths.", -                            "target modules search-paths <subcommand> [<subcommand-options>]") +    CommandObjectTargetModulesImageSearchPaths(CommandInterpreter &interpreter) +        : CommandObjectMultiword(interpreter, "target modules search-paths", +                                 "Commands for managing module search paths for a target.", +                                 "target modules search-paths <subcommand> [<subcommand-options>]")      {          LoadSubCommand ("add",     CommandObjectSP (new CommandObjectTargetModulesSearchPathsAdd (interpreter)));          LoadSubCommand ("clear",   CommandObjectSP (new CommandObjectTargetModulesSearchPathsClear (interpreter))); @@ -4322,13 +4345,9 @@ public:          LoadSubCommand ("query",   CommandObjectSP (new CommandObjectTargetModulesSearchPathsQuery (interpreter)));      } -    ~CommandObjectTargetModulesImageSearchPaths() override -    { -    } +    ~CommandObjectTargetModulesImageSearchPaths() override = default;  }; - -  #pragma mark CommandObjectTargetModules  //------------------------------------------------------------------------- @@ -4341,11 +4360,10 @@ public:      //------------------------------------------------------------------      // Constructors and Destructors      //------------------------------------------------------------------ -    CommandObjectTargetModules(CommandInterpreter &interpreter) : -        CommandObjectMultiword (interpreter, -                                "target modules", -                                "A set of commands for accessing information for one or more target modules.", -                                "target modules <sub-command> ...") +    CommandObjectTargetModules(CommandInterpreter &interpreter) +        : CommandObjectMultiword(interpreter, "target modules", +                                 "Commands for accessing information for one or more target modules.", +                                 "target modules <sub-command> ...")      {          LoadSubCommand ("add",          CommandObjectSP (new CommandObjectTargetModulesAdd (interpreter)));          LoadSubCommand ("load",         CommandObjectSP (new CommandObjectTargetModulesLoad (interpreter))); @@ -4357,9 +4375,7 @@ public:      } -    ~CommandObjectTargetModules() override -    { -    } +    ~CommandObjectTargetModules() override = default;  private:      //------------------------------------------------------------------ @@ -4368,8 +4384,6 @@ private:      DISALLOW_COPY_AND_ASSIGN (CommandObjectTargetModules);  }; - -  class CommandObjectTargetSymbolsAdd : public CommandObjectParsed  {  public: @@ -4389,9 +4403,7 @@ public:          m_option_group.Finalize();      } -    ~CommandObjectTargetSymbolsAdd () override -    { -    } +    ~CommandObjectTargetSymbolsAdd() override = default;      int      HandleArgumentCompletion (Args &input, @@ -4406,14 +4418,14 @@ public:          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); +        CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, +                                                            CommandCompletions::eDiskFileCompletion, +                                                            completion_str.c_str(), +                                                            match_start_point, +                                                            max_return_elements, +                                                            nullptr, +                                                            word_complete, +                                                            matches);          return matches.GetSize();      } @@ -4473,7 +4485,7 @@ protected:                      // No matches yet, iterate through the module specs to find a UUID value that                      // we can match up to an image in our target                      const size_t num_symfile_module_specs = symfile_module_specs.GetSize(); -                    for (size_t i=0; i<num_symfile_module_specs && num_matches == 0; ++i) +                    for (size_t i = 0; i < num_symfile_module_specs && num_matches == 0; ++i)                      {                          if (symfile_module_specs.GetModuleSpecAtIndex(i, symfile_module_spec))                          { @@ -4606,8 +4618,8 @@ protected:          const bool uuid_option_set = m_uuid_option_group.GetOptionValue().OptionWasSet();          const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();          const bool frame_option_set = m_current_frame_option.GetOptionValue().OptionWasSet(); -          const size_t argc = args.GetArgumentCount(); +          if (argc == 0)          {              if (uuid_option_set || file_option_set || frame_option_set) @@ -4682,7 +4694,7 @@ protected:                          {                              module_spec.GetArchitecture() = target->GetArchitecture();                          } -                        success |= module_spec.GetFileSpec().Exists(); +                        success |= module_spec.GetUUID().IsValid() || module_spec.GetFileSpec().Exists();                      }                  } @@ -4738,7 +4750,7 @@ protected:              {                  PlatformSP platform_sp (target->GetPlatform()); -                for (size_t i=0; i<argc; ++i) +                for (size_t i = 0; i < argc; ++i)                  {                      const char *symfile_path = args.GetArgumentAtIndex(i);                      if (symfile_path) @@ -4793,7 +4805,6 @@ protected:      OptionGroupBoolean m_current_frame_option;  }; -  #pragma mark CommandObjectTargetSymbols  //------------------------------------------------------------------------- @@ -4806,19 +4817,14 @@ public:      //------------------------------------------------------------------      // Constructors and Destructors      //------------------------------------------------------------------ -    CommandObjectTargetSymbols(CommandInterpreter &interpreter) : -        CommandObjectMultiword (interpreter, -                            "target symbols", -                            "A set of commands for adding and managing debug symbol files.", -                            "target symbols <sub-command> ...") +    CommandObjectTargetSymbols(CommandInterpreter &interpreter) +        : CommandObjectMultiword(interpreter, "target symbols", "Commands for adding and managing debug symbol files.", +                                 "target symbols <sub-command> ...")      {          LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetSymbolsAdd (interpreter))); -      } -    ~CommandObjectTargetSymbols() override -    { -    } +    ~CommandObjectTargetSymbols() override = default;  private:      //------------------------------------------------------------------ @@ -4827,7 +4833,6 @@ private:      DISALLOW_COPY_AND_ASSIGN (CommandObjectTargetSymbols);  }; -  #pragma mark CommandObjectTargetStopHookAdd  //------------------------------------------------------------------------- @@ -4839,7 +4844,6 @@ class CommandObjectTargetStopHookAdd :      public IOHandlerDelegateMultiline  {  public: -      class CommandOptions : public Options      {      public: @@ -4855,7 +4859,7 @@ public:          {          } -        ~CommandOptions () override {} +        ~CommandOptions() override = default;          const OptionDefinition*          GetDefinitions () override @@ -4875,7 +4879,7 @@ public:                  case 'c':                      m_class_name = option_arg;                      m_sym_ctx_specified = true; -                break; +                    break;                  case 'e':                      m_line_end = StringConvert::ToUInt32 (option_arg, UINT_MAX, 0, &success); @@ -4885,7 +4889,7 @@ public:                          break;                      }                      m_sym_ctx_specified = true; -                break; +                    break;                  case 'l':                      m_line_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success); @@ -4895,57 +4899,60 @@ public:                          break;                      }                      m_sym_ctx_specified = true; -                break; +                    break;                  case 'i':                      m_no_inlines = true; -                break; +                    break;                  case 'n':                      m_function_name = option_arg;                      m_func_name_type_mask |= eFunctionNameTypeAuto;                      m_sym_ctx_specified = true; -                break; +                    break;                  case 'f':                      m_file_name = option_arg;                      m_sym_ctx_specified = true; -                break; +                    break; +                  case 's':                      m_module_name = option_arg;                      m_sym_ctx_specified = true; -                break; +                    break; +                  case 't' : -                {                      m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);                      if (m_thread_id == LLDB_INVALID_THREAD_ID)                         error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);                      m_thread_specified = true; -                } -                break; +                    break; +                  case 'T':                      m_thread_name = option_arg;                      m_thread_specified = true; -                break; +                    break; +                  case 'q':                      m_queue_name = option_arg;                      m_thread_specified = true;                      break; +                  case 'x': -                {                      m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);                      if (m_thread_id == UINT32_MAX)                         error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);                      m_thread_specified = true; -                } -                break; +                    break; +                  case 'o':                      m_use_one_liner = true;                      m_one_liner = option_arg; -                break; +                    break; +                  default:                      error.SetErrorStringWithFormat ("unrecognized option %c.", short_option); -                break; +                    break;              }              return error;          } @@ -4973,7 +4980,6 @@ public:              m_one_liner.clear();          } -          static OptionDefinition g_option_table[];          std::string m_class_name; @@ -4995,12 +5001,6 @@ public:          std::string m_one_liner;      }; -    Options * -    GetOptions () override -    { -        return &m_options; -    } -      CommandObjectTargetStopHookAdd (CommandInterpreter &interpreter) :          CommandObjectParsed (interpreter,                               "target stop-hook add", @@ -5011,8 +5011,12 @@ public:      {      } -    ~CommandObjectTargetStopHookAdd () override +    ~CommandObjectTargetStopHookAdd() override = default; + +    Options * +    GetOptions () override      { +        return &m_options;      }  protected: @@ -5106,7 +5110,7 @@ protected:                  }              } -            if (specifier_ap.get()) +            if (specifier_ap)                  new_hook_sp->SetSpecifier (specifier_ap.release());              // Next see if any of the thread options have been entered: @@ -5141,10 +5145,10 @@ protected:              else              {                  m_stop_hook_sp = new_hook_sp; -                m_interpreter.GetLLDBCommandsFromIOHandler ("> ",   // Prompt -                                                            *this,  // IOHandlerDelegate -                                                            true,   // Run IOHandler in async mode -                                                            NULL);  // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions +                m_interpreter.GetLLDBCommandsFromIOHandler("> ",   // Prompt +                                                           *this,  // IOHandlerDelegate +                                                           true,   // Run IOHandler in async mode +                                                           nullptr);  // Baton for the "io_handler" that will be passed back into our IOHandlerDelegate functions              }              result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -5157,6 +5161,7 @@ protected:          return result.Succeeded();      } +  private:      CommandOptions m_options;      Target::StopHookSP m_stop_hook_sp; @@ -5165,29 +5170,29 @@ private:  OptionDefinition  CommandObjectTargetStopHookAdd::CommandOptions::g_option_table[] =  { -    { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOneLiner, +    { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOneLiner,          "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, -    { LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, +    { LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eModuleCompletion, eArgTypeShlibName,          "Set the module within which the stop-hook is to be run."}, -    { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, +    { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadIndex,          "The stop hook is run only for the thread whose index matches this argument."}, -    { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID, +    { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadID,          "The stop hook is run only for the thread whose TID matches this argument."}, -    { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName, +    { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeThreadName,          "The stop hook is run only for the thread whose thread name matches this argument."}, -    { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName, +    { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeQueueName,          "The stop hook is run only for threads in the queue whose name is given by this argument."}, -    { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, +    { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,          "Specify the source file within which the stop-hook is to be run." }, -    { LLDB_OPT_SET_1, false, "start-line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, +    { LLDB_OPT_SET_1, false, "start-line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,          "Set the start of the line range for which the stop-hook is to be run."}, -    { LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, +    { LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum,          "Set the end of the line range for which the stop-hook is to be run."}, -    { LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeClassName, +    { LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeClassName,          "Specify the class within which the stop-hook is to be run." }, -    { LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, +    { LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,          "Set the function name within which the stop hook will be run." }, -    { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +    { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }  };  #pragma mark CommandObjectTargetStopHookDelete @@ -5199,7 +5204,6 @@ CommandObjectTargetStopHookAdd::CommandOptions::g_option_table[] =  class CommandObjectTargetStopHookDelete : public CommandObjectParsed  {  public: -      CommandObjectTargetStopHookDelete (CommandInterpreter &interpreter) :          CommandObjectParsed (interpreter,                               "target stop-hook delete", @@ -5208,9 +5212,7 @@ public:      {      } -    ~CommandObjectTargetStopHookDelete () override -    { -    } +    ~CommandObjectTargetStopHookDelete() override = default;  protected:      bool @@ -5265,6 +5267,7 @@ protected:          return result.Succeeded();      }  }; +  #pragma mark CommandObjectTargetStopHookEnableDisable  //------------------------------------------------------------------------- @@ -5274,7 +5277,6 @@ protected:  class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed  {  public: -      CommandObjectTargetStopHookEnableDisable (CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax) :          CommandObjectParsed (interpreter,                               name, @@ -5284,9 +5286,7 @@ public:      {      } -    ~CommandObjectTargetStopHookEnableDisable () override -    { -    } +    ~CommandObjectTargetStopHookEnableDisable() override = default;  protected:      bool @@ -5345,7 +5345,6 @@ private:  class CommandObjectTargetStopHookList : public CommandObjectParsed  {  public: -      CommandObjectTargetStopHookList (CommandInterpreter &interpreter) :          CommandObjectParsed (interpreter,                               "target stop-hook list", @@ -5354,9 +5353,7 @@ public:      {      } -    ~CommandObjectTargetStopHookList () override -    { -    } +    ~CommandObjectTargetStopHookList() override = default;  protected:      bool @@ -5391,6 +5388,7 @@ protected:  };  #pragma mark CommandObjectMultiwordTargetStopHooks +  //-------------------------------------------------------------------------  // CommandObjectMultiwordTargetStopHooks  //------------------------------------------------------------------------- @@ -5398,12 +5396,10 @@ protected:  class CommandObjectMultiwordTargetStopHooks : public CommandObjectMultiword  {  public: - -    CommandObjectMultiwordTargetStopHooks (CommandInterpreter &interpreter) : -        CommandObjectMultiword (interpreter,  -                                "target stop-hook", -                                "A set of commands for operating on debugger target stop-hooks.", -                                "target stop-hook <subcommand> [<subcommand-options>]") +    CommandObjectMultiwordTargetStopHooks(CommandInterpreter &interpreter) +        : CommandObjectMultiword(interpreter, "target stop-hook", +                                 "Commands for operating on debugger target stop-hooks.", +                                 "target stop-hook <subcommand> [<subcommand-options>]")      {          LoadSubCommand ("add",      CommandObjectSP (new CommandObjectTargetStopHookAdd (interpreter)));          LoadSubCommand ("delete",   CommandObjectSP (new CommandObjectTargetStopHookDelete (interpreter))); @@ -5420,26 +5416,19 @@ public:          LoadSubCommand ("list",     CommandObjectSP (new CommandObjectTargetStopHookList (interpreter)));      } -    ~CommandObjectMultiwordTargetStopHooks() override -    { -    } +    ~CommandObjectMultiwordTargetStopHooks() override = default;  }; - -  #pragma mark CommandObjectMultiwordTarget  //-------------------------------------------------------------------------  // CommandObjectMultiwordTarget  //------------------------------------------------------------------------- -CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) : -    CommandObjectMultiword (interpreter, -                            "target", -                            "A set of commands for operating on debugger targets.", -                            "target <subcommand> [<subcommand-options>]") +CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(CommandInterpreter &interpreter) +    : CommandObjectMultiword(interpreter, "target", "Commands for operating on debugger targets.", +                             "target <subcommand> [<subcommand-options>]")  { -      LoadSubCommand ("create",    CommandObjectSP (new CommandObjectTargetCreate (interpreter)));      LoadSubCommand ("delete",    CommandObjectSP (new CommandObjectTargetDelete (interpreter)));      LoadSubCommand ("list",      CommandObjectSP (new CommandObjectTargetList   (interpreter))); @@ -5450,8 +5439,4 @@ CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &      LoadSubCommand ("variable",  CommandObjectSP (new CommandObjectTargetVariable (interpreter)));  } -CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () -{ -} - - +CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget() = default;  | 
