Repository navigation
[cDAC] Update DebugInfo contract for new format #121418
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f4c1566
remove patchpoint datadescriptors
max-charlamb 897a891
add docs
max-charlamb e632409
update DebugInfo
max-charlamb 1b06041
update for sourcetype change
max-charlamb 97ec3ae
nit
max-charlamb a85baf7
add const for source type bits
max-charlamb 35a3c6e
update
max-charlamb 1a610a9
rename
max-charlamb 9232b63
update to share code
max-charlamb 4d241fd
update docs
max-charlamb 3fd049c
reformat slightly
max-charlamb 722b5ff
Merge branch 'main' into cdac-debuginfo-2
max-charlamb 636fcce
Merge branch 'main' into cdac-debuginfo-2
max-charlamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...icrosoft.Diagnostics.DataContractReader.Contracts/Contracts/DebugInfo/DebugInfoHelpers.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using ILCompiler.Reflection.ReadyToRun; | ||
|
|
||
| namespace Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
|
||
| /// <summary> | ||
| /// Shared bounds decoding helpers for DebugInfo contract versions. | ||
| /// V1: 2-bit enumerated source type. | ||
| /// V2: 3-bit flags (CallInstruction, StackEmpty, Async). | ||
| /// </summary> | ||
| internal static class DebugInfoHelpers | ||
| { | ||
| private const uint IL_OFFSET_BIAS = unchecked((uint)-3); | ||
| private const uint SOURCE_TYPE_BITS_V1 = 2; | ||
| private const uint SOURCE_TYPE_BITS_V2 = 3; | ||
|
|
||
|
|
||
| internal static IEnumerable<OffsetMapping> DoBounds(NativeReader nativeReader, uint version) | ||
| { | ||
| NibbleReader reader = new(nativeReader, 0); | ||
|
|
||
| uint boundsEntryCount = reader.ReadUInt(); | ||
| Debug.Assert(boundsEntryCount > 0, "Expected at least one entry in bounds."); | ||
|
|
||
| uint bitsForNativeDelta = reader.ReadUInt() + 1; // Number of bits needed for native deltas | ||
| uint bitsForILOffsets = reader.ReadUInt() + 1; // Number of bits needed for IL offsets | ||
|
|
||
| uint sourceTypeBitCount = (version == 1) ? SOURCE_TYPE_BITS_V1 : SOURCE_TYPE_BITS_V2; | ||
| uint bitsPerEntry = bitsForNativeDelta + bitsForILOffsets + sourceTypeBitCount; | ||
| ulong bitsMeaningfulMask = (1UL << ((int)bitsPerEntry)) - 1; | ||
| int offsetOfActualBoundsData = reader.GetNextByteOffset(); | ||
|
|
||
| uint bitsCollected = 0; | ||
| ulong bitTemp = 0; | ||
| uint curBoundsProcessed = 0; | ||
|
|
||
| uint previousNativeOffset = 0; | ||
|
|
||
| while (curBoundsProcessed < boundsEntryCount) | ||
| { | ||
| bitTemp |= ((uint)nativeReader[offsetOfActualBoundsData++]) << (int)bitsCollected; | ||
| bitsCollected += 8; | ||
| while (bitsCollected >= bitsPerEntry) | ||
| { | ||
| ulong mappingDataEncoded = bitsMeaningfulMask & bitTemp; | ||
| bitTemp >>= (int)bitsPerEntry; | ||
| bitsCollected -= bitsPerEntry; | ||
|
|
||
| ulong sourceTypeBitsMask = (1UL << ((int)sourceTypeBitCount)) - 1; | ||
| ulong sourceTypeBits = mappingDataEncoded & sourceTypeBitsMask; | ||
| SourceTypes sourceType = 0; | ||
| if ((sourceTypeBits & 0x1) != 0) sourceType |= SourceTypes.CallInstruction; | ||
| if ((sourceTypeBits & 0x2) != 0) sourceType |= SourceTypes.StackEmpty; | ||
| if ((sourceTypeBits & 0x4) != 0) sourceType |= SourceTypes.Async; | ||
|
|
||
| mappingDataEncoded >>= (int)sourceTypeBitCount; | ||
| uint nativeOffsetDelta = (uint)(mappingDataEncoded & ((1UL << (int)bitsForNativeDelta) - 1)); | ||
| previousNativeOffset += nativeOffsetDelta; | ||
| uint nativeOffset = previousNativeOffset; | ||
|
|
||
| mappingDataEncoded >>= (int)bitsForNativeDelta; | ||
| uint ilOffset = (uint)mappingDataEncoded + IL_OFFSET_BIAS; | ||
|
|
||
| yield return new OffsetMapping() | ||
| { | ||
| NativeOffset = nativeOffset, | ||
| ILOffset = ilOffset, | ||
| SourceType = sourceType | ||
| }; | ||
| curBoundsProcessed++; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.