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

Fix failure when crossgen (*.ni.pdbs) and portable pdbs exists in the debug directory #104

Merged
merged 3 commits into from
Dec 7, 2017

Conversation

mikem8361
Copy link
Member

Start with the last debug directory entry instead of the first.

Also bumped the System.Reflection.Metadata version to 1.5.0 to work properly when running under msbuild on desktop. Otherwise it doesn't work for the DotNet-SymStore repo uploader build task.

… debug directory

Start withe the last debug directory entry instead of the first.

Also bumped the System.Reflection.Metadata version to 1.5.0 to work properly when running under msbuild on desktop. Otherwise it doesn't work for the DotNet-SymStore repo uploader build task.
@@ -83,7 +83,7 @@ public static ImmutableArray<string> GetImportStrings(ISymUnmanagedReader reader

public static bool TryReadPdbId(PEReader peReader, out BlobContentId id, out int age)
{
var codeViewEntry = peReader.ReadDebugDirectory().FirstOrDefault(entry => entry.Type == DebugDirectoryEntryType.CodeView);
var codeViewEntry = peReader.ReadDebugDirectory().LastOrDefault(entry => entry.Type == DebugDirectoryEntryType.CodeView);
Copy link

Choose a reason for hiding this comment

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

Mike for completeness there is another place you should update from FirstOrDefault to LastOrDefault

There is similar logic in GetPdbPathFromCodeViewEntry in the Pdb2Pdb.cs file (used when infering the PDB file name from the DLL).

@mikem8361
Copy link
Member Author

mikem8361 commented Dec 6, 2017 via email

@vancem
Copy link

vancem commented Dec 6, 2017

Note that for others who may not be familiar with the semantics here. The DebugDirectory is a list of PDBs that are associated with the DLL (it is how you find the PDB on the symbol server). Most DLLs have only one entry, but .NET Native images have two (one for the IL code, one for the native code). All debugger to date always choose the LAST entry (which is the IL entry). This change is simply making the converter follow the same conventions as every other tool (if you only care about the IL PDB, choose the last entry, which will be the IL PDB).

@tmat
Copy link
Member

tmat commented Dec 6, 2017

Some feedback:

  1. Could you add a small ngen'd hello world dll to PdbTestResources and add write a unit test for TryReadPdbId that validates the right record is found?
  2. We should document what the semantics of multiple CodeView records is in a spec: https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PE-COFF.md
  3. I think we should disallow multiple portable CodeView records. Is there a way to distinguish record for native PDB vs. record for managed PDB in the native image? If we can I'd also disallow multiple managed PDB records (or perhaps even multiple native PDB records). If we don't disallow multiple portable records we would need to fix https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs#L693 to also pick the last one. This would also require update of .NET Framework, so I would rather not do that. There seems to be no point in allowing multiple portable records. If we decide to disallow some combination of CV records, the converter should validate it and report an error.
  4. I'd also like to follow up with an API in PEReader that finds the right record, so that we don't have the logic spread out everywhere.

@mikem8361
Copy link
Member Author

mikem8361 commented Dec 6, 2017 via email

@tmat
Copy link
Member

tmat commented Dec 6, 2017

Do you mean validate and fail in the converter code if there is more than one portable pdb entry?

Yes. The converter is also a verifier (think of PEVerify for PDBs). This doesn't need to be "fatal" error, we can go on and take the last entry, but it should report diagnostic that something's wrong with the PDB.

@mikem8361
Copy link
Member Author

mikem8361 commented Dec 6, 2017 via email

@tmat
Copy link
Member

tmat commented Dec 6, 2017

I really don’t have a lot of time to do all the things you want.

That's fine. We don't need to block this PR on them, other then adding the test. Let's file issues for them and address them later.

@mikem8361
Copy link
Member Author

mikem8361 commented Dec 7, 2017 via email

@tmat
Copy link
Member

tmat commented Dec 7, 2017

@mikem8361 You should not upload any nuget packages. They are produced and published by our Microbuild build definition.

@tmat
Copy link
Member

tmat commented Dec 7, 2017

👍

@tmat
Copy link
Member

tmat commented Dec 7, 2017

Thanks!

@mikem8361
Copy link
Member Author

@tmat can you merge this PR? I don't have write access.

@tmat tmat merged commit e8527fe into dotnet:master Dec 7, 2017
@tmat
Copy link
Member

tmat commented Dec 7, 2017

New official build will be published shortly on myget

@tmat
Copy link
Member

tmat commented Dec 7, 2017

Microsoft.DiaSymReader.Converter.1.1.0-beta1-62407-01.nupkg

@tmat
Copy link
Member

tmat commented Dec 8, 2017

Filed #105

@mikem8361 mikem8361 deleted the nipdbfix branch July 31, 2021 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants