Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Need to ensure the symbol table and symbol string table for the dylinker
module is part of the core dump for the dump readers. They still need
to look up the "dyld_all_image_infos" symbol.
  • Loading branch information
Mike McLaughlin committed Dec 9, 2022
commit 6c530919fba8e47469520edfc32587f63d2535d4
18 changes: 15 additions & 3 deletions src/coreclr/debug/dbgutil/machoreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ MachOReader::EnumerateModules(mach_vm_address_t dyldInfoAddress)
Trace("MOD: infoArray %p infoArrayCount %d\n", dyldInfo.infoArray, dyldInfo.infoArrayCount);

// Create the dyld module info
if (!CreateModule(dyldInfo.dyldImageLoadAddress, dyldInfo.dyldPath))
if (!TryRegisterModule(dyldInfo.dyldImageLoadAddress, dyldInfo.dyldPath, true))
{
Trace("ERROR: Failed to read dyld header at %p\n", dyldInfo.dyldImageLoadAddress);
return false;
Expand All @@ -393,13 +393,13 @@ MachOReader::EnumerateModules(mach_vm_address_t dyldInfoAddress)
for (int i = 0; i < dyldInfo.infoArrayCount; i++)
{
// Ignore any errors and continue to next module
CreateModule(imageInfos[i].imageLoadAddress, imageInfos[i].imageFilePath);
TryRegisterModule(imageInfos[i].imageLoadAddress, imageInfos[i].imageFilePath, false);
}
return true;
}

bool
MachOReader::CreateModule(const struct mach_header* imageAddress, const char* imageFilePathAddress)
MachOReader::TryRegisterModule(const struct mach_header* imageAddress, const char* imageFilePathAddress, bool dylinker)
{
std::string imagePath;
if (!ReadString(imageFilePathAddress, imagePath))
Expand All @@ -413,6 +413,18 @@ MachOReader::CreateModule(const struct mach_header* imageAddress, const char* im
}
Trace("MOD: %016llx %08x %s\n", imageAddress, module.Header().flags, imagePath.c_str());
VisitModule(module);
if (dylinker)
{
// Make sure the memory for the symbol and string tables are in the core dump for our
// dump readers which still use this symbol to enumerate modules.
uint64_t dyldInfoAddress = 0;
if (!module.TryLookupSymbol("dyld_all_image_infos", &dyldInfoAddress))
{
Trace("ERROR: Can not find the _dyld_all_image_infos symbol\n");
return false;
}
Trace("MOD: dyldInfoAddress %016llx\n", dyldInfoAddress);
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/dbgutil/machoreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MachOReader
bool EnumerateModules(mach_vm_address_t dyldInfoAddress);

private:
bool CreateModule(const struct mach_header* imageAddress, const char* imageFilePathAddress);
bool TryRegisterModule(const struct mach_header* imageAddress, const char* imageFilePathAddress, bool dylinker);
bool ReadString(const char* address, std::string& str);
virtual void VisitModule(MachOModule& module) { };
virtual void VisitSegment(MachOModule& module, const segment_command_64& segment) { };
Expand Down