Skip to content

Generate module rundown events #116338

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

Merged
merged 12 commits into from
Jun 16, 2025

Conversation

MichalStrehovsky
Copy link
Member

This is sufficient to get module information in dotnet-gcdump collect. The tool itself will need tweaks because it only looks at IL paths right now, but this should be all that's necessary to build on top.

Cc @brianrob @noahfalk @dotnet/ilc-contrib

This is sufficient to get module information in `dotnet-gcdump collect`. The tool itself will need tweaks because it only looks at IL paths right now, but this should be all that's necessary to build on top.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for module rundown events to improve module information collection in dotnet-gcdump. It updates provider filtering logic, adds new functions and contexts for rundown events, and implements routines to retrieve PDB information on Windows while stubbing them on Unix.

  • Updated provider filtering in genEventing.py to adjust nativeaot conditions.
  • Added DotNETRuntimeRundownProvider_IsEnabled and related ETW/EventPipe rundown provider contexts/functions.
  • Implemented PalGetPDBInfo for Windows and a stub for Unix, plus updated ep-rt-aot to execute rundown events.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/scripts/genEventing.py Modified filtering logic to remove check for "Microsoft-Windows-DotNETRuntimeRundown".
src/coreclr/scripts/genEventPipe.py Added new function for rundown provider enablement.
src/coreclr/nativeaot/Runtime/windows/PalCommon.cpp Introduced PalGetPDBInfo to extract PDB information from PE headers.
src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp Added stub implementation for PalGetPDBInfo on Unix.
src/coreclr/nativeaot/Runtime/eventtracebase.h, eventtrace_context.h, eventtrace.cpp Created rundown provider contexts and callbacks for ETW/EventPipe.
src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h, ep-rt-aot.cpp Updated to call the new rundown event execution routine.
src/coreclr/nativeaot/Runtime/Pal.h Declared PalGetPDBInfo.
Comments suppressed due to low confidence (3)

src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp:98

  • The stub implementation for PalGetPDBInfo on Unix does not retrieve any PDB info; please add a comment documenting that PDB info is not supported on Unix platforms and ensure that callers handle the empty output appropriately.
void PalGetPDBInfo(HANDLE hOsHandle, GUID * pGuidSignature, _Out_ uint32_t * pdwAge, _Out_writes_z_(cchPath) TCHAR * wszPath, int32_t cchPath)

src/coreclr/scripts/genEventing.py:223

  • The filtering condition for 'Microsoft-Windows-DotNETRuntimeRundown' has been removed; please confirm that this logic change is intentional given that the PR aims to generate module rundown events.
elif runtimeFlavor.nativeaot and providerName == "Microsoft-Windows-DotNETRuntimeStress":

src/coreclr/nativeaot/Runtime/ep-rt-aot.cpp:199

  • [nitpick] Ensure that the newly added rundown event execution via ETW::EnumerationLog::EndRundown integrates correctly with the overall provider enable/disable logic to avoid unintended side effects.
ep_rt_aot_execute_rundown (dn_vector_ptr_t* execution_checkpoints)

Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

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.

Thanks @MichalStrehovsky, this looks nice!

};

// Grab module bounds so we can do some rough sanity checking before we follow any
// RVAs
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to do this? If somebody manages to produce a corrupted binary, they will see crashes. That's by design.

DWORD magic;
GUID signature; // unique identifier
DWORD age; // an always-incrementing value
_Field_z_ char path[MAX_PATH]; // zero terminated string with the name of the PDB file
Copy link
Member

Choose a reason for hiding this comment

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

This is a stale or mangled definition of this structure. The up-to-date definition looks like this (you can check this in the MS internal OS repo) - notice that the file path is an open array:

struct CV_INFO_PDB70 
{
	DWORD      CvSignature; 
	GUID       Signature;       // unique identifier 
	DWORD      Age;             // an always-incrementing value 
	BYTE       PdbFileName[1];  // zero terminated string with the name of the PDB file 
};

Copy link
Member

Choose a reason for hiding this comment

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

(We have the same problem in regular CoreCLR.)

// outright corrupt.

// Verify sane size of raw data
if (cbDebugData > sizeof(CV_INFO_PDB70))
Copy link
Member

Choose a reason for hiding this comment

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

This is bogus sanity check. It is going to reject long paths incorrectly.

MichalStrehovsky and others added 3 commits June 12, 2025 22:57
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Prompt: The use of mbstowcs_s is incorrect here. The input buffer is UTF-8, output is UTF-16. Replace the incorrect use of mbstowcs_s with MultiByteToWideChar.
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky merged commit 0c40743 into dotnet:main Jun 16, 2025
98 of 100 checks passed
@MichalStrehovsky MichalStrehovsky deleted the modulerundown branch June 16, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants