-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Include source files w/o method bodies in the PDB documents #39136
Conversation
@@ -104,6 +104,7 @@ internal static class PeWriter | |||
} | |||
|
|||
nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments); | |||
nativePdbWriterOpt.WriteRemainingDebugDocuments(mdWriter.Module.DebugDocumentsBuilder.GetAllDebugDocuments()); |
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.
Nit: this boxes the ImmutableArray<T>
into IEnumerable<T>
. Given both these APIs are new consider changing the type of one to avoid the box. #Resolved
@@ -768,6 +768,21 @@ public void AddRemainingEmbeddedDocuments(IEnumerable<DebugSourceDocument> docum | |||
} | |||
} | |||
|
|||
/// <summary> | |||
/// Add document entries for all debug documents that does not yet have an entry. |
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.
does [](start = 62, length = 4)
typo: do
#Resolved
@tmat PDB tests have been fixed. |
{ | ||
GetOrAddDocument(document, _documentIndex); | ||
} | ||
} |
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.
Why do we need two methods? They seem to be doing the same thing. #Resolved
@@ -47,6 +47,9 @@ internal void AddDebugDocument(Cci.DebugSourceDocument document) | |||
_debugDocuments.Add(document.Location, document); | |||
} | |||
|
|||
internal ImmutableArray<Cci.DebugSourceDocument> GetAllDebugDocuments() | |||
=> _debugDocuments.Values.ToImmutableArray(); |
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.
_debugDocuments.Values.ToImmutableArray(); [](start = 15, length = 42)
This will result in non-deterministic PDB. We need to order the documents somehow. #Resolved
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.
We could also optimize this to avoid allocations and extra work. Return IReadOnlyDictionary from this method. Enumerate the dictionary in AddRemainingDebugDocuments to filter out documents that are already indexed. Sort the remaining and add them.
In reply to: 333275492 [](ancestors = 333275492)
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.
Sounds good. I just think that filtering is not necessary because we add only item not yet added.
In reply to: 333278515 [](ancestors = 333278515,333275492)
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.
The filtering is an optimization, so that we don't need to sort all the documents upfront just to realize we only need to add a few. #Resolved
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.
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.
@@ -104,6 +104,7 @@ internal static class PeWriter | |||
} | |||
|
|||
nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments); |
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.
WriteRemainingEmbeddedDocuments [](start = 35, length = 31)
I don't think this is necessary anymore - embedded sources are added to the set of all debug documents on the document builder in CreateDebugDocuments
. If we make sure we add an entry for each document then it follows that all embedded documents will also be added.
Also, once we remove this call we can remove EmbeddedDocuments
array from DebugDocumentsBuilder
. #Resolved
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.
🕐
{ | ||
Debug.Assert(document.GetSourceInfo().EmbeddedTextBlob != null); | ||
GetOrAddDocument(document, _documentIndex); | ||
GetOrAddDocument(kvp.Value, _documentIndex); |
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.
GetOrAddDocument [](start = 16, length = 16)
Nit: we could factor out AddDocument
method - here we don't need to check again that the document is in the index. #Resolved
@@ -11037,5 +11039,76 @@ public void InvalidCharacterInPdbPath() | |||
Diagnostic(ErrorCode.FTL_InvalidInputFileName).WithArguments("test\\?.pdb").WithLocation(1, 1)); | |||
} | |||
} | |||
|
|||
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] |
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.
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] [](start = 8, length = 102)
Is there a reason to limit the test to Win desktop? This should work on all platforms. #Resolved
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.
@tmat , neighbor tests apply these restrictions. And in the previous iteration, those tests failed in Linux and Mac only: https://dev.azure.com/dnceng/public/_build/results?buildId=383581&view=ms.vss-test-web.build-test-results-tab #Resolved
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.
The C# ones did not fail. The VB ones failed because VB PDB tests don't normalize line endings yet (WithWindowsLineBreaks
). #Resolved
"); | ||
} | ||
|
||
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] |
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.
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] [](start = 8, length = 102)
The same here. #Resolved
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.
Please mark that test as skipped for now and file an issue to follow up. |
@@ -972,7 +972,7 @@ public async Task BreakMode_RudeEdits_DocumentOutOfSync() | |||
}, _telemetryLog); | |||
} | |||
|
|||
[Fact] | |||
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/39271")] |
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.
Is this just because the test was implicitly assuming the old behavior and we need some new way to write the test? (The filed bug doesn't make it clear if we understand the issue here.)
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.
foreach (var document in embeddedDocuments) | ||
foreach (var kvp in documents | ||
.Where(kvp => !_documentIndex.ContainsKey(kvp.Value)) | ||
.OrderBy(kvp => kvp.Key)) |
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.
OrderBy [](start = 17, length = 7)
I didn't understand why we need ordering. There are other methods that invoke AddDocumentIndex
and don't seem to do so in any particular order (namely GetDocumentIndex
).
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.
This is to resolve #39136 (comment)
I think there is some kind of ordering in documents for ones having sequence points likely governed by sequence points ordering. And we want to have some consistence for the order of documents without sequence points. Let them be ordered by file names. @tmat may want to comment more.
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.
Any time we produce output based on dictionary enumeration we need to order the results in order to achieve determinism.
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.
Makes sense. Thanks
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 Thanks (iteration 9)
Fixes #38954
Currently the compiler does not list source files in the debug documents in the PDB that are part of the compilation but do not have any method body. These documents are only added in order to support sequence points.