diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /lldb/source/Commands/CommandObjectTarget.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
| -rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 129 |
1 files changed, 22 insertions, 107 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1cb21384fd2a..b25514b1ffbc 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -158,9 +158,9 @@ static constexpr OptionEnumValueElement g_dependents_enumaration[] = { class OptionGroupDependents : public OptionGroup { public: - OptionGroupDependents() {} + OptionGroupDependents() = default; - ~OptionGroupDependents() override {} + ~OptionGroupDependents() override = default; llvm::ArrayRef<OptionDefinition> GetDefinitions() override { return llvm::makeArrayRef(g_target_dependents_options); @@ -278,7 +278,6 @@ protected: result.AppendErrorWithFormatv("Cannot open '{0}': {1}.", core_file.GetPath(), llvm::toString(file.takeError())); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -293,7 +292,6 @@ protected: result.AppendErrorWithFormatv("Cannot open '{0}': {1}.", symfile.GetPath(), llvm::toString(file.takeError())); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -320,7 +318,6 @@ protected: if (!target_sp) { result.AppendError(error.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } @@ -344,7 +341,6 @@ protected: Status err = platform_sp->PutFile(file_spec, remote_file); if (err.Fail()) { result.AppendError(err.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -359,20 +355,17 @@ protected: Status err = platform_sp->GetFile(remote_file, file_spec); if (err.Fail()) { result.AppendError(err.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } } else { // make up a local file result.AppendError("remote --> local transfer without local " "path is not implemented yet"); - result.SetStatus(eReturnStatusFailed); return false; } } } else { result.AppendError("no platform found for target"); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -414,7 +407,6 @@ protected: if (error.Fail()) { result.AppendError( error.AsCString("can't find plug-in for core file")); - result.SetStatus(eReturnStatusFailed); return false; } else { result.AppendMessageWithFormatv( @@ -427,7 +419,6 @@ protected: result.AppendErrorWithFormatv( "Unable to find process plug-in for core file '{0}'\n", core_file.GetPath()); - result.SetStatus(eReturnStatusFailed); } } else { result.AppendMessageWithFormat( @@ -441,7 +432,6 @@ protected: result.AppendErrorWithFormat("'%s' takes exactly one executable path " "argument, or use the --core option.\n", m_cmd_name.c_str()); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); @@ -482,7 +472,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendError("the 'target list' command takes no arguments\n"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -524,17 +513,14 @@ protected: "index %u is out of range since there are no active targets\n", target_idx); } - result.SetStatus(eReturnStatusFailed); } } else { result.AppendErrorWithFormat("invalid index string value '%s'\n", target_idx_arg); - result.SetStatus(eReturnStatusFailed); } } else { result.AppendError( "'target select' takes a single argument: a target index\n"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -584,7 +570,6 @@ protected: // Bail out if don't have any targets. if (num_targets == 0) { result.AppendError("no targets to delete"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -593,7 +578,6 @@ protected: if (entry.ref().getAsInteger(0, target_idx)) { result.AppendErrorWithFormat("invalid target index '%s'\n", entry.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } if (target_idx < num_targets) { @@ -612,14 +596,12 @@ protected: "target index %u is out of range, the only valid index is 0\n", target_idx); - result.SetStatus(eReturnStatusFailed); return false; } } else { target_sp = target_list.GetSelectedTarget(); if (!target_sp) { result.AppendErrorWithFormat("no target is currently selected\n"); - result.SetStatus(eReturnStatusFailed); return false; } delete_target_list.push_back(target_sp); @@ -848,12 +830,10 @@ protected: size_t matches = 0; bool use_var_name = false; if (m_option_variable.use_regex) { - RegularExpression regex( - llvm::StringRef::withNullAsEmpty(arg.c_str())); + RegularExpression regex(arg.ref()); if (!regex.IsValid()) { result.GetErrorStream().Printf( "error: invalid regular expression: '%s'\n", arg.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } use_var_name = true; @@ -868,9 +848,8 @@ protected: } if (matches == 0) { - result.GetErrorStream().Printf( - "error: can't find global variable '%s'\n", arg.c_str()); - result.SetStatus(eReturnStatusFailed); + result.AppendErrorWithFormat("can't find global variable '%s'", + arg.c_str()); return false; } else { for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) { @@ -931,7 +910,6 @@ protected: } else result.AppendError("'target variable' takes one or more global " "variable names as arguments\n"); - result.SetStatus(eReturnStatusFailed); } } else { SymbolContextList sc_list; @@ -1054,7 +1032,6 @@ protected: const size_t argc = command.GetArgumentCount(); if (argc & 1) { result.AppendError("add requires an even number of arguments\n"); - result.SetStatus(eReturnStatusFailed); } else { for (size_t i = 0; i < argc; i += 2) { const char *from = command.GetArgumentAtIndex(i); @@ -1078,7 +1055,6 @@ protected: result.AppendError("<path-prefix> can't be empty\n"); else result.AppendError("<new-path-prefix> can't be empty\n"); - result.SetStatus(eReturnStatusFailed); } } } @@ -1186,7 +1162,6 @@ protected: result.AppendErrorWithFormat( "<index> parameter is not an integer: '%s'.\n", command.GetArgumentAtIndex(0)); - result.SetStatus(eReturnStatusFailed); return result.Succeeded(); } @@ -1208,13 +1183,11 @@ protected: result.AppendError("<path-prefix> can't be empty\n"); else result.AppendError("<new-path-prefix> can't be empty\n"); - result.SetStatus(eReturnStatusFailed); return false; } } } else { result.AppendError("insert requires at least three arguments\n"); - result.SetStatus(eReturnStatusFailed); return result.Succeeded(); } return result.Succeeded(); @@ -1239,7 +1212,6 @@ protected: Target *target = &GetSelectedTarget(); if (command.GetArgumentCount() != 0) { result.AppendError("list takes no arguments\n"); - result.SetStatus(eReturnStatusFailed); return result.Succeeded(); } @@ -1280,7 +1252,6 @@ protected: Target *target = &GetSelectedTarget(); if (command.GetArgumentCount() != 1) { result.AppendError("query requires one argument\n"); - result.SetStatus(eReturnStatusFailed); return result.Succeeded(); } @@ -1900,7 +1871,6 @@ protected: 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. @@ -1925,7 +1895,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendError("no matching executable images found"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -1970,7 +1939,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() : Options(), m_sort_order(eSortOrderNone) {} + CommandOptions() : Options() {} ~CommandOptions() override = default; @@ -2006,7 +1975,7 @@ public: return llvm::makeArrayRef(g_target_modules_dump_symtab_options); } - SortOrder m_sort_order; + SortOrder m_sort_order = eSortOrderNone; OptionValueBoolean m_prefer_mangled = {false, false}; }; @@ -2044,7 +2013,6 @@ protected: } } else { result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -2081,7 +2049,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); else { result.AppendError("no matching executable images found"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -2119,7 +2086,6 @@ protected: const size_t num_modules = target->GetImages().GetSize(); if (num_modules == 0) { result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -2168,7 +2134,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); else { result.AppendError("no matching executable images found"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -2198,7 +2163,6 @@ protected: const size_t num_modules = module_list.GetSize(); if (num_modules == 0) { result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -2276,7 +2240,6 @@ protected: const size_t num_modules = target_modules.GetSize(); if (num_modules == 0) { result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); return false; } result.GetOutputStream().Format( @@ -2316,7 +2279,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); else { result.AppendError("no matching executable images found"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -2352,7 +2314,6 @@ protected: if (command.GetArgumentCount() == 0) { result.AppendError("file option must be specified."); - result.SetStatus(eReturnStatusFailed); return result.Succeeded(); } else { // Dump specified images (by basename or fullpath) @@ -2389,7 +2350,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); else { result.AppendError("no source filenames matched any command arguments"); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -2535,7 +2495,6 @@ protected: "or symbol file with UUID %s", strm.GetData()); } - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -2544,13 +2503,11 @@ protected: result.AppendErrorWithFormat( "Unable to locate the executable or symbol file with UUID %s", strm.GetData()); - result.SetStatus(eReturnStatusFailed); return false; } } else { result.AppendError( "one or more executable image paths must be specified"); - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -2579,7 +2536,6 @@ protected: else result.AppendErrorWithFormat("unsupported module: %s", entry.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } else { flush = true; @@ -2587,7 +2543,6 @@ protected: result.SetStatus(eReturnStatusSuccessFinishResult); } else { std::string resolved_path = file_spec.GetPath(); - result.SetStatus(eReturnStatusFailed); if (resolved_path != entry.ref()) { result.AppendErrorWithFormat( "invalid module path '%s' with resolved path '%s'\n", @@ -2685,12 +2640,10 @@ protected: search_using_module_spec = false; result.AppendErrorWithFormat( "more than 1 module matched by name '%s'\n", arg_cstr); - result.SetStatus(eReturnStatusFailed); } else { search_using_module_spec = false; result.AppendErrorWithFormat("no object file for module '%s'\n", arg_cstr); - result.SetStatus(eReturnStatusFailed); } } @@ -2724,7 +2677,6 @@ protected: } else { result.AppendError("one or more section name + load " "address pair must be specified"); - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -2732,7 +2684,6 @@ protected: result.AppendError("The \"--slide <offset>\" option can't " "be used in conjunction with setting " "section load addresses.\n"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -2751,7 +2702,6 @@ protected: "thread specific sections are not yet " "supported (section '%s')\n", sect_name); - result.SetStatus(eReturnStatusFailed); break; } else { if (target->GetSectionLoadList() @@ -2766,13 +2716,11 @@ protected: "matches the section " "name '%s'\n", sect_name); - result.SetStatus(eReturnStatusFailed); break; } } else { result.AppendErrorWithFormat( "invalid load address string '%s'\n", load_addr_cstr); - result.SetStatus(eReturnStatusFailed); break; } } else { @@ -2782,7 +2730,6 @@ protected: else result.AppendError("one or more section name + load " "address pair must be specified.\n"); - result.SetStatus(eReturnStatusFailed); break; } } @@ -2825,7 +2772,6 @@ protected: result.AppendErrorWithFormat("failed to set PC value to " "0x%" PRIx64 "\n", file_entry_addr); - result.SetStatus(eReturnStatusFailed); } } } @@ -2833,13 +2779,11 @@ protected: module->GetFileSpec().GetPath(path, sizeof(path)); result.AppendErrorWithFormat("no sections in object file '%s'\n", path); - result.SetStatus(eReturnStatusFailed); } } else { module->GetFileSpec().GetPath(path, sizeof(path)); result.AppendErrorWithFormat("no object file for module '%s'\n", path); - result.SetStatus(eReturnStatusFailed); } } else { FileSpec *module_spec_file = module_spec.GetFileSpecPtr(); @@ -2848,7 +2792,6 @@ protected: result.AppendErrorWithFormat("invalid module '%s'.\n", path); } else result.AppendError("no module spec"); - result.SetStatus(eReturnStatusFailed); } } else { std::string uuid_str; @@ -2876,12 +2819,10 @@ protected: path[0] ? " file=" : "", path, !uuid_str.empty() ? " uuid=" : "", uuid_str.c_str()); } - result.SetStatus(eReturnStatusFailed); } } else { result.AppendError("either the \"--file <module>\" or the \"--uuid " "<uuid>\" option must be specified.\n"); - result.SetStatus(eReturnStatusFailed); return false; } return result.Succeeded(); @@ -2903,9 +2844,7 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { public: class CommandOptions : public Options { public: - CommandOptions() - : Options(), m_format_array(), m_use_global_module_list(false), - m_module_addr(LLDB_INVALID_ADDRESS) {} + CommandOptions() : Options(), m_format_array() {} ~CommandOptions() override = default; @@ -2940,8 +2879,8 @@ public: // Instance variables to hold the values for command options. typedef std::vector<std::pair<char, uint32_t>> FormatWidthCollection; FormatWidthCollection m_format_array; - bool m_use_global_module_list; - lldb::addr_t m_module_addr; + bool m_use_global_module_list = false; + lldb::addr_t m_module_addr = LLDB_INVALID_ADDRESS; }; CommandObjectTargetModulesList(CommandInterpreter &interpreter) @@ -2966,7 +2905,6 @@ protected: if (target == nullptr && !use_global_module_list) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); - result.SetStatus(eReturnStatusFailed); return false; } else { if (target) { @@ -2990,18 +2928,15 @@ protected: result.AppendErrorWithFormat( "Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr); - result.SetStatus(eReturnStatusFailed); } } else { result.AppendErrorWithFormat( "Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr); - result.SetStatus(eReturnStatusFailed); } } else { result.AppendError( "Can only look up modules by address with a valid target."); - result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); } @@ -3033,7 +2968,6 @@ protected: if (argc == 1) { result.AppendErrorWithFormat("no modules found that match '%s'", arg.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -3080,7 +3014,6 @@ protected: result.AppendError( "the target has no associated executable images"); } - result.SetStatus(eReturnStatusFailed); return false; } } @@ -3254,9 +3187,7 @@ public: class CommandOptions : public Options { public: - CommandOptions() - : Options(), m_type(eLookupTypeInvalid), m_str(), - m_addr(LLDB_INVALID_ADDRESS) {} + CommandOptions() : Options(), m_str() {} ~CommandOptions() override = default; @@ -3302,9 +3233,10 @@ public: // Instance variables to hold the values for command options. - int m_type; // Should be a eLookupTypeXXX enum after parsing options + int m_type = eLookupTypeInvalid; // Should be a eLookupTypeXXX enum after + // parsing options std::string m_str; // Holds name lookup - lldb::addr_t m_addr; // Holds the address to lookup + lldb::addr_t m_addr = LLDB_INVALID_ADDRESS; // Holds the address to lookup }; CommandObjectTargetModulesShowUnwind(CommandInterpreter &interpreter) @@ -3330,21 +3262,18 @@ protected: if (process == nullptr) { result.AppendError( "You must have a process running to use this command."); - result.SetStatus(eReturnStatusFailed); return false; } ThreadList threads(process->GetThreadList()); if (threads.GetSize() == 0) { result.AppendError("The process must be paused to use this command."); - result.SetStatus(eReturnStatusFailed); return false; } ThreadSP thread(threads.GetThreadAtIndex(0)); if (!thread) { result.AppendError("The process must be paused to use this command."); - result.SetStatus(eReturnStatusFailed); return false; } @@ -3369,7 +3298,6 @@ protected: } else { result.AppendError( "address-expression or function name option must be specified."); - result.SetStatus(eReturnStatusFailed); return false; } @@ -3377,7 +3305,6 @@ protected: if (num_matches == 0) { result.AppendErrorWithFormat("no unwind data found that matches '%s'.", m_options.m_str.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } @@ -3894,7 +3821,6 @@ protected: std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex()); if (target_modules.GetSize() == 0) { result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -4064,7 +3990,6 @@ protected: if (!symbol_fspec) { result.AppendError( "one or more executable image paths must be specified"); - result.SetStatus(eReturnStatusFailed); return false; } @@ -4146,7 +4071,6 @@ protected: "use the --uuid option to resolve the " "ambiguity.\n", symfile_path); - result.SetStatus(eReturnStatusFailed); return false; } @@ -4213,7 +4137,6 @@ protected: !llvm::sys::fs::is_regular_file(symbol_fspec.GetPath()) ? "\n please specify the full path to the symbol file" : ""); - result.SetStatus(eReturnStatusFailed); return false; } @@ -4425,11 +4348,7 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed, public: class CommandOptions : public OptionGroup { public: - CommandOptions() - : OptionGroup(), m_line_start(0), m_line_end(UINT_MAX), - m_func_name_type_mask(eFunctionNameTypeAuto), - m_sym_ctx_specified(false), m_thread_specified(false), - m_use_one_liner(false), m_one_liner() {} + CommandOptions() : OptionGroup(), m_line_end(UINT_MAX), m_one_liner() {} ~CommandOptions() override = default; @@ -4556,20 +4475,21 @@ public: std::string m_class_name; std::string m_function_name; - uint32_t m_line_start; + uint32_t m_line_start = 0; uint32_t m_line_end; std::string m_file_name; std::string m_module_name; - uint32_t m_func_name_type_mask; // A pick from lldb::FunctionNameType. + uint32_t m_func_name_type_mask = + eFunctionNameTypeAuto; // A pick from lldb::FunctionNameType. lldb::tid_t m_thread_id; uint32_t m_thread_index; std::string m_thread_name; std::string m_queue_name; - bool m_sym_ctx_specified; + bool m_sym_ctx_specified = false; bool m_no_inlines; - bool m_thread_specified; + bool m_thread_specified = false; // Instance variables to hold the values for one_liner options. - bool m_use_one_liner; + bool m_use_one_liner = false; std::vector<std::string> m_one_liner; bool m_auto_continue; @@ -4602,7 +4522,7 @@ Python Based Stop Hooks: When the stop hook is added, the class is initialized by calling: - def __init__(self, target, extra_args, dict): + def __init__(self, target, extra_args, internal_dict): target: The target that the stop hook is being added to. extra_args: An SBStructuredData Dictionary filled with the -key -value @@ -4780,7 +4700,6 @@ protected: // FIXME: Set the stop hook ID counter back. result.AppendErrorWithFormat("Couldn't add stop hook: %s", error.AsCString()); - result.SetStatus(eReturnStatusFailed); target.UndoCreateStopHook(new_hook_sp->GetID()); return false; } @@ -4841,13 +4760,11 @@ protected: if (!llvm::to_integer(command.GetArgumentAtIndex(i), user_id)) { result.AppendErrorWithFormat("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); - result.SetStatus(eReturnStatusFailed); return false; } if (!target.RemoveStopHookByID(user_id)) { result.AppendErrorWithFormat("unknown stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -4896,14 +4813,12 @@ protected: if (!llvm::to_integer(command.GetArgumentAtIndex(i), user_id)) { result.AppendErrorWithFormat("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); - result.SetStatus(eReturnStatusFailed); return false; } success = target.SetStopHookActiveStateByID(user_id, m_enable); if (!success) { result.AppendErrorWithFormat("unknown stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i)); - result.SetStatus(eReturnStatusFailed); return false; } } |
