Skip to content

Commit

Permalink
Log message when binary log is used
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Jun 5, 2024
1 parent 6268963 commit 6d2e2e3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ public static ILogger MakeLogger(Verbosity verbosity, bool includeConsole)
public static ExitCode Run(string[] args)
{
var options = Options.CreateWithEnvironment(args);
using var logger = MakeLogger(options.Verbosity, options.Console);
if (options.BinaryLogPath is string binlogPath)
{
logger.LogInfo($"Reading compiler calls from binary log {binlogPath}");
using var fileStream = new FileStream(binlogPath, FileMode.Open, FileAccess.Read, FileShare.Read);

// Filter out compiler calls that aren't interesting for examination
Expand All @@ -121,11 +123,13 @@ public static ExitCode Run(string[] args)
var exitCode = ExitCode.Ok;
foreach (var compilerCall in compilerCalls)
{
Console.WriteLine($"Processing {compilerCall.GetDiagnosticName()}");
var diagnosticName = compilerCall.GetDiagnosticName();
Console.WriteLine($"Processing {diagnosticName}");
var compilerCallOptions = Options.CreateWithEnvironment([]);
compilerCallOptions.CompilerName = compilerCall.CompilerFilePath;
compilerCallOptions.CompilerArguments.AddRange(compilerCall.GetArguments());
var ec = Run(compilerCallOptions);
logger.LogInfo($"Running extractor on arguments from binary log. Processing {diagnosticName}.");
var ec = Run(compilerCallOptions, logger);
if (ec != ExitCode.Ok)
{
exitCode = ec;
Expand All @@ -136,19 +140,17 @@ public static ExitCode Run(string[] args)
}
else
{
return Run(options);
return Run(options, logger);
}
}

public static ExitCode Run(Options options)
public static ExitCode Run(Options options, ILogger logger)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var workingDirectory = Directory.GetCurrentDirectory();
var compilerArgs = options.CompilerArguments.ToArray();

using var logger = MakeLogger(options.Verbosity, options.Console);

var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
var pathTransformer = new PathTransformer(canonicalPathCache);

Expand Down

0 comments on commit 6d2e2e3

Please sign in to comment.