static string GetSymbolicatedLine(long offset) { if (!methodsCache.TryGetValue(offset, out var pmipMethodName)) { pmipMethodName = mono_pmip(offset)?.TrimStart(); if (pmipMethodName != null) { pmipMethodName = PmipParser.ToSample(pmipMethodName, offset); } methodsCache.Add(offset, pmipMethodName); } return(pmipMethodName); }
public static void ConvertJITAddressesToMethodNames(string outputPath, string fileName, string profilingType) { // sample line to replace: // ??? (in <unknown binary>) [0x103648455] var rx = new Regex(@"\?\?\? \(in <unknown binary>\) \[0x([0-9a-f]+)\]", RegexOptions.Compiled); if (File.Exists(fileName) && new FileInfo(fileName).Length > 0) { Directory.CreateDirectory(outputPath); var outputFilename = Path.Combine(outputPath, $"{BrandingService.ApplicationName}_{profilingType}_{DateTime.Now:yyyy-MM-dd__HH-mm-ss}.txt"); using (var sr = new StreamReader(fileName)) using (var sw = new StreamWriter(outputFilename)) { string line; while ((line = sr.ReadLine()) != null) { var match = rx.Match(line); if (match.Success) { var offset = long.Parse(match.Groups[1].Value, NumberStyles.HexNumber); if (!methodsCache.TryGetValue(offset, out var pmipMethodName)) { pmipMethodName = mono_pmip(offset)?.TrimStart(); if (pmipMethodName != null) { pmipMethodName = PmipParser.ToSample(pmipMethodName, offset); } methodsCache.Add(offset, pmipMethodName); } if (pmipMethodName != null) { line = line.Remove(match.Index, match.Length); line = line.Insert(match.Index, pmipMethodName); } } sw.WriteLine(line); } } } }