66#include "llvm/ADT/ScopeExit.h"
67#include "llvm/ADT/SetVector.h"
81 m_plugin_up(
PluginManager::CreateArchitectureInstance(spec)) {}
118 static_cast<void *
>(
this));
121 "Target::Target created with architecture {0} ({1})",
123 target_arch.
GetTriple().getTriple().c_str());
131 LLDB_LOG(log,
"{0} Target::~Target()",
static_cast<void *
>(
this));
139 if (breakpoint_sp->IsInternal())
184 std::unique_lock<std::recursive_mutex> lock;
209 llvm::StringRef plugin_name,
216 listener_sp, crash_file, can_connect);
223 const char *repl_options,
bool can_create) {
231 language = *single_lang;
232 }
else if (repl_languages.
Empty()) {
234 "LLDB isn't configured with REPL support for any languages.");
238 "Multiple possible REPL languages. Please specify a language.");
243 REPLMap::iterator pos =
m_repl_map.find(language);
251 "Couldn't find an existing REPL for %s, and can't create a new one",
279 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
286 const bool notify =
false;
309 return abi_sp->GetPluginName();
340 ModuleSP main_module_sp = GetExecutableModule();
342 shared_lib_filter.
Append(main_module_sp->GetFileSpec());
343 llvm::SetVector<std::string, std::vector<std::string>,
344 std::unordered_set<std::string>>
349 error.SetErrorString(
"Language not found\n");
353 if (!entryPointName.empty())
354 entryPointNamesSet.insert(entryPointName);
356 if (entryPointNamesSet.empty()) {
357 error.SetErrorString(
"No entry point name found\n");
362 nullptr, entryPointNamesSet.takeVector(),
363 eFunctionNameTypeFull,
370 error.SetErrorString(
"Breakpoint creation failed.\n");
373 bp_sp->SetOneShot(
true);
380 const std::unordered_set<std::string> &function_names,
384 containingModules, source_file_spec_list));
388 nullptr, std::move(source_regex), function_names,
389 !
static_cast<bool>(move_to_nearest_code)));
395 const FileSpec &file, uint32_t line_no,
398 LazyBool skip_prologue,
bool internal,
402 std::optional<llvm::StringRef> removed_prefix_opt =
404 if (!removed_prefix_opt)
405 remapped_file = file;
409 switch (inline_strategy) {
430 compile_unit_list.
Append(remapped_file);
443 !
static_cast<bool>(move_to_nearest_code));
448 nullptr, offset, skip_prologue, location_spec, removed_prefix_opt));
484 bool request_hardware) {
488 nullptr, file_addr, file_spec));
495 const FileSpecList *containingSourceFiles,
const char *func_name,
496 FunctionNameType func_name_type_mask,
LanguageType language,
501 containingModules, containingSourceFiles));
510 offset, skip_prologue));
519 const std::vector<std::string> &func_names,
520 FunctionNameType func_name_type_mask,
522 LazyBool skip_prologue,
bool internal,
bool hardware) {
524 size_t num_names = func_names.size();
527 containingModules, containingSourceFiles));
536 language, offset, skip_prologue));
545 const char *func_names[],
size_t num_names,
546 FunctionNameType func_name_type_mask,
548 LazyBool skip_prologue,
bool internal,
bool hardware) {
552 containingModules, containingSourceFiles));
564 nullptr, func_names, num_names, func_name_type_mask, language, offset,
566 resolver_sp->SetOffset(offset);
575 if (containingModule !=
nullptr) {
578 filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
583 std::make_shared<SearchFilterForUnconstrainedSearches>(
593 if (containingModules && containingModules->
GetSize() != 0) {
596 filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
601 std::make_shared<SearchFilterForUnconstrainedSearches>(
611 if (containingSourceFiles ==
nullptr || containingSourceFiles->
GetSize() == 0)
615 if (containingModules ==
nullptr) {
619 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
620 shared_from_this(),
FileSpecList(), *containingSourceFiles);
622 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
623 shared_from_this(), *containingModules, *containingSourceFiles);
632 bool internal,
bool hardware) {
634 containingModules, containingSourceFiles));
637 :
static_cast<bool>(skip_prologue);
639 nullptr, std::move(func_regex), requested_language, 0, skip));
646 bool catch_bp,
bool throw_bp,
bool internal,
649 *
this, language, catch_bp, throw_bp, internal);
650 if (exc_bkpt_sp && additional_args) {
652 if (precondition_sp && additional_args) {
654 *
error = precondition_sp->ConfigurePrecondition(*additional_args);
656 precondition_sp->ConfigurePrecondition(*additional_args);
663 const llvm::StringRef class_name,
const FileSpecList *containingModules,
664 const FileSpecList *containingSourceFiles,
bool internal,
671 containingSourceFiles && containingSourceFiles->
GetSize() > 0;
672 bool has_modules = containingModules && containingModules->
GetSize() > 0;
674 if (has_files && has_modules) {
676 containingSourceFiles);
677 }
else if (has_files) {
680 }
else if (has_modules) {
683 filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
694 bool internal,
bool request_hardware,
695 bool resolve_indirect_symbols) {
697 if (filter_sp && resolver_sp) {
699 bp_sp.reset(
new Breakpoint(*
this, filter_sp, resolver_sp, hardware,
700 resolve_indirect_symbols));
701 resolver_sp->SetBreakpoint(bp_sp);
719 LLDB_LOGF(log,
"Target::%s (internal = %s) => break_id = %s\n",
720 __FUNCTION__, bp_sp->IsInternal() ?
"yes" :
"no", s.
GetData());
723 bp_sp->ResolveBreakpoint();
737 error.SetErrorStringWithFormat(
"Could not find breakpoint %s", s.
GetData());
753 bp_sp->AddName(name);
758 std::make_pair(bp_name->GetName(), std::move(bp_name)));
764 if (!
error.Success())
769 return iter->second.get();
773 error.SetErrorStringWithFormat(
"Breakpoint name \"%s\" doesn't exist and "
774 "can_create is false.",
780 .insert(std::make_pair(name, std::make_unique<BreakpointName>(name)))
781 .first->second.get();
788 const char *name_cstr = name.
AsCString();
791 bp_sp->RemoveName(name_cstr);
809 llvm::Expected<std::vector<BreakpointSP>> expected_vector =
812 if (!expected_vector) {
814 llvm::toString(expected_vector.takeError()));
818 for (
auto bp_sp : *expected_vector)
825 names.push_back(bp_name_entry.first.AsCString());
835 std::optional<uint32_t> num_supported_hardware_watchpoints =
840 if (!num_supported_hardware_watchpoints)
843 if (num_supported_hardware_watchpoints == 0) {
844 error.SetErrorStringWithFormat(
845 "Target supports (%u) hardware watchpoint slots.\n",
846 *num_supported_hardware_watchpoints);
859 "Target::%s (addr = 0x%8.8" PRIx64
" size = %" PRIu64
861 __FUNCTION__, addr, (uint64_t)size, kind);
865 error.SetErrorString(
"process is not alive");
871 error.SetErrorString(
"cannot set a watchpoint with watch_size of 0");
873 error.SetErrorStringWithFormat(
"invalid watch address: %" PRIu64, addr);
878 error.SetErrorStringWithFormat(
"invalid watchpoint type: %d", kind);
888 const bool notify =
false;
893 addr = abi->FixDataAddress(addr);
907 std::unique_lock<std::recursive_mutex> lock;
911 size_t old_size = matched_sp->GetByteSize();
917 if (size == old_size && kind == old_type) {
919 wp_sp->SetEnabled(
false, notify);
928 wp_sp = std::make_shared<Watchpoint>(*
this, addr, size, type);
929 wp_sp->SetWatchpointType(kind, notify);
934 LLDB_LOGF(log,
"Target::%s (creation of watchpoint %s with id = %u)\n",
935 __FUNCTION__,
error.Success() ?
"succeeded" :
"failed",
950 LLDB_LOGF(log,
"Target::%s \n", __FUNCTION__);
959 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
960 internal_also ?
"yes" :
"no");
971 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
972 internal_also ?
"yes" :
"no");
981 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
988 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
989 internal_also ?
"yes" :
"no");
998 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
1005 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1025 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1035 bp_sp->SetEnabled(
false);
1043 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1054 bp_sp->SetEnabled(
true);
1070 error.SetErrorString(
"Invalid FileSpec.");
1074 std::string path(file.
GetPath());
1082 if (
error.Success()) {
1083 break_store_ptr = input_data_sp->
GetAsArray();
1084 if (!break_store_ptr) {
1085 error.SetErrorStringWithFormat(
1086 "Tried to append to invalid input file %s", path.c_str());
1092 if (!break_store_ptr) {
1093 break_store_sp = std::make_shared<StructuredData::Array>();
1094 break_store_ptr = break_store_sp.get();
1101 lldb::eFilePermissionsFileDefault);
1103 error.SetErrorStringWithFormat(
"Unable to open output file: %s.",
1108 std::unique_lock<std::recursive_mutex> lock;
1114 size_t num_breakpoints = breakpoints.
GetSize();
1115 for (
size_t i = 0; i < num_breakpoints; i++) {
1120 break_store_ptr->
AddItem(bkpt_save_sp);
1124 std::unordered_set<lldb::break_id_t> processed_bkpts;
1125 const size_t count = bp_ids.
GetSize();
1126 for (
size_t i = 0; i < count; ++i) {
1132 std::pair<std::unordered_set<lldb::break_id_t>::iterator,
bool>
1133 insert_result = processed_bkpts.insert(bp_id);
1134 if (!insert_result.second)
1141 if (!bkpt_save_sp) {
1142 error.SetErrorStringWithFormat(
"Unable to serialize breakpoint %d",
1146 break_store_ptr->
AddItem(bkpt_save_sp);
1151 break_store_ptr->
Dump(out_file,
false);
1158 std::vector<std::string> no_names;
1163 std::vector<std::string> &names,
1165 std::unique_lock<std::recursive_mutex> lock;
1171 if (!
error.Success()) {
1173 }
else if (!input_data_sp || !input_data_sp->IsValid()) {
1174 error.SetErrorStringWithFormat(
"Invalid JSON from input file: %s.",
1181 error.SetErrorStringWithFormat(
1182 "Invalid breakpoint data from input file: %s.", file.
GetPath().c_str());
1186 size_t num_bkpts = bkpt_array->
GetSize();
1187 size_t num_names = names.size();
1189 for (
size_t i = 0; i < num_bkpts; i++) {
1194 error.SetErrorStringWithFormat(
1195 "Invalid breakpoint data for element %zu from input file: %s.", i,
1206 shared_from_this(), bkpt_data_sp,
error);
1207 if (!
error.Success()) {
1208 error.SetErrorStringWithFormat(
1209 "Error restoring breakpoint %zu from %s: %s.", i,
1225 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1254 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1281 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1307 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1313 wp_sp->ResetHitCount();
1321 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1327 wp_sp->ResetHistoricValues();
1336 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1345 wp_sp->SetIgnoreCount(ignore_count);
1353 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1372 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1391 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1406 uint32_t ignore_count) {
1408 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1415 wp_sp->SetIgnoreCount(ignore_count);
1443 if (module_sp && !module_sp->LoadScriptingResourceInTarget(target,
error,
1445 if (
error.AsCString())
1447 "unable to load scripting data for module %s - error reported was "
1449 module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1452 if (feedback_stream.
GetSize())
1475 if (executable_sp) {
1478 executable_sp->GetFileSpec().GetPath().c_str());
1480 const bool notify =
true;
1487 m_arch = executable_sp->GetArchitecture();
1489 "Target::SetExecutableModule setting architecture to {0} ({1}) "
1490 "based on executable file",
1496 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
1497 bool load_dependents =
true;
1498 switch (load_dependent_files) {
1500 load_dependents = executable_sp->IsExecutable();
1503 load_dependents =
true;
1506 load_dependents =
false;
1510 if (executable_objfile && load_dependents) {
1513 for (uint32_t i = 0; i < dependent_files.
GetSize(); i++) {
1515 FileSpec platform_dependent_file_spec;
1517 m_platform_sp->GetFileWithUUID(dependent_file_spec,
nullptr,
1518 platform_dependent_file_spec);
1520 platform_dependent_file_spec = dependent_file_spec;
1525 if (image_module_sp) {
1527 ObjectFile *objfile = image_module_sp->GetObjectFile();
1541 bool replace_local_arch =
true;
1542 bool compatible_local_arch =
false;
1551 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
1555 GetDebugger().GetPlatformList().GetOrCreate(other, {},
1559 other = platform_arch;
1565 if (!missing_local_arch) {
1570 compatible_local_arch =
true;
1571 bool arch_changed, vendor_changed, os_changed, os_ver_changed,
1575 vendor_changed, os_changed,
1576 os_ver_changed, env_changed);
1578 if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
1579 replace_local_arch =
false;
1584 if (compatible_local_arch || missing_local_arch) {
1588 if (replace_local_arch)
1591 "Target::SetArchitecture merging compatible arch; arch "
1602 "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
1604 arch_spec.
GetTriple().getTriple().c_str(),
1613 if (executable_sp) {
1615 "Target::SetArchitecture Trying to select executable file "
1616 "architecture %s (%s)",
1618 arch_spec.
GetTriple().getTriple().c_str());
1619 ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
1622 &search_paths,
nullptr,
nullptr);
1624 if (!
error.Fail() && executable_sp) {
1640 "Target::MergeArchitecture target has arch %s, merging with "
1643 arch_spec.
GetTriple().getTriple().c_str());
1664 my_module_list.
Append(module_sp);
1674 my_module_list.
Append(module_sp);
1687 old_module_sp, new_module_sp);
1696 const size_t num_images = module_list.
GetSize();
1698 for (
size_t idx = 0; idx < num_images; ++idx) {
1716 runtime->SymbolsDidLoad(module_list);
1744 const bool should_flush_type_systems =
1751 auto type = object_file->
GetType();
1761 if (should_flush_type_systems)
1767 const FileSpec &module_file_spec) {
1772 size_t num_modules = matchingModules.
GetSize();
1776 if (num_modules > 0) {
1777 for (
size_t i = 0; i < num_modules; i++) {
1792 return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*
this,
1804 if (section_sp->IsEncrypted()) {
1805 error.SetErrorString(
"section is encrypted");
1808 ModuleSP module_sp(section_sp->GetModule());
1813 section_sp.get(), addr.
GetOffset(), dst, dst_len);
1817 error.SetErrorStringWithFormat(
"error reading data from section %s",
1818 section_sp->GetName().GetCString());
1820 error.SetErrorString(
"address isn't from a object file");
1822 error.SetErrorString(
"address isn't in a module");
1824 error.SetErrorString(
"address doesn't contain a section that points to a "
1825 "section in a object file");
1846 size_t bytes_read = 0;
1853 if (section_load_list.
IsEmpty()) {
1872 resolved_addr = fixed_addr;
1877 std::unique_ptr<uint8_t[]> file_cache_read_buffer;
1878 size_t file_cache_bytes_read = 0;
1884 auto permissions =
Flags(section_sp->GetPermissions());
1885 bool is_readonly = !permissions.Test(ePermissionsWritable) &&
1886 permissions.Test(ePermissionsReadable);
1888 file_cache_bytes_read =
1890 if (file_cache_bytes_read == dst_len)
1891 return file_cache_bytes_read;
1892 else if (file_cache_bytes_read > 0) {
1893 file_cache_read_buffer =
1894 std::make_unique<uint8_t[]>(file_cache_bytes_read);
1895 std::memcpy(file_cache_read_buffer.get(), dst, file_cache_bytes_read);
1907 if (addr_module_sp && addr_module_sp->GetFileSpec())
1908 error.SetErrorStringWithFormatv(
1909 "{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
1912 error.SetErrorStringWithFormat(
"0x%" PRIx64
" can't be resolved",
1916 if (bytes_read != dst_len) {
1917 if (
error.Success()) {
1918 if (bytes_read == 0)
1919 error.SetErrorStringWithFormat(
1920 "read memory from 0x%" PRIx64
" failed", load_addr);
1922 error.SetErrorStringWithFormat(
1923 "only %" PRIu64
" of %" PRIu64
1924 " bytes were read from memory at 0x%" PRIx64,
1925 (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
1930 *load_addr_ptr = load_addr;
1936 if (file_cache_read_buffer && file_cache_bytes_read > 0) {
1939 std::memcpy(dst, file_cache_read_buffer.get(), file_cache_bytes_read);
1940 return file_cache_bytes_read;
1962 out_str.append(buf, length);
1965 if (length ==
sizeof(buf) - 1)
1966 curr_addr += length;
1971 return out_str.size();
1975 size_t dst_max_len,
Status &result_error,
1976 bool force_live_memory) {
1977 size_t total_cstr_len = 0;
1978 if (dst && dst_max_len) {
1979 result_error.
Clear();
1981 memset(dst, 0, dst_max_len);
1989 const size_t cache_line_size = 512;
1991 size_t bytes_left = dst_max_len - 1;
1992 char *curr_dst = dst;
1994 while (bytes_left > 0) {
1995 addr_t cache_line_bytes_left =
1996 cache_line_size - (curr_addr % cache_line_size);
1998 std::min<addr_t>(bytes_left, cache_line_bytes_left);
1999 size_t bytes_read =
ReadMemory(address, curr_dst, bytes_to_read,
error,
2002 if (bytes_read == 0) {
2003 result_error =
error;
2004 dst[total_cstr_len] =
'\0';
2007 const size_t len = strlen(curr_dst);
2009 total_cstr_len += len;
2011 if (len < bytes_to_read)
2014 curr_dst += bytes_read;
2015 curr_addr += bytes_read;
2016 bytes_left -= bytes_read;
2023 result_error.
Clear();
2025 return total_cstr_len;
2033 return cache_line_size - (load_addr % cache_line_size);
2043 size_t type_width,
bool force_live_memory) {
2044 if (!dst || !max_bytes || !type_width || max_bytes < type_width)
2047 size_t total_bytes_read = 0;
2051 memset(dst, 0, max_bytes);
2052 size_t bytes_left = max_bytes - type_width;
2054 const char terminator[4] = {
'\0',
'\0',
'\0',
'\0'};
2055 assert(
sizeof(terminator) >= type_width &&
"Attempting to validate a "
2056 "string with more than 4 bytes "
2060 char *curr_dst = dst;
2063 while (bytes_left > 0 &&
error.Success()) {
2067 ReadMemory(address, curr_dst, bytes_to_read,
error, force_live_memory);
2069 if (bytes_read == 0)
2074 size_t aligned_start = total_bytes_read - total_bytes_read % type_width;
2075 for (
size_t i = aligned_start;
2076 i + type_width <= total_bytes_read + bytes_read; i += type_width)
2077 if (::memcmp(&dst[i], terminator, type_width) == 0) {
2082 total_bytes_read += bytes_read;
2083 curr_dst += bytes_read;
2084 address.
Slide(bytes_read);
2085 bytes_left -= bytes_read;
2087 return total_bytes_read;
2091 bool is_signed,
Scalar &scalar,
2093 bool force_live_memory) {
2096 if (byte_size <=
sizeof(uval)) {
2099 if (bytes_read == byte_size) {
2104 scalar = data.
GetMaxU32(&offset, byte_size);
2106 scalar = data.
GetMaxU64(&offset, byte_size);
2113 error.SetErrorStringWithFormat(
2114 "byte size of %u is too large for integer scalar type", byte_size);
2120 size_t integer_byte_size,
2122 bool force_live_memory) {
2132 bool force_live_memory) {
2135 false, scalar,
error, force_live_memory)) {
2139 if (section_load_list.
IsEmpty()) {
2153 pointer_addr.
SetOffset(pointer_vm_addr);
2174 llvm::SmallVector<ModuleSP, 1>
2177 bool did_create_module =
false;
2187 module_spec, module_sp, symbol_file_spec, &did_create_module);
2218 &search_paths, &old_modules,
2219 &did_create_module);
2237 &old_modules, &did_create_module);
2245 module_spec,
m_process_sp.get(), module_sp, &search_paths,
2246 &old_modules, &did_create_module);
2248 error.SetErrorString(
"no platform is currently set");
2257 ObjectFile *objfile = module_sp->GetObjectFile();
2272 error_ptr->
SetErrorString(
"debug info files aren't valid target "
2273 "modules, please specify an executable");
2280 "modules, please specify an executable");
2285 "unsupported file type, please specify an executable");
2306 old_modules.push_back(found_module);
2313 if (symbol_file_spec)
2314 module_sp->SetSymbolFileFileSpec(symbol_file_spec);
2319 module_sp->PreloadSymbols();
2320 llvm::SmallVector<ModuleSP, 1> replaced_modules;
2321 for (
ModuleSP &old_module_sp : old_modules) {
2324 if (replaced_modules.empty())
2329 replaced_modules.push_back(std::move(old_module_sp));
2333 if (replaced_modules.size() > 1) {
2346 auto dump = [&message](
Module &dump_module) ->
void {
2347 UUID dump_uuid = dump_module.GetUUID();
2351 message <<
" (uuid ";
2354 dump_uuid.
Dump(message);
2356 message <<
"not specified";
2361 message <<
"New module ";
2364 << llvm::formatv(
" simultaneously replaced {0} old modules: ",
2365 replaced_modules.size());
2366 for (
ModuleSP &replaced_module_sp : replaced_modules)
2367 dump(*replaced_module_sp);
2373 if (replaced_modules.empty())
2376 for (
ModuleSP &old_module_sp : replaced_modules) {
2377 Module *old_module_ptr = old_module_sp.get();
2378 old_module_sp.reset();
2415llvm::Expected<lldb::TypeSystemSP>
2417 bool create_on_demand) {
2419 return llvm::make_error<llvm::StringError>(
"Invalid Target",
2420 llvm::inconvertibleErrorCode());
2432 if (languages_for_expressions.
Empty())
2433 return llvm::make_error<llvm::StringError>(
2434 "No expression support for any languages",
2435 llvm::inconvertibleErrorCode());
2446 uint32_t byte_size) {
2449 return provider->GetRegisterType(name, flags, byte_size);
2452std::vector<lldb::TypeSystemSP>
2460 std::vector<lldb::TypeSystemSP> scratch_type_systems;
2465 for (
auto bit : languages_for_expressions.
bitvector.set_bits()) {
2467 auto type_system_or_err =
2469 if (!type_system_or_err)
2472 "Language '{1}' has expression support but no scratch type "
2473 "system available: {0}",
2476 if (
auto ts = *type_system_or_err)
2477 scratch_type_systems.push_back(ts);
2480 std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
2481 scratch_type_systems.erase(
2482 std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
2483 scratch_type_systems.end());
2484 return scratch_type_systems;
2491 if (
auto err = type_system_or_err.takeError()) {
2494 "Unable to get persistent expression state for language {1}: {0}",
2499 if (
auto ts = *type_system_or_err)
2500 return ts->GetPersistentExpressionState();
2503 "Unable to get persistent expression state for language {1}: {0}",
2514 if (
auto err = type_system_or_err.takeError()) {
2515 error.SetErrorStringWithFormat(
2516 "Could not find type system for language %s: %s",
2518 llvm::toString(std::move(err)).c_str());
2522 auto ts = *type_system_or_err;
2524 error.SetErrorStringWithFormat(
2525 "Type system for language %s is no longer live",
2530 auto *user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
2533 error.SetErrorStringWithFormat(
2534 "Could not create an expression for language %s",
2545 if (
auto err = type_system_or_err.takeError()) {
2546 error.SetErrorStringWithFormat(
2547 "Could not find type system for language %s: %s",
2549 llvm::toString(std::move(err)).c_str());
2552 auto ts = *type_system_or_err;
2554 error.SetErrorStringWithFormat(
2555 "Type system for language %s is no longer live",
2559 auto *persistent_fn = ts->GetFunctionCaller(return_type, function_address,
2560 arg_value_list, name);
2562 error.SetErrorStringWithFormat(
2563 "Could not create an expression for language %s",
2566 return persistent_fn;
2569llvm::Expected<std::unique_ptr<UtilityFunction>>
2574 if (!type_system_or_err)
2575 return type_system_or_err.takeError();
2576 auto ts = *type_system_or_err;
2578 return llvm::make_error<llvm::StringError>(
2579 llvm::StringRef(
"Type system for language ") +
2581 llvm::StringRef(
" is no longer live"),
2582 llvm::inconvertibleErrorCode());
2583 std::unique_ptr<UtilityFunction> utility_fn =
2584 ts->CreateUtilityFunction(std::move(expression), std::move(name));
2586 return llvm::make_error<llvm::StringError>(
2587 llvm::StringRef(
"Could not create an expression for language") +
2589 llvm::inconvertibleErrorCode());
2592 if (!utility_fn->Install(diagnostics, exe_ctx))
2593 return llvm::make_error<llvm::StringError>(diagnostics.
GetString(),
2594 llvm::inconvertibleErrorCode());
2596 return std::move(utility_fn);
2617 "setting target's default architecture to {0} ({1})",
2624 if (llvm::to_integer(label, n))
2625 return llvm::make_error<llvm::StringError>(
2626 "Cannot use integer as target label.", llvm::inconvertibleErrorCode());
2630 if (target_sp && target_sp->GetLabel() == label) {
2631 return llvm::make_error<llvm::StringError>(
2633 "Cannot use label '{0}' since it's set in target #{1}.", label,
2635 llvm::inconvertibleErrorCode());
2640 return llvm::Error::success();
2649 Target *target =
nullptr;
2650 if (sc_ptr !=
nullptr)
2652 if (target ==
nullptr && exe_ctx_ptr)
2662 result_valobj_sp.reset();
2668 return execution_results;
2674 auto on_exit = llvm::make_scope_exit([
this, old_suppress_value]() {
2692 if (expr[0] ==
'$') {
2693 auto type_system_or_err =
2695 if (
auto err = type_system_or_err.takeError()) {
2697 "Unable to get scratch type system");
2699 auto ts = *type_system_or_err;
2702 "Scratch type system is no longer live: {0}");
2705 ts->GetPersistentExpressionState()->GetVariable(expr);
2708 if (persistent_var_sp) {
2709 result_valobj_sp = persistent_var_sp->GetValueObject();
2715 result_valobj_sp,
error,
2716 fixed_expression, ctx_obj);
2718 if (
error.Fail() && !result_valobj_sp)
2720 exe_ctx.GetBestExecutionContextScope(),
error);
2727 return execution_results;
2733 [name, &variable_sp](
TypeSystemSP type_system) ->
bool {
2734 auto ts = type_system.get();
2738 ts->GetPersistentExpressionState()) {
2739 variable_sp = persistent_state->GetVariable(name);
2754 auto ts = type_system.get();
2759 ts->GetPersistentExpressionState()) {
2760 address = persistent_state->LookupSymbol(name);
2761 if (address != LLDB_INVALID_ADDRESS)
2773 const bool has_primary_executable = exe_module && exe_module->
GetObjectFile();
2774 if (has_primary_executable) {
2781 const size_t num_images = modules.
GetSize();
2782 for (
size_t idx = 0; idx < num_images; ++idx) {
2784 if (!module_sp || !module_sp->GetObjectFile())
2787 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2793 if (!has_primary_executable)
2794 return llvm::make_error<llvm::StringError>(
2795 "No primary executable found and could not find entry point address in "
2796 "any executable module",
2797 llvm::inconvertibleErrorCode());
2799 return llvm::make_error<llvm::StringError>(
2800 "Could not find entry point address for primary executable module \"" +
2802 llvm::inconvertibleErrorCode());
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();
4252 exp_property->
GetValue()->GetAsProperties();
4258 const uint32_t idx = ePropertyDefaultArch;
4259 return GetPropertyAtIndexAs<ArchSpec>(idx, {});
4263 const uint32_t idx = ePropertyDefaultArch;
4268 const uint32_t idx = ePropertyMoveToNearestCode;
4269 return GetPropertyAtIndexAs<bool>(
4270 idx, g_target_properties[idx].default_uint_value != 0);
4274 const uint32_t idx = ePropertyPreferDynamic;
4275 return GetPropertyAtIndexAs<lldb::DynamicValueType>(
4277 g_target_properties[idx].default_uint_value));
4281 const uint32_t idx = ePropertyPreferDynamic;
4287 "Interrupted checking preload symbols")) {
4290 const uint32_t idx = ePropertyPreloadSymbols;
4291 return GetPropertyAtIndexAs<bool>(
4292 idx, g_target_properties[idx].default_uint_value != 0);
4296 const uint32_t idx = ePropertyPreloadSymbols;
4301 const uint32_t idx = ePropertyDisableASLR;
4302 return GetPropertyAtIndexAs<bool>(
4303 idx, g_target_properties[idx].default_uint_value != 0);
4307 const uint32_t idx = ePropertyDisableASLR;
4312 const uint32_t idx = ePropertyInheritTCC;
4313 return GetPropertyAtIndexAs<bool>(
4314 idx, g_target_properties[idx].default_uint_value != 0);
4318 const uint32_t idx = ePropertyInheritTCC;
4323 const uint32_t idx = ePropertyDetachOnError;
4324 return GetPropertyAtIndexAs<bool>(
4325 idx, g_target_properties[idx].default_uint_value != 0);
4329 const uint32_t idx = ePropertyDetachOnError;
4334 const uint32_t idx = ePropertyDisableSTDIO;
4335 return GetPropertyAtIndexAs<bool>(
4336 idx, g_target_properties[idx].default_uint_value != 0);
4340 const uint32_t idx = ePropertyDisableSTDIO;
4345 const uint32_t idx = ePropertyDisassemblyFlavor;
4346 const char *return_value;
4349 GetPropertyAtIndexAs<x86DisassemblyFlavor>(
4351 g_target_properties[idx].default_uint_value));
4354 return return_value;
4358 const uint32_t idx = ePropertyInlineStrategy;
4359 return GetPropertyAtIndexAs<InlineStrategy>(
4361 static_cast<InlineStrategy>(g_target_properties[idx].default_uint_value));
4365 const uint32_t idx = ePropertyArg0;
4366 return GetPropertyAtIndexAs<llvm::StringRef>(
4367 idx, g_target_properties[idx].default_cstr_value);
4371 const uint32_t idx = ePropertyArg0;
4377 const uint32_t idx = ePropertyRunArgs;
4382 const uint32_t idx = ePropertyRunArgs;
4391 GetPropertyAtIndexAs<bool>(
4392 ePropertyInheritEnv,
4393 g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
4395 Environment platform_env = platform_sp->GetEnvironment();
4396 for (
const auto &KV : platform_env)
4397 env[KV.first()] = KV.second;
4401 Args property_unset_env;
4403 property_unset_env);
4404 for (
const auto &var : property_unset_env)
4405 env.erase(var.ref());
4408 m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyEnvVars, property_env);
4410 env[KV.first()] = KV.second;
4425 if (!GetPropertyAtIndexAs<bool>(
4426 ePropertyInheritEnv,
4427 g_target_properties[ePropertyInheritEnv].default_uint_value != 0))
4431 if (platform_sp ==
nullptr)
4434 Environment platform_environment = platform_sp->GetEnvironment();
4435 for (
const auto &KV : platform_environment)
4436 environment[KV.first()] = KV.second;
4438 Args property_unset_environment;
4440 property_unset_environment);
4441 for (
const auto &var : property_unset_environment)
4442 environment.erase(var.ref());
4448 Args property_environment;
4450 property_environment);
4452 for (
const auto &KV :
Environment(property_environment))
4453 environment[KV.first()] = KV.second;
4460 const uint32_t idx = ePropertyEnvVars;
4465 const uint32_t idx = ePropertySkipPrologue;
4466 return GetPropertyAtIndexAs<bool>(
4467 idx, g_target_properties[idx].default_uint_value != 0);
4471 const uint32_t idx = ePropertySourceMap;
4474 assert(option_value);
4479 const uint32_t idx = ePropertyAutoSourceMapRelative;
4480 return GetPropertyAtIndexAs<bool>(
4481 idx, g_target_properties[idx].default_uint_value != 0);
4485 const uint32_t idx = ePropertyExecutableSearchPaths;
4488 assert(option_value);
4493 const uint32_t idx = ePropertyExecutableSearchPaths;
4494 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4498 const uint32_t idx = ePropertyDebugFileSearchPaths;
4499 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4503 const uint32_t idx = ePropertyClangModuleSearchPaths;
4504 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
4508 const uint32_t idx = ePropertyAutoImportClangModules;
4509 return GetPropertyAtIndexAs<bool>(
4510 idx, g_target_properties[idx].default_uint_value != 0);
4514 const uint32_t idx = ePropertyImportStdModule;
4515 return GetPropertyAtIndexAs<ImportStdModule>(
4517 g_target_properties[idx].default_uint_value));
4521 const uint32_t idx = ePropertyDynamicClassInfoHelper;
4522 return GetPropertyAtIndexAs<DynamicClassInfoHelper>(
4524 g_target_properties[idx].default_uint_value));
4528 const uint32_t idx = ePropertyAutoApplyFixIts;
4529 return GetPropertyAtIndexAs<bool>(
4530 idx, g_target_properties[idx].default_uint_value != 0);
4534 const uint32_t idx = ePropertyRetriesWithFixIts;
4535 return GetPropertyAtIndexAs<uint64_t>(
4536 idx, g_target_properties[idx].default_uint_value);
4540 const uint32_t idx = ePropertyNotifyAboutFixIts;
4541 return GetPropertyAtIndexAs<bool>(
4542 idx, g_target_properties[idx].default_uint_value != 0);
4546 const uint32_t idx = ePropertySaveObjectsDir;
4547 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4556 bool exists = instance.
Exists(new_dir);
4557 bool is_directory = instance.
IsDirectory(new_dir);
4558 std::string path = new_dir.
GetPath(
true);
4559 bool writable = llvm::sys::fs::can_write(path);
4560 if (exists && is_directory && writable)
4568 llvm::raw_string_ostream os(buffer);
4569 os <<
"JIT object dir '" << path <<
"' ";
4571 os <<
"does not exist";
4572 else if (!is_directory)
4573 os <<
"is not a directory";
4575 os <<
"is not writable";
4577 std::optional<lldb::user_id_t> debugger_id;
4584 const uint32_t idx = ePropertyEnableSynthetic;
4585 return GetPropertyAtIndexAs<bool>(
4586 idx, g_target_properties[idx].default_uint_value != 0);
4590 const uint32_t idx = ePropertyShowHexVariableValuesWithLeadingZeroes;
4591 return GetPropertyAtIndexAs<bool>(
4592 idx, g_target_properties[idx].default_uint_value != 0);
4596 const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
4597 return GetPropertyAtIndexAs<uint64_t>(
4598 idx, g_target_properties[idx].default_uint_value);
4602 const uint32_t idx = ePropertyMaxChildrenCount;
4603 return GetPropertyAtIndexAs<int64_t>(
4604 idx, g_target_properties[idx].default_uint_value);
4607std::pair<uint32_t, bool>
4609 const uint32_t idx = ePropertyMaxChildrenDepth;
4610 auto *option_value =
4612 bool is_default = !option_value->OptionWasSet();
4613 return {option_value->GetCurrentValue(), is_default};
4617 const uint32_t idx = ePropertyMaxSummaryLength;
4618 return GetPropertyAtIndexAs<uint64_t>(
4619 idx, g_target_properties[idx].default_uint_value);
4623 const uint32_t idx = ePropertyMaxMemReadSize;
4624 return GetPropertyAtIndexAs<uint64_t>(
4625 idx, g_target_properties[idx].default_uint_value);
4629 const uint32_t idx = ePropertyInputPath;
4630 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4634 const uint32_t idx = ePropertyInputPath;
4639 const uint32_t idx = ePropertyOutputPath;
4640 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4644 const uint32_t idx = ePropertyOutputPath;
4649 const uint32_t idx = ePropertyErrorPath;
4650 return GetPropertyAtIndexAs<FileSpec>(idx, {});
4654 const uint32_t idx = ePropertyErrorPath;
4659 const uint32_t idx = ePropertyLanguage;
4660 return GetPropertyAtIndexAs<LanguageType>(idx, {});
4664 const uint32_t idx = ePropertyExprPrefix;
4670 return llvm::StringRef(
4671 reinterpret_cast<const char *
>(data_sp->GetBytes()),
4672 data_sp->GetByteSize());
4678 const uint32_t idx = ePropertyExprErrorLimit;
4679 return GetPropertyAtIndexAs<uint64_t>(
4680 idx, g_target_properties[idx].default_uint_value);
4684 const uint32_t idx = ePropertyExprAllocAddress;
4685 return GetPropertyAtIndexAs<uint64_t>(
4686 idx, g_target_properties[idx].default_uint_value);
4690 const uint32_t idx = ePropertyExprAllocSize;
4691 return GetPropertyAtIndexAs<uint64_t>(
4692 idx, g_target_properties[idx].default_uint_value);
4696 const uint32_t idx = ePropertyExprAllocAlign;
4697 return GetPropertyAtIndexAs<uint64_t>(
4698 idx, g_target_properties[idx].default_uint_value);
4702 const uint32_t idx = ePropertyBreakpointUseAvoidList;
4703 return GetPropertyAtIndexAs<bool>(
4704 idx, g_target_properties[idx].default_uint_value != 0);
4708 const uint32_t idx = ePropertyUseHexImmediates;
4709 return GetPropertyAtIndexAs<bool>(
4710 idx, g_target_properties[idx].default_uint_value != 0);
4714 const uint32_t idx = ePropertyUseFastStepping;
4715 return GetPropertyAtIndexAs<bool>(
4716 idx, g_target_properties[idx].default_uint_value != 0);
4720 const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
4721 return GetPropertyAtIndexAs<bool>(
4722 idx, g_target_properties[idx].default_uint_value != 0);
4726 const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
4727 return GetPropertyAtIndexAs<LoadScriptFromSymFile>(
4729 g_target_properties[idx].default_uint_value));
4733 const uint32_t idx = ePropertyLoadCWDlldbinitFile;
4734 return GetPropertyAtIndexAs<LoadCWDlldbinitFile>(
4736 g_target_properties[idx].default_uint_value));
4740 const uint32_t idx = ePropertyHexImmediateStyle;
4741 return GetPropertyAtIndexAs<Disassembler::HexImmediateStyle>(
4743 g_target_properties[idx].default_uint_value));
4747 const uint32_t idx = ePropertyMemoryModuleLoadLevel;
4748 return GetPropertyAtIndexAs<MemoryModuleLoadLevel>(
4750 g_target_properties[idx].default_uint_value));
4754 const uint32_t idx = ePropertyTrapHandlerNames;
4759 const uint32_t idx = ePropertyTrapHandlerNames;
4764 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4765 return GetPropertyAtIndexAs<bool>(
4766 idx, g_target_properties[idx].default_uint_value != 0);
4770 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4775 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4776 return GetPropertyAtIndexAs<bool>(
4777 idx, g_target_properties[idx].default_uint_value != 0);
4781 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4797 if (input_file_action) {
4802 if (output_file_action) {
4807 if (error_file_action) {
4813 launch_info.
GetFlags().
Test(lldb::eLaunchFlagInheritTCCFromParent));
4818 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4819 return GetPropertyAtIndexAs<bool>(
4820 idx, g_target_properties[idx].default_uint_value != 0);
4824 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4829 const uint32_t idx = ePropertyAutoInstallMainExecutable;
4830 return GetPropertyAtIndexAs<bool>(
4831 idx, g_target_properties[idx].default_uint_value != 0);
4892 const uint32_t idx = ePropertyDebugUtilityExpression;
4893 return GetPropertyAtIndexAs<bool>(
4894 idx, g_target_properties[idx].default_uint_value != 0);
4898 const uint32_t idx = ePropertyDebugUtilityExpression;
4905 :
EventData(), m_target_sp(target_sp), m_module_list() {}
4909 :
EventData(), m_target_sp(target_sp), m_module_list(module_list) {}
4914 return "Target::TargetEventData";
4918 for (
size_t i = 0; i < m_module_list.GetSize(); ++i) {
4921 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.
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.