431 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
440 m_process->GetTarget().GetArchitecture().GetByteOrder();
442 m_process->GetTarget().GetArchitecture().GetAddressByteSize();
448 const size_t count_v2 =
sizeof(uint32_t) +
455 const size_t count_v11 = count_v2 + addr_size +
469 const size_t count_v13 = count_v11 + addr_size +
472 assert(
sizeof(buf) >= count_v13);
500 const size_t bytes_read =
502 if (bytes_read == count) {
512 offset += addr_size - 2;
515 offset += addr_size * 8;
516 uint64_t dyld_all_image_infos_addr = data.
GetAddress(&offset);
532 uint64_t image_infos_offset =
533 dyld_all_image_infos_addr -
535 uint64_t notification_offset =
552 lldb::addr_t image_infos_addr, uint32_t image_infos_count) {
553 ImageInfo::collection image_infos;
555 LLDB_LOGF(log,
"Adding %d modules.\n", image_infos_count);
557 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
558 std::lock_guard<std::recursive_mutex> baseclass_guard(
GetMutex());
563 m_process->GetLoadedDynamicLibrariesInfos(image_infos_addr,
565 if (image_infos_json_sp.get() && image_infos_json_sp->GetAsDictionary() &&
566 image_infos_json_sp->GetAsDictionary()->HasKey(
"images") &&
567 image_infos_json_sp->GetAsDictionary()
568 ->GetValueForKey(
"images")
570 image_infos_json_sp->GetAsDictionary()
571 ->GetValueForKey(
"images")
573 ->GetSize() == image_infos_count) {
574 bool return_value =
false;
584 if (!
ReadImageInfos(image_infos_addr, image_infos_count, image_infos))
594 lldb::addr_t image_infos_addr, uint32_t image_infos_count) {
595 ImageInfo::collection image_infos;
598 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
599 std::lock_guard<std::recursive_mutex> baseclass_guard(
GetMutex());
605 if (!
ReadImageInfos(image_infos_addr, image_infos_count, image_infos)) {
607 log->
PutCString(
"Failed reading image infos array.");
611 LLDB_LOGF(log,
"Removing %d modules.", image_infos_count);
614 for (uint32_t idx = 0; idx < image_infos.size(); ++idx) {
616 LLDB_LOGF(log,
"Removing module at address=0x%16.16" PRIx64
".",
617 image_infos[idx].address);
618 image_infos[idx].PutToLog(log);
633 if (image_infos[idx].address == (*pos).address) {
634 image_infos[idx].uuid = (*pos).uuid;
641 if (unload_image_module_sp.get()) {
648 LLDB_LOGF(log,
"Could not find module for unloading info entry:");
649 image_infos[idx].PutToLog(log);
663 LLDB_LOGF(log,
"Could not find image_info entry for unloading image:");
664 image_infos[idx].PutToLog(log);
668 if (unloaded_module_list.
GetSize() > 0) {
672 log,
"DynamicLoaderMacOSXDYLD::ModulesDidUnload");
674 m_process->GetTarget().GetImages().Remove(unloaded_module_list);
783 llvm::MachO::mach_header *header,
789 if (bytes_read ==
sizeof(llvm::MachO::mach_header)) {
791 ::memset(header, 0,
sizeof(llvm::MachO::mach_header));
797 header->magic = data.
GetU32(&offset);
801 switch (header->magic) {
802 case llvm::MachO::MH_MAGIC:
803 case llvm::MachO::MH_CIGAM:
805 load_cmd_addr +=
sizeof(llvm::MachO::mach_header);
808 case llvm::MachO::MH_MAGIC_64:
809 case llvm::MachO::MH_CIGAM_64:
811 load_cmd_addr +=
sizeof(llvm::MachO::mach_header_64);
819 if (data.
GetU32(&offset, &header->cputype,
820 (
sizeof(llvm::MachO::mach_header) /
sizeof(uint32_t)) -
822 if (load_command_data ==
nullptr)
829 size_t load_cmd_bytes_read =
830 m_process->ReadMemory(load_cmd_addr, load_cmd_data_sp->GetBytes(),
831 load_cmd_data_sp->GetByteSize(),
error);
833 if (load_cmd_bytes_read == header->sizeofcmds) {
836 load_command_data->
SetData(load_cmd_data_sp, 0, header->sizeofcmds);
1077 std::optional<uint64_t> &size) {
1094 uint32_t version_or_magic =
1095 m_process->ReadUnsignedIntegerFromMemory(all_image_infos, 4, -1, err);
1096 if (version_or_magic !=
static_cast<uint32_t
>(-1) &&
1097 version_or_magic != llvm::MachO::MH_MAGIC &&
1098 version_or_magic != llvm::MachO::MH_CIGAM &&
1099 version_or_magic != llvm::MachO::MH_MAGIC_64 &&
1100 version_or_magic != llvm::MachO::MH_CIGAM_64 &&
1101 version_or_magic >= 13) {
1103 int wordsize =
m_process->GetAddressByteSize();
1104 if (wordsize == 8) {
1105 sharedCacheUUID_address =
1106 all_image_infos + 160;
1108 if (wordsize == 4) {
1109 sharedCacheUUID_address =
1110 all_image_infos + 84;
1113 uuid_t shared_cache_uuid;
1114 if (
m_process->ReadMemory(sharedCacheUUID_address, shared_cache_uuid,
1116 uuid =
UUID(shared_cache_uuid, 16);
1122 if (version_or_magic >= 15) {
1125 addr_t sharedCacheBaseAddr_address = sharedCacheUUID_address + 16;
1127 base_address =
m_process->ReadUnsignedIntegerFromMemory(
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *>
Report warning events.
bool UpdateDYLDImageInfoFromNewImageInfo(ImageInfo &image_info)
lldb::ModuleSP GetDYLDModule()
ImageInfo::collection m_dyld_image_infos
DynamicLoaderDarwin(lldb_private::Process *process)
uint32_t m_dyld_image_infos_stop_id
std::recursive_mutex & GetMutex() const
lldb::ModuleSP FindTargetModuleForImageInfo(const ImageInfo &image_info, bool can_create, bool *did_create_ptr)
bool AddModulesUsingImageInfos(ImageInfo::collection &image_infos)
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)
void UpdateSpecialBinariesFromPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
bool AddModulesUsingPreloadedModules(std::vector< std::pair< ImageInfo, lldb::ModuleSP > > &images)
void SetDYLDModule(lldb::ModuleSP &dyld_module_sp)
static bool UseDYLDSPI(lldb_private::Process *process)
lldb_private::Address m_pthread_getspecific_addr
bool UnloadModuleSections(lldb_private::Module *module, ImageInfo &info)
Process * m_process
The process that this dynamic loader plug-in is tracking.
bool GetStopWhenImagesChange() const
Get whether the process should stop when images change.
DynamicLoader(Process *process)
Construct with a process.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread & GetThreadRef() const
Returns a reference to the thread object.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
void PutCString(const char *cstr)
A collection class for Module objects.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
ModuleIterable Modules() const
size_t GetSize() const
Gets the size of the module list.
void LogUUIDAndPaths(Log *log, const char *prefix_cstr)
A class that describes an executable image and its associated object and symbol files.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
A plug-in interface definition class for object file parsers.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
unsigned int UInt(unsigned int fail_value=0) const
unsigned long long ULongLong(unsigned long long fail_value=0) const
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.
static Status FromErrorString(const char *str)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
lldb::break_id_t GetID() const
const char * GetData() const
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
std::shared_ptr< Object > ObjectSP
lldb::addr_t GetLoadAddress(Target *target) const
ConstString GetName() const
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
Module * GetExecutableModulePointer()
Debugger & GetDebugger() const
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
Represents UUID's of various sizes.
void PushValue(const Value &value)
Value * GetValueAtIndex(size_t idx)
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
@ Scalar
A raw scalar value.
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_BREAK_ID
#define UNUSED_IF_ASSERT_DISABLED(x)
#define LLDB_BREAK_ID_IS_VALID(bid)
#define LLDB_INVALID_ADDRESS
lldb::ByteOrder InlHostByteOrder()
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::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
@ eEncodingUint
unsigned integer
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Module > ModuleSP
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.
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.
std::vector< Segment > segments
All segment vmaddr and vmsize pairs for this executable (from memory of inferior).
void Clear(bool load_cmd_data_only)
lldb::user_id_t GetID() const
Get accessor for the user ID.