Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SymbolStore] Add support to index .NET Framework Runtime debugging modules #4616

Merged

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Apr 18, 2024

SymbolStoreKey generators (*FileKeyGenerator) currently do not support .NET Framework scenarios which contain a different runtime module (clr.dll) than .NET Core scenarios (coreclr.dll). This PR aims to update the PEFileKeyGenerator to support generating SymbolStoreKeys for debugging modules used to debug the .NET Framework clr.dll runtime.

Before

var keygen = new PEFileKeyGenerator(tracer, pefile, filename);
Console.WriteLine("ClrKeys");
foreach (var key in keygen.GetKeys(KeyTypeFlags.ClrKeys))
{
    Console.WriteLine(key.Index);
}
Console.WriteLine("End");

// $dotnet run -- <path-to-clr.dll>
//
// ClrKeys
// End

After

var keygen = new PEFileKeyGenerator(tracer, pefile, filename);
Console.WriteLine("ClrKeys");
foreach (var key in keygen.GetKeys(KeyTypeFlags.ClrKeys))
{
    Console.WriteLine(key.Index);
}
Console.WriteLine("End");

// $dotnet run -- <path-to-clr.dll>
//
// ClrKeys
// <sos_long_name_index>
// <dac_index>
// <dac_long_name_index>
// <dbi_index>
// End

This PR does the following:

  • Refactors GetSpecialFiles logic
    • Splits grabbing DAC/DBI special files and SOS special files into separate steps
    • Refactor logic to generate valid special file long name variants into a separate helper method.
  • Add support for .NET Framework DAC special files
  • Removes SOS key generation from .NET Core logic
  • Adds mock PE files to test ClrKey generation for .NET Framework
  • No longer considers sos.dll as a "special file" as it is not indexed under runtime module properties

.NET Framework runtime module, DAC module, DBI module, SOS module indexing

clr.dll - identity
mscordbi.dll - identity + clr properties
mscordacwks.dll - identity + clr properties
mscordacwks_(long).dll - identity + clr properties
sos.dll - identity
sos_(long).dll - identity + clr properties

.NET Core runtime module, DAC module, DBI module indexing

coreclr.dll - identity
mscordbi.dll - identity + coreclr properties
mscordacwks.dll - identity + coreclr properties
mscordacwks_(long).dll - identity + coreclr properties


Running dotnet-symbol on SOS.DotnetDumpCommands.Heap.dumpgen.dmp

