Skip to content

Commit

Permalink
Fix pgo ci bugs (#49349)
Browse files Browse the repository at this point in the history
* Fix null reference in pgo data merging

* Additional fixes found in CI usage of dotnet-pgo tool
  • Loading branch information
davidwrighton authored Mar 9, 2021
1 parent 4f67869 commit 0c20962
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/coreclr/tools/Common/CommandLine/ArgumentSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,24 @@ public IEnumerable<Argument> GetActiveParameters()
return GetParameters(ActiveCommand);
}

private static int ConsoleWindowWidth()
{
// Console.WindowWidth will throw an exception if the output is redirected in some cases
// This try/catch routine is probably excessive, but it will definitely cover all the cases
try
{
if (!Console.IsOutputRedirected)
return Console.WindowWidth;
}
catch
{
}
return 100;
}

public string GetHelpText()
{
return GetHelpText(Console.WindowWidth - 2);
return GetHelpText(ConsoleWindowWidth() - 2);
}

public string GetHelpText(int maxWidth)
Expand Down
16 changes: 15 additions & 1 deletion src/coreclr/tools/dotnet-pgo/TraceTypeSystemContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ class TraceTypeSystemContext : MetadataTypeSystemContext, IMetadataStringDecoder
private readonly ModuleLoadLogger _moduleLoadLogger;
private int _clrInstanceID;

private readonly Dictionary<string,string> _normalizedFilePathToFilePath = new Dictionary<string,string> (StringComparer.OrdinalIgnoreCase);

public TraceTypeSystemContext(PgoTraceProcess traceProcess, int clrInstanceID, Logger logger)
{
foreach (var traceData in traceProcess.TraceProcess.EventsInProcess.ByEventType<ModuleLoadUnloadTraceData>())
{
if (traceData.ModuleILPath != null)
{
_normalizedFilePathToFilePath[traceData.ModuleILPath] = traceData.ModuleILPath;
}
}

_pgoTraceProcess = traceProcess;
_clrInstanceID = clrInstanceID;
_moduleLoadLogger = new ModuleLoadLogger(logger);
Expand Down Expand Up @@ -132,7 +142,11 @@ public ModuleDesc GetModuleForSimpleName(string simpleName, bool throwIfNotFound

if (PgoTraceProcess.CompareModuleAgainstSimpleName(simpleName, managedModule))
{
filePath = PgoTraceProcess.ComputeFilePathOnDiskForModule(managedModule);
string filePathTemp = PgoTraceProcess.ComputeFilePathOnDiskForModule(managedModule);

// This path may be normalized
if (File.Exists(filePathTemp) || !_normalizedFilePathToFilePath.TryGetValue(filePathTemp, out filePath))
filePath = filePathTemp;
break;
}
}
Expand Down

0 comments on commit 0c20962

Please sign in to comment.