65#include "llvm/ADT/ScopeExit.h"
66#include "llvm/ADT/SetVector.h"
79 m_plugin_up(
PluginManager::CreateArchitectureInstance(spec)) {}
93 const lldb::PlatformSP &platform_sp,
bool is_dummy_target)
116 static_cast<void *
>(
this));
119 "Target::Target created with architecture {0} ({1})",
121 target_arch.
GetTriple().getTriple().c_str());
129 LLDB_LOG(log,
"{0} Target::~Target()",
static_cast<void *
>(
this));
137 if (breakpoint_sp->IsInternal())
182 std::unique_lock<std::recursive_mutex> lock;
207 llvm::StringRef plugin_name,
214 listener_sp, crash_file, can_connect);
221 const char *repl_options,
bool can_create) {
229 language = *single_lang;
230 }
else if (repl_languages.
Empty()) {
232 "LLDB isn't configured with REPL support for any languages.");
236 "Multiple possible REPL languages. Please specify a language.");
241 REPLMap::iterator pos =
m_repl_map.find(language);
249 "Couldn't find an existing REPL for %s, and can't create a new one",
251 return lldb::REPLSP();
255 lldb::REPLSP ret =
REPL::Create(err, language, debugger,
this, repl_options);
267 return lldb::REPLSP();
277 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
284 const bool notify =
false;
306 return abi_sp->GetPluginName();
336 const FileSpecList *containingModules,
337 const FileSpecList *source_file_spec_list,
338 const std::unordered_set<std::string> &function_names,
342 containingModules, source_file_spec_list));
346 nullptr, std::move(source_regex), function_names,
347 !
static_cast<bool>(move_to_nearest_code)));
356 LazyBool skip_prologue,
bool internal,
360 std::optional<llvm::StringRef> removed_prefix_opt =
362 if (!removed_prefix_opt)
363 remapped_file = file;
367 switch (inline_strategy) {
384 SearchFilterSP filter_sp;
387 FileSpecList compile_unit_list;
388 compile_unit_list.Append(remapped_file);
401 !
static_cast<bool>(move_to_nearest_code));
406 nullptr, offset, skip_prologue, location_spec, removed_prefix_opt));
432 SearchFilterSP filter_sp(
434 BreakpointResolverSP resolver_sp(
442 bool request_hardware) {
443 SearchFilterSP filter_sp(
446 nullptr, file_addr, file_spec ? *file_spec :
FileSpec()));
452 const FileSpecList *containingModules,
453 const FileSpecList *containingSourceFiles,
const char *func_name,
454 FunctionNameType func_name_type_mask,
LanguageType language,
459 containingModules, containingSourceFiles));
468 offset, skip_prologue));
476 const FileSpecList *containingSourceFiles,
477 const std::vector<std::string> &func_names,
478 FunctionNameType func_name_type_mask,
480 LazyBool skip_prologue,
bool internal,
bool hardware) {
482 size_t num_names = func_names.size();
485 containingModules, containingSourceFiles));
492 BreakpointResolverSP resolver_sp(
494 language, offset, skip_prologue));
502 const FileSpecList *containingSourceFiles,
503 const char *func_names[],
size_t num_names,
504 FunctionNameType func_name_type_mask,
506 LazyBool skip_prologue,
bool internal,
bool hardware) {
510 containingModules, containingSourceFiles));
522 nullptr, func_names, num_names, func_name_type_mask, language, offset,
524 resolver_sp->SetOffset(offset);
532 SearchFilterSP filter_sp;
533 if (containingModule !=
nullptr) {
536 filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
541 std::make_shared<SearchFilterForUnconstrainedSearches>(
550 SearchFilterSP filter_sp;
551 if (containingModules && containingModules->GetSize() != 0) {
554 filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
559 std::make_shared<SearchFilterForUnconstrainedSearches>(
567 const FileSpecList *containingModules,
568 const FileSpecList *containingSourceFiles) {
569 if (containingSourceFiles ==
nullptr || containingSourceFiles->GetSize() == 0)
572 SearchFilterSP filter_sp;
573 if (containingModules ==
nullptr) {
577 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
578 shared_from_this(), FileSpecList(), *containingSourceFiles);
580 filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
581 shared_from_this(), *containingModules, *containingSourceFiles);
587 const FileSpecList *containingModules,
590 bool internal,
bool hardware) {
592 containingModules, containingSourceFiles));
595 :
static_cast<bool>(skip_prologue);
597 nullptr, std::move(func_regex), requested_language, 0, skip));
604 bool catch_bp,
bool throw_bp,
bool internal,
607 *
this, language, catch_bp, throw_bp, internal);
608 if (exc_bkpt_sp && additional_args) {
609 BreakpointPreconditionSP precondition_sp = exc_bkpt_sp->GetPrecondition();
610 if (precondition_sp && additional_args) {
612 *
error = precondition_sp->ConfigurePrecondition(*additional_args);
614 precondition_sp->ConfigurePrecondition(*additional_args);
621 const llvm::StringRef class_name,
const FileSpecList *containingModules,
622 const FileSpecList *containingSourceFiles,
bool internal,
625 SearchFilterSP filter_sp;
629 containingSourceFiles && containingSourceFiles->GetSize() > 0;
630 bool has_modules = containingModules && containingModules->GetSize() > 0;
632 if (has_files && has_modules) {
634 containingSourceFiles);
635 }
else if (has_files) {
638 }
else if (has_modules) {
641 filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
651 BreakpointResolverSP &resolver_sp,
652 bool internal,
bool request_hardware,
653 bool resolve_indirect_symbols) {
655 if (filter_sp && resolver_sp) {
657 bp_sp.reset(
new Breakpoint(*
this, filter_sp, resolver_sp, hardware,
658 resolve_indirect_symbols));
659 resolver_sp->SetBreakpoint(bp_sp);
677 LLDB_LOGF(log,
"Target::%s (internal = %s) => break_id = %s\n",
678 __FUNCTION__, bp_sp->IsInternal() ?
"yes" :
"no", s.
GetData());
681 bp_sp->ResolveBreakpoint();
695 error.SetErrorStringWithFormat(
"Could not find breakpoint %s", s.
GetData());
711 bp_sp->AddName(name);
716 std::make_pair(bp_name->GetName(), std::move(bp_name)));
722 if (!
error.Success())
727 return iter->second.get();
731 error.SetErrorStringWithFormat(
"Breakpoint name \"%s\" doesn't exist and "
732 "can_create is false.",
738 .insert(std::make_pair(name, std::make_unique<BreakpointName>(name)))
739 .first->second.get();
746 const char *name_cstr = name.
AsCString();
749 bp_sp->RemoveName(name_cstr);
767 llvm::Expected<std::vector<BreakpointSP>> expected_vector =
770 if (!expected_vector) {
772 llvm::toString(expected_vector.takeError()));
776 for (
auto bp_sp : *expected_vector)
783 names.push_back(bp_name_entry.first.AsCString());
793 std::optional<uint32_t> num_supported_hardware_watchpoints =
798 if (!num_supported_hardware_watchpoints)
801 if (num_supported_hardware_watchpoints == 0) {
802 error.SetErrorStringWithFormat(
803 "Target supports (%u) hardware watchpoint slots.\n",
804 *num_supported_hardware_watchpoints);
817 "Target::%s (addr = 0x%8.8" PRIx64
" size = %" PRIu64
819 __FUNCTION__, addr, (uint64_t)size, kind);
823 error.SetErrorString(
"process is not alive");
829 error.SetErrorString(
"cannot set a watchpoint with watch_size of 0");
831 error.SetErrorStringWithFormat(
"invalid watch address: %" PRIu64, addr);
836 error.SetErrorStringWithFormat(
"invalid watchpoint type: %d", kind);
846 const bool notify =
false;
851 addr = abi->FixDataAddress(addr);
853 std::unique_lock<std::recursive_mutex> lock;
857 size_t old_size = matched_sp->GetByteSize();
862 if (size == old_size && kind == old_type) {
864 wp_sp->SetEnabled(
false, notify);
867 m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
873 wp_sp = std::make_shared<Watchpoint>(*
this, addr, size, type);
874 wp_sp->SetWatchpointType(kind, notify);
879 LLDB_LOGF(log,
"Target::%s (creation of watchpoint %s with id = %u)\n",
880 __FUNCTION__,
error.Success() ?
"succeeded" :
"failed",
889 error.SetErrorStringWithFormat(
890 "watch size of %" PRIu64
" is not supported", (uint64_t)size);
900 LLDB_LOGF(log,
"Target::%s \n", __FUNCTION__);
909 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
910 internal_also ?
"yes" :
"no");
921 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
922 internal_also ?
"yes" :
"no");
931 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
938 LLDB_LOGF(log,
"Target::%s (internal_also = %s)\n", __FUNCTION__,
939 internal_also ?
"yes" :
"no");
948 LLDB_LOGF(log,
"Target::%s", __FUNCTION__);
955 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
975 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
985 bp_sp->SetEnabled(
false);
993 LLDB_LOGF(log,
"Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__,
1004 bp_sp->SetEnabled(
true);
1020 error.SetErrorString(
"Invalid FileSpec.");
1024 std::string path(file.
GetPath());
1032 if (
error.Success()) {
1033 break_store_ptr = input_data_sp->
GetAsArray();
1034 if (!break_store_ptr) {
1035 error.SetErrorStringWithFormat(
1036 "Tried to append to invalid input file %s", path.c_str());
1042 if (!break_store_ptr) {
1043 break_store_sp = std::make_shared<StructuredData::Array>();
1044 break_store_ptr = break_store_sp.get();
1051 lldb::eFilePermissionsFileDefault);
1053 error.SetErrorStringWithFormat(
"Unable to open output file: %s.",
1058 std::unique_lock<std::recursive_mutex> lock;
1064 size_t num_breakpoints = breakpoints.
GetSize();
1065 for (
size_t i = 0; i < num_breakpoints; i++) {
1070 break_store_ptr->
AddItem(bkpt_save_sp);
1074 std::unordered_set<lldb::break_id_t> processed_bkpts;
1075 const size_t count = bp_ids.
GetSize();
1076 for (
size_t i = 0; i < count; ++i) {
1082 std::pair<std::unordered_set<lldb::break_id_t>::iterator,
bool>
1083 insert_result = processed_bkpts.insert(bp_id);
1084 if (!insert_result.second)
1091 if (!bkpt_save_sp) {
1092 error.SetErrorStringWithFormat(
"Unable to serialize breakpoint %d",
1096 break_store_ptr->
AddItem(bkpt_save_sp);
1101 break_store_ptr->
Dump(out_file,
false);
1108 std::vector<std::string> no_names;
1113 std::vector<std::string> &names,
1115 std::unique_lock<std::recursive_mutex> lock;
1121 if (!
error.Success()) {
1123 }
else if (!input_data_sp || !input_data_sp->IsValid()) {
1124 error.SetErrorStringWithFormat(
"Invalid JSON from input file: %s.",
1131 error.SetErrorStringWithFormat(
1132 "Invalid breakpoint data from input file: %s.", file.
GetPath().c_str());
1136 size_t num_bkpts = bkpt_array->
GetSize();
1137 size_t num_names = names.size();
1139 for (
size_t i = 0; i < num_bkpts; i++) {
1144 error.SetErrorStringWithFormat(
1145 "Invalid breakpoint data for element %zu from input file: %s.", i,
1156 shared_from_this(), bkpt_data_sp,
error);
1157 if (!
error.Success()) {
1158 error.SetErrorStringWithFormat(
1159 "Error restoring breakpoint %zu from %s: %s.", i,
1175 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1204 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1231 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1257 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1263 wp_sp->ResetHitCount();
1271 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1277 wp_sp->ResetHistoricValues();
1286 LLDB_LOGF(log,
"Target::%s\n", __FUNCTION__);
1295 wp_sp->SetIgnoreCount(ignore_count);
1303 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1322 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1341 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1358 LLDB_LOGF(log,
"Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
1365 wp_sp->SetIgnoreCount(ignore_count);
1393 if (module_sp && !module_sp->LoadScriptingResourceInTarget(
1394 target,
error, &feedback_stream)) {
1395 if (
error.AsCString())
1397 "unable to load scripting data for module %s - error reported was "
1399 module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
1402 if (feedback_stream.
GetSize())
1425 if (executable_sp) {
1428 executable_sp->GetFileSpec().GetPath().c_str());
1430 const bool notify =
true;
1437 m_arch = executable_sp->GetArchitecture();
1439 "Target::SetExecutableModule setting architecture to {0} ({1}) "
1440 "based on executable file",
1445 FileSpecList dependent_files;
1446 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
1447 bool load_dependents =
true;
1448 switch (load_dependent_files) {
1450 load_dependents = executable_sp->IsExecutable();
1453 load_dependents =
true;
1456 load_dependents =
false;
1460 if (executable_objfile && load_dependents) {
1463 for (
uint32_t i = 0; i < dependent_files.GetSize(); i++) {
1464 FileSpec dependent_file_spec(dependent_files.GetFileSpecAtIndex(i));
1465 FileSpec platform_dependent_file_spec;
1467 m_platform_sp->GetFileWithUUID(dependent_file_spec,
nullptr,
1468 platform_dependent_file_spec);
1470 platform_dependent_file_spec = dependent_file_spec;
1473 ModuleSP image_module_sp(
1475 if (image_module_sp) {
1477 ObjectFile *objfile = image_module_sp->GetObjectFile();
1491 bool replace_local_arch =
true;
1492 bool compatible_local_arch =
false;
1501 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
1504 if (PlatformSP arch_platform_sp =
1505 GetDebugger().GetPlatformList().GetOrCreate(other, {},
1509 other = platform_arch;
1515 if (!missing_local_arch) {
1520 compatible_local_arch =
true;
1521 bool arch_changed, vendor_changed, os_changed, os_ver_changed,
1525 vendor_changed, os_changed,
1526 os_ver_changed, env_changed);
1528 if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
1529 replace_local_arch =
false;
1534 if (compatible_local_arch || missing_local_arch) {
1538 if (replace_local_arch)
1541 "Target::SetArchitecture merging compatible arch; arch "
1552 "Target::SetArchitecture changing architecture to %s (%s) from %s (%s)",
1554 arch_spec.
GetTriple().getTriple().c_str(),
1563 if (executable_sp) {
1565 "Target::SetArchitecture Trying to select executable file "
1566 "architecture %s (%s)",
1568 arch_spec.
GetTriple().getTriple().c_str());
1569 ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
1572 &search_paths,
nullptr,
nullptr);
1574 if (!
error.Fail() && executable_sp) {
1590 "Target::MergeArchitecture target has arch %s, merging with "
1593 arch_spec.
GetTriple().getTriple().c_str());
1610 const ModuleSP &module_sp) {
1614 my_module_list.
Append(module_sp);
1620 const ModuleSP &module_sp) {
1624 my_module_list.
Append(module_sp);
1630 const ModuleSP &old_module_sp,
1631 const ModuleSP &new_module_sp) {
1637 old_module_sp, new_module_sp);
1646 const size_t num_images = module_list.
GetSize();
1648 for (
size_t idx = 0; idx < num_images; ++idx) {
1666 runtime->SymbolsDidLoad(module_list);
1694 const bool should_flush_type_systems =
1701 auto type = object_file->
GetType();
1711 if (should_flush_type_systems)
1717 const FileSpec &module_file_spec) {
1722 size_t num_modules = matchingModules.
GetSize();
1726 if (num_modules > 0) {
1727 for (
size_t i = 0; i < num_modules; i++) {
1739 const lldb::ModuleSP &module_sp) {
1742 return m_platform_sp->ModuleIsExcludedForUnconstrainedSearches(*
this,
1754 if (section_sp->IsEncrypted()) {
1755 error.SetErrorString(
"section is encrypted");
1758 ModuleSP module_sp(section_sp->GetModule());
1763 section_sp.get(), addr.
GetOffset(), dst, dst_len);
1767 error.SetErrorStringWithFormat(
"error reading data from section %s",
1768 section_sp->GetName().GetCString());
1770 error.SetErrorString(
"address isn't from a object file");
1772 error.SetErrorString(
"address isn't in a module");
1774 error.SetErrorString(
"address doesn't contain a section that points to a "
1775 "section in a object file");
1796 size_t bytes_read = 0;
1803 if (section_load_list.
IsEmpty()) {
1822 resolved_addr = fixed_addr;
1827 std::unique_ptr<uint8_t[]> file_cache_read_buffer;
1828 size_t file_cache_bytes_read = 0;
1832 SectionSP section_sp(resolved_addr.
GetSection());
1834 auto permissions =
Flags(section_sp->GetPermissions());
1835 bool is_readonly = !permissions.Test(ePermissionsWritable) &&
1836 permissions.Test(ePermissionsReadable);
1838 file_cache_bytes_read =
1840 if (file_cache_bytes_read == dst_len)
1841 return file_cache_bytes_read;
1842 else if (file_cache_bytes_read > 0) {
1843 file_cache_read_buffer =
1844 std::make_unique<uint8_t[]>(file_cache_bytes_read);
1845 std::memcpy(file_cache_read_buffer.get(), dst, file_cache_bytes_read);
1856 ModuleSP addr_module_sp(resolved_addr.
GetModule());
1857 if (addr_module_sp && addr_module_sp->GetFileSpec())
1858 error.SetErrorStringWithFormatv(
1859 "{0:F}[{1:x+}] can't be resolved, {0:F} is not currently loaded",
1862 error.SetErrorStringWithFormat(
"0x%" PRIx64
" can't be resolved",
1866 if (bytes_read != dst_len) {
1867 if (
error.Success()) {
1868 if (bytes_read == 0)
1869 error.SetErrorStringWithFormat(
1870 "read memory from 0x%" PRIx64
" failed", load_addr);
1872 error.SetErrorStringWithFormat(
1873 "only %" PRIu64
" of %" PRIu64
1874 " bytes were read from memory at 0x%" PRIx64,
1875 (uint64_t)bytes_read, (uint64_t)dst_len, load_addr);
1880 *load_addr_ptr = load_addr;
1886 if (file_cache_read_buffer && file_cache_bytes_read > 0) {
1889 std::memcpy(dst, file_cache_read_buffer.get(), file_cache_bytes_read);
1890 return file_cache_bytes_read;
1912 out_str.append(buf, length);
1915 if (length ==
sizeof(buf) - 1)
1916 curr_addr += length;
1921 return out_str.size();
1925 size_t dst_max_len,
Status &result_error,
1926 bool force_live_memory) {
1927 size_t total_cstr_len = 0;
1928 if (dst && dst_max_len) {
1929 result_error.
Clear();
1931 memset(dst, 0, dst_max_len);
1939 const size_t cache_line_size = 512;
1941 size_t bytes_left = dst_max_len - 1;
1942 char *curr_dst = dst;
1944 while (bytes_left > 0) {
1945 addr_t cache_line_bytes_left =
1946 cache_line_size - (curr_addr % cache_line_size);
1948 std::min<addr_t>(bytes_left, cache_line_bytes_left);
1949 size_t bytes_read =
ReadMemory(address, curr_dst, bytes_to_read,
error,
1952 if (bytes_read == 0) {
1953 result_error =
error;
1954 dst[total_cstr_len] =
'\0';
1957 const size_t len = strlen(curr_dst);
1959 total_cstr_len += len;
1961 if (len < bytes_to_read)
1964 curr_dst += bytes_read;
1965 curr_addr += bytes_read;
1966 bytes_left -= bytes_read;
1973 result_error.
Clear();
1975 return total_cstr_len;
1983 return cache_line_size - (load_addr % cache_line_size);
1993 size_t type_width,
bool force_live_memory) {
1994 if (!dst || !max_bytes || !type_width || max_bytes < type_width)
1997 size_t total_bytes_read = 0;
2001 memset(dst, 0, max_bytes);
2002 size_t bytes_left = max_bytes - type_width;
2004 const char terminator[4] = {
'\0',
'\0',
'\0',
'\0'};
2005 assert(
sizeof(terminator) >= type_width &&
"Attempting to validate a "
2006 "string with more than 4 bytes "
2010 char *curr_dst = dst;
2013 while (bytes_left > 0 &&
error.Success()) {
2017 ReadMemory(address, curr_dst, bytes_to_read,
error, force_live_memory);
2019 if (bytes_read == 0)
2024 size_t aligned_start = total_bytes_read - total_bytes_read % type_width;
2025 for (
size_t i = aligned_start;
2026 i + type_width <= total_bytes_read + bytes_read; i += type_width)
2027 if (::memcmp(&dst[i], terminator, type_width) == 0) {
2032 total_bytes_read += bytes_read;
2033 curr_dst += bytes_read;
2034 address.
Slide(bytes_read);
2035 bytes_left -= bytes_read;
2037 return total_bytes_read;
2041 bool is_signed,
Scalar &scalar,
2043 bool force_live_memory) {
2046 if (byte_size <=
sizeof(uval)) {
2049 if (bytes_read == byte_size) {
2054 scalar = data.
GetMaxU32(&offset, byte_size);
2056 scalar = data.
GetMaxU64(&offset, byte_size);
2063 error.SetErrorStringWithFormat(
2064 "byte size of %u is too large for integer scalar type", byte_size);
2070 size_t integer_byte_size,
2072 bool force_live_memory) {
2082 bool force_live_memory) {
2085 false, scalar,
error, force_live_memory)) {
2089 if (section_load_list.
IsEmpty()) {
2103 pointer_addr.
SetOffset(pointer_vm_addr);
2124 llvm::SmallVector<ModuleSP, 1>
2127 bool did_create_module =
false;
2140 &search_paths, &old_modules,
2141 &did_create_module);
2158 &old_modules, &did_create_module);
2166 module_spec,
m_process_sp.get(), module_sp, &search_paths,
2167 &old_modules, &did_create_module);
2169 error.SetErrorString(
"no platform is currently set");
2178 ObjectFile *objfile = module_sp->GetObjectFile();
2193 error_ptr->
SetErrorString(
"debug info files aren't valid target "
2194 "modules, please specify an executable");
2201 "modules, please specify an executable");
2206 "unsupported file type, please specify an executable");
2226 found_modules.
ForEach([&](
const ModuleSP &found_module) ->
bool {
2227 old_modules.push_back(found_module);
2235 module_sp->PreloadSymbols();
2237 llvm::SmallVector<ModuleSP, 1> replaced_modules;
2238 for (ModuleSP &old_module_sp : old_modules) {
2241 if (replaced_modules.empty())
2246 replaced_modules.push_back(std::move(old_module_sp));
2250 if (replaced_modules.size() > 1) {
2263 auto dump = [&message](
Module &dump_module) ->
void {
2264 UUID dump_uuid = dump_module.GetUUID();
2268 message <<
" (uuid ";
2271 dump_uuid.
Dump(&message);
2273 message <<
"not specified";
2278 message <<
"New module ";
2281 << llvm::formatv(
" simultaneously replaced {0} old modules: ",
2282 replaced_modules.size());
2283 for (ModuleSP &replaced_module_sp : replaced_modules)
2284 dump(*replaced_module_sp);
2290 if (replaced_modules.empty())
2293 for (ModuleSP &old_module_sp : replaced_modules) {
2294 Module *old_module_ptr = old_module_sp.get();
2295 old_module_sp.reset();
2332llvm::Expected<lldb::TypeSystemSP>
2334 bool create_on_demand) {
2336 return llvm::make_error<llvm::StringError>(
"Invalid Target",
2337 llvm::inconvertibleErrorCode());
2349 if (languages_for_expressions.
Empty())
2350 return llvm::make_error<llvm::StringError>(
2351 "No expression support for any languages",
2352 llvm::inconvertibleErrorCode());
2361std::vector<lldb::TypeSystemSP>
2369 std::vector<lldb::TypeSystemSP> scratch_type_systems;
2374 for (
auto bit : languages_for_expressions.
bitvector.set_bits()) {
2376 auto type_system_or_err =
2378 if (!type_system_or_err)
2380 "Language '{}' has expression support but no scratch type "
2384 if (
auto ts = *type_system_or_err)
2385 scratch_type_systems.push_back(ts);
2388 std::sort(scratch_type_systems.begin(), scratch_type_systems.end());
2389 scratch_type_systems.erase(
2390 std::unique(scratch_type_systems.begin(), scratch_type_systems.end()),
2391 scratch_type_systems.end());
2392 return scratch_type_systems;
2399 if (
auto err = type_system_or_err.takeError()) {
2401 "Unable to get persistent expression state for language {}",
2406 if (
auto ts = *type_system_or_err)
2407 return ts->GetPersistentExpressionState();
2410 "Unable to get persistent expression state for language {}",
2421 if (
auto err = type_system_or_err.takeError()) {
2422 error.SetErrorStringWithFormat(
2423 "Could not find type system for language %s: %s",
2425 llvm::toString(std::move(err)).c_str());
2429 auto ts = *type_system_or_err;
2431 error.SetErrorStringWithFormat(
2432 "Type system for language %s is no longer live",
2437 auto *user_expr = ts->GetUserExpression(expr, prefix, language, desired_type,
2440 error.SetErrorStringWithFormat(
2441 "Could not create an expression for language %s",
2452 if (
auto err = type_system_or_err.takeError()) {
2453 error.SetErrorStringWithFormat(
2454 "Could not find type system for language %s: %s",
2456 llvm::toString(std::move(err)).c_str());
2459 auto ts = *type_system_or_err;
2461 error.SetErrorStringWithFormat(
2462 "Type system for language %s is no longer live",
2466 auto *persistent_fn = ts->GetFunctionCaller(return_type, function_address,
2467 arg_value_list, name);
2469 error.SetErrorStringWithFormat(
2470 "Could not create an expression for language %s",
2473 return persistent_fn;
2476llvm::Expected<std::unique_ptr<UtilityFunction>>
2481 if (!type_system_or_err)
2482 return type_system_or_err.takeError();
2483 auto ts = *type_system_or_err;
2485 return llvm::make_error<llvm::StringError>(
2486 llvm::StringRef(
"Type system for language ") +
2488 llvm::StringRef(
" is no longer live"),
2489 llvm::inconvertibleErrorCode());
2490 std::unique_ptr<UtilityFunction> utility_fn =
2491 ts->CreateUtilityFunction(std::move(expression), std::move(name));
2493 return llvm::make_error<llvm::StringError>(
2494 llvm::StringRef(
"Could not create an expression for language") +
2496 llvm::inconvertibleErrorCode());
2499 if (!utility_fn->Install(diagnostics, exe_ctx))
2500 return llvm::make_error<llvm::StringError>(diagnostics.
GetString(),
2501 llvm::inconvertibleErrorCode());
2503 return std::move(utility_fn);
2524 "setting target's default architecture to {0} ({1})",
2535 Target *target =
nullptr;
2536 if (sc_ptr !=
nullptr)
2538 if (target ==
nullptr && exe_ctx_ptr)
2545 lldb::ValueObjectSP &result_valobj_sp,
2548 result_valobj_sp.reset();
2554 return execution_results;
2560 auto on_exit = llvm::make_scope_exit([
this, old_suppress_value]() {
2577 lldb::ExpressionVariableSP persistent_var_sp;
2578 if (expr[0] ==
'$') {
2579 auto type_system_or_err =
2581 if (
auto err = type_system_or_err.takeError()) {
2583 "Unable to get scratch type system");
2585 auto ts = *type_system_or_err;
2588 "Scratch type system is no longer live");
2591 ts->GetPersistentExpressionState()->GetVariable(expr);
2594 if (persistent_var_sp) {
2595 result_valobj_sp = persistent_var_sp->GetValueObject();
2601 result_valobj_sp,
error,
2602 fixed_expression, ctx_obj);
2604 if (
error.Fail() && !result_valobj_sp)
2606 exe_ctx.GetBestExecutionContextScope(),
error);
2613 return execution_results;
2617 lldb::ExpressionVariableSP variable_sp;
2619 [name, &variable_sp](TypeSystemSP type_system) ->
bool {
2620 auto ts = type_system.get();
2624 ts->GetPersistentExpressionState()) {
2625 variable_sp = persistent_state->GetVariable(name);
2639 [name, &address](lldb::TypeSystemSP type_system) ->
bool {
2640 auto ts = type_system.get();
2645 ts->GetPersistentExpressionState()) {
2646 address = persistent_state->LookupSymbol(name);
2647 if (address != LLDB_INVALID_ADDRESS)
2659 const bool has_primary_executable = exe_module && exe_module->
GetObjectFile();
2660 if (has_primary_executable) {
2667 const size_t num_images = modules.
GetSize();
2668 for (
size_t idx = 0; idx < num_images; ++idx) {
2670 if (!module_sp || !module_sp->GetObjectFile())
2673 Address entry_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
2679 if (!has_primary_executable)
2680 return llvm::make_error<llvm::StringError>(
2681 "No primary executable found and could not find entry point address in "
2682 "any executable module",
2683 llvm::inconvertibleErrorCode());
2685 return llvm::make_error<llvm::StringError>(
2686 "Could not find entry point address for primary executable module \"" +
2688 llvm::inconvertibleErrorCode());
2695 ? arch_plugin->GetCallableLoadAddress(load_addr, addr_class)
2702 return arch_plugin ? arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class)
2708 return arch_plugin ? arch_plugin->GetBreakableLoadAddress(addr, *
this) : addr;
2729 return stop_hook_sp;
2741 return (num_removed != 0);
2749 StopHookCollection::iterator specified_hook_iter;
2752 found_hook = (*specified_hook_iter).second;
2757 bool active_state) {
2758 StopHookCollection::iterator specified_hook_iter;
2763 (*specified_hook_iter).second->SetIsActive(active_state);
2768 StopHookCollection::iterator pos, end =
m_stop_hooks.end();
2770 (*pos).second->SetIsActive(active_state);
2790 bool any_active_hooks =
false;
2792 if (hook.second->IsActive()) {
2793 any_active_hooks =
true;
2797 if (!any_active_hooks)
2812 std::vector<ExecutionContext> exc_ctx_with_reasons;
2815 size_t num_threads = cur_threadlist.
GetSize();
2816 for (
size_t i = 0; i < num_threads; i++) {
2818 if (cur_thread_sp->ThreadStoppedForAReason()) {
2819 lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
2820 exc_ctx_with_reasons.emplace_back(
m_process_sp.get(), cur_thread_sp.get(),
2821 cur_frame_sp.get());
2826 size_t num_exe_ctx = exc_ctx_with_reasons.size();
2827 if (num_exe_ctx == 0)
2832 bool auto_continue =
false;
2833 bool hooks_ran =
false;
2835 bool print_thread_header = (num_exe_ctx != 1);
2836 bool should_stop =
false;
2837 bool somebody_restarted =
false;
2841 if (!cur_hook_sp->IsActive())
2844 bool any_thread_matched =
false;
2845 for (
auto exc_ctx : exc_ctx_with_reasons) {
2848 if (somebody_restarted)
2851 if (!cur_hook_sp->ExecutionContextPasses(exc_ctx))
2856 auto_continue |= cur_hook_sp->GetAutoContinue();
2861 if (print_hook_header && !any_thread_matched) {
2865 output_sp->
Printf(
"\n- Hook %" PRIu64
" (%s)\n", cur_hook_sp->GetID(),
2868 output_sp->Printf(
"\n- Hook %" PRIu64
"\n", cur_hook_sp->GetID());
2869 any_thread_matched =
true;
2872 if (print_thread_header)
2873 output_sp->Printf(
"-- Thread %d\n",
2874 exc_ctx.GetThreadPtr()->GetIndexID());
2877 cur_hook_sp->HandleStop(exc_ctx, output_sp);
2878 bool this_should_stop =
true;
2880 switch (this_result) {
2884 if (cur_hook_sp->GetAutoContinue())
2885 this_should_stop =
false;
2887 this_should_stop =
true;
2891 this_should_stop =
false;
2897 output_sp->Printf(
"\nAborting stop hooks, hook %" PRIu64
2898 " set the program running.\n"
2899 " Consider using '-G true' to make "
2900 "stop hooks auto-continue.\n",
2901 cur_hook_sp->GetID());
2902 somebody_restarted =
true;
2909 if (somebody_restarted)
2914 should_stop = this_should_stop;
2922 if (somebody_restarted)
2928 if ((hooks_ran && !should_stop) || auto_continue) {
2931 if (
error.Success()) {
2932 LLDB_LOG(log,
"Resuming from RunStopHooks");
2935 LLDB_LOG(log,
"Resuming from RunStopHooks failed: {0}",
error);
2948 return *g_settings_ptr;
2955 if (platform_sp->IsRemote()) {
2956 if (platform_sp->IsConnected()) {
2962 const size_t num_images = modules.
GetSize();
2963 for (
size_t idx = 0; idx < num_images; ++idx) {
2967 FileSpec local_file(module_sp->GetFileSpec());
2969 FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
2973 remote_file = platform_sp->GetRemoteWorkingDirectory();
2975 module_sp->GetFileSpec().GetFilename().GetCString());
2979 error = platform_sp->Install(local_file, remote_file);
2980 if (
error.Success()) {
2981 module_sp->SetPlatformFileSpec(remote_file);
2982 if (is_main_executable) {
2983 platform_sp->SetFilePermissions(remote_file, 0700);
3010 addr_t new_section_load_addr,
3011 bool warn_multiple) {
3012 const addr_t old_section_load_addr =
3015 if (old_section_load_addr != new_section_load_addr) {
3019 stop_id = process_sp->GetStopID();
3023 stop_id, section_sp, new_section_load_addr, warn_multiple))
3030 size_t section_unload_count = 0;
3031 size_t num_modules = module_list.
GetSize();
3032 for (
size_t i = 0; i < num_modules; ++i) {
3033 section_unload_count +=
3036 return section_unload_count;
3043 stop_id = process_sp->GetStopID();
3046 SectionList *sections = module_sp->GetSectionList();
3047 size_t section_unload_count = 0;
3050 for (
uint32_t i = 0; i < num_sections; ++i) {
3055 return section_unload_count;
3062 stop_id = process_sp->GetStopID();
3073 stop_id = process_sp->GetStopID();
3098 LLDB_LOGF(log,
"Target::%s() called for %s", __FUNCTION__,
3110 state = process_sp->GetState();
3112 "Target::%s the process exists, and its current state is %s",
3115 LLDB_LOGF(log,
"Target::%s the process instance doesn't currently exist.",
3128 const bool synchronous_execution =
3136 if (launch_info.
GetFlags().
Test(eLaunchFlagLaunchInTTY)) {
3137 error.SetErrorString(
3138 "can't launch in tty when launching through a remote connection");
3158 LLDB_LOGF(log,
"Target::%s asking the platform to debug the process",
3172 "Target::%s the platform doesn't know how to debug a "
3173 "process, getting a process plugin to do this for us.",
3192 error.SetErrorString(
"failed to launch or debug process");
3194 if (!
error.Success())
3197 bool rebroadcast_first_stop =
3198 !synchronous_execution &&
3203 EventSP first_stop_event_sp;
3204 state =
m_process_sp->WaitForProcessToStop(std::nullopt, &first_stop_event_sp,
3205 rebroadcast_first_stop,
3209 if (rebroadcast_first_stop) {
3210 assert(first_stop_event_sp);
3217 if (launch_info.
GetFlags().
Test(eLaunchFlagStopAtEntry))
3219 if (synchronous_execution)
3226 if (!
error.Success()) {
3229 "process resume at entry point failed: %s",
error.AsCString());
3234 bool with_shell = !!launch_info.
GetShell();
3236 const char *exit_desc =
m_process_sp->GetExitDescription();
3238 if (exit_desc && exit_desc[0])
3239 desc =
" (" + std::string(exit_desc) +
')';
3241 error.SetErrorStringWithFormat(
3242 "process exited with status %i%s\n"
3243 "'r' and 'run' are aliases that default to launching through a "
3245 "Try launching without going through a shell by using "
3246 "'process launch'.",
3247 exit_status, desc.c_str());
3249 error.SetErrorStringWithFormat(
"process exited with status %i%s",
3250 exit_status, desc.c_str());
3253 error.SetErrorStringWithFormat(
"initial process state wasn't stopped: %s",
3266 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3267 "A process is required for tracing");
3269 return llvm::createStringError(llvm::inconvertibleErrorCode(),
3270 "A trace already exists for the target");
3272 llvm::Expected<TraceSupportedResponse> trace_type =
3275 return llvm::createStringError(
3276 llvm::inconvertibleErrorCode(),
"Tracing is not supported. %s",
3277 llvm::toString(trace_type.takeError()).c_str());
3278 if (llvm::Expected<TraceSP> trace_sp =
3282 return llvm::createStringError(
3283 llvm::inconvertibleErrorCode(),
3284 "Couldn't create a Trace object for the process. %s",
3285 llvm::toString(trace_sp.takeError()).c_str());
3300 state = process_sp->GetState();
3303 return Status(
"process attach is in progress");
3304 return Status(
"a process is already being debugged");
3313 if (old_exec_module_sp)
3315 old_exec_module_sp->GetPlatformFileSpec().GetFilename());
3318 return Status(
"no process specified, create a target with a file, or "
3319 "specify the --pid or --name");
3323 const auto platform_sp =
3325 ListenerSP hijack_listener_sp;
3326 const bool async = attach_info.
GetAsync();
3328 hijack_listener_sp =
3344 plugin_name,
nullptr,
false);
3345 if (process_sp ==
nullptr) {
3346 error.SetErrorStringWithFormat(
3347 "failed to create process using plugin %s",
3348 (plugin_name) ? plugin_name :
"null");
3352 if (hijack_listener_sp)
3353 process_sp->HijackProcessEvents(hijack_listener_sp);
3354 error = process_sp->Attach(attach_info);
3357 if (
error.Success() && process_sp) {
3359 process_sp->RestoreProcessEvents();
3361 state = process_sp->WaitForProcessToStop(std::nullopt,
nullptr,
false,
3364 process_sp->RestoreProcessEvents();
3367 const char *exit_desc = process_sp->GetExitDescription();
3369 error.SetErrorStringWithFormat(
"%s", exit_desc);
3371 error.SetErrorString(
3372 "process did not stop (no such process or permission problem?)");
3373 process_sp->Destroy(
false);
3386 const bool default_to_use_pty =
3390 "have platform={0}, platform_sp->IsHost()={1}, default_to_use_pty={2}",
3392 platform_sp ? (platform_sp->IsHost() ?
"true" :
"false") :
"n/a",
3393 default_to_use_pty);
3400 LLDB_LOG(log,
"at least one of stdin/stdout/stderr was not set, evaluating "
3401 "default handling");
3410 LLDB_LOG(log,
"eLaunchFlagDisableSTDIO set, adding suppression action "
3411 "for stdin, stdout and stderr");
3431 LLDB_LOG(log,
"target stdin='{0}', target stdout='{1}', stderr='{1}'",
3432 in_file_spec, out_file_spec, err_file_spec);
3436 LLDB_LOG(log,
"appended stdin open file action for {0}", in_file_spec);
3439 if (out_file_spec) {
3441 LLDB_LOG(log,
"appended stdout open file action for {0}",
3445 if (err_file_spec) {
3447 LLDB_LOG(log,
"appended stderr open file action for {0}",
3451 if (default_to_use_pty) {
3453 LLDB_LOG_ERROR(log, std::move(Err),
"SetUpPtyRedirection failed: {0}");
3470 elem.notify = notify;
3480 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3485 signals_sp->SetShouldSuppress(signo,
false);
3487 signals_sp->SetShouldSuppress(signo,
true);
3490 signals_sp->SetShouldNotify(signo,
true);
3492 signals_sp->SetShouldNotify(signo,
false);
3495 signals_sp->SetShouldStop(signo,
true);
3497 signals_sp->SetShouldStop(signo,
false);
3506 = signals_sp->GetSignalNumberFromName(elem.first().str().c_str());
3512 signals_sp->ResetSignal(signo, do_stop, do_notify, do_pass);
3517 StreamSP warning_stream_sp) {
3523 warning_stream_sp->Printf(
"Target signal '%s' not found in process\n",
3524 elem.first().str().c_str());
3535 UnixSignalsSP signals_sp;
3537 signals_sp = process_sp->GetUnixSignals();
3540 const char *signal_name = entry.c_str();
3554 strm.
Printf(
"NAME PASS STOP NOTIFY\n");
3555 strm.
Printf(
"=========== ======= ======= =======\n");
3557 auto str_for_lazy = [] (
LazyBool lazy) ->
const char * {
3563 llvm_unreachable(
"Fully covered switch above!");
3567 bool print_it =
false;
3568 for (
size_t idx = 0; idx < num_args; idx++) {
3575 strm.
Printf(
"%-11s ", elem.first().str().c_str());
3576 strm.
Printf(
"%s %s %s\n", str_for_lazy(elem.second.pass),
3577 str_for_lazy(elem.second.stop),
3578 str_for_lazy(elem.second.notify));
3585 :
UserID(uid), m_target_sp(target_sp), m_specifier_sp(),
3586 m_thread_spec_up() {}
3589 :
UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
3590 m_specifier_sp(rhs.m_specifier_sp), m_thread_spec_up(),
3591 m_active(rhs.m_active), m_auto_continue(rhs.m_auto_continue) {
3597 m_specifier_sp.reset(specifier);
3601 m_thread_spec_up.reset(specifier);
3609 bool will_run =
true;
3611 will_run = GetSpecifier()->SymbolContextMatches(
3613 if (will_run && GetThreadSpecifier() !=
nullptr)
3615 GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx.
GetThreadRef());
3625 GetSubclassDescription(s, level);
3633 s->
Printf(
"Hook: %" PRIu64
"\n", GetID());
3635 s->
Indent(
"State: enabled\n");
3637 s->
Indent(
"State: disabled\n");
3639 if (m_auto_continue)
3640 s->
Indent(
"AutoContinue on\n");
3642 if (m_specifier_sp) {
3646 m_specifier_sp->GetDescription(s, level);
3650 if (m_thread_spec_up) {
3653 m_thread_spec_up->GetDescription(&tmp, level);
3659 GetSubclassDescription(s, level);
3666 if (m_commands.GetSize() == 1)
3667 s->
PutCString(m_commands.GetStringAtIndex(0));
3670 s->
Indent(
"Commands: \n");
3672 uint32_t num_commands = m_commands.GetSize();
3673 for (
uint32_t i = 0; i < num_commands; i++) {
3674 s->
Indent(m_commands.GetStringAtIndex(i));
3682 GetCommands().SplitIntoLines(
string);
3686 const std::vector<std::string> &strings) {
3687 for (
auto string : strings)
3688 GetCommands().AppendString(
string.c_str());
3693 StreamSP output_sp) {
3694 assert(exc_ctx.
GetTargetPtr() &&
"Can't call PerformAction on a context "
3697 if (!m_commands.GetSize())
3698 return StopHookResult::KeepStopped;
3721 return StopHookResult::AlreadyContinued;
3722 return StopHookResult::KeepStopped;
3731 GetTarget()->GetDebugger().GetScriptInterpreter();
3732 if (!script_interp) {
3733 error.SetErrorString(
"No script interpreter installed.");
3737 m_class_name = class_name;
3738 m_extra_args.SetObjectSP(extra_args_sp);
3741 GetTarget(), m_class_name.c_str(), m_extra_args,
error);
3748 StreamSP output_sp) {
3749 assert(exc_ctx.
GetTargetPtr() &&
"Can't call HandleStop on a context "
3753 GetTarget()->GetDebugger().GetScriptInterpreter();
3755 return StopHookResult::KeepStopped;
3758 m_implementation_sp, exc_ctx, output_sp);
3760 return should_stop ? StopHookResult::KeepStopped
3761 : StopHookResult::RequestContinue;
3771 s->
Printf(
"%s\n", m_class_name.c_str());
3776 if (!m_extra_args.IsValid())
3779 if (!object_sp || !object_sp->IsValid())
3783 if (!as_dict || !as_dict->
IsValid())
3797 object->GetStringValue().str().c_str());
3801 as_dict->
ForEach(print_one_element);
3809 "no-dynamic-values",
3810 "Don't calculate the dynamic type of values",
3815 "Calculate the dynamic type of values "
3816 "even if you have to run the target.",
3821 "Calculate the dynamic type of values, but don't run the target.",
3833 "Never look for inline breakpoint locations (fastest). This setting "
3834 "should only be used if you know that no inlining occurs in your"
3840 "Only check for inline breakpoint locations when setting breakpoints "
3841 "in header files, but not when setting breakpoint in implementation "
3842 "source files (default).",
3847 "Always look for inline breakpoint locations when setting file and "
3848 "line breakpoints (slower but most accurate).",
3862 "Disassembler default (currently att).",
3867 "Intel disassembler flavor.",
3872 "AT&T disassembler flavor.",
3880 "Never import the 'std' C++ module in the expression parser.",
3885 "Retry evaluating expressions with an imported 'std' C++ module if they"
3886 " failed to parse without the module. This allows evaluating more "
3887 "complex expressions involving C++ standard library types."
3892 "Always import the 'std' C++ module. This allows evaluating more "
3893 "complex expressions involving C++ standard library types. This feature"
3898static constexpr OptionEnumValueElement
3903 "Automatically determine the most appropriate method for the "
3907 "Prefer using the realized classes struct."},
3909 "Prefer using the CopyRealizedClassList API."},
3911 "Prefer using the GetRealizedClassList API."},
3918 "C-style (0xffff).",
3923 "Asm-style (0ffffh).",
3931 "Load debug scripts inside symbol files",
3936 "Do not load debug scripts inside symbol files.",
3941 "Warn about debug scripts inside symbol files but do not load them.",
3949 "Load .lldbinit files from current directory",
3954 "Do not load .lldbinit files from current directory",
3959 "Warn about loading .lldbinit files from current directory",
3967 "Load minimal information when loading modules from memory. Currently "
3968 "this setting loads sections only.",
3973 "Load partial information when loading modules from memory. Currently "
3974 "this setting loads sections and function bounds.",
3979 "Load complete information when loading modules from memory. Currently "
3980 "this setting loads sections and all symbols.",
3984#define LLDB_PROPERTIES_target
3985#include "TargetProperties.inc"
3988#define LLDB_PROPERTIES_target
3989#include "TargetPropertiesEnum.inc"
3994 :
public Cloneable<TargetOptionValueProperties, OptionValueProperties> {
4010 if (
this != target_properties)
4014 return ProtectedGetPropertyAtIndex(idx);
4019#define LLDB_PROPERTIES_target_experimental
4020#include "TargetProperties.inc"
4023#define LLDB_PROPERTIES_target_experimental
4024#include "TargetPropertiesEnum.inc"
4028 :
public Cloneable<TargetExperimentalOptionValueProperties,
4029 OptionValueProperties> {
4043 :
Properties(), m_launch_info(), m_target(target) {
4066 m_collection_sp->SetValueChangedCallback(ePropertyDetachOnError, [
this] {
4079 std::make_unique<TargetExperimentalProperties>();
4082 ConstString(
"Experimental settings - setting these won't produce "
4083 "errors if the setting is not present."),
4087 std::make_shared<TargetOptionValueProperties>(
ConstString(
"target"));
4090 std::make_unique<TargetExperimentalProperties>();
4093 ConstString(
"Experimental settings - setting these won't produce "
4094 "errors if the setting is not present."),
4124 exp_property->
GetValue()->GetAsProperties();
4127 exe_ctx, ePropertyInjectLocalVars,
true);
4137 exp_property->
GetValue()->GetAsProperties();
4145 nullptr, ePropertyDefaultArch);
4153 nullptr, ePropertyDefaultArch);
4159 const uint32_t idx = ePropertyMoveToNearestCode;
4161 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4165 const uint32_t idx = ePropertyPreferDynamic;
4168 nullptr, idx, g_target_properties[idx].default_uint_value);
4172 const uint32_t idx = ePropertyPreferDynamic;
4173 return m_collection_sp->SetPropertyAtIndexAsEnumeration(
nullptr, idx, d);
4177 const uint32_t idx = ePropertyPreloadSymbols;
4179 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4183 const uint32_t idx = ePropertyPreloadSymbols;
4188 const uint32_t idx = ePropertyDisableASLR;
4190 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4194 const uint32_t idx = ePropertyDisableASLR;
4199 const uint32_t idx = ePropertyInheritTCC;
4201 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4205 const uint32_t idx = ePropertyInheritTCC;
4210 const uint32_t idx = ePropertyDetachOnError;
4212 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4216 const uint32_t idx = ePropertyDetachOnError;
4221 const uint32_t idx = ePropertyDisableSTDIO;
4223 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4227 const uint32_t idx = ePropertyDisableSTDIO;
4232 const uint32_t idx = ePropertyDisassemblyFlavor;
4233 const char *return_value;
4237 nullptr, idx, g_target_properties[idx].default_uint_value);
4239 return return_value;
4243 const uint32_t idx = ePropertyInlineStrategy;
4245 nullptr, idx, g_target_properties[idx].default_uint_value);
4249 const uint32_t idx = ePropertyArg0;
4255 const uint32_t idx = ePropertyArg0;
4261 const uint32_t idx = ePropertyRunArgs;
4266 const uint32_t idx = ePropertyRunArgs;
4276 nullptr, ePropertyInheritEnv,
4277 g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
4279 Environment platform_env = platform_sp->GetEnvironment();
4280 for (
const auto &KV : platform_env)
4281 env[KV.first()] = KV.second;
4285 Args property_unset_env;
4286 m_collection_sp->GetPropertyAtIndexAsArgs(
nullptr, ePropertyUnsetEnvVars,
4287 property_unset_env);
4288 for (
const auto &var : property_unset_env)
4289 env.erase(var.ref());
4295 env[KV.first()] = KV.second;
4311 nullptr, ePropertyInheritEnv,
4312 g_target_properties[ePropertyInheritEnv].default_uint_value != 0))
4316 if (platform_sp ==
nullptr)
4319 Environment platform_environment = platform_sp->GetEnvironment();
4320 for (
const auto &KV : platform_environment)
4321 environment[KV.first()] = KV.second;
4323 Args property_unset_environment;
4324 m_collection_sp->GetPropertyAtIndexAsArgs(
nullptr, ePropertyUnsetEnvVars,
4325 property_unset_environment);
4326 for (
const auto &var : property_unset_environment)
4327 environment.erase(var.ref());
4333 Args property_environment;
4335 property_environment);
4337 for (
const auto &KV :
Environment(property_environment))
4338 environment[KV.first()] = KV.second;
4345 const uint32_t idx = ePropertyEnvVars;
4350 const uint32_t idx = ePropertySkipPrologue;
4352 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4356 const uint32_t idx = ePropertySourceMap;
4360 assert(option_value);
4365 const uint32_t idx = ePropertyAutoSourceMapRelative;
4367 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4371 const uint32_t idx = ePropertyExecutableSearchPaths;
4375 assert(option_value);
4380 const uint32_t idx = ePropertyExecutableSearchPaths;
4384 assert(option_value);
4389 const uint32_t idx = ePropertyDebugFileSearchPaths;
4393 assert(option_value);
4398 const uint32_t idx = ePropertyClangModuleSearchPaths;
4402 assert(option_value);
4407 const uint32_t idx = ePropertyAutoImportClangModules;
4409 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4413 const uint32_t idx = ePropertyImportStdModule;
4415 nullptr, idx, g_target_properties[idx].default_uint_value);
4419 const uint32_t idx = ePropertyDynamicClassInfoHelper;
4422 nullptr, idx, g_target_properties[idx].default_uint_value);
4426 const uint32_t idx = ePropertyAutoApplyFixIts;
4428 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4432 const uint32_t idx = ePropertyRetriesWithFixIts;
4434 nullptr, idx, g_target_properties[idx].default_uint_value);
4438 const uint32_t idx = ePropertyNotifyAboutFixIts;
4440 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4444 const uint32_t idx = ePropertySaveObjectsDir;
4454 bool exists = instance.
Exists(new_dir);
4455 bool is_directory = instance.
IsDirectory(new_dir);
4456 std::string path = new_dir.
GetPath(
true);
4457 bool writable = llvm::sys::fs::can_write(path);
4458 if (exists && is_directory && writable)
4461 m_collection_sp->GetPropertyAtIndex(
nullptr,
true, ePropertySaveObjectsDir)
4466 llvm::raw_string_ostream os(buffer);
4467 os <<
"JIT object dir '" << path <<
"' ";
4469 os <<
"does not exist";
4470 else if (!is_directory)
4471 os <<
"is not a directory";
4473 os <<
"is not writable";
4475 std::optional<lldb::user_id_t> debugger_id;
4482 const uint32_t idx = ePropertyEnableSynthetic;
4484 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4488 const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat;
4490 nullptr, idx, g_target_properties[idx].default_uint_value);
4494 const uint32_t idx = ePropertyMaxChildrenCount;
4496 nullptr, idx, g_target_properties[idx].default_uint_value);
4499std::pair<uint32_t, bool>
4501 const uint32_t idx = ePropertyMaxChildrenDepth;
4502 auto *option_value =
4504 bool is_default = !option_value->OptionWasSet();
4505 return {option_value->GetCurrentValue(), is_default};
4509 const uint32_t idx = ePropertyMaxSummaryLength;
4511 nullptr, idx, g_target_properties[idx].default_uint_value);
4515 const uint32_t idx = ePropertyMaxMemReadSize;
4517 nullptr, idx, g_target_properties[idx].default_uint_value);
4521 const uint32_t idx = ePropertyInputPath;
4526 const uint32_t idx = ePropertyInputPath;
4531 const uint32_t idx = ePropertyOutputPath;
4536 const uint32_t idx = ePropertyOutputPath;
4541 const uint32_t idx = ePropertyErrorPath;
4546 const uint32_t idx = ePropertyErrorPath;
4553 nullptr, ePropertyLanguage);
4560 const uint32_t idx = ePropertyExprPrefix;
4562 m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(
nullptr,
false,
4567 return llvm::StringRef(
4568 reinterpret_cast<const char *
>(data_sp->GetBytes()),
4569 data_sp->GetByteSize());
4575 const uint32_t idx = ePropertyExprErrorLimit;
4577 nullptr, idx, g_target_properties[idx].default_uint_value);
4581 const uint32_t idx = ePropertyBreakpointUseAvoidList;
4583 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4587 const uint32_t idx = ePropertyUseHexImmediates;
4589 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4593 const uint32_t idx = ePropertyUseFastStepping;
4595 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4599 const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs;
4601 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4605 const uint32_t idx = ePropertyLoadScriptFromSymbolFile;
4608 nullptr, idx, g_target_properties[idx].default_uint_value);
4612 const uint32_t idx = ePropertyLoadCWDlldbinitFile;
4614 nullptr, idx, g_target_properties[idx].default_uint_value);
4618 const uint32_t idx = ePropertyHexImmediateStyle;
4621 nullptr, idx, g_target_properties[idx].default_uint_value);
4625 const uint32_t idx = ePropertyMemoryModuleLoadLevel;
4628 nullptr, idx, g_target_properties[idx].default_uint_value);
4632 const uint32_t idx = ePropertyTrapHandlerNames;
4637 const uint32_t idx = ePropertyTrapHandlerNames;
4642 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4643 return m_collection_sp->GetPropertyAtIndexAsBoolean(
nullptr, idx,
false);
4647 const uint32_t idx = ePropertyDisplayRuntimeSupportValues;
4652 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4653 return m_collection_sp->GetPropertyAtIndexAsBoolean(
nullptr, idx,
false);
4657 const uint32_t idx = ePropertyDisplayRecognizedArguments;
4673 if (input_file_action) {
4678 if (output_file_action) {
4683 if (error_file_action) {
4689 launch_info.
GetFlags().
Test(lldb::eLaunchFlagInheritTCCFromParent));
4694 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4696 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4700 const uint32_t idx = ePropertyRequireHardwareBreakpoints;
4705 const uint32_t idx = ePropertyAutoInstallMainExecutable;
4707 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4768 const uint32_t idx = ePropertyDebugUtilityExpression;
4770 nullptr, idx, g_target_properties[idx].default_uint_value != 0);
4774 const uint32_t idx = ePropertyDebugUtilityExpression;
4781 :
EventData(), m_target_sp(target_sp), m_module_list() {}
4785 :
EventData(), m_target_sp(target_sp), m_module_list(module_list) {}
4790 static ConstString g_flavor(
"Target::TargetEventData");
4795 for (
size_t i = 0; i < m_module_list.GetSize(); ++i) {
4798 m_module_list.GetModuleAtIndex(i)->GetDescription(
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
static constexpr OptionEnumValueElement g_dynamic_class_info_helper_value_types[]
static bool CheckIfWatchpointsSupported(Target *target, Status &error)
static constexpr OptionEnumValueElement g_load_cwd_lldbinit_values[]
static void LoadScriptingResourceForModule(const ModuleSP &module_sp, Target *target)
static constexpr OptionEnumValueElement g_dynamic_value_types[]
static constexpr OptionEnumValueElement g_memory_module_load_level_values[]
static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[]
static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[]
static constexpr OptionEnumValueElement g_hex_immediate_style_values[]
static constexpr OptionEnumValueElement g_inline_breakpoint_enums[]
static constexpr OptionEnumValueElement g_import_std_module_value_types[]
#define LLDB_SCOPED_TIMERF(...)
TargetExperimentalOptionValueProperties()
const Property * GetPropertyAtIndex(const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const override
TargetOptionValueProperties(ConstString name)
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
lldb::SectionSP GetSection() const
Get const accessor for the section.
bool Slide(int64_t offset)
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsValid() const
Check if the object state is valid.
bool IsSectionOffset() const
Check if an address is section offset.
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different, bool &vendor_different, bool &os_different, bool &os_version_different, bool &env_different) const
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
const BreakpointID & GetBreakpointIDAtIndex(size_t index) const
bool AddBreakpointID(BreakpointID bp_id)