Downloading from https://symweb/
Writing files to mihw_dotnet_symbol
ERROR: Not Found: DotnetDumpCommands.exe - 'https://symweb/dotnetdumpcommands.exe/94C48F736000/dotnetdumpcommands.exe'
ERROR: Not Found: DotnetDumpCommands.pdb - 'https://symweb/dotnetdumpcommands.pdb/259bd51db1d64df89a4e33ec340748c31/dotnetdumpcommands.pdb'
Writing: mihw_dotnet_symbol\ntdll.dll
Writing: mihw_dotnet_symbol\ntdll.pdb
Writing: mihw_dotnet_symbol\mscoree.dll
Writing: mihw_dotnet_symbol\mscoree.pdb
Writing: mihw_dotnet_symbol\kernel32.dll
Writing: mihw_dotnet_symbol\kernel32.pdb
Writing: mihw_dotnet_symbol\KERNELBASE.dll
Writing: mihw_dotnet_symbol\kernelbase.pdb
Writing: mihw_dotnet_symbol\advapi32.dll
Writing: mihw_dotnet_symbol\advapi32.pdb
Writing: mihw_dotnet_symbol\msvcrt.dll
Writing: mihw_dotnet_symbol\msvcrt.pdb
Writing: mihw_dotnet_symbol\sechost.dll
Writing: mihw_dotnet_symbol\sechost.pdb
Writing: mihw_dotnet_symbol\bcrypt.dll
Writing: mihw_dotnet_symbol\bcrypt.pdb
Writing: mihw_dotnet_symbol\rpcrt4.dll
Writing: mihw_dotnet_symbol\rpcrt4.pdb
Writing: mihw_dotnet_symbol\mscoreei.dll
Writing: mihw_dotnet_symbol\mscoreei.pdb
Writing: mihw_dotnet_symbol\shlwapi.dll
Writing: mihw_dotnet_symbol\shlwapi.pdb
Writing: mihw_dotnet_symbol\kernel.appcore.dll
Writing: mihw_dotnet_symbol\Kernel.Appcore.pdb
Writing: mihw_dotnet_symbol\version.dll
Writing: mihw_dotnet_symbol\version.pdb
Writing: mihw_dotnet_symbol\clr.dll
Writing: mihw_dotnet_symbol\clr.pdb
Writing: mihw_dotnet_symbol\SOS_amd64_amd64_4.8.9232.00.dll
ERROR: Not Found: mscordacwks.dll - 'https://symweb/mscordacwks.dll/65EFB9129a4000/mscordacwks.dll'
Writing: mihw_dotnet_symbol\mscordbi.dll
Writing: mihw_dotnet_symbol\mscordacwks_amd64_amd64_4.8.9232.00.dll
Writing: mihw_dotnet_symbol\user32.dll
Writing: mihw_dotnet_symbol\user32.pdb
Writing: mihw_dotnet_symbol\win32u.dll
Writing: mihw_dotnet_symbol\win32u.pdb
Writing: mihw_dotnet_symbol\gdi32.dll
Writing: mihw_dotnet_symbol\gdi32.pdb
Writing: mihw_dotnet_symbol\gdi32full.dll
Writing: mihw_dotnet_symbol\gdi32full.pdb
Writing: mihw_dotnet_symbol\msvcp_win.dll
Writing: mihw_dotnet_symbol\msvcp_win.pdb
Writing: mihw_dotnet_symbol\ucrtbase.dll
Writing: mihw_dotnet_symbol\ucrtbase.pdb
Writing: mihw_dotnet_symbol\VCRUNTIME140_CLR0400.dll
Writing: mihw_dotnet_symbol\vcruntime140_clr0400.amd64.pdb
Writing: mihw_dotnet_symbol\VCRUNTIME140_1_CLR0400.dll
Writing: mihw_dotnet_symbol\vcruntime140_1_clr0400.amd64.pdb
Writing: mihw_dotnet_symbol\ucrtbase_clr0400.dll
Writing: mihw_dotnet_symbol\ucrtbase_clr0400.amd64.pdb
Writing: mihw_dotnet_symbol\imm32.dll
Writing: mihw_dotnet_symbol\imm32.pdb
Writing: mihw_dotnet_symbol\psapi.dll
Writing: mihw_dotnet_symbol\psapi.pdb
ERROR: Not Found: mscorlib.ni.dll - 'https://symweb/mscorlib.ni.dll/65EFB8AD160f000/mscorlib.ni.dll'
ERROR: Not Found: mscorlib.ni.pdb - 'https://symweb/mscorlib.ni.pdb/448a486950dceb6a540939cbe7df7d2c1/mscorlib.ni.pdb'
Writing: mihw_dotnet_symbol\mscorlib.pdb
Writing: mihw_dotnet_symbol\ole32.dll
Writing: mihw_dotnet_symbol\ole32.pdb
Writing: mihw_dotnet_symbol\combase.dll
Writing: mihw_dotnet_symbol\combase.pdb
Writing: mihw_dotnet_symbol\bcryptPrimitives.dll
Writing: mihw_dotnet_symbol\bcryptprimitives.pdb
Writing: mihw_dotnet_symbol\cryptsp.dll
Writing: mihw_dotnet_symbol\cryptsp.pdb
Writing: mihw_dotnet_symbol\rsaenh.dll
Writing: mihw_dotnet_symbol\rsaenh.pdb
Writing: mihw_dotnet_symbol\CRYPTBASE.dll
Writing: mihw_dotnet_symbol\cryptbase.pdb
Writing: mihw_dotnet_symbol\clrjit.dll
Writing: mihw_dotnet_symbol\clrjit.pdb
ERROR: Not Found: System.ni.dll - 'https://symweb/system.ni.dll/65F11862c1e000/system.ni.dll'
ERROR: Not Found: System.ni.pdb - 'https://symweb/system.ni.pdb/95d0282b6c6403bae690dcd3e65e7fad1/system.ni.pdb'
Writing: mihw_dotnet_symbol\System.pdb
ERROR: Not Found: System.Core.ni.dll - 'https://symweb/system.core.ni.dll/65F11851a86000/system.core.ni.dll'
ERROR: Not Found: System.Core.ni.pdb - 'https://symweb/system.core.ni.pdb/a85edf146d386a1d27e22549b5e480431/system.core.ni.pdb'
Writing: mihw_dotnet_symbol\System.Core.pdb

C:\Users\mihw\Source\Repos\mdh1418\diagnostics\artifacts\bin\dotnet-symbol\Debug\net6.0\dotnet-symbol.exe (process 43788) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

@mdh1418 mdh1418 force-pushed the update_pe_file_key_generator_for_net_framework branch from a171274 to 8b86dea Compare April 18, 2024 17:35
@mdh1418 mdh1418 changed the title Update pe file key generator for net framework [SymbolStore] Add support to index .NET Framework Runtime debugging modules Apr 19, 2024
@mdh1418 mdh1418 force-pushed the update_pe_file_key_generator_for_net_framework branch from 8b86dea to 3447506 Compare April 24, 2024 15:22
@mikem8361
Copy link
Member

