-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add PDB support for PersistedAssemblyBuilder #100706
Conversation
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs
Show resolved
Hide resolved
… name to the locals table
Fixes the failure from dotnet/runtime#100706 (comment)
src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
/// <param name="endColumn">The column in the line where the sequence point ends.</param> | ||
/// <exception cref="ArgumentException"><paramref name="document"/> is not valid.</exception> | ||
/// <remarks>The parameters validated in the caller: <see cref="MarkSequencePoint"/>.</remarks> | ||
protected virtual void MarkSequencePointCore(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { } |
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.
I made it no-op in order to avoid breaking somebody that is not using/emitting PDB, but the more think about it is seems better to throw here so that people know that they are using an AssemblyBuilder
implementation that doesn't support symbols.
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/PersistedAssemblyBuilder.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
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.
LGTM!
/// <exception cref="ArgumentNullException"><paramref name="document"/> is <see langword="null"/>.</exception> | ||
/// <exception cref="ArgumentException"><paramref name="document"/> is not valid.</exception> | ||
/// <exception cref="ArgumentOutOfRangeException"> | ||
/// <paramref name="startLine"/> is not within range [0, 0x20000000) or |
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.
Where did these max values come from?
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.
From the runtime doc
runtime/docs/design/specs/PortablePdb-Metadata.md
Lines 124 to 133 in 617f81f
The values of non-hidden sequence point must satisfy the following constraints | |
* IL Offset is within range [0, 0x20000000) | |
* IL Offset of a sequence point is lesser than IL Offset of the subsequent sequence point. | |
* Start Line is within range [0, 0x20000000) and not equal to 0xfeefee. | |
* End Line is within range [0, 0x20000000) and not equal to 0xfeefee. | |
* Start Column is within range [0, 0x10000) | |
* End Column is within range [0, 0x10000) | |
* End Line is greater or equal to Start Line. | |
* If Start Line is equal to End Line then End Column is greater than Start Column. |
src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs
Show resolved
Hide resolved
parentImport = GetImportScopeHandle(scope._importNamespaces, parentImport); | ||
firstLocalVariableHandle = GetLocalVariableHandle(scope._locals, firstLocalVariableHandle); | ||
_pdbBuilder.AddLocalScope(methodHandle, parentImport, firstLocalVariableHandle, | ||
constantList: MetadataTokens.LocalConstantHandle(1), scope._startOffset, scope._endOffset - scope._startOffset); |
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.
Where is LocalConstantHandle(1) coming from?
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.
Line 1266 in 64a937c
/// If no scope defines any constants, <see cref="MetadataTokens.LocalConstantHandle(int)"/>(1). |
…tatrtLine/StartColumn
* Initial PDB API shape and sequence point implementation * Finish PDB implementation and testing * Fix bug in multi doc sequence point * Validate null name for SetLocalSymInfo, do not add locals that has no name to the locals table * Throw on parent virtual methods, remove unnecessary throw * Apply suggestions from code review Co-authored-by: Aaron Robinson <arobins@microsoft.com> * Apply feedback, fix issue found in sequence point PreviousNonHidden.StatrtLine/StartColumn --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Added new APIs needed for adding symbol info and implemented PDB metadata generation
MetadataReader
Approved API shape:
Contributes to #92975
Fixes #99935