68#include "llvm/ADT/ScopeExit.h"
69#include "llvm/ADT/SetVector.h"
70#include "llvm/Support/ThreadPool.h"
82struct ExecutableInstaller {
85 : m_platform{platform}, m_module{module},
86 m_local_file{m_module->GetFileSpec()},
87 m_remote_file{m_module->GetRemoteInstallFileSpec()} {}
89 void setupRemoteFile()
const { m_module->SetPlatformFileSpec(m_remote_file); }
97struct MainExecutableInstaller {
101 : m_platform{platform}, m_module{module},
102 m_local_file{m_module->GetFileSpec()},
104 getRemoteFileSpec(m_platform, target, m_module, m_local_file)},
105 m_launch_info{launch_info} {}
107 void setupRemoteFile()
const {
108 m_module->SetPlatformFileSpec(m_remote_file);
111 m_platform->SetFilePermissions(m_remote_file, 0700 );
123 FileSpec remote_file = module->GetRemoteInstallFileSpec();
124 if (remote_file || !target->GetAutoInstallMainExecutable())
130 remote_file = platform->GetRemoteWorkingDirectory();
140template <
typename Installer>
142 if (!installer.m_local_file || !installer.m_remote_file)
145 Status error = installer.m_platform->Install(installer.m_local_file,
146 installer.m_remote_file);
150 installer.setupRemoteFile();
158 m_plugin_up(
PluginManager::CreateArchitectureInstance(spec)) {}
167 static constexpr llvm::StringLiteral class_name(
"lldb.target");
195 static_cast<void *
>(
this));
198 "Target::Target created with architecture {0} ({1})",
200 target_arch.
GetTriple().getTriple().c_str());
208 LLDB_LOG(log,
"{0} Target::~Target()",
static_cast<void *
>(
this));
216 if (breakpoint_sp->IsInternal())
261 std::unique_lock<std::recursive_mutex> lock;
286 llvm::StringRef plugin_name,
293 listener_sp, crash_file, can_connect);
300 const char *repl_options,
bool can_create) {
308 language = *single_lang;
309 }
else if (repl_languages.
Empty()) {
311 "LLDB isn't configured with REPL support for any languages.");
315 "Multiple possible REPL languages. Please specify a language.");
320 REPLMap::iterator pos =
m_repl_map.find(language);
328 "Couldn't find an existing REPL for %s, and can't create a new one",
343 "Couldn't create a REPL for %s",
357 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
364 const bool notify =
false;
387 return abi_sp->GetPluginName();
418 ModuleSP main_module_sp = GetExecutableModule();
420 shared_lib_filter.
Append(main_module_sp->GetFileSpec());
421 llvm::SetVector<std::string, std::vector<std::string>,
422 std::unordered_set<std::string>>
431 if (!entryPointName.empty())
432 entryPointNamesSet.insert(entryPointName);
434 if (entryPointNamesSet.empty()) {
440 nullptr, entryPointNamesSet.takeVector(),
441 eFunctionNameTypeFull,
451 bp_sp->SetOneShot(
true);
458 const std::unordered_set<std::string> &function_names,
462 containingModules, source_file_spec_list));
466 nullptr, std::move(source_regex), function_names,
467 !
static_cast<bool>(move_to_nearest_code)));
473 const FileSpec &file, uint32_t line_no,
476 LazyBool skip_prologue,
bool internal,
480 std::optional<llvm::StringRef> removed_prefix_opt =
482 if (!removed_prefix_opt)
483 remapped_file = file;
487 switch (inline_strategy) {
508 compile_unit_list.
Append(remapped_file);
521 !
static_cast<bool>(move_to_nearest_code));
526 nullptr, offset, skip_prologue, location_spec, removed_prefix_opt));
562 bool request_hardware) {
566 nullptr, file_addr, file_spec));
573 const FileSpecList *containingSourceFiles,
const char *func_name,
574 FunctionNameType func_name_type_mask,
LanguageType language,
579 containingModules, containingSourceFiles));
588 offset, skip_prologue));
597 const std::vector<std::string> &func_names,
598 FunctionNameType func_name_type_mask,
600 LazyBool skip_prologue,
bool internal,
bool hardware) {
602 size_t num_names = func_names.size();
605 containingModules, containingSourceFiles));
614 language, offset, skip_prologue));
623 const char *func_names[],
size_t num_names,
624 FunctionNameType func_name_type_mask,
626 LazyBool skip_prologue,
bool internal,
bool hardware) {
630 containingModules, containingSourceFiles));
642 nullptr, func_names, num_names, func_name_type_mask, language, offset,
644 resolver_sp->SetOffset(offset);
653 if (containingModule !=
nullptr) {
656 filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
661 std::make_shared<SearchFilterForUnconstrainedSearches>(
671 if (containingModules && containingModules->
GetSize() != 0) {
674 filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
679 std::make_shared<SearchFilterForUnconstrainedSearches>(
689 if (containingSourceFiles ==
nullptr || containingSourceFiles->
GetSize() == 0)
693 if (containingModules ==
nullptr) {
697 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
698 shared_from_this(),
FileSpecList(), *containingSourceFiles);
700 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
701 shared_from_this(), *containingModules, *containingSourceFiles);
710 bool internal,
bool hardware) {
712 containingModules, containingSourceFiles));
715 :
static_cast<bool>(skip_prologue);
717 nullptr, std::move(func_regex), requested_language, 0, skip));
724 bool catch_bp,
bool throw_bp,
bool internal,
727 *
this, language, catch_bp, throw_bp, internal);
728 if (exc_bkpt_sp && additional_args) {
730 if (precondition_sp && additional_args) {
732 *
error = precondition_sp->ConfigurePrecondition(*additional_args);
734 precondition_sp->ConfigurePrecondition(*additional_args);
741 const llvm::StringRef class_name,
const FileSpecList *containingModules,
742 const FileSpecList *containingSourceFiles,
bool internal,
749 containingSourceFiles && containingSourceFiles->
GetSize() > 0;
750 bool has_modules = containingModules && containingModules->
GetSize() > 0;
752 if (has_files && has_modules) {
754 containingSourceFiles);
755 }
else if (has_files) {
758 }
else if (has_modules) {
761 filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
772 bool internal,
bool request_hardware,
773 bool resolve_indirect_symbols) {
775 if (filter_sp && resolver_sp) {
777 bp_sp.reset(
new Breakpoint(*
this, filter_sp, resolver_sp, hardware,
778 resolve_indirect_symbols));
779 resolver_sp->SetBreakpoint(bp_sp);
797 LLDB_LOGF(log,
"Target::%s (internal = %s) => break_id = %s\n",
798 __FUNCTION__, bp_sp->IsInternal() ?
"yes" :
"no", s.
GetData());
801 bp_sp->ResolveBreakpoint();
832 bp_sp->AddName(name);
837 std::make_pair(bp_name->GetName(), std::move(bp_name)));
843 if (!
error.Success())
848 return iter->second.get();
853 "Breakpoint name \"%s\" doesn't exist and "
854 "can_create is false.",
860 .insert(std::make_pair(name, std::make_unique<BreakpointName>(name)))
861 .first->second.get();
868 const char *name_cstr = name.
AsCString();
871 bp_sp->RemoveName(name_cstr);
889 llvm::Expected<std::vector<BreakpointSP>> expected_vector =
892 if (!expected_vector) {
894 llvm::toString(expected_vector.takeError()));
898 for (
auto bp_sp : *expected_vector)
905 names.push_back(bp_name_entry.first.AsCString());
915 std::optional<uint32_t> num_supported_hardware_watchpoints =
920 if (!num_supported_hardware_watchpoints)
923 if (*num_supported_hardware_watchpoints == 0) {
925 "Target supports (%u) hardware watchpoint slots.\n",
926 *num_supported_hardware_watchpoints);
939 "Target::%s (addr = 0x%8.8" PRIx64
" size = %" PRIu64
941 __FUNCTION__, addr, (uint64_t)size, kind);
952 "cannot set a watchpoint with watch_size of 0");
955 "invalid watch address: %" PRIu64, addr);
971 const bool notify =
false;
976 addr = abi->FixDataAddress(addr);
990 std::unique_lock<std::recursive_mutex> lock;
994 size_t old_size = matched_sp->GetByteSize();
1000 if (size == old_size && kind == old_type) {
1002 wp_sp->SetEnabled(
false, notify);
1011 wp_sp = std::make_shared<Watchpoint>(*
this, addr, size, type);
1012 wp_sp->SetWatchpointType(kind, notify);
1017 LLDB_LOGF(log,
"Target::%s (creation of watchpoint %s with id = %u)\n",
1018 __FUNCTION__,
error.Success() ?
"succeeded" :
"failed",
1033 LLDB_LOGF(log,
"Target::%s \n", __FUNCTION__);
1042 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
1043 internal_also ?
"yes" :
"no");
1054 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
1055 internal_also ?
"yes" :
"no");
1064 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
1071 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
1072 internal_also ?
"yes" :
"no");
1081 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
1088 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1108 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1118 bp_sp->SetEnabled(
false);
1126 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1137 bp_sp->SetEnabled(
true);
1157 std::string path(file.
GetPath());
1165 if (
error.Success()) {
1166 break_store_ptr = input_data_sp->
GetAsArray();
1167 if (!break_store_ptr) {
1169 "Tried to append to invalid input file %s", path.c_str());
1175 if (!break_store_ptr) {
1176 break_store_sp = std::make_shared<StructuredData::Array>();
1177 break_store_ptr = break_store_sp.get();
1184 lldb::eFilePermissionsFileDefault);
1191 std::unique_lock<std::recursive_mutex> lock;
1197 size_t num_breakpoints = breakpoints.
GetSize();
1198 for (
size_t i = 0; i < num_breakpoints; i++) {
1203 break_store_ptr->
AddItem(bkpt_save_sp);
1207 std::unordered_set<lldb::break_id_t> processed_bkpts;
1208 const size_t count = bp_ids.
GetSize();
1209 for (
size_t i = 0; i < count; ++i) {
1215 std::pair<std::unordered_set<lldb::break_id_t>::iterator,
bool>
1216 insert_result = processed_bkpts.insert(bp_id);
1217 if (!insert_result.second)
1224 if (!bkpt_save_sp) {
1226 "Unable to serialize breakpoint %d", bp_id);
1229 break_store_ptr->
AddItem(bkpt_save_sp);
1234 break_store_ptr->
Dump(out_file,
false);
1241 std::vector<std::string> no_names;
1246 std::vector<std::string> &names,
1248 std::unique_lock<std::recursive_mutex> lock;
1254 if (!
error.Success()) {
1256 }
else if (!input_data_sp || !input_data_sp->IsValid()) {
1258 "Invalid JSON from input file: %s.", file.
GetPath().c_str());
1265 "Invalid breakpoint data from input file: %s.", file.
GetPath().c_str());
1269 size_t num_bkpts = bkpt_array->
GetSize();
1270 size_t num_names = names.size();
1272 for (
size_t i = 0; i < num_bkpts; i++) {
1278 "Invalid breakpoint data for element %zu from input file: %s.", i,
1289 shared_from_this(), bkpt_data_sp,
error);
1290 if (!
error.Success()) {
1292 "Error restoring breakpoint %zu from %s: %s.", i,
1308 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1337 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1364 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1390 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1396 wp_sp->ResetHitCount();
1404 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1410 wp_sp->ResetHistoricValues();
1419 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1428 wp_sp->SetIgnoreCount(ignore_count);
1436 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1455 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1474 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1489 uint32_t ignore_count) {
1491 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1498 wp_sp->SetIgnoreCount(ignore_count);
1526 if (module_sp && !module_sp->LoadScriptingResourceInTarget(target,
error,
1528 if (
error.AsCString())
1530 "unable to load scripting data for module %s - error reported was "
1532 module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1535 if (feedback_stream.
GetSize())
1558 if (executable_sp) {
1561 executable_sp->GetFileSpec().GetPath().c_str());
1563 const bool notify =
true;
1570 m_arch = executable_sp->GetArchitecture();
1572 "Target::SetExecutableModule setting architecture to {0} ({1}) "
1573 "based on executable file",
1578 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
1579 bool load_dependents =
true;
1580 switch (load_dependent_files) {
1582 load_dependents = executable_sp->IsExecutable();
1585 load_dependents =
true;
1588 load_dependents =
false;
1592 if (executable_objfile && load_dependents) {
1595 std::mutex dependent_files_mutex;
1600 auto GetDependentModules = [&](
FileSpec dependent_file_spec) {
1601 FileSpec platform_dependent_file_spec;
1603 m_platform_sp->GetFileWithUUID(dependent_file_spec,
nullptr,
1604 platform_dependent_file_spec);
1606 platform_dependent_file_spec = dependent_file_spec;
1611 if (image_module_sp) {
1613 ObjectFile *objfile = image_module_sp->GetObjectFile();
1619 std::lock_guard<std::mutex> guard(dependent_files_mutex);
1620 dependent_files_copy = dependent_files;
1625 const size_t previous_dependent_files =
1626 dependent_files_copy.
GetSize();
1631 std::lock_guard<std::mutex> guard(dependent_files_mutex);
1632 for (
size_t i = previous_dependent_files;
1633 i < dependent_files_copy.
GetSize(); ++i)
1644 for (uint32_t i = 0; i < dependent_files.
GetSize(); i++) {
1650 std::lock_guard<std::mutex> guard(dependent_files_mutex);
1651 for (; i < dependent_files.
GetSize(); i++)
1652 task_group.async(GetDependentModules,
1666 bool replace_local_arch =
true;
1667 bool compatible_local_arch =
false;
1676 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
1680 GetDebugger().GetPlatformList().GetOrCreate(other, {},
1684 other = platform_arch;
1690 if (!missing_local_arch) {
1695 compatible_local_arch =
true;
1698 replace_local_arch =
false;
1703 if (compatible_local_arch || missing_local_arch) {
1707 if (replace_local_arch)
1710 "Target::SetArchitecture merging compatible arch; arch "
1721 "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
1723 arch_spec.
GetTriple().getTriple().c_str(),
1732 if (executable_sp) {
1734 "Target::SetArchitecture Trying to select executable file "
1735 "architecture %s (%s)",
1737 arch_spec.
GetTriple().getTriple().c_str());
1738 ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
1741 &search_paths,
nullptr,
nullptr);
1743 if (!
error.Fail() && executable_sp) {
1759 "Target::MergeArchitecture target has arch %s, merging with "
1762 arch_spec.
GetTriple().getTriple().c_str());
1783 my_module_list.
Append(module_sp);
1793 my_module_list.
Append(module_sp);
1806 old_module_sp, new_module_sp);
1815 const size_t num_images = module_list.
GetSize();
1817 for (
size_t idx = 0; idx < num_images; ++idx) {
1829 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1838 runtime->SymbolsDidLoad(module_list);
1845 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1854 std::make_shared<TargetEventData>(shared_from_this(), module_list);
1868 const bool should_flush_type_systems =
1875 auto type = object_file->
GetType();
1885 if (should_flush_type_systems)
1891 const FileSpec &module_file_spec) {
1896 size_t num_modules = matchingModules.
GetSize();
1900 if (num_modules > 0) {
1901 for (
size_t i = 0; i < num_modules; i++) {
1916 return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*
this,
1928 if (section_sp->IsEncrypted()) {
1932 ModuleSP module_sp(section_sp->GetModule());
1937 section_sp.get(), addr.
GetOffset(), dst, dst_len);
1942 "error reading data from section %s",
1943 section_sp->GetName().GetCString());
1950 "address doesn't contain a section that points to a "
1951 "section in a object file");
1972 size_t bytes_read = 0;
1979 if (section_load_list.
IsEmpty()) {
1998 resolved_addr = fixed_addr;
2003 std::unique_ptr<uint8_t[]> file_cache_read_buffer;
2004 size_t file_cache_bytes_read = 0;
2010 auto permissions =
Flags(section_sp->GetPermissions());
2011 bool is_readonly = !permissions.Test(ePermissionsWritable) &&
2012 permissions.Test(ePermissionsReadable);
2014 file_cache_bytes_read =
2016 if (file_cache_bytes_read == dst_len)
2017 return file_cache_bytes_read;
2018 else if (file_cache_bytes_read > 0) {
2019 file_cache_read_buffer =
2020 std::make_unique<uint8_t[]>(file_cache_bytes_read);
2021 std::memcpy(file_cache_read_buffer.get(), dst, file_cache_bytes_read);
2033 if (addr_module_sp && addr_module_sp->GetFileSpec())
2035 "{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
2039 "0x%" PRIx64
" can't be resolved", resolved_addr.
GetFileAddress());
2042 if (bytes_read != dst_len) {
2043 if (
error.Success()) {
2044 if (bytes_read == 0)
2046 "read memory from 0x%" PRIx64
" failed", load_addr);
2049 "only %" PRIu64
" of %" PRIu64
2050 " bytes were read from memory at 0x%" PRIx64,
2051 (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
2056 *load_addr_ptr = load_addr;
2062 if (file_cache_read_buffer && file_cache_bytes_read > 0) {
2065 std::memcpy(dst, file_cache_read_buffer.get(), file_cache_bytes_read);
2066 return file_cache_bytes_read;
2088 out_str.append(buf, length);
2091 if (length ==
sizeof(buf) - 1)
2092 curr_addr += length;
2097 return out_str.size();
2101 size_t dst_max_len,
Status &result_error,
2102 bool force_live_memory) {
2103 size_t total_cstr_len = 0;
2104 if (dst && dst_max_len) {
2105 result_error.
Clear();
2107 memset(dst, 0, dst_max_len);
2114 const size_t cache_line_size = 512;
2116 size_t bytes_left = dst_max_len - 1;
2117 char *curr_dst = dst;
2119 while (bytes_left > 0) {
2120 addr_t cache_line_bytes_left =
2121 cache_line_size - (curr_addr % cache_line_size);
2123 std::min<addr_t>(bytes_left, cache_line_bytes_left);
2125 size_t bytes_read =
ReadMemory(address, curr_dst, bytes_to_read,
error,
2128 if (bytes_read == 0) {
2129 result_error = std::move(
error);
2130 dst[total_cstr_len] =
'\0';
2133 const size_t len = strlen(curr_dst);
2135 total_cstr_len += len;
2137 if (len < bytes_to_read)
2140 curr_dst += bytes_read;
2141 curr_addr += bytes_read;
2142 bytes_left -= bytes_read;
2149 result_error.
Clear();
2151 return total_cstr_len;
2159 return cache_line_size - (load_addr % cache_line_size);
2169 size_t type_width,
bool force_live_memory) {
2170 if (!dst || !max_bytes || !type_width || max_bytes < type_width)
2173 size_t total_bytes_read = 0;
2177 memset(dst, 0, max_bytes);
2178 size_t bytes_left = max_bytes - type_width;
2180 const char terminator[4] = {
'\0',
'\0',
'\0',
'\0'};
2181 assert(
sizeof(terminator) >= type_width &&
"Attempting to validate a "
2182 "string with more than 4 bytes "
2186 char *curr_dst = dst;
2189 while (bytes_left > 0 &&
error.Success()) {
2193 ReadMemory(address, curr_dst, bytes_to_read,
error, force_live_memory);
2195 if (bytes_read == 0)
2200 size_t aligned_start = total_bytes_read - total_bytes_read % type_width;
2201 for (
size_t i = aligned_start;
2202 i + type_width <= total_bytes_read + bytes_read; i += type_width)
2203 if (::memcmp(&dst[i], terminator, type_width) == 0) {
2208 total_bytes_read += bytes_read;
2209 curr_dst += bytes_read;
2210 address.
Slide(bytes_read);
2211 bytes_left -= bytes_read;
2213 return total_bytes_read;
2217 bool is_signed,
Scalar &scalar,
2219 bool force_live_memory) {
2222 if (byte_size <=
sizeof(uval)) {
2225 if (bytes_read == byte_size) {
2230 scalar = data.
GetMaxU32(&offset, byte_size);
2232 scalar = data.
GetMaxU64(&offset, byte_size);
2240 "byte size of %u is too large for integer scalar type", byte_size);
2246 size_t integer_byte_size,
2248 bool force_live_memory) {
2258 bool force_live_memory) {
2261 false, scalar,
error, force_live_memory)) {
2265 if (section_load_list.
IsEmpty()) {
2279 pointer_addr.
SetOffset(pointer_vm_addr);
2287 bool notify,
Status *error_ptr) {
2295 if (std::optional<FileSpec> remapped_obj_file =
2309 llvm::SmallVector<ModuleSP, 1>
2312 bool did_create_module =
false;
2322 module_spec, module_sp, symbol_file_spec, &did_create_module);
2353 &search_paths, &old_modules,
2354 &did_create_module);
2372 &old_modules, &did_create_module);
2380 module_spec,
m_process_sp.get(), module_sp, &search_paths,
2381 &old_modules, &did_create_module);
2392 ObjectFile *objfile = module_sp->GetObjectFile();
2408 "debug info files aren't valid target "
2409 "modules, please specify an executable");
2416 "stub libraries aren't valid target "
2417 "modules, please specify an executable");
2422 "unsupported file type, please specify an executable");
2443 old_modules.push_back(found_module);
2450 if (symbol_file_spec)
2451 module_sp->SetSymbolFileFileSpec(symbol_file_spec);
2456 module_sp->PreloadSymbols();
2457 llvm::SmallVector<ModuleSP, 1> replaced_modules;
2458 for (
ModuleSP &old_module_sp : old_modules) {
2461 if (replaced_modules.empty())
2466 replaced_modules.push_back(std::move(old_module_sp));
2470 if (replaced_modules.size() > 1) {
2483 auto dump = [&message](
Module &dump_module) ->
void {
2484 UUID dump_uuid = dump_module.GetUUID();
2488 message <<
" (uuid ";
2491 dump_uuid.
Dump(message);
2493 message <<
"not specified";
2498 message <<
"New module ";
2501 << llvm::formatv(
" simultaneously replaced {0} old modules: ",
2502 replaced_modules.size());
2503 for (
ModuleSP &replaced_module_sp : replaced_modules)
2504 dump(*replaced_module_sp);
2510 if (replaced_modules.empty())
2513 for (
ModuleSP &old_module_sp : replaced_modules) {
2514 Module *old_module_ptr = old_module_sp.get();
2515 old_module_sp.reset();
2523 *error_ptr = std::move(
error);
2552llvm::Expected<lldb::TypeSystemSP>
2554 bool create_on_demand) {
2556 return llvm::createStringError(
"Invalid Target");
2568 if (languages_for_expressions.
Empty())
2569 return llvm::createStringError(
2570 "No expression support for any languages");
2581 uint32_t byte_size) {
2584 return provider->GetRegisterType(name, flags, byte_size);
2587std::vector<lldb::TypeSystemSP>
2595 std::vector<lldb::TypeSystemSP> scratch_type_systems;
2600 for (
auto bit : languages_for_expressions.
bitvector.set_bits()) {
2602 auto type_system_or_err =
2604 if (!type_system_or_err)
2607 "Language '{1}' has expression support but no scratch type "
2608 "system available: {0}",
2611 if (
auto ts = *type_system_or_err)
2612 scratch_type_systems.push_back(ts);
2615 std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
2616 scratch_type_systems.erase(
2617 std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
2618 scratch_type_systems.end());
2619 return scratch_type_systems;
2626 if (
auto err = type_system_or_err.takeError()) {
2629 "Unable to get persistent expression state for language {1}: {0}",
2634 if (
auto ts = *type_system_or_err)
2635 return ts->GetPersistentExpressionState();
2638 "Unable to get persistent expression state for language {1}: {0}",
2644 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
2648 auto type_system_or_err =
2650 if (
auto err = type_system_or_err.takeError()) {
2652 "Could not find type system for language %s: %s",
2654 llvm::toString(std::move(err)).c_str());
2658 auto ts = *type_system_or_err;
2661 "Type system for language %s is no longer live",
2666 auto *user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
2670 "Could not create an expression for language %s",
2681 if (
auto err = type_system_or_err.takeError()) {
2683 "Could not find type system for language %s: %s",
2685 llvm::toString(std::move(err)).c_str());
2688 auto ts = *type_system_or_err;
2691 "Type system for language %s is no longer live",
2695 auto *persistent_fn = ts->GetFunctionCaller(return_type, function_address,
2696 arg_value_list, name);
2699 "Could not create an expression for language %s",
2702 return persistent_fn;
2705llvm::Expected<std::unique_ptr<UtilityFunction>>
2710 if (!type_system_or_err)
2711 return type_system_or_err.takeError();
2712 auto ts = *type_system_or_err;
2714 return llvm::createStringError(
2715 llvm::StringRef(
"Type system for language ") +
2717 llvm::StringRef(
" is no longer live"));
2718 std::unique_ptr<UtilityFunction> utility_fn =
2719 ts->CreateUtilityFunction(std::move(expression), std::move(name));
2721 return llvm::createStringError(
2722 llvm::StringRef(
"Could not create an expression for language") +
2726 if (!utility_fn->Install(diagnostics, exe_ctx))
2728 "Could not install utility function:");
2730 return std::move(utility_fn);
2751 "setting target's default architecture to {0} ({1})",
2758 if (llvm::to_integer(label, n))
2759 return llvm::createStringError(
"Cannot use integer as target label.");
2763 if (target_sp && target_sp->GetLabel() == label) {
2764 return llvm::make_error<llvm::StringError>(
2766 "Cannot use label '{0}' since it's set in target #{1}.", label,
2768 llvm::inconvertibleErrorCode());
2773 return llvm::Error::success();
2782 Target *target =
nullptr;
2783 if (sc_ptr !=
nullptr)
2785 if (target ==
nullptr && exe_ctx_ptr)
2795 result_valobj_sp.reset();
2801 return execution_results;
2807 auto on_exit = llvm::make_scope_exit([
this, old_suppress_value]() {
2825 if (expr[0] ==
'$') {
2826 auto type_system_or_err =
2828 if (
auto err = type_system_or_err.takeError()) {
2830 "Unable to get scratch type system");
2832 auto ts = *type_system_or_err;
2835 "Scratch type system is no longer live: {0}");
2838 ts->GetPersistentExpressionState()->GetVariable(expr);
2841 if (persistent_var_sp) {
2842 result_valobj_sp = persistent_var_sp->GetValueObject();
2848 result_valobj_sp, fixed_expression, ctx_obj);
2855 return execution_results;
2861 [name, &variable_sp](
TypeSystemSP type_system) ->
bool {
2862 auto ts = type_system.get();
2866 ts->GetPersistentExpressionState()) {
2867 variable_sp = persistent_state->GetVariable(name);
2882 auto ts = type_system.get();
2887 ts->GetPersistentExpressionState()) {
2888 address = persistent_state->LookupSymbol(name);
2889 if (address != LLDB_INVALID_ADDRESS)
2901 const bool has_primary_executable = exe_module && exe_module->
GetObjectFile();
2902 if (has_primary_executable) {
2909 const size_t num_images = modules.
GetSize();
2910 for (
size_t idx = 0; idx < num_images; ++idx) {
2912 if (!module_sp || !module_sp->GetObjectFile())
2915 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2921 if (!has_primary_executable)
2922 return llvm::createStringError(
2923 "No primary executable found and could not find entry point address in "
2924 "any executable module");
2926 return llvm::createStringError(
2927 "Could not find entry point address for primary executable module \"" +
2935 ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
2942 return arch_plugin ? arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class)
2948 return arch_plugin ? arch_plugin->GetBreakableLoadAddress(addr, *
this) : addr;
2969 return stop_hook_sp;
2981 return (num_removed != 0);
2989 StopHookCollection::iterator specified_hook_iter;
2992 found_hook = (*specified_hook_iter).second;
2997 bool active_state) {
2998 StopHookCollection::iterator specified_hook_iter;
3003 (*specified_hook_iter).second->SetIsActive(active_state);
3008 StopHookCollection::iterator pos, end =
m_stop_hooks.end();
3010 (*pos).second->SetIsActive(active_state);
3030 bool any_active_hooks =
false;
3032 if (hook.second->IsActive()) {
3033 any_active_hooks =
true;
3037 if (!any_active_hooks)
3046 uint32_t last_natural_stop =
m_process_sp->GetModIDRef().GetLastNaturalStopID();
3052 std::vector<ExecutionContext> exc_ctx_with_reasons;
3055 size_t num_threads = cur_threadlist.
GetSize();
3056 for (
size_t i = 0; i < num_threads; i++) {
3058 if (cur_thread_sp->ThreadStoppedForAReason()) {
3060 exc_ctx_with_reasons.emplace_back(
m_process_sp.get(), cur_thread_sp.get(),
3061 cur_frame_sp.get());
3066 size_t num_exe_ctx = exc_ctx_with_reasons.size();
3067 if (num_exe_ctx == 0)
3072 bool auto_continue =
false;
3073 bool hooks_ran =
false;
3075 bool print_thread_header = (num_exe_ctx != 1);
3076 bool should_stop =
false;
3077 bool somebody_restarted =
false;
3081 if (!cur_hook_sp->IsActive())
3084 bool any_thread_matched =
false;
3085 for (
auto exc_ctx : exc_ctx_with_reasons) {
3088 if (somebody_restarted)
3091 if (!cur_hook_sp->ExecutionContextPasses(exc_ctx))
3096 auto_continue |= cur_hook_sp->GetAutoContinue();
3101 if (print_hook_header && !any_thread_matched) {
3105 output_sp->
Printf(
"\n- Hook %" PRIu64
" (%s)\n", cur_hook_sp->GetID(),
3108 output_sp->Printf(
"\n- Hook %" PRIu64
"\n", cur_hook_sp->GetID());
3109 any_thread_matched =
true;
3112 if (print_thread_header)
3113 output_sp->Printf(
"-- Thread %d\n",
3114 exc_ctx.GetThreadPtr()->GetIndexID());
3117 cur_hook_sp->HandleStop(exc_ctx, output_sp);
3118 bool this_should_stop =
true;
3120 switch (this_result) {
3124 if (cur_hook_sp->GetAutoContinue())
3125 this_should_stop =
false;
3127 this_should_stop =
true;
3131 this_should_stop =
false;
3137 output_sp->Printf(
"\nAborting stop hooks, hook %" PRIu64
3138 " set the program running.\n"
3139 " Consider using '-G true' to make "
3140 "stop hooks auto-continue.\n",
3141 cur_hook_sp->GetID());
3142 somebody_restarted =
true;
3149 if (somebody_restarted)
3154 should_stop = this_should_stop;
3162 if (somebody_restarted)
3168 if ((hooks_ran && !should_stop) || auto_continue) {
3171 if (
error.Success()) {
3172 LLDB_LOG(log,
"Resuming from RunStopHooks");
3175 LLDB_LOG(log,
"Resuming from RunStopHooks failed: {0}",
error);
3188 return *g_settings_ptr;
3194 if (!platform_sp || !platform_sp->IsRemote() || !platform_sp->IsConnected())
3204 MainExecutableInstaller installer{platform_sp, module_sp,
3205 shared_from_this(), *launch_info};
3208 ExecutableInstaller installer{platform_sp, module_sp};
3230 addr_t new_section_load_addr,
3231 bool warn_multiple) {
3232 const addr_t old_section_load_addr =
3235 if (old_section_load_addr != new_section_load_addr) {
3236 uint32_t stop_id = 0;
3239 stop_id = process_sp->GetStopID();
3243 stop_id, section_sp, new_section_load_addr, warn_multiple))
3250 size_t section_unload_count = 0;
3251 size_t num_modules = module_list.
GetSize();
3252 for (
size_t i = 0; i < num_modules; ++i) {
3253 section_unload_count +=
3256 return section_unload_count;
3260 uint32_t stop_id = 0;
3263 stop_id = process_sp->GetStopID();
3266 SectionList *sections = module_sp->GetSectionList();
3267 size_t section_unload_count = 0;
3270 for (uint32_t i = 0; i < num_sections; ++i) {
3275 return section_unload_count;
3279 uint32_t stop_id = 0;
3282 stop_id = process_sp->GetStopID();
3290 uint32_t stop_id = 0;
3293 stop_id = process_sp->GetStopID();
3328 LLDB_LOGF(log,
"Target::%s() called for %s", __FUNCTION__,
3340 state = process_sp->GetState();
3342 "Target::%s the process exists, and its current state is %s",
3345 LLDB_LOGF(log,
"Target::%s the process instance doesn't currently exist.",
3358 const bool synchronous_execution =
3366 if (launch_info.
GetFlags().
Test(eLaunchFlagLaunchInTTY))
3368 "can't launch in tty when launching through a remote connection");
3386 LLDB_LOGF(log,
"Target::%s asking the platform to debug the process",
3400 "Target::%s the platform doesn't know how to debug a "
3401 "process, getting a process plugin to do this for us.",
3420 if (!
error.Success())
3426 bool rebroadcast_first_stop =
3427 !synchronous_execution &&
3433 state =
m_process_sp->WaitForProcessToStop(std::nullopt, &first_stop_event_sp,
3434 rebroadcast_first_stop,
3438 if (rebroadcast_first_stop) {
3439 assert(first_stop_event_sp);
3446 if (launch_info.
GetFlags().
Test(eLaunchFlagStopAtEntry))
3448 if (synchronous_execution)
3455 if (!
error.Success()) {
3457 "process resume at entry point failed: %s",
error.AsCString());
3461 bool with_shell = !!launch_info.
GetShell();
3463 const char *exit_desc =
m_process_sp->GetExitDescription();
3465 if (exit_desc && exit_desc[0])
3466 desc =
" (" + std::string(exit_desc) +
')';
3469 "process exited with status %i%s\n"
3470 "'r' and 'run' are aliases that default to launching through a "
3472 "Try launching without going through a shell by using "
3473 "'process launch'.",
3474 exit_status, desc.c_str());
3477 "process exited with status %i%s", exit_status, desc.c_str());
3481 "initial process state wasn't stopped: %s",
StateAsCString(state));
3493 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3494 "A process is required for tracing");
3496 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3497 "A trace already exists for the target");
3499 llvm::Expected<TraceSupportedResponse> trace_type =
3502 return llvm::createStringError(
3503 llvm::inconvertibleErrorCode(),
"Tracing is not supported. %s",
3504 llvm::toString(trace_type.takeError()).c_str());
3505 if (llvm::Expected<TraceSP> trace_sp =
3509 return llvm::createStringError(
3510 llvm::inconvertibleErrorCode(),
3511 "Couldn't create a Trace object for the process. %s",
3512 llvm::toString(trace_sp.takeError()).c_str());
3527 state = process_sp->GetState();
3540 if (old_exec_module_sp)
3542 old_exec_module_sp->GetPlatformFileSpec().GetFilename());
3546 "no process specified, create a target with a file, or "
3547 "specify the --pid or --name");
3551 const auto platform_sp =
3554 const bool async = attach_info.
GetAsync();
3572 plugin_name,
nullptr,
false);
3575 "failed to create process using plugin '{0}'",
3576 plugin_name.empty() ?
"<empty>" : plugin_name);
3580 if (hijack_listener_sp)
3581 process_sp->HijackProcessEvents(hijack_listener_sp);
3582 error = process_sp->Attach(attach_info);
3585 if (
error.Success() && process_sp) {
3587 process_sp->RestoreProcessEvents();
3590 state = process_sp->WaitForProcessToStop(
3593 process_sp->RestoreProcessEvents();
3596 const char *exit_desc = process_sp->GetExitDescription();
3601 "process did not stop (no such process or permission problem?)");
3602 process_sp->Destroy(
false);
3615 const bool default_to_use_pty =
3619 "have platform={0}, platform_sp->IsHost()={1}, default_to_use_pty={2}",
3621 platform_sp ? (platform_sp->IsHost() ?
"true" :
"false") :
"n/a",
3622 default_to_use_pty);
3629 LLDB_LOG(log,
"at least one of stdin/stdout/stderr was not set, evaluating "
3630 "default handling");
3639 LLDB_LOG(log,
"eLaunchFlagDisableSTDIO set, adding suppression action "
3640 "for stdin, stdout and stderr");
3660 LLDB_LOG(log,
"target stdin='{0}', target stdout='{1}', stderr='{2}'",
3661 in_file_spec, out_file_spec, err_file_spec);
3665 LLDB_LOG(log,
"appended stdin open file action for {0}", in_file_spec);
3668 if (out_file_spec) {
3670 LLDB_LOG(log,
"appended stdout open file action for {0}",
3674 if (err_file_spec) {
3676 LLDB_LOG(log,
"appended stderr open file action for {0}",
3680 if (default_to_use_pty) {
3682 LLDB_LOG_ERROR(log, std::move(Err),
"SetUpPtyRedirection failed: {0}");
3699 elem.notify = notify;
3709 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3714 signals_sp->SetShouldSuppress(signo,
false);
3716 signals_sp->SetShouldSuppress(signo,
true);
3719 signals_sp->SetShouldNotify(signo,
true);
3721 signals_sp->SetShouldNotify(signo,
false);
3724 signals_sp->SetShouldStop(signo,
true);
3726 signals_sp->SetShouldStop(signo,
false);
3735 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3741 signals_sp->ResetSignal(signo, do_stop, do_notify, do_pass);
3752 warning_stream_sp->Printf(
"Target signal '%s' not found in process\n",
3753 elem.first().str().c_str());
3766 signals_sp = process_sp->GetUnixSignals();
3769 const char *signal_name = entry.c_str();
3783 strm.
Printf(
"NAME PASS STOP NOTIFY\n");
3784 strm.
Printf(
"=========== ======= ======= =======\n");
3786 auto str_for_lazy = [] (
LazyBool lazy) ->
const char * {
3792 llvm_unreachable(
"Fully covered switch above!");
3796 bool print_it =
false;
3797 for (
size_t idx = 0; idx < num_args; idx++) {
3804 strm.
Printf(
"%-11s ", elem.first().str().c_str());
3805 strm.
Printf(
"%s %s %s\n", str_for_lazy(elem.second.pass),
3806 str_for_lazy(elem.second.stop),
3807 str_for_lazy(elem.second.notify));
3814 :
UserID(uid), m_target_sp(target_sp), m_specifier_sp(),
3815 m_thread_spec_up() {}
3818 :
UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
3819 m_specifier_sp(rhs.m_specifier_sp), m_thread_spec_up(),
3820 m_active(rhs.m_active), m_auto_continue(rhs.m_auto_continue) {
3826 m_specifier_sp.reset(specifier);
3830 m_thread_spec_up.reset(specifier);
3838 bool will_run =
true;
3840 will_run = GetSpecifier()->SymbolContextMatches(
3842 if (will_run && GetThreadSpecifier() !=
nullptr)
3844 GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx.
GetThreadRef());
3854 GetSubclassDescription(s, level);
3862 s.
Printf(
"Hook: %" PRIu64
"\n", GetID());
3864 s.
Indent(
"State: enabled\n");
3866 s.
Indent(
"State: disabled\n");
3868 if (m_auto_continue)
3869 s.
Indent(
"AutoContinue on\n");
3871 if (m_specifier_sp) {
3875 m_specifier_sp->GetDescription(&s, level);
3879 if (m_thread_spec_up) {
3882 m_thread_spec_up->GetDescription(&tmp, level);
3888 GetSubclassDescription(s, level);
3895 if (m_commands.GetSize() == 1)
3896 s.
PutCString(m_commands.GetStringAtIndex(0));
3899 s.
Indent(
"Commands: \n");
3901 uint32_t num_commands = m_commands.GetSize();
3902 for (uint32_t i = 0; i < num_commands; i++) {
3903 s.
Indent(m_commands.GetStringAtIndex(i));
3911 GetCommands().SplitIntoLines(
string);
3915 const std::vector<std::string> &strings) {
3916 for (
auto string : strings)
3917 GetCommands().AppendString(
string.c_str());
3923 assert(exc_ctx.
GetTargetPtr() &&
"Can't call PerformAction on a context "
3926 if (!m_commands.GetSize())
3927 return StopHookResult::KeepStopped;
3950 return StopHookResult::AlreadyContinued;
3951 return StopHookResult::KeepStopped;
3960 GetTarget()->GetDebugger().GetScriptInterpreter();
3961 if (!script_interp) {
3967 if (!m_interface_sp) {
3969 "ScriptedStopHook::%s () - ERROR: %s", __FUNCTION__,
3970 "Script interpreter couldn't create Scripted Stop Hook Interface");
3974 m_class_name = class_name;
3975 m_extra_args.SetObjectSP(extra_args_sp);
3977 auto obj_or_err = m_interface_sp->CreatePluginObject(
3978 m_class_name, GetTarget(), m_extra_args);
3984 if (!object_sp || !object_sp->IsValid()) {
3986 "ScriptedStopHook::%s () - ERROR: %s", __FUNCTION__,
3987 "Failed to create valid script object");
3997 assert(exc_ctx.
GetTargetPtr() &&
"Can't call HandleStop on a context "
4000 if (!m_interface_sp)
4001 return StopHookResult::KeepStopped;
4003 lldb::StreamSP stream = std::make_shared<lldb_private::StreamString>();
4004 auto should_stop_or_err = m_interface_sp->HandleStop(exc_ctx, stream);
4005 output_sp->PutCString(
4007 if (!should_stop_or_err)
4008 return StopHookResult::KeepStopped;
4010 return *should_stop_or_err ? StopHookResult::KeepStopped
4011 : StopHookResult::RequestContinue;
4021 s.
Printf(
"%s\n", m_class_name.c_str());
4026 if (!m_extra_args.IsValid())
4029 if (!object_sp || !object_sp->IsValid())
4033 if (!as_dict || !as_dict->
IsValid())
4036 uint32_t num_keys = as_dict->
GetSize();
4043 auto print_one_element = [&s](llvm::StringRef key,
4046 s.
Format(
"{0} : {1}\n", key, object->GetStringValue());
4050 as_dict->
ForEach(print_one_element);
4058 "no-dynamic-values",
4059 "Don't calculate the dynamic type of values",
4064 "Calculate the dynamic type of values "
4065 "even if you have to run the target.",
4070 "Calculate the dynamic type of values, but don't run the target.",
4082 "Never look for inline breakpoint locations (fastest). This setting "
4083 "should only be used if you know that no inlining occurs in your"
4089 "Only check for inline breakpoint locations when setting breakpoints "
4090 "in header files, but not when setting breakpoint in implementation "
4091 "source files (default).",
4096 "Always look for inline breakpoint locations when setting file and "
4097 "line breakpoints (slower but most accurate).",
4111 "Disassembler default (currently att).",
4116 "Intel disassembler flavor.",
4121 "AT&T disassembler flavor.",
4129 "Never import the 'std' C++ module in the expression parser.",
4134 "Retry evaluating expressions with an imported 'std' C++ module if they"
4135 " failed to parse without the module. This allows evaluating more "
4136 "complex expressions involving C++ standard library types."
4141 "Always import the 'std' C++ module. This allows evaluating more "
4142 "complex expressions involving C++ standard library types. This feature"
4152 "Automatically determine the most appropriate method for the "
4156 "Prefer using the realized classes struct."},
4158 "Prefer using the CopyRealizedClassList API."},
4160 "Prefer using the GetRealizedClassList API."},
4167 "C-style (0xffff).",
4172 "Asm-style (0ffffh).",
4180 "Load debug scripts inside symbol files",
4185 "Do not load debug scripts inside symbol files.",
4190 "Warn about debug scripts inside symbol files but do not load them.",
4198 "Load .lldbinit files from current directory",
4203 "Do not load .lldbinit files from current directory",
4208 "Warn about loading .lldbinit files from current directory",
4216 "Load minimal information when loading modules from memory. Currently "
4217 "this setting loads sections only.",
4222 "Load partial information when loading modules from memory. Currently "
4223 "this setting loads sections and function bounds.",
4228 "Load complete information when loading modules from memory. Currently "
4229 "this setting loads sections and all symbols.",
4233#define LLDB_PROPERTIES_target
4234#include "TargetProperties.inc"
4237#define LLDB_PROPERTIES_target
4238#include "TargetPropertiesEnum.inc"
4243 :
public Cloneable<TargetOptionValueProperties, OptionValueProperties> {
4254 Target *target = exe_ctx->GetTargetPtr();
4259 if (
this != target_properties)
4263 return ProtectedGetPropertyAtIndex(idx);
4268#define LLDB_PROPERTIES_target_experimental
4269#include "TargetProperties.inc"
4272#define LLDB_PROPERTIES_target_experimental
4273#include "TargetPropertiesEnum.inc"
4277 :
public Cloneable<TargetExperimentalOptionValueProperties,
4278 OptionValueProperties> {
4292 :
Properties(), m_launch_info(), m_target(target) {
4315 m_collection_sp->SetValueChangedCallback(ePropertyDetachOnError, [
this] {
4328 std::make_unique<TargetExperimentalProperties>();
4331 "Experimental settings - setting these won't produce "
4332 "errors if the setting is not present.",
4335 m_collection_sp = std::make_shared<TargetOptionValueProperties>(
"target");
4338 std::make_unique<TargetExperimentalProperties>();
4341 "Experimental settings - setting these won't produce "
4342 "errors if the setting is not present.",
4345 "process",
"Settings specific to processes.",
true,
4372 exp_property->
GetValue()->GetAsProperties();
4375 return std::nullopt;
4388 exp_property->
GetValue()->GetAsProperties();
4400 exp_property->
GetValue()->GetAsProperties();
4406 const uint32_t idx = ePropertyDefaultArch;
4407 return GetPropertyAtIndexAs<ArchSpec>(idx, {});
4411 const uint32_t idx = ePropertyDefaultArch;
4416 const uint32_t idx = ePropertyMoveToNearestCode;
4417 return GetPropertyAtIndexAs<bool>(
4418 idx, g_target_properties[idx].default_uint_value != 0);
4422 const uint32_t idx = ePropertyPreferDynamic;
4423 return GetPropertyAtIndexAs<lldb::DynamicValueType>(
4425 g_target_properties[idx].default_uint_value));
4429 const uint32_t idx = ePropertyPreferDynamic;
4435 "Interrupted checking preload symbols")) {
4438 const uint32_t idx = ePropertyPreloadSymbols;
4439 return GetPropertyAtIndexAs<bool>(
4440 idx, g_target_properties[idx].default_uint_value != 0);
4444 const uint32_t idx = ePropertyPreloadSymbols;
4449 const uint32_t idx = ePropertyDisableASLR;
4450 return GetPropertyAtIndexAs<bool>(
4451 idx, g_target_properties[idx].default_uint_value != 0);
4455 const uint32_t idx = ePropertyDisableASLR;
4460 const uint32_t idx = ePropertyInheritTCC;
4461 return GetPropertyAtIndexAs<bool>(
4462 idx, g_target_properties[idx].default_uint_value != 0);
4466 const uint32_t idx = ePropertyInheritTCC;
4471 const uint32_t idx = ePropertyDetachOnError;
4472 return GetPropertyAtIndexAs<bool>(
4473 idx, g_target_properties[idx].default_uint_value != 0);
4477 const uint32_t idx = ePropertyDetachOnError;
4482 const uint32_t idx = ePropertyDisableSTDIO;
4483 return GetPropertyAtIndexAs<bool>(
4484 idx, g_target_properties[idx].default_uint_value != 0);
4488 const uint32_t idx = ePropertyDisableSTDIO;
4492 const uint32_t idx = ePropertyLaunchWorkingDir;
4493 return GetPropertyAtIndexAs<llvm::StringRef>(
4494 idx, g_target_properties[idx].default_cstr_value);
4498 const uint32_t idx = ePropertyDisassemblyFlavor;
4499 const char *return_value;
4502 GetPropertyAtIndexAs<x86DisassemblyFlavor>(
4504 g_target_properties[idx].default_uint_value));
4507 return return_value;
4511 const uint32_t idx = ePropertyDisassemblyCPU;
4512 llvm::StringRef str = GetPropertyAtIndexAs<llvm::StringRef>(
4513 idx, g_target_properties[idx].default_cstr_value);
4514 return str.empty() ? nullptr : str.data();
4518 const uint32_t idx = ePropertyDisassemblyFeatures;
4519 llvm::StringRef str = GetPropertyAtIndexAs<llvm::StringRef>(
4520 idx, g_target_properties[idx].default_cstr_value);
4521 return str.empty() ? nullptr : str.data();
4525 const uint32_t idx = ePropertyInlineStrategy;
4526 return GetPropertyAtIndexAs<InlineStrategy>(
4528 static_cast<InlineStrategy>(g_target_properties[idx].default_uint_value));
4534 const uint32_t idx = ePropertySourceRealpathPrefixes;
4539 const uint32_t idx = ePropertyArg0;
4540 return GetPropertyAtIndexAs<llvm::StringRef>(
4541 idx, g_target_properties[idx].default_cstr_value);
4545 const uint32_t idx = ePropertyArg0;
4551 const uint32_t idx = ePropertyRunArgs;
4556 const uint32_t idx = ePropertyRunArgs;
4565 GetPropertyAtIndexAs<bool>(
4566 ePropertyInheritEnv,
4567 g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
4569 Environment platform_env = platform_sp->GetEnvironment();
4570 for (
const auto &KV : platform_env)
4571 env[KV.first()] = KV.second;
4575 Args property_unset_env;
4577 property_unset_env);
4578 for (
const auto &var : property_unset_env)
4579 env.erase(var.ref());
4582 m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyEnvVars, property_env);
4584 env[KV.first()] = KV.second;
4599 if (!GetPropertyAtIndexAs<bool>(
4600 ePropertyInheritEnv,
4601 g_target_properties[ePropertyInheritEnv].default_uint_value != 0))
4605 if (platform_sp ==
nullptr)
4608 Environment platform_environment = platform_sp->GetEnvironment();
4609 for (
const auto &KV : platform_environment)
4610 environment[KV.first()] = KV.second;
4612 Args property_unset_environment;
4614 property_unset_environment);
4615 for (
const auto &var : property_unset_environment)
4616 environment.erase(var.ref());
4622 Args property_environment;
4624 property_environment);
4626 for (
const auto &KV :
Environment(property_environment))
4627 environment[KV.first()] = KV.second;
4634 const uint32_t idx = ePropertyEnvVars;
4639 const uint32_t idx = ePropertySkipPrologue;
4640 return GetPropertyAtIndexAs<bool>(
4641 idx, g_target_properties[idx].default_uint_value != 0);
4645 const uint32_t idx = ePropertySourceMap;
4648 assert(option_value);
4653 const uint32_t idx = ePropertyObjectMap;
4656 assert(option_value);
4661 const uint32_t idx = ePropertyAutoSourceMapRelative;
4662 return GetPropertyAtIndexAs<bool>(
4663 idx, g_target_properties[idx].default_uint_value != 0);
4667 const uint32_t idx = ePropertyExecutableSearchPaths;
4670 assert(option_value);
4675 const uint32_t idx = ePropertyExecutableSearchPaths;
4676 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4680 const uint32_t idx = ePropertyDebugFileSearchPaths;
4681 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4685 const uint32_t idx = ePropertyClangModuleSearchPaths;
4686 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4690 const uint32_t idx = ePropertyAutoImportClangModules;
4691 return GetPropertyAtIndexAs<bool>(
4692 idx, g_target_properties[idx].default_uint_value != 0);
4696 const uint32_t idx = ePropertyImportStdModule;
4697 return GetPropertyAtIndexAs<ImportStdModule>(
4699 g_target_properties[idx].default_uint_value));
4703 const uint32_t idx = ePropertyDynamicClassInfoHelper;
4704 return GetPropertyAtIndexAs<DynamicClassInfoHelper>(
4706 g_target_properties[idx].default_uint_value));
4710 const uint32_t idx = ePropertyAutoApplyFixIts;
4711 return GetPropertyAtIndexAs<bool>(
4712 idx, g_target_properties[idx].default_uint_value != 0);
4716 const uint32_t idx = ePropertyRetriesWithFixIts;
4717 return GetPropertyAtIndexAs<uint64_t>(
4718 idx, g_target_properties[idx].default_uint_value);
4722 const uint32_t idx = ePropertyNotifyAboutFixIts;
4723 return GetPropertyAtIndexAs<bool>(
4724 idx, g_target_properties[idx].default_uint_value != 0);
4728 const uint32_t idx = ePropertySaveObjectsDir;
4729 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4738 bool exists = instance.
Exists(new_dir);
4739 bool is_directory = instance.
IsDirectory(new_dir);
4740 std::string path = new_dir.
GetPath(
true);
4741 bool writable = llvm::sys::fs::can_write(path);
4742 if (exists && is_directory && writable)
4750 llvm::raw_string_ostream os(buffer);
4751 os <<
"JIT object dir '" << path <<
"' ";
4753 os <<
"does not exist";
4754 else if (!is_directory)
4755 os <<
"is not a directory";
4757 os <<
"is not writable";
4759 std::optional<lldb::user_id_t> debugger_id;
4766 const uint32_t idx = ePropertyEnableSynthetic;
4767 return GetPropertyAtIndexAs<bool>(
4768 idx, g_target_properties[idx].default_uint_value != 0);
4772 const uint32_t idx = ePropertyShowHexVariableValuesWithLeadingZeroes;
4773 return GetPropertyAtIndexAs<bool>(
4774 idx, g_target_properties[idx].default_uint_value != 0);
4778 const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
4779 return GetPropertyAtIndexAs<uint64_t>(
4780 idx, g_target_properties[idx].default_uint_value);
4784 const uint32_t idx = ePropertyMaxChildrenCount;
4785 return GetPropertyAtIndexAs<uint64_t>(
4786 idx, g_target_properties[idx].default_uint_value);
4789std::pair<uint32_t, bool>
4791 const uint32_t idx = ePropertyMaxChildrenDepth;
4792 auto *option_value =
4794 bool is_default = !option_value->OptionWasSet();
4795 return {option_value->GetCurrentValue(), is_default};
4799 const uint32_t idx = ePropertyMaxSummaryLength;
4800 return GetPropertyAtIndexAs<uint64_t>(
4801 idx, g_target_properties[idx].default_uint_value);
4805 const uint32_t idx = ePropertyMaxMemReadSize;
4806 return GetPropertyAtIndexAs<uint64_t>(
4807 idx, g_target_properties[idx].default_uint_value);
4811 const uint32_t idx = ePropertyInputPath;
4812 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4816 const uint32_t idx = ePropertyInputPath;
4821 const uint32_t idx = ePropertyOutputPath;
4822 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4826 const uint32_t idx = ePropertyOutputPath;
4831 const uint32_t idx = ePropertyErrorPath;
4832 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4836 const uint32_t idx = ePropertyErrorPath;
4841 const uint32_t idx = ePropertyLanguage;
4842 return {GetPropertyAtIndexAs<LanguageType>(idx, {})};
4846 const uint32_t idx = ePropertyExprPrefix;
4852 return llvm::StringRef(
4853 reinterpret_cast<const char *
>(data_sp->GetBytes()),
4854 data_sp->GetByteSize());
4860 const uint32_t idx = ePropertyExprErrorLimit;
4861 return GetPropertyAtIndexAs<uint64_t>(
4862 idx, g_target_properties[idx].default_uint_value);
4866 const uint32_t idx = ePropertyExprAllocAddress;
4867 return GetPropertyAtIndexAs<uint64_t>(
4868 idx, g_target_properties[idx].default_uint_value);
4872 const uint32_t idx = ePropertyExprAllocSize;
4873 return GetPropertyAtIndexAs<uint64_t>(
4874 idx, g_target_properties[idx].default_uint_value);
4878 const uint32_t idx = ePropertyExprAllocAlign;
4879 return GetPropertyAtIndexAs<uint64_t>(
4880 idx, g_target_properties[idx].default_uint_value);
4884 const uint32_t idx = ePropertyBreakpointUseAvoidList;
4885 return GetPropertyAtIndexAs<bool>(
4886 idx, g_target_properties[idx].default_uint_value != 0);
4890 const uint32_t idx = ePropertyUseHexImmediates;
4891 return GetPropertyAtIndexAs<bool>(
4892 idx, g_target_properties[idx].default_uint_value != 0);
4896 const uint32_t idx = ePropertyUseFastStepping;
4897 return GetPropertyAtIndexAs<bool>(
4898 idx, g_target_properties[idx].default_uint_value != 0);
4902 const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
4903 return GetPropertyAtIndexAs<bool>(
4904 idx, g_target_properties[idx].default_uint_value != 0);
4908 const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
4909 return GetPropertyAtIndexAs<LoadScriptFromSymFile>(
4911 g_target_properties[idx].default_uint_value));
4915 const uint32_t idx = ePropertyLoadCWDlldbinitFile;
4916 return GetPropertyAtIndexAs<LoadCWDlldbinitFile>(
4918 g_target_properties[idx].default_uint_value));
4922 const uint32_t idx = ePropertyHexImmediateStyle;
4923 return GetPropertyAtIndexAs<Disassembler::HexImmediateStyle>(
4925 g_target_properties[idx].default_uint_value));
4929 const uint32_t idx = ePropertyMemoryModuleLoadLevel;
4930 return GetPropertyAtIndexAs<MemoryModuleLoadLevel>(
4932 g_target_properties[idx].default_uint_value));
4936 const uint32_t idx = ePropertyTrapHandlerNames;
4941 const uint32_t idx = ePropertyTrapHandlerNames;
4946 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4947 return GetPropertyAtIndexAs<bool>(
4948 idx, g_target_properties[idx].default_uint_value != 0);
4952 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4957 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4958 return GetPropertyAtIndexAs<bool>(
4959 idx, g_target_properties[idx].default_uint_value != 0);
4963 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4979 if (input_file_action) {
4984 if (output_file_action) {
4989 if (error_file_action) {
4995 launch_info.
GetFlags().
Test(lldb::eLaunchFlagInheritTCCFromParent));
5000 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
5001 return GetPropertyAtIndexAs<bool>(
5002 idx, g_target_properties[idx].default_uint_value != 0);