Skip to content

Commit

Permalink
Log the environment variables and failures that occur as part of DRIV…
Browse files Browse the repository at this point in the history
…EALL (#325)

* Log the environment variables that are set in DRIVEALL

* Print the method and type # on failure
  • Loading branch information
tannergooding authored Apr 28, 2021
1 parent 464a4c1 commit 3c7bb1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/pmi/PMIDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ private static PrepAllResult Compute(PrepAllInfo pi)

Console.WriteLine($"DRIVEALL: Invoking {driverName} {newCommandLine}");

foreach (var pair in pi.environment)
{
Console.WriteLine($" {pair.Key}={pair.Value}");
}

p.Start();
p.BeginErrorReadLine();
szOutput = p.StandardOutput.ReadToEnd();
Expand Down
20 changes: 12 additions & 8 deletions src/pmi/pmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,18 @@ public override void StartMethod(Type type, MethodBase method)

public abstract void AttemptMethod(Type type, MethodBase method);

protected TimeSpan PrepareMethod(Type type, MethodBase method)
protected bool TryPrepareMethod(Type type, MethodBase method, out TimeSpan elapsedFunc)
{
TimeSpan elapsedFunc = TimeSpan.MinValue;
bool success = false;
elapsedFunc = TimeSpan.MinValue;

try
{
DateTime startFunc = DateTime.Now;
GC.WaitForPendingFinalizers();
System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(method.MethodHandle);
elapsedFunc = DateTime.Now - startFunc;
success = true;
}
catch (System.EntryPointNotFoundException)
{
Expand Down Expand Up @@ -512,7 +514,7 @@ protected TimeSpan PrepareMethod(Type type, MethodBase method)
Console.WriteLine(e);
}

return elapsedFunc;
return success;
}

protected string GetGenericArgumentsString(MethodBase method)
Expand Down Expand Up @@ -603,11 +605,11 @@ public override void AttemptMethod(Type type, MethodBase method)
Console.WriteLine($"PREPALL type# {typeCount} method# {methodCount} {type.FullName}::{method.Name}{genericArgString}");
}

TimeSpan elapsedFunc = PrepareMethod(type, method);
var succeeded = TryPrepareMethod(type, method, out TimeSpan elapsedFunc);

if (_verbose)
if (_verbose || !succeeded)
{
Console.Write($"Completed method {type.FullName}::{method.Name}{genericArgString}");
Console.Write($"{(succeeded ? "Completed" : "Failed")} type# {typeCount} method# {methodCount} {type.FullName}::{method.Name}{genericArgString}");
if (elapsedFunc != TimeSpan.MinValue)
{
Console.WriteLine($", elapsed ms: {elapsedFunc.TotalMilliseconds:F2}");
Expand Down Expand Up @@ -671,8 +673,10 @@ public override void AttemptMethod(Type type, MethodBase method)
{
string genericArgString = GetGenericArgumentsString(method);
Console.WriteLine($"PREPONE type# {typeCount} method# {methodCount} {type.FullName}::{method.Name}{genericArgString}");
TimeSpan elapsedFunc = PrepareMethod(type, method);
Console.Write($"Completed method {type.FullName}::{method.Name}{genericArgString}");

var succeeded = TryPrepareMethod(type, method, out TimeSpan elapsedFunc);
Console.Write($"{(succeeded ? "Completed" : "Failed")} type# {typeCount} method# {methodCount} {type.FullName}::{method.Name}{genericArgString}");

if (elapsedFunc != TimeSpan.MinValue)
{
Console.WriteLine($", elapsed ms: {elapsedFunc.TotalMilliseconds:F2}");
Expand Down

0 comments on commit 3c7bb1c

Please sign in to comment.