microsoft / clrmd

Microsoft.Diagnostics.Runtime is a set of APIs for introspecting processes and dumps.
MIT License
1.05k stars 254 forks source link

Better error handling for Linux dumps loaded on Windows #977

Closed noahfalk closed 2 years ago

noahfalk commented 2 years ago

Currently if I load a linux core file when running CLRMD on Windows I get FileNotFoundException 'Could not find matching DAC for this runtime'. Could we improve this error to a NotSupportedException (assuming it isn't intended to be supported right now?)

Repro:

        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", "https://msdl.microsoft.com/download/symbols");
            DataTarget target = DataTarget.LoadDump("some_linux_dump");
            ClrInfo info = target.ClrVersions[0];
            ClrRuntime r = info.CreateRuntime();
        }

Expected result: A NotSupportedException (or working is cool too) Actual result: FileNotFoundException

Debugging into it I see that CLRMD issues a symbol server request for mscordaccore like this: mscordaccore.dll\000000006f7000\mscordaccore.dll If the scenario is intended to work CLRMD would instead need to issue a request for: mscordaccore.dll\elf-buildid-coreclr-2cb234c544d6a97745e89f207485dc027a86b7a5\mscordaccore.dll The 20 byte hex value is the buildid for coreclr binary and I confirmed CLRMD did parse that correctly if you wanted to go this route.

When I manually downloaded the correct xplat DAC and pointed CLRMD at it my simple test for runtime.EnumerateObjects().Count() gave me a reasonable number so this might be a viable workaround for others as well.

PS. CLRMD remains one of the most reliable repos where I can clone, build and debug in literally seconds with zero hassle. It made it really convenient for me to investigate this. Thanks 👍

leculver commented 2 years ago

@noahfalk Just back from vacation, working on this now. Along with more OS X, Linux, and Windows -> Linux debugging improvements.