public ExceptionViewModel(ExceptionTraceData data, TraceCallStack stack, SymbolReader reader) { _data = data; _stack = stack; _reader = reader; ProcessName = GetProcessName(); }
private static void PrintStack(TraceCallStack callStack, SymbolReader symbolReader) { while (callStack != null) { var method = callStack.CodeAddress.Method; var module = callStack.CodeAddress.ModuleFile; if (method != null) { // see if we can get line number information var lineInfo = ""; var sourceLocation = callStack.CodeAddress.GetSourceLine(symbolReader); if (sourceLocation != null) { lineInfo = string.Format(" AT: {0}({1})", Path.GetFileName(sourceLocation.SourceFile.BuildTimeFilePath), sourceLocation.LineNumber); } Console.WriteLine(" Method: {0}!{1}{2}", module.Name, method.FullMethodName, lineInfo); } else if (module != null) { Console.WriteLine(" Module: {0}!0x{1:x}", module.Name, callStack.CodeAddress.Address); } else { Console.WriteLine(" ?!0x{0:x}", callStack.CodeAddress.Address); } callStack = callStack.Caller; } }
private void DumpStack(TraceCallStack callStack) { while (callStack != null) { var codeAddress = callStack.CodeAddress; if (codeAddress.Method == null) { var moduleFile = codeAddress.ModuleFile; if (moduleFile == null) { Debug.WriteLine($"Could not find module for Address 0x{codeAddress.Address:x}"); } else { codeAddress.CodeAddresses.LookupSymbolsForModule(_symbolReader, moduleFile); } } if (!string.IsNullOrEmpty(codeAddress.FullMethodName)) { Console.WriteLine($" {codeAddress.FullMethodName}"); } else { Console.WriteLine($" 0x{codeAddress.Address:x}"); } callStack = callStack.Caller; } }
public TraceCodeAddress GetManagedMethodOnStack(SampledProfileTraceData se) { TraceCodeAddress ca = TraceLogExtensions.IntructionPointerCodeAddress(se); if (ManagedModulePaths.Contains(ca.ModuleFilePath)) { return(ca); } // We don't have a managed method, so walk to the managed method by skipping calls // inside clr or clrjit TraceCallStack cs = TraceLogExtensions.CallStack(se); while (cs != null) { ca = cs.CodeAddress; if (ca == null) { return(null); } if (ManagedModulePaths.Contains(ca.ModuleFilePath)) { return(ca); } // This is to ensure we calculate time spent in the JIT helpers, for example. cs = ca.ModuleName.IndexOf("clr", StringComparison.OrdinalIgnoreCase) >= 0 || ca.ModuleName.IndexOf("clrjit", StringComparison.OrdinalIgnoreCase) >= 0 ? cs.Caller : null; } return(null); }
private void WriteStack(TraceCallStack stack, IConsole console) { while (stack != null) { console.WriteLine($" at {stack.CodeAddress.ModuleName}!{stack.CodeAddress.FullMethodName} + 0x{stack.CodeAddress.ILOffset:X4}"); stack = stack.Caller; } }
protected void MergeCallStack(TraceCallStack callStack, SymbolReader reader) { var currentFrame = callStack.Depth; var frames = new SymbolicFrame[callStack.Depth]; // the first element of callstack is the last frame: we need to iterate on each frame // up to the first one before adding them into the MergedSymbolicStack while (callStack != null) { var codeAddress = callStack.CodeAddress; if (codeAddress.Method == null) { var moduleFile = codeAddress.ModuleFile; if (moduleFile != null) { // TODO: this seems to trigger extremely slow retrieval of symbols // through HTTP requests: see how to delay it AFTER the user // stops the profiling if (!_missingSymbols.TryGetValue(moduleFile, out var _)) { codeAddress.CodeAddresses.LookupSymbolsForModule(reader, moduleFile); if (codeAddress.Method == null) { _missingSymbols[moduleFile] = true; #if DEBUG Console.WriteLine($"Missing symbols for {moduleFile.ImageBase:x} - {moduleFile.Name}"); #endif } } } } frames[--currentFrame] = new SymbolicFrame( codeAddress.Address, codeAddress.FullMethodName ); #if DEBUG if (!string.IsNullOrEmpty(codeAddress.FullMethodName)) { Console.WriteLine($" {codeAddress.FullMethodName}"); } else { Console.WriteLine($" 0x{codeAddress.Address:x}"); } #endif callStack = callStack.Caller; } #if DEBUG Console.WriteLine($"-----------------------------------------"); Console.WriteLine(); #endif _stackCount++; _stacks.AddStack(frames); }
/// <summary> /// Because it is expensive and often unnecessary, lookup of native symbols needs to be explicitly requested. /// Here we do this for every frame in the stack. Note that this is not needed for JIT compiled managed code. /// </summary> static private void ResolveNativeCode(TraceCallStack callStack, SymbolReader symbolReader) { while (callStack != null) { var codeAddress = callStack.CodeAddress; if (codeAddress.Method == null) { var moduleFile = codeAddress.ModuleFile; if (moduleFile == null) { Trace.WriteLine(string.Format("Could not find module for Address 0x{0:x}", codeAddress.Address)); } else { codeAddress.CodeAddresses.LookupSymbolsForModule(symbolReader, moduleFile); } } callStack = callStack.Caller; } }
public void AllocationTick(GCAllocationTickTraceData data, bool large, double value) { AllocTick key = new AllocTick(); // May not have type name prior to 4.5 if (!String.IsNullOrEmpty(data.TypeName)) { key.m_type = data.TypeName; } TraceCallStack stack = data.CallStack(); // Walk the call stack to find module above clr while ((stack != null) && (stack.Caller != null) && stack.CodeAddress.ModuleName.IsClr()) { stack = stack.Caller; } if (stack != null) { key.m_caller1 = stack.CodeAddress.CodeAddressIndex; stack = stack.Caller; // Walk call stack to find module above mscorlib while ((stack != null) && (stack.Caller != null) && stack.CodeAddress.ModuleName.IsMscorlib()) { stack = stack.Caller; } if (stack != null) { key.m_caller2 = stack.CodeAddress.CodeAddressIndex; } } AddAlloc(key, large, value); }
private void DumpStack(TraceCallStack frame) { while (frame != null) { var codeAddress = frame.CodeAddress; if (codeAddress.Method == null) { var moduleFile = codeAddress.ModuleFile; if (moduleFile != null) { codeAddress.CodeAddresses.LookupSymbolsForModule(_symbolReader, moduleFile); } } if (!string.IsNullOrEmpty(codeAddress.FullMethodName)) { Console.WriteLine($" {codeAddress.FullMethodName}"); } else { Console.WriteLine($" 0x{codeAddress.Address:x}"); } frame = frame.Caller; } }
private static void PrintStack(TraceCallStack callStack, SymbolReader symbolReader) { Out.WriteLine("STACKTRACE:"); while (callStack != null) { var method = callStack.CodeAddress.Method; var module = callStack.CodeAddress.ModuleFile; if (method != null) { // see if we can get line number information var lineInfo = ""; var sourceLocation = callStack.CodeAddress.GetSourceLine(symbolReader); if (sourceLocation != null) lineInfo = string.Format(" AT: {0}({1})", Path.GetFileName(sourceLocation.SourceFile.BuildTimeFilePath), sourceLocation.LineNumber); Out.WriteLine(" Method: {0}!{1}{2}", module.Name, method.FullMethodName, lineInfo); } else if (module != null) Out.WriteLine(" Module: {0}!0x{1:x}", module.Name, callStack.CodeAddress.Address); else Out.WriteLine(" ?!0x{0:x}", callStack.CodeAddress.Address); callStack = callStack.Caller; } }
public CallStackViewModel(TraceCallStack callStack, ExceptionViewModel ex) { _callStack = callStack; _ex = ex; }
/// <summary> /// Because it is expensive and often unnecessary, lookup of native symbols needs to be explicitly requested. /// Here we do this for every frame in the stack. Note that this is not needed for JIT compiled managed code. /// </summary> static private void ResolveNativeCode(TraceCallStack callStack, SymbolReader symbolReader) { while (callStack != null) { var codeAddress = callStack.CodeAddress; if (codeAddress.Method == null) { var moduleFile = codeAddress.ModuleFile; if (moduleFile == null) Trace.WriteLine(string.Format("Could not find module for Address 0x{0:x}", codeAddress.Address)); else codeAddress.CodeAddresses.LookupSymbolsForModule(symbolReader, moduleFile); } callStack = callStack.Caller; } }