36#include "llvm/Support/ThreadPool.h"
42#ifdef ENABLE_DEBUG_PRINTF
44#define DEBUG_PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__)
46#define DEBUG_PRINTF(fmt, ...)
85 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
94 const ImageInfo &image_info,
bool can_create,
bool *did_create_ptr) {
96 *did_create_ptr =
false;
106 if (target_triple.getOS() == llvm::Triple::IOS &&
107 target_triple.getEnvironment() == llvm::Triple::MacABI) {
117 !module_sp->GetUUID().IsValid()) {
120 if (module_sp->GetModificationTime() !=
125 if (module_sp || !can_create)
133 HostInfo::GetArchitecture().IsCompatibleMatch(target.
GetArchitecture())) {
146 std::optional<uint64_t> size;
153 image_info = HostInfo::GetSharedCacheImageInfo(module_spec.
GetUUID(),
159 HostInfo::GetSharedCacheImageInfo(filepath, sc_uuid, sc_mode);
164 image_info = HostInfo::GetSharedCacheImageInfo(filepath, sc_mode);
181 if (!module_sp || module_sp->GetObjectFile() ==
nullptr) {
182 llvm::Expected<ModuleSP> module_sp_or_err =
m_process->ReadModuleFromMemory(
185 if (
auto err = module_sp_or_err.takeError()) {
187 "Failed to load module from memory: {0}");
190 module_sp = *module_sp_or_err;
194 *did_create_ptr = (
bool)module_sp;
200 const std::vector<lldb::addr_t> &solib_addresses) {
201 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
207 LLDB_LOGF(log,
"Removing %" PRId64
" modules.",
208 (uint64_t)solib_addresses.size());
212 for (
addr_t solib_addr : solib_addresses) {
217 if (module_to_remove.get()) {
218 LLDB_LOGF(log,
"Removing module at address 0x%" PRIx64, solib_addr);
226 if (solib_addr == (*pos).address) {
236 if (unloaded_module_list.
GetSize() > 0) {
240 log,
"DynamicLoaderDarwin::UnloadModules");
242 m_process->GetTarget().GetImages().Remove(unloaded_module_list);
253 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
259 if (module_sp && module_sp != dyld_sp) {
261 unloaded_modules_list.
Append(module_sp);
265 if (unloaded_modules_list.
GetSize() != 0) {
269 log,
"DynamicLoaderDarwin::UnloadAllImages");
281 bool changed =
false;
284 ObjectFile *image_object_file =
module->GetObjectFile();
285 if (image_object_file) {
288 std::vector<uint32_t> inaccessible_segment_indexes;
291 const size_t num_segments = info.
segments.size();
292 for (
size_t i = 0; i < num_segments; ++i) {
298 if (info.
segments[i].maxprot == 0) {
299 inaccessible_segment_indexes.push_back(i);
301 const addr_t new_section_load_addr =
303 static ConstString g_section_name_LINKEDIT(
"__LINKEDIT");
310 const bool warn_multiple =
311 section_sp->GetName() != g_section_name_LINKEDIT;
316 LLDB_LOG(log,
"{0}: Omitting zero-size segment {1}",
321 if (info.
segments[i].vmsize != section_sp->GetByteSize())
323 "{0}: In-memory segment size for {1} is {2:x}"
324 " but file segment size is {3:x}",
326 info.
segments[i].vmsize, section_sp->GetByteSize());
328 changed =
m_process->GetTarget().SetSectionLoadAddress(
329 section_sp, new_section_load_addr, warn_multiple);
340 if (changed && !inaccessible_segment_indexes.empty()) {
341 for (uint32_t i = 0; i < inaccessible_segment_indexes.size(); ++i) {
342 const uint32_t seg_idx = inaccessible_segment_indexes[i];
347 static ConstString g_pagezero_section_name(
"__PAGEZERO");
348 if (g_pagezero_section_name == section_sp->GetName()) {
353 m_process->AddInvalidMemoryRegion(pagezero_range);
374 bool changed =
false;
376 ObjectFile *image_object_file =
module->GetObjectFile();
377 if (image_object_file) {
380 const size_t num_segments = info.
segments.size();
381 for (
size_t i = 0; i < num_segments; ++i) {
385 const addr_t old_section_load_addr =
387 if (
m_process->GetTarget().SetSectionUnloaded(
388 section_sp, old_section_load_addr))
392 "unable to find and unload segment named "
393 "'{0}' in '{1}' in macosx dynamic loader plug-in",
411 image_details->GetAsDictionary()->GetValueForKey(
"images");
412 if (images_sp.get() ==
nullptr)
415 image_infos.resize(images_sp->GetAsArray()->GetSize());
417 for (
size_t i = 0; i < image_infos.size(); i++) {
419 images_sp->GetAsArray()->GetItemAtIndex(i);
420 if (image_sp.get() ==
nullptr || image_sp->GetAsDictionary() ==
nullptr)
424 if (!image->
HasKey(
"load_address") ||
425 !image->
HasKey(
"pathname") ||
426 !image->
HasKey(
"mach_header") ||
427 image->
GetValueForKey(
"mach_header")->GetAsDictionary() ==
nullptr ||
428 !image->
HasKey(
"segments") ||
434 image_infos[i].address =
436 image_infos[i].file_spec.SetFile(
438 FileSpec::Style::native);
442 image_infos[i].header.magic =
444 image_infos[i].header.cputype =
446 image_infos[i].header.cpusubtype =
448 image_infos[i].header.filetype =
450 if (mh->
HasKey(
"sizeof_mh_and_loadcmds"))
451 image_infos[i].mh_and_load_cmd_size =
453 ->GetUnsignedIntegerValue();
455 if (image->
HasKey(
"min_version_os_name")) {
456 std::string os_name =
460 if (os_name ==
"macosx")
461 image_infos[i].os_type = llvm::Triple::MacOSX;
462 else if (os_name ==
"ios" || os_name ==
"iphoneos")
463 image_infos[i].os_type = llvm::Triple::IOS;
464 else if (os_name ==
"tvos")
465 image_infos[i].os_type = llvm::Triple::TvOS;
466 else if (os_name ==
"watchos")
467 image_infos[i].os_type = llvm::Triple::WatchOS;
468 else if (os_name ==
"bridgeos")
469 image_infos[i].os_type = llvm::Triple::BridgeOS;
470 else if (os_name ==
"driverkit")
471 image_infos[i].os_type = llvm::Triple::DriverKit;
472 else if (os_name ==
"xros")
473 image_infos[i].os_type = llvm::Triple::XROS;
474 else if (os_name ==
"maccatalyst") {
475 image_infos[i].os_type = llvm::Triple::IOS;
476 image_infos[i].os_env = llvm::Triple::MacABI;
477 }
else if (os_name ==
"iossimulator") {
478 image_infos[i].os_type = llvm::Triple::IOS;
479 image_infos[i].os_env = llvm::Triple::Simulator;
480 }
else if (os_name ==
"tvossimulator") {
481 image_infos[i].os_type = llvm::Triple::TvOS;
482 image_infos[i].os_env = llvm::Triple::Simulator;
483 }
else if (os_name ==
"watchossimulator") {
484 image_infos[i].os_type = llvm::Triple::WatchOS;
485 image_infos[i].os_env = llvm::Triple::Simulator;
486 }
else if (os_name ==
"xrsimulator") {
487 image_infos[i].os_type = llvm::Triple::XROS;
488 image_infos[i].os_env = llvm::Triple::Simulator;
491 if (image->
HasKey(
"min_version_os_sdk")) {
492 image_infos[i].min_version_os_sdk =
502 image_infos[i].header.flags =
505 image_infos[i].header.flags = 0;
508 image_infos[i].header.ncmds =
511 image_infos[i].header.ncmds = 0;
513 if (mh->
HasKey(
"sizeofcmds"))
514 image_infos[i].header.sizeofcmds =
517 image_infos[i].header.sizeofcmds = 0;
521 uint32_t segcount = segments->
GetSize();
522 for (
size_t j = 0; j < segcount; j++) {
526 llvm::StringRef seg_name =
529 std::min(seg_name.size(),
size_t(16)));
543 if (seg->
HasKey(
"initprot"))
554 if (seg->
HasKey(
"nsects"))
560 image_infos[i].segments.push_back(
segment);
563 image_infos[i].uuid.SetFromStringRef(
573 const size_t num_sections = image_infos[i].segments.size();
574 for (
size_t k = 0; k < num_sections; ++k) {
577 if ((image_infos[i].segments[k].fileoff == 0 &&
578 image_infos[i].segments[k].filesize > 0) ||
579 (llvm::StringRef(image_infos[i].segments[k].name) ==
"__TEXT")) {
580 image_infos[i].slide =
581 image_infos[i].address - image_infos[i].segments[k].vmaddr;
592 std::vector<std::pair<ImageInfo, ModuleSP>> &images) {
600 const size_t images_size = images.size();
601 for (
size_t i = 0; i < images_size; i++) {
602 const auto &image_info = images[i].first;
603 if (image_info.header.filetype == llvm::MachO::MH_DYLINKER) {
608 if (target_arch.
GetTriple().getEnvironment() == llvm::Triple::Simulator &&
609 image_info.os_type != llvm::Triple::OSType::MacOSX) {
615 if (image_info.header.filetype == llvm::MachO::MH_EXECUTE) {
622 ModuleSP exe_module_sp = images[exe_idx].second;
624 LLDB_LOGF(log,
"Found executable module: %s",
625 exe_module_sp->GetFileSpec().GetPath().c_str());
633 auto exe_triple = exe_module_sp->GetArchitecture().GetTriple();
634 if (target_arch.
GetTriple().isArm64e() &&
635 exe_triple.getArch() == llvm::Triple::aarch64 &&
636 !exe_triple.isArm64e()) {
646 triple.setArchName(exe_triple.getArchName());
655 ModuleSP dyld_sp = images[dyld_idx].second;
658 dyld_sp->GetFileSpec().GetPath().c_str());
668 if (image_info.
header.filetype == llvm::MachO::MH_DYLINKER) {
669 const bool can_create =
true;
686 auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t {
693 return log_err(
"Couldn't retrieve DYLD module. Cannot get `start` symbol.");
696 dyld_sp->FindFirstSymbolWithNameAndType(
ConstString(
"_dyld_start"));
698 return log_err(
"Cannot find `start` symbol in DYLD module.");
714std::vector<std::pair<DynamicLoaderDarwin::ImageInfo, ModuleSP>>
717 const auto size = image_infos.size();
718 std::vector<std::pair<DynamicLoaderDarwin::ImageInfo, ModuleSP>> images(size);
719 auto LoadImage = [&](
size_t i, ImageInfo::collection::const_iterator it) {
720 const auto &image_info = *it;
721 images[i] = std::make_pair(
724 auto it = image_infos.begin();
725 bool is_parallel_load =
m_process->GetTarget().GetParallelModuleLoad();
726 if (is_parallel_load) {
728 for (
size_t i = 0; i < size; ++i, ++it) {
729 taskGroup.async(LoadImage, i, it);
733 for (
size_t i = 0; i < size; ++i, ++it) {
742 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
748 std::vector<std::pair<ImageInfo, ModuleSP>> &images) {
749 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
756 for (uint32_t idx = 0; idx < images.size(); ++idx) {
757 auto &image_info = images[idx].first;
758 const auto &image_module_sp = images[idx].second;
760 LLDB_LOGF(log,
"Adding new image at address=0x%16.16" PRIx64
".",
762 image_info.PutToLog(log);
766 if (image_module_sp) {
767 ObjectFile *objfile = image_module_sp->GetObjectFile();
771 llvm::StringRef commpage_sect_name(
"__commpage");
774 if (commpage_section) {
776 image_info.GetArchitecture());
780 if (!commpage_image_module_sp) {
786 if (!commpage_image_module_sp ||
787 commpage_image_module_sp->GetObjectFile() ==
nullptr) {
788 llvm::Expected<ModuleSP> module_sp_or_err =
789 m_process->ReadModuleFromMemory(image_info.file_spec,
791 if (
auto err = module_sp_or_err.takeError()) {
793 "Failed to read module from memory: {0}");
799 commpage_image_module_sp = *module_sp_or_err;
800 bool changed =
false;
805 image_info.load_stop_id =
m_process->GetStopID();
826 ArchSpec dyld_spec = image_info.GetArchitecture();
827 auto &dyld_triple = dyld_spec.
GetTriple();
828 if ((dyld_triple.getEnvironment() == llvm::Triple::MacABI &&
829 dyld_triple.getOS() == llvm::Triple::IOS) ||
830 (dyld_triple.getEnvironment() == llvm::Triple::Simulator &&
831 (dyld_triple.getOS() == llvm::Triple::IOS ||
832 dyld_triple.getOS() == llvm::Triple::TvOS ||
833 dyld_triple.getOS() == llvm::Triple::WatchOS ||
834 dyld_triple.getOS() == llvm::Triple::XROS)))
835 image_module_sp->MergeArchitecture(dyld_spec);
839 if (loaded_module_list.
GetSize() > 0) {
842 "DynamicLoaderDarwin::ModulesDidLoad");
843 m_process->GetTarget().ModulesDidLoad(loaded_module_list);
865 if (module_sp.get() ==
nullptr && sym_ctx.
function)
867 if (module_sp.get() ==
nullptr)
871 return objc_runtime !=
nullptr &&
879 LLDB_LOGF(log,
"\t\t%16s [0x%16.16" PRIx64
" - 0x%16.16" PRIx64
")",
name,
883 "\t\t%16s [0x%16.16" PRIx64
" - 0x%16.16" PRIx64
884 ") slide = 0x%" PRIx64,
892 if (
os_env == llvm::Triple::MacABI &&
os_type == llvm::Triple::IOS) {
899 if (
os_env == llvm::Triple::Simulator &&
901 os_type == llvm::Triple::WatchOS ||
os_type == llvm::Triple::XROS)) {
903 "-apple-" + llvm::Triple::getOSTypeName(
os_type) +
917 LLDB_LOG(log,
"uuid={} path='{}' (UNLOADED)",
uuid.GetAsString(),
922 for (uint32_t i = 0; i <
segments.size(); ++i)
928 DEBUG_PRINTF(
"DynamicLoaderDarwin::%s() process state = %s\n", __FUNCTION__,
937 DEBUG_PRINTF(
"DynamicLoaderDarwin::%s(%s)\n", __FUNCTION__,
973 StackFrame *current_frame = thread.GetStackFrameAtIndex(0).get();
978 TargetSP target_sp(thread.CalculateTarget());
980 if (current_symbol !=
nullptr) {
981 std::vector<Address> addresses;
985 llvm::StringRef target_symbol_name = current_name;
986 static const llvm::StringRef g_lazy_stub_name =
"$lazyLoadStub";
990 if (current_name && target_symbol_name.consume_back(g_lazy_stub_name)) {
991 auto bkpt_sp = target_sp->CreateBreakpoint(
992 nullptr,
nullptr, target_symbol_name.str().c_str(),
997 return std::make_shared<ThreadPlanRunToBreakpoint>(thread, bkpt_sp,
1003 const ModuleList &images = target_sp->GetImages();
1009 Address addr = context.GetFunctionOrSymbolAddress();
1010 addresses.push_back(addr);
1014 LLDB_LOGF(log,
"Found a trampoline target symbol at 0x%" PRIx64
".",
1020 reexported_symbols);
1022 if (context.symbol) {
1023 const Symbol *actual_symbol =
1025 if (actual_symbol) {
1027 if (actual_symbol_addr.
IsValid()) {
1028 addresses.push_back(actual_symbol_addr);
1033 "Found a re-exported symbol: %s at 0x%" PRIx64
".",
1046 Address addr = context.GetFunctionOrSymbolAddress();
1047 addresses.push_back(addr);
1051 LLDB_LOGF(log,
"Found an indirect target symbol at 0x%" PRIx64
".",
1060 const Symbol *actual_symbol =
1062 if (actual_symbol) {
1067 "Found a re-exported symbol: %s pointing to: %s at 0x%" PRIx64
1072 addresses.push_back(
1078 if (addresses.size() > 0) {
1081 std::vector<lldb::addr_t> load_addrs;
1082 for (
Address address : addresses) {
1087 addr_t resolved_addr = thread.GetProcess()->ResolveIndirectFunction(
1088 &symbol_address,
error);
1089 if (
error.Success()) {
1090 load_addrs.push_back(resolved_addr);
1092 "ResolveIndirectFunction found resolved target for "
1093 "%s at 0x%" PRIx64
".",
1097 load_addrs.push_back(address.GetLoadAddress(target_sp.get()));
1100 thread_plan_sp = std::make_shared<ThreadPlanRunToAddress>(
1101 thread, load_addrs, stop_others);
1108 static const char *g_branch_island_pattern =
"\\.island\\.?[0-9]*$";
1111 bool is_branch_island = g_branch_island_regex.
Execute(current_name);
1112 if (!thread_plan_sp && is_branch_island) {
1113 thread_plan_sp = std::make_shared<ThreadPlanStepInstruction>(
1117 LLDB_LOG(log,
"Stepping one instruction over branch island: '{0}'.",
1121 LLDB_LOGF(log,
"Could not find symbol for step through.");
1124 return thread_plan_sp;
1133 if (!trampoline_name)
1136 static const char *resolver_name_regex =
"(_gc|_non_gc|\\$[A-Za-z0-9\\$]+)$";
1137 std::string equivalent_regex_buf(
"^");
1138 equivalent_regex_buf.append(trampoline_name.
GetCString());
1139 equivalent_regex_buf.append(resolver_name_regex);
1143 equivalent_symbols);
1153 m_process->GetTarget().GetImages().FindModules(module_spec, module_list);
1155 if (module_list.
GetSize() == 1) {
1170 module_sp->FindSymbolsWithNameAndType(
ConstString(
"pthread_getspecific"),
1186 if (!thread_sp || !module_sp)
1189 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
1192 if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
1204 auto evaluate_tls_address = [
this, &thread_sp, &clang_void_ptr_type](
1206 llvm::ArrayRef<addr_t> args) ->
addr_t {
1210 *thread_sp, func_ptr, clang_void_ptr_type, args, options));
1215 exe_ctx, thread_plan_sp, options, execution_errors);
1219 thread_plan_sp->GetReturnValueObject()) {
1241 const uint32_t addr_size =
m_process->GetAddressByteSize();
1242 uint8_t buf[
sizeof(
addr_t) * 3];
1244 const size_t tls_data_size = addr_size * 3;
1246 tls_addr, buf, tls_data_size,
error,
true);
1247 if (bytes_read != tls_data_size ||
error.Fail())
1256 if (tls_thunk != 0) {
1261 const addr_t tls_data = evaluate_tls_address(
1262 thunk_load_addr, llvm::ArrayRef<addr_t>(tls_load_addr));
1276 auto tls_pos = tid_pos->second.find(key);
1277 if (tls_pos != tid_pos->second.end()) {
1278 return tls_pos->second + tls_offset;
1282 if (pthread_getspecific_addr.
IsValid()) {
1283 const addr_t tls_data = evaluate_tls_address(pthread_getspecific_addr,
1284 llvm::ArrayRef<addr_t>(key));
1286 return tls_data + tls_offset;
1294 bool use_new_spi_interface =
true;
1297 if (!version.empty()) {
1298 using namespace llvm;
1299 const Triple::OSType os_type =
1302 auto OlderThan = [os_type, version](llvm::Triple::OSType o,
1303 llvm::VersionTuple v) ->
bool {
1304 return os_type == o && version < v;
1307 if (OlderThan(Triple::MacOSX, VersionTuple(10, 12)))
1308 use_new_spi_interface =
false;
1310 if (OlderThan(Triple::IOS, VersionTuple(10)))
1311 use_new_spi_interface =
false;
1313 if (OlderThan(Triple::TvOS, VersionTuple(10)))
1314 use_new_spi_interface =
false;
1316 if (OlderThan(Triple::WatchOS, VersionTuple(3)))
1317 use_new_spi_interface =
false;
1325 use_new_spi_interface =
false;
1332 use_new_spi_interface =
false;
1335 if (use_new_spi_interface)
1337 log,
"DynamicLoaderDarwin::UseDYLDSPI: Use new DynamicLoader plugin");
1340 log,
"DynamicLoaderDarwin::UseDYLDSPI: Use old DynamicLoader plugin");
1342 return use_new_spi_interface;
static llvm::raw_ostream & error(Stream &strm)
#define DEBUG_PRINTF(fmt,...)
#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,...)
#define LLDB_LOG_VERBOSE(log,...)
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::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsValid() const
Check if the object state is valid.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
void MergeFrom(const ArchSpec &other)
Merges fields from another ArchSpec into this ArchSpec.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Generic representation of a type in a programming language.
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
void PutToLog(lldb_private::Log *log, lldb::addr_t slide) const
lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) override
Retrieves the per-module TLS block for a given thread.
bool UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info)
lldb::ModuleSP GetDYLDModule()
bool AlwaysRelyOnEHUnwindInfo(lldb_private::SymbolContext &sym_ctx) override
Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the fi...
virtual bool NeedToDoInitialImageFetch()=0
ImageInfo::collection m_dyld_image_infos
virtual void DoInitialImageFetch()=0
DynamicLoaderDarwin(lldb_private::Process *process)
std::recursive_mutex m_mutex
uint32_t m_dyld_image_infos_stop_id
void PrivateProcessStateChanged(lldb_private::Process *process, lldb::StateType state)
void DidLaunch() override
Called after attaching a process.
lldb::ModuleWP m_dyld_module_wp
lldb::ModuleSP FindTargetModuleForImageInfo(const ImageInfo &image_info, bool can_create, bool *did_create_ptr)
virtual bool SetNotificationBreakpoint()=0
bool AddModulesUsingImageInfos(ImageInfo::collection &image_infos)
void FindEquivalentSymbols(const lldb_private::Symbol *original_symbol, lldb_private::ModuleList &module_list, lldb_private::SymbolContextList &equivalent_symbols) override
Some dynamic loaders provide features where there are a group of symbols "equivalent to" a given symb...
void DidAttach() override
Called after attaching a process.
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
std::vector< std::pair< ImageInfo, lldb::ModuleSP > > PreloadModulesFromImageInfos(const ImageInfo::collection &image_infos)
lldb::ModuleWP m_libpthread_module_wp
bool JSONImageInformationIntoImageInfo(lldb_private::StructuredData::ObjectSP image_details, ImageInfo::collection &image_infos)
bool UpdateImageLoadAddress(lldb_private::Module *module, ImageInfo &info)
std::optional< lldb_private::Address > GetStartAddress() override
Return the start address in the dynamic loader module.
void UpdateSpecialBinariesFromPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
void PrivateInitialize(lldb_private::Process *process)
~DynamicLoaderDarwin() override
lldb_private::Address GetPthreadSetSpecificAddress()
void Clear(bool clear_process)
bool AddModulesUsingPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
void SetDYLDModule(lldb::ModuleSP &dyld_module_sp)
ThreadIDToTLSMap m_tid_to_tls_map
static bool UseDYLDSPI(lldb_private::Process *process)
lldb_private::Address m_pthread_getspecific_addr
bool UnloadModuleSections(lldb_private::Module *module, ImageInfo &info)
lldb::ModuleSP GetPThreadLibraryModule()
void UnloadImages(const std::vector< lldb::addr_t > &solib_addresses)
virtual bool DidSetNotificationBreakpoint()=0
Process * m_process
The process that this dynamic loader plug-in is tracking.
DynamicLoader(Process *process)
Construct with a process.
virtual bool GetSharedCacheInformation(lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache, lldb_private::FileSpec &shared_cache_path, std::optional< uint64_t > &size)
Get information about the shared cache for a process, if possible.
virtual void UnloadSections(const lldb::ModuleSP module)
Removes the loaded sections from the target in module.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFilename(llvm::StringRef filename)
Filename string set accessor.
llvm::StringRef GetFilename() const
Filename string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static FileSystem & Instance()
const Address & GetAddress() const
Return the address of the function (its entry point).
void PutCString(const char *cstr)
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
lldb::SymbolSharedCacheUse GetSharedCacheBinaryLoading() const
A collection class for Module objects.
std::recursive_mutex & GetMutex() const
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
static ModuleListProperties & GetGlobalModuleListProperties()
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
void FindSymbolsMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
ModuleIterable Modules() const
size_t GetSize() const
Gets the size of the module list.
void LogUUIDAndPaths(Log *log, const char *prefix_cstr)
void SetObjectSize(uint64_t object_size)
ConstString & GetObjectName()
ArchSpec & GetArchitecture()
void SetObjectOffset(uint64_t object_offset)
A class that describes an executable image and its associated object and symbol files.
virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp)=0
static ObjCLanguageRuntime * Get(Process &process)
A plug-in interface definition class for object file parsers.
virtual lldb::addr_t GetFileOffset() const
Returns the offset into a file at which this object resides.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
virtual lldb::addr_t GetByteSize() const
A plug-in interface definition class for debugging a process.
Range< lldb::addr_t, lldb::addr_t > LoadRange
virtual llvm::VersionTuple GetHostOSVersion()
Sometimes the connection to a process can detect the host OS version that the process is running on.
virtual bool IsLiveDebugSession() const
Check if a process is a live debug session, or a corefile/post-mortem.
Target & GetTarget()
Get the target object pointer for this module.
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
lldb::offset_t GetFileOffset() const
This base class provides an interface to stack frames.
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
ObjectSP GetItemAtIndex(size_t idx) const
ObjectSP GetValueForKey(llvm::StringRef key) const
bool HasKey(llvm::StringRef key) const
std::shared_ptr< Object > ObjectSP
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Symbol * symbol
The Symbol for a given query.
bool IsTrampoline() const
Address & GetAddressRef()
ConstString GetName() const
lldb::SymbolType GetType() const
Address GetAddress() const
Symbol * ResolveReExportedSymbol(Target &target, const lldb::ModuleSP &containing_module_sp=lldb::ModuleSP()) const
Find the symbol this re-exported symbol resolves to.
Symbol * CalculateSymbolContextSymbol() override
Module * GetExecutableModulePointer()
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr, bool *did_read_live_memory=nullptr)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
void RebuildModuleListWithExecutable(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Clear the module list and rebuild it around a new main executable.
Represents UUID's of various sizes.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateLaunching
Process is in the process of launching.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
@ eLanguageTypeUnknown
Unknown or invalid language value.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
lldb_private::ArchSpec GetArchitecture() const
std::vector< ImageInfo > collection
lldb_private::UUID uuid
UUID for this dylib if it has one, else all zeros.
lldb::addr_t address
Address of mach header for this dylib.
std::string min_version_os_sdk
LC_VERSION_MIN_... SDK.
lldb::addr_t slide
The amount to slide all segments by if there is a global slide.
llvm::MachO::mach_header header
The mach header for this image.
llvm::Triple::OSType os_type
LC_VERSION_MIN_... load command os type.
std::vector< Segment > segments
All segment vmaddr and vmsize pairs for this executable (from memory of inferior).
lldb_private::FileSpec file_spec
Resolved path for this dylib.
uint32_t mh_and_load_cmd_size
When we need to read a binary's mach header and load commands out of memory, this specifies how much ...
llvm::Triple::EnvironmentType os_env
LC_VERSION_MIN_... load command os environment.
uint32_t load_stop_id
The process stop ID that the sections for this image were loaded.
void PutToLog(lldb_private::Log *log) const
const UUID & GetUUID() const
lldb::DataExtractorSP GetExtractor()