/// <summary> /// Initializes a new instance of the <see cref="ClrMdThread"/> class. /// </summary> /// <param name="thread">The thread.</param> /// <param name="clrThread">The CLR thread.</param> /// <param name="process">The process.</param> internal ClrMdThread(Thread thread, Microsoft.Diagnostics.Runtime.ClrThread clrThread, Process process) { Thread = thread; Process = process; ClrThread = clrThread; runtime = SimpleCache.Create(() => Process.ClrRuntimes.Single(r => ((ClrMdRuntime)r).ClrRuntime == clrThread.Runtime)); appDomain = SimpleCache.Create(() => Runtime.AppDomains.Single(a => a.Address == clrThread.AppDomain)); clrStackTrace = SimpleCache.Create(() => { CLR.ClrMdProvider provider = ((ClrMdRuntime)Runtime).Provider; StackTrace stackTrace = new StackTrace(Thread); uint frameNumber = 0; stackTrace.Frames = ClrThread.StackTrace.Where(f => f.Method != null).Select(f => { return(new StackFrame(stackTrace, new ThreadContext(f.InstructionPointer, f.StackPointer, ulong.MaxValue, null)) { FrameNumber = frameNumber++, InstructionOffset = f.InstructionPointer, StackOffset = f.StackPointer, FrameOffset = ulong.MaxValue, ReturnOffset = ulong.MaxValue, ClrStackFrame = new ClrMdStackFrame(provider, f), }); }).ToArray(); return(stackTrace); }); lastThrownException = SimpleCache.Create(() => { if (ClrThread.CurrentException != null) { CLR.ClrMdProvider provider = ((ClrMdRuntime)Runtime).Provider; Microsoft.Diagnostics.Runtime.ClrException clrException = ClrThread.CurrentException; return(Variable.CreatePointer(Process.FromClrType(provider.FromClrType(clrException.Type)), clrException.Address)); } return(null); }); }
/// <summary> /// Initializes a new instance of the <see cref="ClrException"/> class. /// </summary> /// <param name="clrThread">The CLR thread.</param> /// <param name="clrException">The CLR exception.</param> internal ClrException(ClrThread clrThread, Microsoft.Diagnostics.Runtime.ClrException clrException) : base(clrThread.Process.FromClrType(clrException.Type), ulong.MaxValue, Variable.ComputedName, Variable.UnknownPath, clrException.Address) { }