/// <inheritdoc/> public void StartTriggerBasedProcessDump(int processId, string dumpFileGuid, string testResultsDirectory, bool isFullDump = false) { this.dumpFileName = $"{this.processHelper.GetProcessName(processId)}_{processId}_{dumpFileGuid}"; this.testResultsDirectory = testResultsDirectory; string procDumpArgs = new ProcDumpArgsBuilder().BuildTriggerBasedProcDumpArgs( processId, this.dumpFileName, ProcDumpExceptionsList, isFullDump); if (EqtTrace.IsInfoEnabled) { EqtTrace.Info($"ProcessDumpUtility : The proc dump argument is {procDumpArgs}"); } this.procDumpProcess = this.processHelper.LaunchProcess( this.GetProcDumpExecutable(processId), procDumpArgs, testResultsDirectory, null, null, null, this.OutputReceivedCallback) as Process; }
/// <inheritdoc/> public void AttachToTargetProcess(int processId, string outputDirectory, DumpTypeOption dumpType, bool collectAlways) { var process = Process.GetProcessById(processId); var outputFile = Path.Combine(outputDirectory, $"{process.ProcessName}_{process.Id}_{DateTime.Now:yyyyMMddTHHmmss}_crashdump.dmp"); EqtTrace.Info($"ProcDumpCrashDumper.AttachToTargetProcess: Attaching to process '{processId}' to dump into '{outputFile}'."); // Procdump will append .dmp at the end of the dump file. We generate this internally so it is rather a safety check. if (!outputFile.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } if (!this.TryGetProcDumpExecutable(processId, out var procDumpPath)) { var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; ConsoleOutput.Instance.Warning(false, err); EqtTrace.Error($"ProcDumpCrashDumper.AttachToTargetProcess: {err}"); return; } this.tempDirectory = Path.GetDirectoryName(outputFile); this.dumpFileName = Path.GetFileNameWithoutExtension(outputFile); string procDumpArgs = new ProcDumpArgsBuilder().BuildTriggerBasedProcDumpArgs( processId, this.dumpFileName, ProcDumpExceptionsList, isFullDump: dumpType == DumpTypeOption.Full, collectAlways: collectAlways); EqtTrace.Info($"ProcDumpCrashDumper.AttachToTargetProcess: Running ProcDump with arguments: '{procDumpArgs}'."); this.procDumpProcess = this.processHelper.LaunchProcess( procDumpPath, procDumpArgs, this.tempDirectory, null, null, null, this.OutputReceivedCallback) as Process; EqtTrace.Info($"ProcDumpCrashDumper.AttachToTargetProcess: ProcDump started as process with id '{this.procDumpProcess.Id}'."); }
/// <inheritdoc/> public void StartHangBasedProcessDump(int processId, string dumpFileGuid, string testResultsDirectory, bool isFullDump = false) { this.dumpFileName = $"{this.processHelper.GetProcessName(processId)}_{processId}_{dumpFileGuid}_hangdump"; this.testResultsDirectory = testResultsDirectory; string procDumpArgs = new ProcDumpArgsBuilder().BuildHangBasedProcDumpArgs( processId, this.dumpFileName, isFullDump); if (EqtTrace.IsInfoEnabled) { EqtTrace.Info($"ProcessDumpUtility : The hang based procdump invocation argument is {procDumpArgs}"); } this.procDumpProcess = this.processHelper.LaunchProcess( this.GetProcDumpExecutable(processId), procDumpArgs, testResultsDirectory, null, null, null) as Process; }