Skip to content

Commit d19cf50

Browse files
author
Mike McLaughlin
authored
Need to ensure the symbol table and symbol string table for the dylinker (#79728)
module is part of the core dump for the dump readers. They still need to look up the "dyld_all_image_infos" symbol.
1 parent c0ebf2b commit d19cf50

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/coreclr/debug/dbgutil/machoreader.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ MachOReader::EnumerateModules(mach_vm_address_t dyldInfoAddress)
372372
Trace("MOD: infoArray %p infoArrayCount %d\n", dyldInfo.infoArray, dyldInfo.infoArrayCount);
373373

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

401401
bool
402-
MachOReader::CreateModule(const struct mach_header* imageAddress, const char* imageFilePathAddress)
402+
MachOReader::TryRegisterModule(const struct mach_header* imageAddress, const char* imageFilePathAddress, bool dylinker)
403403
{
404404
std::string imagePath;
405405
if (!ReadString(imageFilePathAddress, imagePath))
@@ -413,6 +413,18 @@ MachOReader::CreateModule(const struct mach_header* imageAddress, const char* im
413413
}
414414
Trace("MOD: %016llx %08x %s\n", imageAddress, module.Header().flags, imagePath.c_str());
415415
VisitModule(module);
416+
if (dylinker)
417+
{
418+
// Make sure the memory for the symbol and string tables are in the core dump for our
419+
// dump readers which still use this symbol to enumerate modules.
420+
uint64_t dyldInfoAddress = 0;
421+
if (!module.TryLookupSymbol("dyld_all_image_infos", &dyldInfoAddress))
422+
{
423+
Trace("ERROR: Can not find the _dyld_all_image_infos symbol\n");
424+
return false;
425+
}
426+
Trace("MOD: dyldInfoAddress %016llx\n", dyldInfoAddress);
427+
}
416428
return true;
417429
}
418430

src/coreclr/debug/dbgutil/machoreader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MachOReader
5555
bool EnumerateModules(mach_vm_address_t dyldInfoAddress);
5656

5757
private:
58-
bool CreateModule(const struct mach_header* imageAddress, const char* imageFilePathAddress);
58+
bool TryRegisterModule(const struct mach_header* imageAddress, const char* imageFilePathAddress, bool dylinker);
5959
bool ReadString(const char* address, std::string& str);
6060
virtual void VisitModule(MachOModule& module) { };
6161
virtual void VisitSegment(MachOModule& module, const segment_command_64& segment) { };

0 commit comments

Comments
 (0)