microsoft/clrmd

Could not find matching DAC for process on macOS after switching to ClrMD 2.1

k15tfu opened this issue · 0 comments

k15tfu commented

Hi! After upgrading to ClrMD >= 2.1 (specifically #999), ClrInfo.CreateRuntime() cannot find DAC for .NET 7 app on macOS ARM64 with the following error Debugging a 'OSX' crash is not supported on 'OSX':

// We should have had at least one dac enumerated if this is a supported scenario.
if (!foundOne)
ThrowCrossDebugError(currentPlatform);

ClrInfo.DebuggingLibraries is empty because all of ClrInfo.IndexTimeStamp, ClrInfo.IndexFileSize, ClrInfo.BuildId are zero/empty as well:

else
{
IndexTimeStamp = module.IndexTimeStamp;
IndexFileSize = module.IndexFileSize;
BuildId = module.BuildId;
Version = module.Version;
}

and therefore nothing is added:

if (IndexFileSize != 0 && IndexTimeStamp != 0)
{
DebugLibraryInfo dacLibraryInfo = new(DebugLibraryKind.Dac, dacCurrentPlatform, targetArch, SymbolProperties.Coreclr, IndexFileSize, IndexTimeStamp);
if (foundLocalDac)
artifacts.Insert(0, dacLibraryInfo);
else
artifacts.Add(dacLibraryInfo);
}
if (!BuildId.IsDefaultOrEmpty)
{
DebugLibraryInfo dacLibraryInfo = new(DebugLibraryKind.Dac, dacCurrentPlatform, targetArch, targetPlatform, SymbolProperties.Coreclr, BuildId);
if (foundLocalDac)
artifacts.Insert(0, dacLibraryInfo);
else
artifacts.Add(dacLibraryInfo);
}

As far as I can see, MacOSProcessDataReader.EnumerateModules() doesn't grab the UUID or provide MachOModule (passed as null) when creating MachOModuleInfo:

// TODO: UUID?
Native.dyld_image_info info = Read<Native.dyld_image_info>(infos.infoArray, i);
ulong imageAddress = info.imageLoadAddress;
string imageFilePath = ReadNullTerminatedAscii(info.imageFilePath);
Version version = GetVersionInfo(info.imageLoadAddress) ?? new Version();
yield return new MachOModuleInfo(null, imageAddress, imageFilePath, version, 0);

Can we do create MachOModuleInfo here similarly as it's done on Linux in LinuxLiveDataReader? cc @leculver

.NET 7.0.7
macOS ARM64