Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,15 @@ private PdbSymbolReader OpenAssociatedSymbolFile(string peFilePath, PEReader peR
if (debugEntry.Type != DebugDirectoryEntryType.CodeView)
continue;

CodeViewDebugDirectoryData debugDirectoryData = peReader.ReadCodeViewDebugDirectoryData(debugEntry);
CodeViewDebugDirectoryData debugDirectoryData;
try
{
debugDirectoryData = peReader.ReadCodeViewDebugDirectoryData(debugEntry);
}
catch (BadImageFormatException)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

BadImageFormatException here refers to System.BadImageFormatException, but this file also deals with Internal.TypeSystem.TypeSystemException.BadImageFormatException (see TODO earlier). Qualifying the caught exception as System.BadImageFormatException would avoid ambiguity for future readers/maintainers.

Suggested change
catch (BadImageFormatException)
catch (System.BadImageFormatException)

Copilot uses AI. Check for mistakes.
{
continue;
}

string candidatePath = debugDirectoryData.Path;
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

There are two spaces before '=' in string candidatePath = ...; please remove the extra whitespace to match typical formatting in this file.

Suggested change
string candidatePath = debugDirectoryData.Path;
string candidatePath = debugDirectoryData.Path;

Copilot uses AI. Check for mistakes.
if (!Path.IsPathRooted(candidatePath) || !File.Exists(candidatePath))
Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/tools/dotnet-pgo/TraceTypeSystemContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,15 @@ private PdbSymbolReader OpenAssociatedSymbolFile(string peFilePath, PEReader peR
if (debugEntry.Type != DebugDirectoryEntryType.CodeView)
continue;

CodeViewDebugDirectoryData debugDirectoryData = peReader.ReadCodeViewDebugDirectoryData(debugEntry);
CodeViewDebugDirectoryData debugDirectoryData;
try
{
debugDirectoryData = peReader.ReadCodeViewDebugDirectoryData(debugEntry);
}
catch (BadImageFormatException)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

To make it explicit that this is handling malformed PE debug data from PEReader.ReadCodeViewDebugDirectoryData, consider qualifying the caught exception as System.BadImageFormatException (this codebase also has Internal.TypeSystem.TypeSystemException.BadImageFormatException, which can be easy to confuse with).

Suggested change
catch (BadImageFormatException)
catch (System.BadImageFormatException)

Copilot uses AI. Check for mistakes.
{
continue;
}

string candidatePath = debugDirectoryData.Path;
if (!Path.IsPathRooted(candidatePath) || !File.Exists(candidatePath))
Expand Down
Loading