67#include "llvm/ADT/ScopeExit.h"
68#include "llvm/ADT/SetVector.h"
82 m_plugin_up(
PluginManager::CreateArchitectureInstance(spec)) {}
91 static constexpr llvm::StringLiteral class_name(
"lldb.target");
119 static_cast<void *
>(
this));
122 "Target::Target created with architecture {0} ({1})",
124 target_arch.
GetTriple().getTriple().c_str());
132 LLDB_LOG(log,
"{0} Target::~Target()",
static_cast<void *
>(
this));
140 if (breakpoint_sp->IsInternal())
185 std::unique_lock<std::recursive_mutex> lock;
210 llvm::StringRef plugin_name,
217 listener_sp, crash_file, can_connect);
224 const char *repl_options,
bool can_create) {
232 language = *single_lang;
233 }
else if (repl_languages.
Empty()) {
235 "LLDB isn't configured with REPL support for any languages.");
239 "Multiple possible REPL languages. Please specify a language.");
244 REPLMap::iterator pos =
m_repl_map.find(language);
252 "Couldn't find an existing REPL for %s, and can't create a new one",
280 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
287 const bool notify =
false;
310 return abi_sp->GetPluginName();
341 ModuleSP main_module_sp = GetExecutableModule();
343 shared_lib_filter.
Append(main_module_sp->GetFileSpec());
344 llvm::SetVector<std::string, std::vector<std::string>,
345 std::unordered_set<std::string>>
350 error.SetErrorString(
"Language not found\n");
354 if (!entryPointName.empty())
355 entryPointNamesSet.insert(entryPointName);
357 if (entryPointNamesSet.empty()) {
358 error.SetErrorString(
"No entry point name found\n");
363 nullptr, entryPointNamesSet.takeVector(),
364 eFunctionNameTypeFull,
371 error.SetErrorString(
"Breakpoint creation failed.\n");
374 bp_sp->SetOneShot(
true);
381 const std::unordered_set<std::string> &function_names,
385 containingModules, source_file_spec_list));
389 nullptr, std::move(source_regex), function_names,
390 !
static_cast<bool>(move_to_nearest_code)));
396 const FileSpec &file, uint32_t line_no,
399 LazyBool skip_prologue,
bool internal,
403 std::optional<llvm::StringRef> removed_prefix_opt =
405 if (!removed_prefix_opt)
406 remapped_file = file;
410 switch (inline_strategy) {
431 compile_unit_list.
Append(remapped_file);
444 !
static_cast<bool>(move_to_nearest_code));
449 nullptr, offset, skip_prologue, location_spec, removed_prefix_opt));
485 bool request_hardware) {
489 nullptr, file_addr, file_spec));
496 const FileSpecList *containingSourceFiles,
const char *func_name,
497 FunctionNameType func_name_type_mask,
LanguageType language,
502 containingModules, containingSourceFiles));
511 offset, skip_prologue));
520 const std::vector<std::string> &func_names,
521 FunctionNameType func_name_type_mask,
523 LazyBool skip_prologue,
bool internal,
bool hardware) {
525 size_t num_names = func_names.size();
528 containingModules, containingSourceFiles));
537 language, offset, skip_prologue));
546 const char *func_names[],
size_t num_names,
547 FunctionNameType func_name_type_mask,
549 LazyBool skip_prologue,
bool internal,
bool hardware) {
553 containingModules, containingSourceFiles));
565 nullptr, func_names, num_names, func_name_type_mask, language, offset,
567 resolver_sp->SetOffset(offset);
576 if (containingModule !=
nullptr) {
579 filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
584 std::make_shared<SearchFilterForUnconstrainedSearches>(
594 if (containingModules && containingModules->
GetSize() != 0) {
597 filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
602 std::make_shared<SearchFilterForUnconstrainedSearches>(
612 if (containingSourceFiles ==
nullptr || containingSourceFiles->
GetSize() == 0)
616 if (containingModules ==
nullptr) {
620 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
621 shared_from_this(),
FileSpecList(), *containingSourceFiles);
623 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
624 shared_from_this(), *containingModules, *containingSourceFiles);
633 bool internal,
bool hardware) {
635 containingModules, containingSourceFiles));
638 :
static_cast<bool>(skip_prologue);
640 nullptr, std::move(func_regex), requested_language, 0, skip));
647 bool catch_bp,
bool throw_bp,
bool internal,
650 *
this, language, catch_bp, throw_bp, internal);
651 if (exc_bkpt_sp && additional_args) {
653 if (precondition_sp && additional_args) {
655 *
error = precondition_sp->ConfigurePrecondition(*additional_args);
657 precondition_sp->ConfigurePrecondition(*additional_args);
664 const llvm::StringRef class_name,
const FileSpecList *containingModules,
665 const FileSpecList *containingSourceFiles,
bool internal,
672 containingSourceFiles && containingSourceFiles->
GetSize() > 0;
673 bool has_modules = containingModules && containingModules->
GetSize() > 0;
675 if (has_files && has_modules) {
677 containingSourceFiles);
678 }
else if (has_files) {
681 }
else if (has_modules) {
684 filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
695 bool internal,
bool request_hardware,
696 bool resolve_indirect_symbols) {
698 if (filter_sp && resolver_sp) {
700 bp_sp.reset(
new Breakpoint(*
this, filter_sp, resolver_sp, hardware,
701 resolve_indirect_symbols));
702 resolver_sp->SetBreakpoint(bp_sp);
720 LLDB_LOGF(log,
"Target::%s (internal = %s) => break_id = %s\n",
721 __FUNCTION__, bp_sp->IsInternal() ?
"yes" :
"no", s.
GetData());
724 bp_sp->ResolveBreakpoint();
738 error.SetErrorStringWithFormat(
"Could not find breakpoint %s", s.
GetData());
754 bp_sp->AddName(name);
759 std::make_pair(bp_name->GetName(), std::move(bp_name)));
765 if (!
error.Success())
770 return iter->second.get();
774 error.SetErrorStringWithFormat(
"Breakpoint name \"%s\" doesn't exist and "
775 "can_create is false.",
781 .insert(std::make_pair(name, std::make_unique<BreakpointName>(name)))
782 .first->second.get();
789 const char *name_cstr = name.
AsCString();
792 bp_sp->RemoveName(name_cstr);
810 llvm::Expected<std::vector<BreakpointSP>> expected_vector =
813 if (!expected_vector) {
815 llvm::toString(expected_vector.takeError()));
819 for (
auto bp_sp : *expected_vector)
826 names.push_back(bp_name_entry.first.AsCString());
836 std::optional<uint32_t> num_supported_hardware_watchpoints =
841 if (!num_supported_hardware_watchpoints)
844 if (*num_supported_hardware_watchpoints == 0) {
845 error.SetErrorStringWithFormat(
846 "Target supports (%u) hardware watchpoint slots.\n",
847 *num_supported_hardware_watchpoints);
860 "Target::%s (addr = 0x%8.8" PRIx64
" size = %" PRIu64
862 __FUNCTION__, addr, (uint64_t)size, kind);
866 error.SetErrorString(
"process is not alive");
872 error.SetErrorString(
"cannot set a watchpoint with watch_size of 0");
874 error.SetErrorStringWithFormat(
"invalid watch address: %" PRIu64, addr);
879 error.SetErrorStringWithFormat(
"invalid watchpoint type: %d", kind);
889 const bool notify =
false;
894 addr = abi->FixDataAddress(addr);
908 std::unique_lock<std::recursive_mutex> lock;
912 size_t old_size = matched_sp->GetByteSize();
918 if (size == old_size && kind == old_type) {
920 wp_sp->SetEnabled(
false, notify);
929 wp_sp = std::make_shared<Watchpoint>(*
this, addr, size, type);
930 wp_sp->SetWatchpointType(kind, notify);
935 LLDB_LOGF(log,
"Target::%s (creation of watchpoint %s with id = %u)\n",
936 __FUNCTION__,
error.Success() ?
"succeeded" :
"failed",
951 LLDB_LOGF(log,
"Target::%s \n", __FUNCTION__);
960 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
961 internal_also ?
"yes" :
"no");
972 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
973 internal_also ?
"yes" :
"no");
982 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
989 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
990 internal_also ?
"yes" :
"no");
999 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
1006 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1026 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1036 bp_sp->SetEnabled(
false);
1044 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1055 bp_sp->SetEnabled(
true);
1071 error.SetErrorString(
"Invalid FileSpec.");
1075 std::string path(file.
GetPath());
1083 if (
error.Success()) {
1084 break_store_ptr = input_data_sp->
GetAsArray();
1085 if (!break_store_ptr) {
1086 error.SetErrorStringWithFormat(
1087 "Tried to append to invalid input file %s", path.c_str());
1093 if (!break_store_ptr) {
1094 break_store_sp = std::make_shared<StructuredData::Array>();
1095 break_store_ptr = break_store_sp.get();
1102 lldb::eFilePermissionsFileDefault);
1104 error.SetErrorStringWithFormat(
"Unable to open output file: %s.",
1109 std::unique_lock<std::recursive_mutex> lock;
1115 size_t num_breakpoints = breakpoints.
GetSize();
1116 for (
size_t i = 0; i < num_breakpoints; i++) {
1121 break_store_ptr->
AddItem(bkpt_save_sp);
1125 std::unordered_set<lldb::break_id_t> processed_bkpts;
1126 const size_t count = bp_ids.
GetSize();
1127 for (
size_t i = 0; i < count; ++i) {
1133 std::pair<std::unordered_set<lldb::break_id_t>::iterator,
bool>
1134 insert_result = processed_bkpts.insert(bp_id);
1135 if (!insert_result.second)
1142 if (!bkpt_save_sp) {
1143 error.SetErrorStringWithFormat(
"Unable to serialize breakpoint %d",
1147 break_store_ptr->
AddItem(bkpt_save_sp);
1152 break_store_ptr->
Dump(out_file,
false);
1159 std::vector<std::string> no_names;
1164 std::vector<std::string> &names,
1166 std::unique_lock<std::recursive_mutex> lock;
1172 if (!
error.Success()) {
1174 }
else if (!input_data_sp || !input_data_sp->IsValid()) {
1175 error.SetErrorStringWithFormat(
"Invalid JSON from input file: %s.",
1182 error.SetErrorStringWithFormat(
1183 "Invalid breakpoint data from input file: %s.", file.
GetPath().c_str());
1187 size_t num_bkpts = bkpt_array->
GetSize();
1188 size_t num_names = names.size();
1190 for (
size_t i = 0; i < num_bkpts; i++) {
1195 error.SetErrorStringWithFormat(
1196 "Invalid breakpoint data for element %zu from input file: %s.", i,
1207 shared_from_this(), bkpt_data_sp,
error);
1208 if (!
error.Success()) {
1209 error.SetErrorStringWithFormat(
1210 "Error restoring breakpoint %zu from %s: %s.", i,
1226 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1255 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1282 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1308 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1314 wp_sp->ResetHitCount();
1322 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1328 wp_sp->ResetHistoricValues();
1337 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1346 wp_sp->SetIgnoreCount(ignore_count);
1354 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1373 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1392 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1407 uint32_t ignore_count) {
1409 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1416 wp_sp->SetIgnoreCount(ignore_count);
1444 if (module_sp && !module_sp->LoadScriptingResourceInTarget(target,
error,
1446 if (
error.AsCString())
1448 "unable to load scripting data for module %s - error reported was "
1450 module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1453 if (feedback_stream.
GetSize())
1476 if (executable_sp) {
1479 executable_sp->GetFileSpec().GetPath().c_str());
1481 const bool notify =
true;
1488 m_arch = executable_sp->GetArchitecture();
1490 "Target::SetExecutableModule setting architecture to {0} ({1}) "
1491 "based on executable file",
1497 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
1498 bool load_dependents =
true;
1499 switch (load_dependent_files) {
1501 load_dependents = executable_sp->IsExecutable();
1504 load_dependents =
true;
1507 load_dependents =
false;
1511 if (executable_objfile && load_dependents) {
1514 for (uint32_t i = 0; i < dependent_files.
GetSize(); i++) {
1516 FileSpec platform_dependent_file_spec;
1518 m_platform_sp->GetFileWithUUID(dependent_file_spec,
nullptr,
1519 platform_dependent_file_spec);
1521 platform_dependent_file_spec = dependent_file_spec;
1526 if (image_module_sp) {
1528 ObjectFile *objfile = image_module_sp->GetObjectFile();
1542 bool replace_local_arch =
true;
1543 bool compatible_local_arch =
false;
1552 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
1556 GetDebugger().GetPlatformList().GetOrCreate(other, {},
1560 other = platform_arch;
1566 if (!missing_local_arch) {
1571 compatible_local_arch =
true;
1574 replace_local_arch =
false;
1579 if (compatible_local_arch || missing_local_arch) {
1583 if (replace_local_arch)
1586 "Target::SetArchitecture merging compatible arch; arch "
1597 "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
1599 arch_spec.
GetTriple().getTriple().c_str(),
1608 if (executable_sp) {
1610 "Target::SetArchitecture Trying to select executable file "
1611 "architecture %s (%s)",
1613 arch_spec.
GetTriple().getTriple().c_str());
1614 ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
1617 &search_paths,
nullptr,
nullptr);
1619 if (!
error.Fail() && executable_sp) {
1635 "Target::MergeArchitecture target has arch %s, merging with "
1638 arch_spec.
GetTriple().getTriple().c_str());
1659 my_module_list.
Append(module_sp);
1669 my_module_list.
Append(module_sp);
1682 old_module_sp, new_module_sp);
1691 const size_t num_images = module_list.
GetSize();
1693 for (
size_t idx = 0; idx < num_images; ++idx) {
1703 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1712 runtime->SymbolsDidLoad(module_list);
1719 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1728 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1742 const bool should_flush_type_systems =
1749 auto type = object_file->
GetType();
1759 if (should_flush_type_systems)
1765 const FileSpec &module_file_spec) {
1770 size_t num_modules = matchingModules.
GetSize();
1774 if (num_modules > 0) {
1775 for (
size_t i = 0; i < num_modules; i++) {
1790 return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*
this,
1802 if (section_sp->IsEncrypted()) {
1803 error.SetErrorString(
"section is encrypted");
1806 ModuleSP module_sp(section_sp->GetModule());
1811 section_sp.get(), addr.
GetOffset(), dst, dst_len);
1815 error.SetErrorStringWithFormat(
"error reading data from section %s",
1816 section_sp->GetName().GetCString());
1818 error.SetErrorString(
"address isn't from a object file");
1820 error.SetErrorString(
"address isn't in a module");
1822 error.SetErrorString(
"address doesn't contain a section that points to a "
1823 "section in a object file");
1844 size_t bytes_read = 0;
1851 if (section_load_list.
IsEmpty()) {
1870 resolved_addr = fixed_addr;
1875 std::unique_ptr<uint8_t[]> file_cache_read_buffer;
1876 size_t file_cache_bytes_read = 0;
1882 auto permissions =
Flags(section_sp->GetPermissions());
1883 bool is_readonly = !permissions.Test(ePermissionsWritable) &&
1884 permissions.Test(ePermissionsReadable);
1886 file_cache_bytes_read =
1888 if (file_cache_bytes_read == dst_len)
1889 return file_cache_bytes_read;
1890 else if (file_cache_bytes_read > 0) {
1891 file_cache_read_buffer =
1892 std::make_unique<uint8_t[]>(file_cache_bytes_read);
1893 std::memcpy(file_cache_read_buffer.get(), dst, file_cache_bytes_read);
1905 if (addr_module_sp && addr_module_sp->GetFileSpec())
1906 error.SetErrorStringWithFormatv(
1907 "{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
1910 error.SetErrorStringWithFormat(
"0x%" PRIx64
" can't be resolved",
1914 if (bytes_read != dst_len) {
1915 if (
error.Success()) {
1916 if (bytes_read == 0)
1917 error.SetErrorStringWithFormat(
1918 "read memory from 0x%" PRIx64
" failed", load_addr);
1920 error.SetErrorStringWithFormat(
1921 "only %" PRIu64
" of %" PRIu64
1922 " bytes were read from memory at 0x%" PRIx64,
1923 (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
1928 *load_addr_ptr = load_addr;
1934 if (file_cache_read_buffer && file_cache_bytes_read > 0) {
1937 std::memcpy(dst, file_cache_read_buffer.get(), file_cache_bytes_read);
1938 return file_cache_bytes_read;
1960 out_str.append(buf, length);
1963 if (length ==
sizeof(buf) - 1)
1964 curr_addr += length;
1969 return out_str.size();
1973 size_t dst_max_len,
Status &result_error,
1974 bool force_live_memory) {
1975 size_t total_cstr_len = 0;
1976 if (dst && dst_max_len) {
1977 result_error.
Clear();
1979 memset(dst, 0, dst_max_len);
1987 const size_t cache_line_size = 512;
1989 size_t bytes_left = dst_max_len - 1;
1990 char *curr_dst = dst;
1992 while (bytes_left > 0) {
1993 addr_t cache_line_bytes_left =
1994 cache_line_size - (curr_addr % cache_line_size);
1996 std::min<addr_t>(bytes_left, cache_line_bytes_left);
1997 size_t bytes_read =
ReadMemory(address, curr_dst, bytes_to_read,
error,
2000 if (bytes_read == 0) {
2001 result_error =
error;
2002 dst[total_cstr_len] =
'\0';
2005 const size_t len = strlen(curr_dst);
2007 total_cstr_len += len;
2009 if (len < bytes_to_read)
2012 curr_dst += bytes_read;
2013 curr_addr += bytes_read;
2014 bytes_left -= bytes_read;
2021 result_error.
Clear();
2023 return total_cstr_len;
2031 return cache_line_size - (load_addr % cache_line_size);
2041 size_t type_width,
bool force_live_memory) {
2042 if (!dst || !max_bytes || !type_width || max_bytes < type_width)
2045 size_t total_bytes_read = 0;
2049 memset(dst, 0, max_bytes);
2050 size_t bytes_left = max_bytes - type_width;
2052 const char terminator[4] = {
'\0',
'\0',
'\0',
'\0'};
2053 assert(
sizeof(terminator) >= type_width &&
"Attempting to validate a "
2054 "string with more than 4 bytes "
2058 char *curr_dst = dst;
2061 while (bytes_left > 0 &&
error.Success()) {
2065 ReadMemory(address, curr_dst, bytes_to_read,
error, force_live_memory);
2067 if (bytes_read == 0)
2072 size_t aligned_start = total_bytes_read - total_bytes_read % type_width;
2073 for (
size_t i = aligned_start;
2074 i + type_width <= total_bytes_read + bytes_read; i += type_width)
2075 if (::memcmp(&dst[i], terminator, type_width) == 0) {
2080 total_bytes_read += bytes_read;
2081 curr_dst += bytes_read;
2082 address.
Slide(bytes_read);
2083 bytes_left -= bytes_read;
2085 return total_bytes_read;
2089 bool is_signed,
Scalar &scalar,
2091 bool force_live_memory) {
2094 if (byte_size <=
sizeof(uval)) {
2097 if (bytes_read == byte_size) {
2102 scalar = data.
GetMaxU32(&offset, byte_size);
2104 scalar = data.
GetMaxU64(&offset, byte_size);
2111 error.SetErrorStringWithFormat(
2112 "byte size of %u is too large for integer scalar type", byte_size);
2118 size_t integer_byte_size,
2120 bool force_live_memory) {
2130 bool force_live_memory) {
2133 false, scalar,
error, force_live_memory)) {
2137 if (section_load_list.
IsEmpty()) {
2151 pointer_addr.
SetOffset(pointer_vm_addr);
2159 bool notify,
Status *error_ptr) {
2167 if (std::optional<FileSpec> remapped_obj_file =
2181 llvm::SmallVector<ModuleSP, 1>
2184 bool did_create_module =
false;
2194 module_spec, module_sp, symbol_file_spec, &did_create_module);
2225 &search_paths, &old_modules,
2226 &did_create_module);
2244 &old_modules, &did_create_module);
2252 module_spec,
m_process_sp.get(), module_sp, &search_paths,
2253 &old_modules, &did_create_module);
2255 error.SetErrorString(
"no platform is currently set");
2264 ObjectFile *objfile = module_sp->GetObjectFile();
2279 error_ptr->
SetErrorString(
"debug info files aren't valid target "
2280 "modules, please specify an executable");
2287 "modules, please specify an executable");
2292 "unsupported file type, please specify an executable");
2313 old_modules.push_back(found_module);
2320 if (symbol_file_spec)
2321 module_sp->SetSymbolFileFileSpec(symbol_file_spec);
2326 module_sp->PreloadSymbols();
2327 llvm::SmallVector<ModuleSP, 1> replaced_modules;
2328 for (
ModuleSP &old_module_sp : old_modules) {
2331 if (replaced_modules.empty())
2336 replaced_modules.push_back(std::move(old_module_sp));
2340 if (replaced_modules.size() > 1) {
2353 auto dump = [&message](
Module &dump_module) ->
void {
2354 UUID dump_uuid = dump_module.GetUUID();
2358 message <<
" (uuid ";
2361 dump_uuid.
Dump(message);
2363 message <<
"not specified";
2368 message <<
"New module ";
2371 << llvm::formatv(
" simultaneously replaced {0} old modules: ",
2372 replaced_modules.size());
2373 for (
ModuleSP &replaced_module_sp : replaced_modules)
2374 dump(*replaced_module_sp);
2380 if (replaced_modules.empty())
2383 for (
ModuleSP &old_module_sp : replaced_modules) {
2384 Module *old_module_ptr = old_module_sp.get();
2385 old_module_sp.reset();
2422llvm::Expected<lldb::TypeSystemSP>
2424 bool create_on_demand) {
2426 return llvm::createStringError(
"Invalid Target");
2438 if (languages_for_expressions.
Empty())
2439 return llvm::createStringError(
2440 "No expression support for any languages");
2451 uint32_t byte_size) {
2454 return provider->GetRegisterType(name, flags, byte_size);
2457std::vector<lldb::TypeSystemSP>
2465 std::vector<lldb::TypeSystemSP> scratch_type_systems;
2470 for (
auto bit : languages_for_expressions.
bitvector.set_bits()) {
2472 auto type_system_or_err =
2474 if (!type_system_or_err)
2477 "Language '{1}' has expression support but no scratch type "
2478 "system available: {0}",
2481 if (
auto ts = *type_system_or_err)
2482 scratch_type_systems.push_back(ts);
2485 std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
2486 scratch_type_systems.erase(
2487 std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
2488 scratch_type_systems.end());
2489 return scratch_type_systems;
2496 if (
auto err = type_system_or_err.takeError()) {
2499 "Unable to get persistent expression state for language {1}: {0}",
2504 if (
auto ts = *type_system_or_err)
2505 return ts->GetPersistentExpressionState();
2508 "Unable to get persistent expression state for language {1}: {0}",
2514 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
2518 auto type_system_or_err =
2520 if (
auto err = type_system_or_err.takeError()) {
2521 error.SetErrorStringWithFormat(
2522 "Could not find type system for language %s: %s",
2524 llvm::toString(std::move(err)).c_str());
2528 auto ts = *type_system_or_err;
2530 error.SetErrorStringWithFormat(
2531 "Type system for language %s is no longer live",
2536 auto *user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
2539 error.SetErrorStringWithFormat(
2540 "Could not create an expression for language %s",
2551 if (
auto err = type_system_or_err.takeError()) {
2552 error.SetErrorStringWithFormat(
2553 "Could not find type system for language %s: %s",
2555 llvm::toString(std::move(err)).c_str());
2558 auto ts = *type_system_or_err;
2560 error.SetErrorStringWithFormat(
2561 "Type system for language %s is no longer live",
2565 auto *persistent_fn = ts->GetFunctionCaller(return_type, function_address,
2566 arg_value_list, name);
2568 error.SetErrorStringWithFormat(
2569 "Could not create an expression for language %s",
2572 return persistent_fn;
2575llvm::Expected<std::unique_ptr<UtilityFunction>>
2580 if (!type_system_or_err)
2581 return type_system_or_err.takeError();
2582 auto ts = *type_system_or_err;
2584 return llvm::createStringError(
2585 llvm::StringRef(
"Type system for language ") +
2587 llvm::StringRef(
" is no longer live"));
2588 std::unique_ptr<UtilityFunction> utility_fn =
2589 ts->CreateUtilityFunction(std::move(expression), std::move(name));
2591 return llvm::createStringError(
2592 llvm::StringRef(
"Could not create an expression for language") +
2596 if (!utility_fn->Install(diagnostics, exe_ctx))
2597 return llvm::createStringError(diagnostics.
GetString());
2599 return std::move(utility_fn);
2620 "setting target's default architecture to {0} ({1})",
2627 if (llvm::to_integer(label, n))
2628 return llvm::createStringError(
"Cannot use integer as target label.");
2632 if (target_sp && target_sp->GetLabel() == label) {
2633 return llvm::make_error<llvm::StringError>(
2635 "Cannot use label '{0}' since it's set in target #{1}.", label,
2637 llvm::inconvertibleErrorCode());
2642 return llvm::Error::success();
2651 Target *target =
nullptr;
2652 if (sc_ptr !=
nullptr)
2654 if (target ==
nullptr && exe_ctx_ptr)
2664 result_valobj_sp.reset();
2670 return execution_results;
2676 auto on_exit = llvm::make_scope_exit([
this, old_suppress_value]() {
2694 if (expr[0] ==
'$') {
2695 auto type_system_or_err =
2697 if (
auto err = type_system_or_err.takeError()) {
2699 "Unable to get scratch type system");
2701 auto ts = *type_system_or_err;
2704 "Scratch type system is no longer live: {0}");
2707 ts->GetPersistentExpressionState()->GetVariable(expr);
2710 if (persistent_var_sp) {
2711 result_valobj_sp = persistent_var_sp->GetValueObject();
2717 result_valobj_sp,
error,
2718 fixed_expression, ctx_obj);
2720 if (
error.Fail() && !result_valobj_sp)
2722 exe_ctx.GetBestExecutionContextScope(),
error);
2729 return execution_results;
2735 [name, &variable_sp](
TypeSystemSP type_system) ->
bool {
2736 auto ts = type_system.get();
2740 ts->GetPersistentExpressionState()) {
2741 variable_sp = persistent_state->GetVariable(name);
2756 auto ts = type_system.get();
2761 ts->GetPersistentExpressionState()) {
2762 address = persistent_state->LookupSymbol(name);
2763 if (address != LLDB_INVALID_ADDRESS)
2775 const bool has_primary_executable = exe_module && exe_module->
GetObjectFile();
2776 if (has_primary_executable) {
2783 const size_t num_images = modules.
GetSize();
2784 for (
size_t idx = 0; idx < num_images; ++idx) {
2786 if (!module_sp || !module_sp->GetObjectFile())
2789 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2795 if (!has_primary_executable)
2796 return llvm::createStringError(
2797 "No primary executable found and could not find entry point address in "
2798 "any executable module");
2800 return llvm::createStringError(
2801 "Could not find entry point address for primary executable module \"" +
2809 ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
2816 return arch_plugin ? arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class)
2822 return arch_plugin ? arch_plugin->GetBreakableLoadAddress(addr, *
this) : addr;
2843 return stop_hook_sp;
2855 return (num_removed != 0);
2863 StopHookCollection::iterator specified_hook_iter;
2866 found_hook = (*specified_hook_iter).second;
2871 bool active_state) {
2872 StopHookCollection::iterator specified_hook_iter;
2877 (*specified_hook_iter).second->SetIsActive(active_state);
2882 StopHookCollection::iterator pos, end =
m_stop_hooks.end();
2884 (*pos).second->SetIsActive(active_state);
2904 bool any_active_hooks =
false;
2906 if (hook.second->IsActive()) {
2907 any_active_hooks =
true;
2911 if (!any_active_hooks)
2920 uint32_t last_natural_stop =
m_process_sp->GetModIDRef().GetLastNaturalStopID();
2926 std::vector<ExecutionContext> exc_ctx_with_reasons;
2929 size_t num_threads = cur_threadlist.
GetSize();
2930 for (
size_t i = 0; i < num_threads; i++) {
2932 if (cur_thread_sp->ThreadStoppedForAReason()) {
2934 exc_ctx_with_reasons.emplace_back(
m_process_sp.get(), cur_thread_sp.get(),
2935 cur_frame_sp.get());
2940 size_t num_exe_ctx = exc_ctx_with_reasons.size();
2941 if (num_exe_ctx == 0)
2946 bool auto_continue =
false;
2947 bool hooks_ran =
false;
2949 bool print_thread_header = (num_exe_ctx != 1);
2950 bool should_stop =
false;
2951 bool somebody_restarted =
false;
2955 if (!cur_hook_sp->IsActive())
2958 bool any_thread_matched =
false;
2959 for (
auto exc_ctx : exc_ctx_with_reasons) {
2962 if (somebody_restarted)
2965 if (!cur_hook_sp->ExecutionContextPasses(exc_ctx))
2970 auto_continue |= cur_hook_sp->GetAutoContinue();
2975 if (print_hook_header && !any_thread_matched) {
2979 output_sp->
Printf(
"\n- Hook %" PRIu64
" (%s)\n", cur_hook_sp->GetID(),
2982 output_sp->Printf(
"\n- Hook %" PRIu64
"\n", cur_hook_sp->GetID());
2983 any_thread_matched =
true;
2986 if (print_thread_header)
2987 output_sp->Printf(
"-- Thread %d\n",
2988 exc_ctx.GetThreadPtr()->GetIndexID());
2991 cur_hook_sp->HandleStop(exc_ctx, output_sp);
2992 bool this_should_stop =
true;
2994 switch (this_result) {
2998 if (cur_hook_sp->GetAutoContinue())
2999 this_should_stop =
false;
3001 this_should_stop =
true;
3005 this_should_stop =
false;
3011 output_sp->Printf(
"\nAborting stop hooks, hook %" PRIu64
3012 " set the program running.\n"
3013 " Consider using '-G true' to make "
3014 "stop hooks auto-continue.\n",
3015 cur_hook_sp->GetID());
3016 somebody_restarted =
true;
3023 if (somebody_restarted)
3028 should_stop = this_should_stop;
3036 if (somebody_restarted)
3042 if ((hooks_ran && !should_stop) || auto_continue) {
3045 if (
error.Success()) {
3046 LLDB_LOG(log,
"Resuming from RunStopHooks");
3049 LLDB_LOG(log,
"Resuming from RunStopHooks failed: {0}",
error);
3062 return *g_settings_ptr;
3069 if (platform_sp->IsRemote()) {
3070 if (platform_sp->IsConnected()) {
3076 const size_t num_images = modules.
GetSize();
3077 for (
size_t idx = 0; idx < num_images; ++idx) {
3081 FileSpec local_file(module_sp->GetFileSpec());
3083 FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
3087 remote_file = platform_sp->GetRemoteWorkingDirectory();
3089 module_sp->GetFileSpec().GetFilename().GetCString());
3093 error = platform_sp->Install(local_file, remote_file);
3094 if (
error.Success()) {
3095 module_sp->SetPlatformFileSpec(remote_file);
3096 if (is_main_executable) {
3097 platform_sp->SetFilePermissions(remote_file, 0700);
3124 addr_t new_section_load_addr,
3125 bool warn_multiple) {
3126 const addr_t old_section_load_addr =
3129 if (old_section_load_addr != new_section_load_addr) {
3130 uint32_t stop_id = 0;
3133 stop_id = process_sp->GetStopID();
3137 stop_id, section_sp, new_section_load_addr, warn_multiple))
3144 size_t section_unload_count = 0;
3145 size_t num_modules = module_list.
GetSize();
3146 for (
size_t i = 0; i < num_modules; ++i) {
3147 section_unload_count +=
3150 return section_unload_count;
3154 uint32_t stop_id = 0;
3157 stop_id = process_sp->GetStopID();
3160 SectionList *sections = module_sp->GetSectionList();
3161 size_t section_unload_count = 0;
3164 for (uint32_t i = 0; i < num_sections; ++i) {
3169 return section_unload_count;
3173 uint32_t stop_id = 0;
3176 stop_id = process_sp->GetStopID();
3184 uint32_t stop_id = 0;
3187 stop_id = process_sp->GetStopID();
3212 LLDB_LOGF(log,
"Target::%s() called for %s", __FUNCTION__,
3224 state = process_sp->GetState();
3226 "Target::%s the process exists, and its current state is %s",
3229 LLDB_LOGF(log,
"Target::%s the process instance doesn't currently exist.",
3242 const bool synchronous_execution =
3250 if (launch_info.
GetFlags().
Test(eLaunchFlagLaunchInTTY)) {
3251 error.SetErrorString(
3252 "can't launch in tty when launching through a remote connection");
3272 LLDB_LOGF(log,
"Target::%s asking the platform to debug the process",
3286 "Target::%s the platform doesn't know how to debug a "
3287 "process, getting a process plugin to do this for us.",
3307 error.SetErrorString(
"failed to launch or debug process");
3309 if (!
error.Success())
3312 bool rebroadcast_first_stop =
3313 !synchronous_execution &&
3319 state =
m_process_sp->WaitForProcessToStop(std::nullopt, &first_stop_event_sp,
3320 rebroadcast_first_stop,
3324 if (rebroadcast_first_stop) {
3325 assert(first_stop_event_sp);
3332 if (launch_info.
GetFlags().
Test(eLaunchFlagStopAtEntry))
3334 if (synchronous_execution)
3341 if (!
error.Success()) {
3344 "process resume at entry point failed: %s",
error.AsCString());
3349 bool with_shell = !!launch_info.
GetShell();
3351 const char *exit_desc =
m_process_sp->GetExitDescription();
3353 if (exit_desc && exit_desc[0])
3354 desc =
" (" + std::string(exit_desc) +
')';
3356 error.SetErrorStringWithFormat(
3357 "process exited with status %i%s\n"
3358 "'r' and 'run' are aliases that default to launching through a "
3360 "Try launching without going through a shell by using "
3361 "'process launch'.",
3362 exit_status, desc.c_str());
3364 error.SetErrorStringWithFormat(
"process exited with status %i%s",
3365 exit_status, desc.c_str());
3368 error.SetErrorStringWithFormat(
"initial process state wasn't stopped: %s",
3381 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3382 "A process is required for tracing");
3384 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3385 "A trace already exists for the target");
3387 llvm::Expected<TraceSupportedResponse> trace_type =
3390 return llvm::createStringError(
3391 llvm::inconvertibleErrorCode(),
"Tracing is not supported. %s",
3392 llvm::toString(trace_type.takeError()).c_str());
3393 if (llvm::Expected<TraceSP> trace_sp =
3397 return llvm::createStringError(
3398 llvm::inconvertibleErrorCode(),
3399 "Couldn't create a Trace object for the process. %s",
3400 llvm::toString(trace_sp.takeError()).c_str());
3415 state = process_sp->GetState();
3418 return Status(
"process attach is in progress");
3419 return Status(
"a process is already being debugged");
3428 if (old_exec_module_sp)
3430 old_exec_module_sp->GetPlatformFileSpec().GetFilename());
3433 return Status(
"no process specified, create a target with a file, or "
3434 "specify the --pid or --name");
3438 const auto platform_sp =
3441 const bool async = attach_info.
GetAsync();
3459 plugin_name,
nullptr,
false);
3461 error.SetErrorStringWithFormatv(
3462 "failed to create process using plugin '{0}'",
3463 plugin_name.empty() ?
"<empty>" : plugin_name);
3467 if (hijack_listener_sp)
3468 process_sp->HijackProcessEvents(hijack_listener_sp);
3469 error = process_sp->Attach(attach_info);
3472 if (
error.Success() && process_sp) {
3474 process_sp->RestoreProcessEvents();
3477 state = process_sp->WaitForProcessToStop(
3480 process_sp->RestoreProcessEvents();
3483 const char *exit_desc = process_sp->GetExitDescription();
3485 error.SetErrorStringWithFormat(
"%s", exit_desc);
3487 error.SetErrorString(
3488 "process did not stop (no such process or permission problem?)");
3489 process_sp->Destroy(
false);
3502 const bool default_to_use_pty =
3506 "have platform={0}, platform_sp->IsHost()={1}, default_to_use_pty={2}",
3508 platform_sp ? (platform_sp->IsHost() ?
"true" :
"false") :
"n/a",
3509 default_to_use_pty);
3516 LLDB_LOG(log,
"at least one of stdin/stdout/stderr was not set, evaluating "
3517 "default handling");
3526 LLDB_LOG(log,
"eLaunchFlagDisableSTDIO set, adding suppression action "
3527 "for stdin, stdout and stderr");
3547 LLDB_LOG(log,
"target stdin='{0}', target stdout='{1}', stderr='{1}'",
3548 in_file_spec, out_file_spec, err_file_spec);
3552 LLDB_LOG(log,
"appended stdin open file action for {0}", in_file_spec);
3555 if (out_file_spec) {
3557 LLDB_LOG(log,
"appended stdout open file action for {0}",
3561 if (err_file_spec) {
3563 LLDB_LOG(log,
"appended stderr open file action for {0}",
3567 if (default_to_use_pty) {
3569 LLDB_LOG_ERROR(log, std::move(Err),
"SetUpPtyRedirection failed: {0}");
3586 elem.notify = notify;
3596 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3601 signals_sp->SetShouldSuppress(signo,
false);
3603 signals_sp->SetShouldSuppress(signo,
true);
3606 signals_sp->SetShouldNotify(signo,
true);
3608 signals_sp->SetShouldNotify(signo,
false);
3611 signals_sp->SetShouldStop(signo,
true);
3613 signals_sp->SetShouldStop(signo,
false);
3622 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3628 signals_sp->ResetSignal(signo, do_stop, do_notify, do_pass);
3639 warning_stream_sp->Printf(
"Target signal '%s' not found in process\n",
3640 elem.first().str().c_str());
3653 signals_sp = process_sp->GetUnixSignals();
3656 const char *signal_name = entry.c_str();
3670 strm.
Printf(
"NAME PASS STOP NOTIFY\n");
3671 strm.
Printf(
"=========== ======= ======= =======\n");
3673 auto str_for_lazy = [] (
LazyBool lazy) ->
const char * {
3679 llvm_unreachable(
"Fully covered switch above!");
3683 bool print_it =
false;
3684 for (
size_t idx = 0; idx < num_args; idx++) {
3691 strm.
Printf(
"%-11s ", elem.first().str().c_str());
3692 strm.
Printf(
"%s %s %s\n", str_for_lazy(elem.second.pass),
3693 str_for_lazy(elem.second.stop),
3694 str_for_lazy(elem.second.notify));
3701 :
UserID(uid), m_target_sp(target_sp), m_specifier_sp(),
3702 m_thread_spec_up() {}
3705 :
UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
3706 m_specifier_sp(rhs.m_specifier_sp), m_thread_spec_up(),
3707 m_active(rhs.m_active), m_auto_continue(rhs.m_auto_continue) {
3713 m_specifier_sp.reset(specifier);
3717 m_thread_spec_up.reset(specifier);
3725 bool will_run =
true;
3727 will_run = GetSpecifier()->SymbolContextMatches(
3729 if (will_run && GetThreadSpecifier() !=
nullptr)
3731 GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx.
GetThreadRef());
3741 GetSubclassDescription(s, level);
3749 s.
Printf(
"Hook: %" PRIu64
"\n", GetID());
3751 s.
Indent(
"State: enabled\n");
3753 s.
Indent(
"State: disabled\n");
3755 if (m_auto_continue)
3756 s.
Indent(
"AutoContinue on\n");
3758 if (m_specifier_sp) {
3762 m_specifier_sp->GetDescription(&s, level);
3766 if (m_thread_spec_up) {
3769 m_thread_spec_up->GetDescription(&tmp, level);
3775 GetSubclassDescription(s, level);
3782 if (m_commands.GetSize() == 1)
3783 s.
PutCString(m_commands.GetStringAtIndex(0));
3786 s.
Indent(
"Commands: \n");
3788 uint32_t num_commands = m_commands.GetSize();
3789 for (uint32_t i = 0; i < num_commands; i++) {
3790 s.
Indent(m_commands.GetStringAtIndex(i));
3798 GetCommands().SplitIntoLines(
string);
3802 const std::vector<std::string> &strings) {
3803 for (
auto string : strings)
3804 GetCommands().AppendString(
string.c_str());
3810 assert(exc_ctx.
GetTargetPtr() &&
"Can't call PerformAction on a context "
3813 if (!m_commands.GetSize())
3814 return StopHookResult::KeepStopped;
3837 return StopHookResult::AlreadyContinued;
3838 return StopHookResult::KeepStopped;
3847 GetTarget()->GetDebugger().GetScriptInterpreter();
3848 if (!script_interp) {
3849 error.SetErrorString(
"No script interpreter installed.");
3853 m_class_name = class_name;
3854 m_extra_args.SetObjectSP(extra_args_sp);
3857 GetTarget(), m_class_name.c_str(), m_extra_args,
error);
3865 assert(exc_ctx.
GetTargetPtr() &&
"Can't call HandleStop on a context "
3869 GetTarget()->GetDebugger().GetScriptInterpreter();
3871 return StopHookResult::KeepStopped;
3874 m_implementation_sp, exc_ctx, output_sp);
3876 return should_stop ? StopHookResult::KeepStopped
3877 : StopHookResult::RequestContinue;
3887 s.
Printf(
"%s\n", m_class_name.c_str());
3892 if (!m_extra_args.IsValid())
3895 if (!object_sp || !object_sp->IsValid())
3899 if (!as_dict || !as_dict->
IsValid())
3902 uint32_t num_keys = as_dict->
GetSize();
3909 auto print_one_element = [&s](llvm::StringRef key,
3912 s.
Format(
"{0} : {1}\n", key, object->GetStringValue());
3916 as_dict->
ForEach(print_one_element);
3924 "no-dynamic-values",
3925 "Don't calculate the dynamic type of values",
3930 "Calculate the dynamic type of values "
3931 "even if you have to run the target.",
3936 "Calculate the dynamic type of values, but don't run the target.",
3948 "Never look for inline breakpoint locations (fastest). This setting "
3949 "should only be used if you know that no inlining occurs in your"
3955 "Only check for inline breakpoint locations when setting breakpoints "
3956 "in header files, but not when setting breakpoint in implementation "
3957 "source files (default).",
3962 "Always look for inline breakpoint locations when setting file and "
3963 "line breakpoints (slower but most accurate).",
3977 "Disassembler default (currently att).",
3982 "Intel disassembler flavor.",
3987 "AT&T disassembler flavor.",
3995 "Never import the 'std' C++ module in the expression parser.",
4000 "Retry evaluating expressions with an imported 'std' C++ module if they"
4001 " failed to parse without the module. This allows evaluating more "
4002 "complex expressions involving C++ standard library types."
4007 "Always import the 'std' C++ module. This allows evaluating more "
4008 "complex expressions involving C++ standard library types. This feature"
4018 "Automatically determine the most appropriate method for the "
4022 "Prefer using the realized classes struct."},
4024 "Prefer using the CopyRealizedClassList API."},
4026 "Prefer using the GetRealizedClassList API."},
4033 "C-style (0xffff).",
4038 "Asm-style (0ffffh).",
4046 "Load debug scripts inside symbol files",
4051 "Do not load debug scripts inside symbol files.",
4056 "Warn about debug scripts inside symbol files but do not load them.",
4064 "Load .lldbinit files from current directory",
4069 "Do not load .lldbinit files from current directory",
4074 "Warn about loading .lldbinit files from current directory",
4082 "Load minimal information when loading modules from memory. Currently "
4083 "this setting loads sections only.",
4088 "Load partial information when loading modules from memory. Currently "
4089 "this setting loads sections and function bounds.",
4094 "Load complete information when loading modules from memory. Currently "
4095 "this setting loads sections and all symbols.",
4099#define LLDB_PROPERTIES_target
4100#include "TargetProperties.inc"
4103#define LLDB_PROPERTIES_target
4104#include "TargetPropertiesEnum.inc"
4109 :
public Cloneable<TargetOptionValueProperties, OptionValueProperties> {
4120 Target *target = exe_ctx->GetTargetPtr();
4125 if (
this != target_properties)
4129 return ProtectedGetPropertyAtIndex(idx);
4134#define LLDB_PROPERTIES_target_experimental
4135#include "TargetProperties.inc"
4138#define LLDB_PROPERTIES_target_experimental
4139#include "TargetPropertiesEnum.inc"
4143 :
public Cloneable<TargetExperimentalOptionValueProperties,
4144 OptionValueProperties> {
4158 :
Properties(), m_launch_info(), m_target(target) {
4181 m_collection_sp->SetValueChangedCallback(ePropertyDetachOnError, [
this] {
4194 std::make_unique<TargetExperimentalProperties>();
4197 "Experimental settings - setting these won't produce "
4198 "errors if the setting is not present.",
4201 m_collection_sp = std::make_shared<TargetOptionValueProperties>(
"target");
4204 std::make_unique<TargetExperimentalProperties>();
4207 "Experimental settings - setting these won't produce "
4208 "errors if the setting is not present.",
4211 "process",
"Settings specific to processes.",
true,
4238 exp_property->
GetValue()->GetAsProperties();
4241 return std::nullopt;
4251 const uint32_t idx = ePropertyDefaultArch;
4252 return GetPropertyAtIndexAs<ArchSpec>(idx, {});
4256 const uint32_t idx = ePropertyDefaultArch;
4261 const uint32_t idx = ePropertyMoveToNearestCode;
4262 return GetPropertyAtIndexAs<bool>(
4263 idx, g_target_properties[idx].default_uint_value != 0);
4267 const uint32_t idx = ePropertyPreferDynamic;
4268 return GetPropertyAtIndexAs<lldb::DynamicValueType>(
4270 g_target_properties[idx].default_uint_value));
4274 const uint32_t idx = ePropertyPreferDynamic;
4280 "Interrupted checking preload symbols")) {
4283 const uint32_t idx = ePropertyPreloadSymbols;
4284 return GetPropertyAtIndexAs<bool>(
4285 idx, g_target_properties[idx].default_uint_value != 0);
4289 const uint32_t idx = ePropertyPreloadSymbols;
4294 const uint32_t idx = ePropertyDisableASLR;
4295 return GetPropertyAtIndexAs<bool>(
4296 idx, g_target_properties[idx].default_uint_value != 0);
4300 const uint32_t idx = ePropertyDisableASLR;
4305 const uint32_t idx = ePropertyInheritTCC;
4306 return GetPropertyAtIndexAs<bool>(
4307 idx, g_target_properties[idx].default_uint_value != 0);
4311 const uint32_t idx = ePropertyInheritTCC;
4316 const uint32_t idx = ePropertyDetachOnError;
4317 return GetPropertyAtIndexAs<bool>(
4318 idx, g_target_properties[idx].default_uint_value != 0);
4322 const uint32_t idx = ePropertyDetachOnError;
4327 const uint32_t idx = ePropertyDisableSTDIO;
4328 return GetPropertyAtIndexAs<bool>(
4329 idx, g_target_properties[idx].default_uint_value != 0);
4333 const uint32_t idx = ePropertyDisableSTDIO;
4338 const uint32_t idx = ePropertyDisassemblyFlavor;
4339 const char *return_value;
4342 GetPropertyAtIndexAs<x86DisassemblyFlavor>(
4344 g_target_properties[idx].default_uint_value));
4347 return return_value;
4351 const uint32_t idx = ePropertyInlineStrategy;
4352 return GetPropertyAtIndexAs<InlineStrategy>(
4354 static_cast<InlineStrategy>(g_target_properties[idx].default_uint_value));
4358 const uint32_t idx = ePropertyArg0;
4359 return GetPropertyAtIndexAs<llvm::StringRef>(
4360 idx, g_target_properties[idx].default_cstr_value);
4364 const uint32_t idx = ePropertyArg0;
4370 const uint32_t idx = ePropertyRunArgs;
4375 const uint32_t idx = ePropertyRunArgs;
4384 GetPropertyAtIndexAs<bool>(
4385 ePropertyInheritEnv,
4386 g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
4388 Environment platform_env = platform_sp->GetEnvironment();
4389 for (
const auto &KV : platform_env)
4390 env[KV.first()] = KV.second;
4394 Args property_unset_env;
4396 property_unset_env);
4397 for (
const auto &var : property_unset_env)
4398 env.erase(var.ref());
4401 m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyEnvVars, property_env);
4403 env[KV.first()] = KV.second;
4418 if (!GetPropertyAtIndexAs<bool>(
4419 ePropertyInheritEnv,
4420 g_target_properties[ePropertyInheritEnv].default_uint_value != 0))
4424 if (platform_sp ==
nullptr)
4427 Environment platform_environment = platform_sp->GetEnvironment();
4428 for (
const auto &KV : platform_environment)
4429 environment[KV.first()] = KV.second;
4431 Args property_unset_environment;
4433 property_unset_environment);
4434 for (
const auto &var : property_unset_environment)
4435 environment.erase(var.ref());
4441 Args property_environment;
4443 property_environment);
4445 for (
const auto &KV :
Environment(property_environment))
4446 environment[KV.first()] = KV.second;
4453 const uint32_t idx = ePropertyEnvVars;
4458 const uint32_t idx = ePropertySkipPrologue;
4459 return GetPropertyAtIndexAs<bool>(
4460 idx, g_target_properties[idx].default_uint_value != 0);
4464 const uint32_t idx = ePropertySourceMap;
4467 assert(option_value);
4472 const uint32_t idx = ePropertyObjectMap;
4475 assert(option_value);
4480 const uint32_t idx = ePropertyAutoSourceMapRelative;
4481 return GetPropertyAtIndexAs<bool>(
4482 idx, g_target_properties[idx].default_uint_value != 0);
4486 const uint32_t idx = ePropertyExecutableSearchPaths;
4489 assert(option_value);
4494 const uint32_t idx = ePropertyExecutableSearchPaths;
4495 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4499 const uint32_t idx = ePropertyDebugFileSearchPaths;
4500 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4504 const uint32_t idx = ePropertyClangModuleSearchPaths;
4505 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4509 const uint32_t idx = ePropertyAutoImportClangModules;
4510 return GetPropertyAtIndexAs<bool>(
4511 idx, g_target_properties[idx].default_uint_value != 0);
4515 const uint32_t idx = ePropertyImportStdModule;
4516 return GetPropertyAtIndexAs<ImportStdModule>(
4518 g_target_properties[idx].default_uint_value));
4522 const uint32_t idx = ePropertyDynamicClassInfoHelper;
4523 return GetPropertyAtIndexAs<DynamicClassInfoHelper>(
4525 g_target_properties[idx].default_uint_value));
4529 const uint32_t idx = ePropertyAutoApplyFixIts;
4530 return GetPropertyAtIndexAs<bool>(
4531 idx, g_target_properties[idx].default_uint_value != 0);
4535 const uint32_t idx = ePropertyRetriesWithFixIts;
4536 return GetPropertyAtIndexAs<uint64_t>(
4537 idx, g_target_properties[idx].default_uint_value);
4541 const uint32_t idx = ePropertyNotifyAboutFixIts;
4542 return GetPropertyAtIndexAs<bool>(
4543 idx, g_target_properties[idx].default_uint_value != 0);
4547 const uint32_t idx = ePropertySaveObjectsDir;
4548 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4557 bool exists = instance.
Exists(new_dir);
4558 bool is_directory = instance.
IsDirectory(new_dir);
4559 std::string path = new_dir.
GetPath(
true);
4560 bool writable = llvm::sys::fs::can_write(path);
4561 if (exists && is_directory && writable)
4569 llvm::raw_string_ostream os(buffer);
4570 os <<
"JIT object dir '" << path <<
"' ";
4572 os <<
"does not exist";
4573 else if (!is_directory)
4574 os <<
"is not a directory";
4576 os <<
"is not writable";
4578 std::optional<lldb::user_id_t> debugger_id;
4585 const uint32_t idx = ePropertyEnableSynthetic;
4586 return GetPropertyAtIndexAs<bool>(
4587 idx, g_target_properties[idx].default_uint_value != 0);
4591 const uint32_t idx = ePropertyShowHexVariableValuesWithLeadingZeroes;
4592 return GetPropertyAtIndexAs<bool>(
4593 idx, g_target_properties[idx].default_uint_value != 0);
4597 const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
4598 return GetPropertyAtIndexAs<uint64_t>(
4599 idx, g_target_properties[idx].default_uint_value);
4603 const uint32_t idx = ePropertyMaxChildrenCount;
4604 return GetPropertyAtIndexAs<int64_t>(
4605 idx, g_target_properties[idx].default_uint_value);
4608std::pair<uint32_t, bool>
4610 const uint32_t idx = ePropertyMaxChildrenDepth;
4611 auto *option_value =
4613 bool is_default = !option_value->OptionWasSet();
4614 return {option_value->GetCurrentValue(), is_default};
4618 const uint32_t idx = ePropertyMaxSummaryLength;
4619 return GetPropertyAtIndexAs<uint64_t>(
4620 idx, g_target_properties[idx].default_uint_value);
4624 const uint32_t idx = ePropertyMaxMemReadSize;
4625 return GetPropertyAtIndexAs<uint64_t>(
4626 idx, g_target_properties[idx].default_uint_value);
4630 const uint32_t idx = ePropertyInputPath;
4631 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4635 const uint32_t idx = ePropertyInputPath;
4640 const uint32_t idx = ePropertyOutputPath;
4641 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4645 const uint32_t idx = ePropertyOutputPath;
4650 const uint32_t idx = ePropertyErrorPath;
4651 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4655 const uint32_t idx = ePropertyErrorPath;
4660 const uint32_t idx = ePropertyLanguage;
4661 return {GetPropertyAtIndexAs<LanguageType>(idx, {})};
4665 const uint32_t idx = ePropertyExprPrefix;
4671 return llvm::StringRef(
4672 reinterpret_cast<const char *
>(data_sp->GetBytes()),
4673 data_sp->GetByteSize());
4679 const uint32_t idx = ePropertyExprErrorLimit;
4680 return GetPropertyAtIndexAs<uint64_t>(
4681 idx, g_target_properties[idx].default_uint_value);
4685 const uint32_t idx = ePropertyExprAllocAddress;
4686 return GetPropertyAtIndexAs<uint64_t>(
4687 idx, g_target_properties[idx].default_uint_value);
4691 const uint32_t idx = ePropertyExprAllocSize;
4692 return GetPropertyAtIndexAs<uint64_t>(
4693 idx, g_target_properties[idx].default_uint_value);
4697 const uint32_t idx = ePropertyExprAllocAlign;
4698 return GetPropertyAtIndexAs<uint64_t>(
4699 idx, g_target_properties[idx].default_uint_value);
4703 const uint32_t idx = ePropertyBreakpointUseAvoidList;
4704 return GetPropertyAtIndexAs<bool>(
4705 idx, g_target_properties[idx].default_uint_value != 0);
4709 const uint32_t idx = ePropertyUseHexImmediates;
4710 return GetPropertyAtIndexAs<bool>(
4711 idx, g_target_properties[idx].default_uint_value != 0);
4715 const uint32_t idx = ePropertyUseFastStepping;
4716 return GetPropertyAtIndexAs<bool>(
4717 idx, g_target_properties[idx].default_uint_value != 0);
4721 const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
4722 return GetPropertyAtIndexAs<bool>(
4723 idx, g_target_properties[idx].default_uint_value != 0);
4727 const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
4728 return GetPropertyAtIndexAs<LoadScriptFromSymFile>(
4730 g_target_properties[idx].default_uint_value));
4734 const uint32_t idx = ePropertyLoadCWDlldbinitFile;
4735 return GetPropertyAtIndexAs<LoadCWDlldbinitFile>(
4737 g_target_properties[idx].default_uint_value));
4741 const uint32_t idx = ePropertyHexImmediateStyle;
4742 return GetPropertyAtIndexAs<Disassembler::HexImmediateStyle>(
4744 g_target_properties[idx].default_uint_value));
4748 const uint32_t idx = ePropertyMemoryModuleLoadLevel;
4749 return GetPropertyAtIndexAs<MemoryModuleLoadLevel>(
4751 g_target_properties[idx].default_uint_value));
4755 const uint32_t idx = ePropertyTrapHandlerNames;
4760 const uint32_t idx = ePropertyTrapHandlerNames;
4765 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4766 return GetPropertyAtIndexAs<bool>(
4767 idx, g_target_properties[idx].default_uint_value != 0);
4771 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4776 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4777 return GetPropertyAtIndexAs<bool>(
4778 idx, g_target_properties[idx].default_uint_value != 0);
4782 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4798 if (input_file_action) {
4803 if (output_file_action) {
4808 if (error_file_action) {
4814 launch_info.
GetFlags().
Test(lldb::eLaunchFlagInheritTCCFromParent));
4819 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4820 return GetPropertyAtIndexAs<bool>(
4821 idx, g_target_properties[idx].default_uint_value != 0);
4825 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4830 const uint32_t idx = ePropertyAutoInstallMainExecutable;
4831 return GetPropertyAtIndexAs<bool>(
4832 idx, g_target_properties[idx].default_uint_value != 0);
4893 const uint32_t idx = ePropertyDebugUtilityExpression;
4894 return GetPropertyAtIndexAs<bool>(
4895 idx, g_target_properties[idx].default_uint_value != 0);
4899 const uint32_t idx = ePropertyDebugUtilityExpression;
4906 :
EventData(), m_target_sp(target_sp), m_module_list() {}
4910 :
EventData(), m_target_sp(target_sp), m_module_list(module_list) {}
4915 return "Target::TargetEventData";
4919 for (
size_t i = 0; i < m_module_list.GetSize(); ++i) {
4922 m_module_list.GetModuleAtIndex(i)->GetDescription(
static llvm::raw_ostream & error(Stream &strm)
#define INTERRUPT_REQUESTED(debugger,...)
This handy define will keep you from having to generate a report for the interruption by hand.