public Microsoft.Diagnostics.RuntimeExt.SourceLocation GetFileAndLineNumberSafe(ClrStackFrame frame) { if (frame.Method == null || frame.Method.Type == null || frame.Method.Type.Module == null) { return(null); } string moduleName = frame.Method.Type.Module.Name; if (_failedToLoadSymbols.Contains(moduleName)) { return(null); } // ClrStackFrame.GetFileAndLineNumber throws occasionally when something is wrong with the module. try { var location = frame.GetSourceLocation(); if (location == null) { _failedToLoadSymbols.Add(moduleName); } return(location); } catch (ClrDiagnosticsException) { _failedToLoadSymbols.Add(moduleName); return(null); } catch (InvalidOperationException) { _failedToLoadSymbols.Add(moduleName); return(null); } }
public CombinedStackFrame(ClrStackFrame frame) { if (frame.Kind == ClrStackFrameType.ManagedMethod) { Type = StackFrameType.Managed; } if (frame.Kind == ClrStackFrameType.Runtime) { Type = StackFrameType.Special; } InstructionPointer = frame.InstructionPointer; StackPointer = frame.StackPointer; if (frame.Method == null) { MethodName = frame.DisplayString; //for example GCFrame return; } MethodName = frame.Method.GetFullSignature(); if (frame.Method.Type != null) { ModuleName = Path.GetFileNameWithoutExtension(frame.Method.Type.Module.Name); if (string.IsNullOrEmpty(ModuleName)) { ModuleName = "UNKNOWN"; } } // calculate IL offset with instruction pointer of frame and instruction pointer // in the target dump file of the start of the method's assembly OffsetInMethod = InstructionPointer - frame.Method.NativeCode; this.SourceInfo = frame.GetSourceLocation(); }