You may have already down this, but one way to test this end to end (at for downloading), is the run all the diagnostics repo tests on Windows with test.cmd. That creates some .NET Framework dumps in diagnostics\artifacts\tmp\Debug\dumps\Desktop\net462. Then take the dotnet-symbol built with your changes and run it (dotnet artifacts\bin\dotnet-symbol\Debug\shims\net6.0\dotnet-symbol.dll -o <path-to-put-files> <dump-file>). "clr.dll", "sos.dll" and "mscordacwks.dll" should be downloaded. You may have to use the --internal-server option to download from symweb.

@mdh1418 mdh1418 marked this pull request as ready for review April 25, 2024 02:44
@mdh1418 mdh1418 requested a review from a team as a code owner April 25, 2024 02:44
@mdh1418 mdh1418 added the DO NOT MERGE do not merge this PR label May 1, 2024
@mdh1418 mdh1418 force-pushed the update_pe_file_key_generator_for_net_framework branch 3 times, most recently from a5c6f55 to ca97c6e Compare May 2, 2024 18:15
@mdh1418
Copy link
Member Author

mdh1418 commented May 7, 2024

@hoyosjs @noahfalk Thanks for the feedback, could I get another review?

@mdh1418
Copy link
Member Author

mdh1418 commented May 7, 2024

I believe the failures are unrelated, created issues #4654, #4655, and one Socket connection issue that might be the same as #1742

@mdh1418 mdh1418 enabled auto-merge (squash) May 7, 2024 21:06
@mdh1418 mdh1418 force-pushed the update_pe_file_key_generator_for_net_framework branch from 2064495 to e94c414 Compare May 8, 2024 02:53
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hoyosjs hoyosjs disabled auto-merge May 8, 2024 18:15
@hoyosjs hoyosjs merged commit 5906cc6 into dotnet:main May 8, 2024
16 of 18 checks passed
@mdh1418 mdh1418 deleted the update_pe_file_key_generator_for_net_framework branch May 8, 2024 18:23
mikem8361 pushed a commit that referenced this pull request May 9, 2024
It was discovered in #4616
that SOS.OtherCommands DumpMT Verification fails on Alpine Release
builds for PRs starting Friday 4/26.
As PRs cannot be merged until all checks are passing, this test failure
is blocking.

This PR disables the test for Alpine, with
#4654 as the tracking issue
@mdh1418 mdh1418 removed the DO NOT MERGE do not merge this PR label May 13, 2024
hoyosjs added a commit that referenced this pull request Jun 8, 2024
- Update Alpine versions (#4589)
- Followup 1ES template changes (#4596)
- Fix Test Results tab in github UI (#4607)
- Move the symstore repo to diagnostics (#4603)
- Fix recent Alpine repo build (#4612)
- Fix issue #4611 - Switch to cross build for Alpine (#4621)
- Add waithandle to --clrevents option (#4624)
- Fix SOS unit tests dump generation fixture (#4636)
- Fix CONTRACT return type (#4649)
- [SymbolStore] Add support to index .NET Framework Runtime debugging
modules (#4616)
- [test][SOS] Disable OtherCommands Dumpmt test on Alpine (#4656)
- Supports collecting GCSettingsEvent for gc-collect profile (#4615)
- Update ipc-protocol.md (#4658)
- Fixing a case where we should set the RundownKeyword (#4662)
- Fix versioning of symstore ported assets (#4670)
- Add ubuntu 22.04 testing. Update 6,7 and 8 runtime versions (#4676)
- Update locker action version to update node version (#4682)
- Use managed identity for blob upload of release assets (#4680)
- Remove the symweb symbol server support (#4694)
- [RISC-V] Add gcinfodumper implementation. (#4703)
- Fix `pathto` SOS command. (#4706)
- Add support for new exception trace storage format (#4635)
- Change SOS breaking change from warning to error; better dotnet-dump
target errors (#4713)
- [Symbol] Add manifest generator (#4693)
- Remove references to obsolete storage account variables (#4719)
- Update DIA to 17.10.0-beta1.24272.1 (#4683)
- Reenable SDL requirements (#4722)

---------

Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rich Lander <rlander@microsoft.com>
Co-authored-by: Mike McLaughlin <mikem@microsoft.com>
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Co-authored-by: Grégoire <gregoire.verdier@gmail.com>
Co-authored-by: Tom McDonald <tommcdon@microsoft.com>
Co-authored-by: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com>
Co-authored-by: Andrew Au <andrewau@microsoft.com>
Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
Co-authored-by: Mikhail Kurinnoi <m.kurinnoi@samsung.com>
Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants