dotnet / dotnet/linker

ILLinker fails to load portable pdb files for crossgen'd assemblies

Open
#1,620 3 comments 0 reactions 0 assignees View on GitHub
external
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

In order to debug a trimmed application, I need to give the untrimmed symbols to the ILLinker so it can update the symbols as necessary.

The symbols for `System.*` assemblies I get from the Microsoft Symbols Server when debugging an untrimmed application appear to be the portable pdb format. However, if I feed these symbols into the ILLinker when trimming an app, the ILLinker refuses to load the .pdb because of the following check:

https://github.com/mono/cecil/blob/8cf97c125748b0a2832f0420728c8fac2ae22348/Mono.Cecil.Cil/PortablePdb.cs#L86-L96

```C#
public bool ProcessDebugHeader (ImageDebugHeader header)
{
if (image == module.Image)
return true;

var entry = header.GetCodeViewEntry ();
if (entry == null)
return false;

var data = entry.Data;

if (data.Length < 24)
return false;

var magic = ReadInt32 (data, 0);
if (magic != 0x53445352)
return false;

var buffer = new byte [16];
Buffer.BlockCopy (data, 4, buffer, 0, 16);

var module_guid = new Guid (buffer);

Buffer.BlockCopy (image.PdbHeap.Id, 0, buffer, 0, 16);

var pdb_guid = new Guid (buffer);

if (module_guid != pdb_guid)
return false;
```

When debugging the ILLinker, `module_guid` and `pdb_guid` don't match, thus it returns `false`.

Building dotnet/runtime locally, I grabbed the crossgen'd .dll and the 2 pdb files (the `.ni.pdb` and portable `.pdb`) and tried each with the ILLinker. The ILLinker loaded the `.ni.pdb` file, but complained about the portable .pdb file.

@noahfalk @mikem8361 - is the above Cecil code for checking the image Guid's correct? Or does it need to be updated for crossgen'd assemblies? I know that Visual Studio can successfully load a portable .pdb with a crossgen'd binary. So I assume there is something wrong with the ILLinker in this case.

cc @vitek-karas

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.