Files
dotnet-runtime/eng/testing/debug-dump-template.md
T
Mike McLaughlinandJuan Sebastian Hoyos Ayala 79ad10cf22 Add MachO dump writer to createdump (#51150)
* Add MachO dump writer to createdump

Instead of the hacky ELF core dumps on MacOS now createdump generates true MachO dumps.

Setting the COMPlus_DbgEnableElfDumpOnMacOS environment variable is no longer needed.

Add special thread info memory region containing the OS thread ids missing from macho core dumps. This allows SOS to map the thread indexes to thread ids. The address (0x7fffffff00000000) of this special memory region is above the highest user address (0x0007FFFFFFFFF000) and below a kernel reserved address (0xffffff8000xxxxxx) which is kind of moot because dumps don't include any kernel regions. lldb seems just fine with this memory region.

The changes include ARM64 support also, but since I don't have a M1 device I can't build/test them. I'm hoping Steve can at least review them.

Add --verbose/TRACE_VERBOSE support to tone down all the macho dump generation spew.

Issue: #48664

* Fix build problem

* Update docs

* Code review feedback

Co-authored-by: Juan Sebastian Hoyos Ayala <[email protected]>
2021-04-15 21:45:55 +00:00

5.4 KiB

Get the Helix payload

Runfo helps get information about helix test runs and azure devops builds. We will use it to download the payload and symbols (recommended version 0.6.4 or later):

dotnet tool install --global runfo
dotnet tool update --global runfo

If prompted, open a new command prompt to pick up the updated PATH.

# On Windows
# assumes %WOUTDIR% does not exist
runfo get-helix-payload -j %JOBID% -w %WORKITEM% -o %WOUTDIR%
# On Linux and macOS
# assumes %LOUTDIR% does not exist
runfo get-helix-payload -j %JOBID% -w %WORKITEM% -o %LOUTDIR%

Any dump files published by helix will be downloaded.

NOTE: if the helix job is an internal job, you need to pass down a helix authentication token using the --helix-token argument.

Now extract the files:

# On Windows
for /f %i in ('dir /s/b %WOUTDIR%\*zip') do tar -xf %i -C %WOUTDIR%

# On Linux and macOS
# obtain `unzip` if necessary; eg `sudo apt-get install unzip` or `sudo dnf install unzip`
find %LOUTDIR% -name '*zip' -exec unzip -d %LOUTDIR% {} \;

Now use the dotnet-sos global tool to install the SOS debugging extension.

dotnet tool install --global dotnet-sos
dotnet tool update --global dotnet-sos

If prompted, open a new command prompt to pick up the updated PATH.

# Install only one: the one matching your dump
dotnet sos install --architecture Arm
dotnet sos install --architecture Arm64
dotnet sos install --architecture x86
dotnet sos install --architecture x64

Now choose a section below based on your OS.

If it's a Windows dump on Windows...

... and you want to debug with WinDbg

Install or update WinDbg if necessary (external, internal). If you don't have a recent WinDbg you may have to do .update sos.

Open WinDbg and open the dump with File>Open Dump.

<win-path-to-dump>
!setclrpath %WOUTDIR%\shared\Microsoft.NETCore.App\6.0.0
.sympath+ %WOUTDIR%\shared\Microsoft.NETCore.App\6.0.0

Now you can use regular SOS commands like !dumpstack, !pe, etc.

... and you want to debug with Visual Studio

Currently this is not possible because mscordbi.dll is not signed.

... and you want to debug with dotnet-dump

Install the dotnet-dump global tool.

dotnet tool install --global dotnet-dump
dotnet tool update --global dotnet-dump

If prompted, open a new command prompt to pick up the updated PATH.

dotnet-dump analyze <win-path-to-dump>

Within dotnet-dump:

setclrpath %WOUTDIR%\shared\Microsoft.NETCore.App\6.0.0
setsymbolserver -directory %WOUTDIR%\shared\Microsoft.NETCore.App\6.0.0

Now you can use regular SOS commands like dumpstack, pe, etc. If you are debugging a 32 bit dump using 64 bit dotnet, you will get an error SOS does not support the current target architecture. In that case replace dotnet-dump with the 32 bit version:

dotnet tool uninstall --global dotnet-dump
"C:\Program Files (x86)\dotnet\dotnet.exe" tool install --global dotnet-dump

If it's a Linux dump on Windows...

Download the Cross DAC Binaries, open it and choose the flavor that matches the dump you are to debug, and copy those files to %WOUTDIR%\shared\Microsoft.NETCore.App\6.0.0.

Now you can debug with WinDbg or dotnet-dump as if it was a Windows dump. See above.


If it's a Linux dump on Linux...

... and you want to debug with LLDB

Install or update LLDB if necessary (instructions here)

Load the dump:

lldb --core <lin-path-to-dump> %LOUTDIR%/shared/Microsoft.NETCore.App/6.0.0/dotnet

Within lldb:

setclrpath %LOUTDIR%/shared/Microsoft.NETCore.App/6.0.0
sethostruntime /usr/bin/dotnet
setsymbolserver -directory %LOUTDIR%/shared/Microsoft.NETCore.App/6.0.0

If you want to load native symbols

loadsymbols

... and you want to debug with dotnet-dump

Install the dotnet-dump global tool.

dotnet tool install --global dotnet-dump
dotnet tool update --global dotnet-dump

If prompted, open a new command prompt to pick up the updated PATH.

dotnet-dump analyze <lin-path-to-dump>

Within dotnet-dump:

setclrpath %LOUTDIR%/shared/Microsoft.NETCore.App/6.0.0
setsymbolserver -directory %LOUTDIR%/shared/Microsoft.NETCore.App/6.0.0

If it's a macOS dump

Instructions for debugging dumps on macOS are essentially the same as Linux with one exception: dotnet-dump cannot analyze macOS system dumps yet: you must use lldb for those. As of .NET 6, createdump on macOS will start generating native Mach-O core files. dotnet-dump and ClrMD are still being worked on to handle these dumps.


Other Helpful Information