Skip to content

Commit ffa46a1

Browse files
brianrobCopilot
andauthored
Fix PDB Symbol Resolution for Unmerged Windows Traces (#2407)
* Fix PDB symbol resolution for unmerged Windows traces The ELF symbol work introduced a switch on BinaryFormat in LookupSymbolsForModule that only handled PE and ELF cases. For unmerged Windows traces, symbolInfo is null (no RSDS events in the ETL), so BinaryFormat returns Unspecified, causing symbol resolution to be skipped entirely. Add a case for ModuleBinaryFormat.Unspecified that falls back to PDB lookup on Windows. OpenPdbForModuleFile handles missing PDB signatures gracefully by checking the local file on disk. Also rename ModuleBinaryFormat.Unknown to Unspecified to better reflect that the format was not specified in the trace data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Bump version to 3.2.2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 543e9e9 commit ffa46a1

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<PropertyGroup>
2121
<!-- These are the versions of the things we are CREATING in this repository -->
22-
<ReleaseVersion>3.2.1</ReleaseVersion>
22+
<ReleaseVersion>3.2.2</ReleaseVersion>
2323
<FastSerializationVersion>$(ReleaseVersion)</FastSerializationVersion>
2424
<HeapDumpDllVersion>$(ReleaseVersion)</HeapDumpDllVersion>
2525
<MemoryGraphVersion>$(ReleaseVersion)</MemoryGraphVersion>

src/TraceEvent/TraceLog.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8970,10 +8970,34 @@ private void LookupSymbolsForModule(SymbolReader reader, TraceModuleFile moduleF
89708970
}
89718971
break;
89728972

8973+
case ModuleBinaryFormat.Unspecified:
8974+
{
8975+
// For unmerged Windows traces, symbolInfo is null because the ETL
8976+
// didn't contain RSDS events with PDB identity info.
8977+
// Fall back to PDB lookup on Windows, which handles missing signatures
8978+
// gracefully and returns null if the file isn't a PE binary.
8979+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
8980+
{
8981+
reader.m_log.WriteLine("LookupSymbolsForModule: Binary format unspecified for {0}, looking up PDB info from local file.", moduleFile.FilePath);
8982+
NativeSymbolModule moduleReader = OpenPdbForModuleFile(reader, moduleFile) as NativeSymbolModule;
8983+
if (moduleReader != null)
8984+
{
8985+
symbolLookup = moduleReader;
8986+
}
8987+
// Standard PE RVA computation.
8988+
computeRva = (address) => (uint)(address - moduleFile.ImageBase);
8989+
}
8990+
else
8991+
{
8992+
reader.m_log.WriteLine("LookupSymbolsForModule: Binary format unspecified for {0}, skipping.", moduleFile.FilePath);
8993+
}
8994+
}
8995+
break;
8996+
89738997
default:
89748998
{
8975-
Debug.Assert(false, "LookupSymbolsForModule: unknown binary format " + moduleFile.BinaryFormat);
8976-
reader.m_log.WriteLine("LookupSymbolsForModule: Unknown binary format {0} for {1}, skipping.", moduleFile.BinaryFormat, moduleFile.FilePath);
8999+
Debug.Assert(false, "LookupSymbolsForModule: unrecognized binary format " + moduleFile.BinaryFormat);
9000+
reader.m_log.WriteLine("LookupSymbolsForModule: Unrecognized binary format {0} for {1}, skipping.", moduleFile.BinaryFormat, moduleFile.FilePath);
89779001
}
89789002
break;
89799003
}
@@ -10568,7 +10592,7 @@ public string Name
1056810592
/// <summary>
1056910593
/// The binary format of this module file (PE, ELF, or Unknown).
1057010594
/// </summary>
10571-
public ModuleBinaryFormat BinaryFormat { get { return symbolInfo?.Format ?? ModuleBinaryFormat.Unknown; } }
10595+
public ModuleBinaryFormat BinaryFormat { get { return symbolInfo?.Format ?? ModuleBinaryFormat.Unspecified; } }
1057210596

1057310597
/// <summary>
1057410598
/// PE-specific symbol info (PDB identity + R2R). Null if this is not a PE module.
@@ -10780,7 +10804,7 @@ void IFastSerializable.ToStream(Serializer serializer)
1078010804
serializer.WriteAddress(imageBase);
1078110805

1078210806
// Write symbol info with format discriminator
10783-
byte format = (byte)(symbolInfo?.Format ?? ModuleBinaryFormat.Unknown);
10807+
byte format = (byte)(symbolInfo?.Format ?? ModuleBinaryFormat.Unspecified);
1078410808
serializer.Write(format);
1078510809
if (symbolInfo != null)
1078610810
{
@@ -10836,8 +10860,8 @@ void IFastSerializable.FromStream(Deserializer deserializer)
1083610860
/// </summary>
1083710861
public enum ModuleBinaryFormat : byte
1083810862
{
10839-
/// <summary>The module format is unknown.</summary>
10840-
Unknown = 0,
10863+
/// <summary>The module format was not specified in the trace.</summary>
10864+
Unspecified = 0,
1084110865
/// <summary>Windows Portable Executable format.</summary>
1084210866
PE = 1,
1084310867
/// <summary>Linux ELF (Executable and Linkable Format).</summary>

0 commit comments

Comments
 (0)