public static SDClrException ToSDModel(this ClrException clrException) { var model = new SDClrException(); if (clrException != null) { model.Address = clrException.Address; model.Type = clrException.Type.Name; //this.HResult = clrException.HResult; if (model.InnerException != null) { model.InnerException = clrException.Inner.ToSDModel(); } model.Message = clrException.GetExceptionMessageSafe(); var frames = new List <SDCombinedStackFrame>(); foreach (ClrStackFrame clrFrame in clrException.StackTrace) { model.StackTrace.Add(clrFrame.ToSDModel()); } model.StackTrace = new SDCombinedStackTrace(frames); } return(model); }
private static void DisplayException(ClrException exception, CommandExecutionContext context) { context.WriteLine("Exception object: {0:x16}", exception.Address); context.WriteLine("Exception type: {0}", exception.Type.Name); if (context.TargetType != TargetType.DumpFileNoHeap) { // In no-heap dumps, stuff goes wrong inside DesktopException because some fields can't // be found. It can be fixed with a lot of refactoring (not relying on fields at all and // using offsets instead), but it's probably not such a big deal anyway. var innerException = exception.Inner; context.WriteLine("Message: {0}", exception.GetExceptionMessageSafe()); context.WriteLine("Inner exception: {0}", innerException == null ? "<none>" : String.Format("{0:x16}", innerException.Address)); context.WriteLine("HResult: {0:x}", exception.HResult); } context.WriteLine("Stack trace:"); ClrThreadExtensions.WriteStackTraceToContext(null, exception.StackTrace, context, displayArgumentsAndLocals: false); }
private void PrintException(ClrException exception) { if (exception != null) { context.WriteLine("Address: {0:X}, Type: {1}, Message: {2}", exception.Address, exception.Type.Name, exception.GetExceptionMessageSafe()); context.WriteLine("Stacktrace:"); foreach (ClrStackFrame frame in exception.StackTrace) { context.WriteLine("{0,-20:x16} {1}!{2}", frame.InstructionPointer, frame.ModuleName, frame.DisplayString); } } }
public SDClrException(ClrException clrException) { if (clrException != null) { this.Address = clrException.Address; //this.HResult = clrException.HResult; if (this.InnerException != null) { this.InnerException = new SDClrException(clrException.Inner); } this.Message = clrException.GetExceptionMessageSafe(); this.StackTrace = new List <CombinedStackFrame>(); foreach (ClrStackFrame clrFrame in clrException.StackTrace) { this.StackTrace.Add(new CombinedStackFrame(clrFrame)); } } }
public void PrintExceptionsObjects() { if (this.context.Heap != null && this.context.Heap.CanWalkHeap) { foreach (var address in this.context.Heap.EnumerateObjectAddresses()) { ClrType type = this.context.Heap.GetObjectType(address); if (type != null) { if (this.context.Heap.GetObjectType(address).IsException) { ClrException exception = this.context.Heap.GetExceptionObject(address); if (exception != null) { context.WriteLine("Address: {0:X}, Type: {1}, Message: {2}", exception.Address, exception.Type.Name, exception.GetExceptionMessageSafe()); context.WriteLine("Stacktrace:"); foreach (ClrStackFrame frame in exception.StackTrace) { context.WriteLine("{0,-20:x16} {1}!{2}", frame.InstructionPointer, frame.ModuleName, frame.DisplayString); } } } } } } else { context.WriteError("no heap information is avaliable"); } }