Skip to content
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

Merged
merged 9 commits into from
Oct 14, 2019

Conversation

ivanbasov
Copy link
Contributor

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.

@ivanbasov ivanbasov requested review from tmat, jcouv and a team October 8, 2019 22:03
@@ -104,6 +104,7 @@ internal static class PeWriter
}

nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments);
nativePdbWriterOpt.WriteRemainingDebugDocuments(mdWriter.Module.DebugDocumentsBuilder.GetAllDebugDocuments());
Copy link
Member

@jaredpar jaredpar Oct 8, 2019

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.
Copy link
Member

@tmat tmat Oct 9, 2019

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

@ivanbasov
Copy link
Contributor Author

ivanbasov commented Oct 9, 2019

@tmat PDB tests have been fixed.
BreakMode_RudeEdits_DocumentWithoutSequencePoints is still broken. Either the test should be corrected, or maybe CommitedSolution.cs should be updated as well. #Resolved

{
GetOrAddDocument(document, _documentIndex);
}
}
Copy link
Member

@tmat tmat Oct 9, 2019

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

@tmat
Copy link
Member

tmat commented Oct 9, 2019

        set { Debug.Assert(value != null); _embeddedDocuments = value; }

This Assert is always true. #Resolved


Refers to: src/Compilers/Core/Portable/Emit/DebugDocumentsBuilder.cs:40 in d26e2ef. [](commit_id = d26e2ef, deletion_comment = False)

@@ -47,6 +47,9 @@ internal void AddDebugDocument(Cci.DebugSourceDocument document)
_debugDocuments.Add(document.Location, document);
}

internal ImmutableArray<Cci.DebugSourceDocument> GetAllDebugDocuments()
=> _debugDocuments.Values.ToImmutableArray();
Copy link
Member

@tmat tmat Oct 9, 2019

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

Copy link
Member

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)

Copy link
Contributor Author

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)

Copy link
Member

@tmat tmat Oct 10, 2019

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me try


In reply to: 333303087 [](ancestors = 333303087)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, @tmat! Updated.


In reply to: 333303897 [](ancestors = 333303897,333303087)

@@ -104,6 +104,7 @@ internal static class PeWriter
}

nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments);
Copy link
Member

@tmat tmat Oct 9, 2019

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

Copy link
Member

@tmat tmat left a 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);
Copy link
Member

@tmat tmat Oct 10, 2019

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)]
Copy link
Member

@tmat tmat Oct 10, 2019

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

Copy link
Contributor Author

@ivanbasov ivanbasov Oct 10, 2019

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

Copy link
Member

@tmat tmat Oct 10, 2019

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)]
Copy link
Member

@tmat tmat Oct 10, 2019

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

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

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

:shipit:

@tmat
Copy link
Member

tmat commented Oct 11, 2019

BreakMode_RudeEdits_DocumentWithoutSequencePoints is still broken.

Please mark that test as skipped for now and file an issue to follow up.

@ivanbasov ivanbasov requested a review from a team as a code owner October 14, 2019 18:44
@@ -972,7 +972,7 @@ public async Task BreakMode_RudeEdits_DocumentOutOfSync()
}, _telemetryLog);
}

[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/39271")]
Copy link
Member

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was introduced recently #38905 with a workaround for the particular issue. The current PR is a step toward a regular solution but it requires more changes in CommitedSolution.cs started at #38905.

@ivanbasov ivanbasov merged commit fce41a7 into dotnet:master Oct 14, 2019
@ivanbasov ivanbasov deleted the PDB branch October 14, 2019 20:17
@jcouv jcouv self-assigned this Oct 14, 2019
@jcouv jcouv added this to the 16.4.P3 milestone Oct 14, 2019
foreach (var document in embeddedDocuments)
foreach (var kvp in documents
.Where(kvp => !_documentIndex.ContainsKey(kvp.Value))
.OrderBy(kvp => kvp.Key))
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Thanks

Copy link
Member

@jcouv jcouv left a 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)

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.

Include source files w/o method bodies in the PDB documents
5 participants