private static void HandleTsvStacktrace(string tsvPath, IDiaSession pdbSession) { var lines = File.ReadAllLines(tsvPath); for (int i = 1; i < lines.Length; i++) { string[] frags = lines[i].Split('\t'); string methodName = ""; string module = ""; if (frags.Length >= 4) { module = frags[1]; string rvaStr = frags[3]; string rva = rvaStr.Replace("0x", ""); if (frags[2] != "null") { methodName = frags[2]; } uint offset = HexToUint(rva); if (pdbSession != null && offset != 0) { string tmpMethodName = DiaHelper.GetMethodName(pdbSession, offset); if (!String.IsNullOrEmpty(tmpMethodName)) { methodName = tmpMethodName; } } } _writer.WriteLine($"at {module}!{methodName}"); } }
private static void HandleCrash(string hash, IDiaSession pdbSession, int crashCount) { if (!String.IsNullOrEmpty(hash)) { var crashDetails = GetCrashDetails(hash); int crashOccurence = 0; foreach (var crashDetail in crashDetails) { crashOccurence++; string cabId = crashDetail.cabId; if (!String.IsNullOrEmpty(cabId)) { var stackTrace = GetCrashStacktrace(cabId); _writer.WriteLine(); _writer.WriteLine(); _writer.WriteLine(); _writer.WriteLine($"Crash #{crashCount}.{crashOccurence}: {crashDetail.failureName}"); _writer.WriteLine(); if (stackTrace != null) { foreach (var stackLine in stackTrace) { string methodName = stackLine.function; if (String.IsNullOrEmpty(methodName) || methodName == "null") { string fullOffset = stackLine.offset; string hexOffset = fullOffset.Replace("0x", ""); uint offset = HexToUint(hexOffset); if (pdbSession != null && offset != 0) { methodName = DiaHelper.GetMethodName(pdbSession, offset); } } _writer.WriteLine($"at {stackLine.image}!{methodName}"); } if (_preventDuplication) { break; } } } } } }
private static void HandleCrashTxtStacktrace(string crashTxt, IDiaSession pdbSession) { var lines = File.ReadAllLines(crashTxt); for (int i = 0; i < lines.Length; i++) { var currentLine = lines[i]; if (currentLine.Contains("<BaseAddress>")) { string outputLine = ""; string[] splitted = currentLine.Split(new string[] { "<BaseAddress>" }, StringSplitOptions.None); outputLine += splitted[0]; string rva = splitted[1].Replace("+0x", ""); uint offset = HexToUint(rva); if (pdbSession != null && offset != 0) { string tmpMethodName = DiaHelper.GetMethodName(pdbSession, offset); if (!String.IsNullOrEmpty(tmpMethodName)) { outputLine += tmpMethodName; } else { outputLine += "<BaseAddress>" + splitted[1]; } } else { outputLine += "<BaseAddress>" + splitted[1]; } _writer.WriteLine(outputLine); } else { _writer.WriteLine(currentLine); } } }