private DasmResult RunDasmTool(List <string> commandArgs, List <AssemblyInfo> assemblyWorkList) { DasmResult result = new DasmResult(); DasmWorkTask[] taskArray = new DasmWorkTask[0]; try { StartDasmWorkBaseDiff(commandArgs, assemblyWorkList); taskArray = DasmWorkTasks.ToArray(); Task.WaitAll(taskArray); } catch (AggregateException ex) { Console.Error.WriteLine("Dasm task failed with {0}", ex.Message); result.CaughtException = true; } foreach (var t in taskArray) { if (t.Result.kind == DasmWorkKind.Base) { result.BaseErrors += t.Result.errorCount; } else { result.DiffErrors += t.Result.errorCount; } } if (!result.Success) { Console.Error.WriteLine("Dasm commands returned {0} base failures, {1} diff failures{2}.", result.BaseErrors, result.DiffErrors, (result.CaughtException ? ", exception occurred" : "")); } return(result); }
// Returns 0 on success, 1 on failure. public static int DiffCommand(Config config) { DiffTool diffTool = NewDiffTool(config); string diffString = $"{diffTool.Name} Diffs for "; bool needPrefix = false; if (config.CoreLib) { diffString += "System.Private.CoreLib.dll"; needPrefix = true; } else if (config.DoFrameworks) { diffString += "System.Private.CoreLib.dll, framework assemblies"; needPrefix = true; } if (config.Benchmarks) { if (needPrefix) { diffString += ", "; } diffString += "benchstones and benchmarks game in " + config.TestRoot; needPrefix = true; } else if (config.DoTestTree) { if (needPrefix) { diffString += ", "; } diffString += "assemblies in " + config.TestRoot; needPrefix = true; } if (config.AssemblyName != null) { if (needPrefix) { diffString += ", "; } diffString += Path.GetFileName(config.AssemblyName); } Console.WriteLine($"Beginning {diffString}"); // Create subjob that runs jit-dasm or jit-dasm-pmi (which should be in path) // with the relevent coreclr assemblies/paths. List <string> commandArgs = new List <string>(); commandArgs.Add("--platform"); commandArgs.Add(config.CoreRoot); if (config.GenerateGCInfo) { commandArgs.Add("--gcinfo"); } if (config.GenerateDebugInfo) { commandArgs.Add("--debuginfo"); } if (config.Verbose) { commandArgs.Add("--verbose"); } if (config.AltJit != null) { commandArgs.Add("--altjit"); commandArgs.Add(config.AltJit); } DateTime startTime = DateTime.Now; List <AssemblyInfo> assemblyWorkList = GenerateAssemblyWorklist(config); DasmResult dasmResult = diffTool.RunDasmTool(commandArgs, assemblyWorkList); Console.WriteLine($"Completed {diffString} in {(DateTime.Now - startTime).TotalSeconds:F2}s"); Console.WriteLine($"Diffs (if any) can be viewed by comparing: {Path.Combine(config.OutputPath, "base")} {Path.Combine(config.OutputPath, "diff")}"); // Analyze completed run. if (config.DoAnalyze && config.DoDiffCompiles && config.DoBaseCompiles) { List <string> analysisArgs = new List <string>(); analysisArgs.Add("--base"); analysisArgs.Add(Path.Combine(config.OutputPath, "base")); analysisArgs.Add("--diff"); analysisArgs.Add(Path.Combine(config.OutputPath, "diff")); analysisArgs.Add("--recursive"); analysisArgs.Add("--note"); string jitName = config.AltJit ?? "default jit"; analysisArgs.Add($"{diffString} for {config.Arch} {jitName}"); if (config.tsv) { analysisArgs.Add("--tsv"); analysisArgs.Add(Path.Combine(config.OutputPath, "diffs.tsv")); } if (config.Verbose) { Console.WriteLine("Analyze command: {0} {1}", s_analysisTool, String.Join(" ", analysisArgs)); } Console.WriteLine("Analyzing diffs..."); startTime = DateTime.Now; CommandResult analyzeResult = Utility.TryCommand(s_analysisTool, analysisArgs); Console.WriteLine($"Completed analysis in {(DateTime.Now - startTime).TotalSeconds:F2}s"); } // Report any failures to generate asm at the very end (again). This is so // this information doesn't get buried in previous output. if (!dasmResult.Success) { Console.Error.WriteLine(""); Console.Error.WriteLine("Warning: Failures detected generating asm: {0} base, {1} diff{2}", dasmResult.BaseErrors, dasmResult.DiffErrors, (dasmResult.CaughtException ? ", exception occurred" : "")); return(1); // failure result } else { return(0); // success result } }
// Returns 0 on success, 1 on failure. public static int DiffCommand(Config config) { string diffString = ""; if (config.CoreLib) { diffString += "System.Private.CoreLib.dll"; } else if (config.DoFrameworks) { diffString += "System.Private.CoreLib.dll, framework assemblies"; } if (config.Benchmarks) { if (!String.IsNullOrEmpty(diffString)) { diffString += ", "; } diffString += "benchstones and benchmarks game in " + config.TestRoot; } else if (config.DoTestTree) { if (!String.IsNullOrEmpty(diffString)) { diffString += ", "; } diffString += "assemblies in " + config.TestRoot; } Console.WriteLine("Beginning diff of {0}", diffString); // Create subjob that runs jit-dasm, which should be in path, with the // relevent coreclr assemblies/paths. List <string> commandArgs = new List <string>(); commandArgs.Add("--platform"); commandArgs.Add(config.CoreRoot); if (config.GenerateGCInfo) { commandArgs.Add("--gcinfo"); } if (config.Verbose) { commandArgs.Add("--verbose"); } if (config.AltJit != null) { commandArgs.Add("--altjit"); commandArgs.Add(config.AltJit); } List <AssemblyInfo> assemblyWorkList = GenerateAssemblyWorklist(config); DiffTool diffTool = new DiffTool(config); DasmResult dasmResult = diffTool.RunDasmTool(commandArgs, assemblyWorkList); // Analyze completed run. if (config.DoAnalyze && config.DoDiffCompiles && config.DoBaseCompiles) { List <string> analysisArgs = new List <string>(); analysisArgs.Add("--base"); analysisArgs.Add(Path.Combine(config.OutputPath, "base")); analysisArgs.Add("--diff"); analysisArgs.Add(Path.Combine(config.OutputPath, "diff")); analysisArgs.Add("--recursive"); Console.WriteLine("Analyze command: {0} {1}", s_analysisTool, String.Join(" ", analysisArgs)); CommandResult analyzeResult = Utility.TryCommand(s_analysisTool, analysisArgs); } // Report any failures to generate asm at the very end (again). This is so // this information doesn't get buried in previous output. if (!dasmResult.Success) { Console.Error.WriteLine(""); Console.Error.WriteLine("Warning: Failures detected generating asm: {0} base, {1} diff{2}", dasmResult.BaseErrors, dasmResult.DiffErrors, (dasmResult.CaughtException ? ", exception occurred" : "")); return(1); // failure result } else { return(0); // success result } }