-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Allow emitting line number information into native AOT apps #122227
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
Conversation
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
There was a problem hiding this 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 adds support for embedding line number information into native AOT applications, allowing stack traces to include file names and line numbers without requiring separate debug symbol files (PDB/DWO/DSYM). The implementation uses hashtables to map methods to their line number data, with two different lookup mechanisms: one for methods with dedicated stack trace metadata and another for methods with reflection metadata.
Key Changes
- Introduces
StackTraceLineNumbersNodeandStackTraceDocumentsNodeto embed line number and document information into the executable - Adds
HasLineNumbersflag toMethodStackTraceVisibilityFlagsand correspondingStackTraceRecordFlagsto control line number emission - Extends
VersionResilientHashCodewithCombineThreeValuesIntoHashmethod for hashing three values
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs |
Adds regression test for issue #121093 validating stack trace contains method names for both reflected and non-reflected generic methods |
src/libraries/Common/src/Internal/VersionResilientHashCode.cs |
Adds CombineThreeValuesIntoHash method for creating stable hash codes from three values |
src/coreclr/tools/aot/ILCompiler/Program.cs |
Updates stack trace emission policy to enable line numbers when stack trace data is emitted |
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj |
Adds new node files to project |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs |
Updates ComputeMetadata signature to include reflection-based stack trace mappings |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/StackTraceEmissionPolicy.cs |
Adds HasLineNumbers flag support and constructor parameter to control line number inclusion |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs |
Refactors stack trace mapping to support both regular and reflection-based line number generation, adds flag-based filtering |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs |
Updates to use flag enum instead of boolean |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs |
New node that generates hashtable mapping methods to compressed line number data |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceDocumentsNode.cs |
New node that stores document paths with offset-based indexing |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs |
Updates ComputeMetadata signature to include reflection-based stack trace mappings |
src/coreclr/tools/Common/Internal/Runtime/MetadataBlob.cs |
Adds blob IDs for line numbers and documents |
src/coreclr/tools/Common/Compiler/DependencyAnalysis/SortableDependencyNode.cs |
Adds ordering entries for new node types |
...reclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs
Outdated
Show resolved
Hide resolved
...reclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs
Show resolved
Hide resolved
...tion.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
Show resolved
Hide resolved
|
The extra data adds 5-10% in size (MichalStrehovsky/rt-sz#199 (comment)) to existing apps. So I'm not folding this into StackTraceSupport property (that we enable by default and is by itself a 10% cost). I triggered a another rt-sz run on what is in the branch now to verify the additional cost is zero when this is not enabled (well, not fully zero since we still have code to read it, but close). This is ready for review now. |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/StackTraceEmissionPolicy.cs
Show resolved
Hide resolved
...eaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Resources/Strings.resx
Show resolved
Hide resolved
...tion.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
Show resolved
Hide resolved
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
...eaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs
Outdated
Show resolved
Hide resolved
...eaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs
Outdated
Show resolved
Hide resolved
...eaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs
Show resolved
Hide resolved
...coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceDocumentsNode.cs
Show resolved
Hide resolved
Updates the repro project according to #122227.
Fixes #121093 (because I needed more precise tracking of what gets stack trace data)
Fixes #103156 (because I needed to change how we stringify anyway)
Fixes #68714 (the thing I wanted to fix when I started)
Cc @dotnet/ilc-contrib