Пример #1
0
 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");
     }
 }