public void Setup(ClrDump clrDump, ClrThread clrThread)
 {
     ClrDump = clrDump;
     ClrThread = clrThread;
     Icon = Properties.Resources.exclamation_small;
     Name = $"#{clrDump.Id} - Exception";
 }
        internal List<UnifiedBlockingObject> GetManagedBlockingObjects(ClrThread thread, List<UnifiedStackFrame> unmanagedStack, ClrRuntime runtime)
        {
            List<UnifiedBlockingObject> result = new List<UnifiedBlockingObject>();
            if (thread.BlockingObjects?.Count > 0)
            {
                foreach (var item in thread.BlockingObjects)
                {
                    result.Add(new UnifiedBlockingObject(item));
                }
            }

            CheckForCriticalSections(result, unmanagedStack, runtime);

            foreach (var frame in unmanagedStack)
            {
                if (frame?.Handles?.Count > 0)
                {
                    foreach (var handle in frame.Handles)
                    {
                        result.Add(new UnifiedBlockingObject(handle.Id, handle.ObjectName, handle.Type));
                    }
                }
            }
            return result;
        }
        public Thread(ClrThread thread)
        {
            OSThreadId = thread.OSThreadId;
            ManagedThreadId = thread.ManagedThreadId;
            LockCount = thread.LockCount;
            IsAlive = thread.IsAlive;
            IsAborted = thread.IsAborted;
            IsGC = thread.IsGC;
            IsFinalizer = thread.IsFinalizer;
            IsBackground = thread.IsBackground;
            IsAborted = thread.IsAborted;
            IsAbortRequested = thread.IsAbortRequested;
            IsGCSuspending = thread.IsGCSuspendPending;
            IsThreadpoolCompletionPort = thread.IsThreadpoolCompletionPort;
            IsUserSuspended = thread.IsUserSuspended;
            IsSuspendingEE = thread.IsSuspendingEE;
            IsThreadpoolTimer = thread.IsThreadpoolTimer;
            IsThreadpoolWorker = thread.IsThreadpoolWorker;
            IsUnstarted = thread.IsUnstarted;
            //			BlockingObjects = thread.BlockingObjects.Select(x =>
            //				new BlockingObject
            //				{
            //					ObjectRef = x.Object,
            //					Reason = x.Reason,
            //					RecursionCount = x.RecursionCount,
            //					Taken = x.Taken,
            //				});
            if (thread.CurrentException != null)
                CurrentExceptionMessage = thread.CurrentException.Message;

            Stacktrace = thread.StackTrace.Select(frame => String.Format("{0} {1,12:X} {2}", frame.Kind, frame.StackPointer, frame.DisplayString)).ToList();
        }
 public UnifiedManagedThread(ClrThread waiter)
     : base(new ThreadInfo()
     {
         OSThreadId = waiter.OSThreadId,
         ManagedThread = waiter
     })
 {
     //TODO: complete logic -> used with Blocking object Wiater
 }
        public void Setup(ClrDump clrDump, ClrThread thread)
        {
            ClrDump = clrDump;
            Thread = thread;
            Icon = Properties.Resources.red_line_small;
            Name = $"#{clrDump.Id} - StackTrace - Id: {Thread?.ManagedThreadId}";

            dlvStackFrames.InitColumns<StackFrameInformation>();
        }
Exemple #6
0
        /// <summary>
        ///     Converts the specified thread.
        /// </summary>
        /// <param name="thread">The thread.</param>
        /// <returns>IClrThread.</returns>
        public IClrThread Convert(ClrMd.ClrThread thread)
        {
            if (thread == null)
            {
                return(null);
            }
            var item = new ClrThreadAdapter(this, thread);

            return(Cache.GetOrAdd <IClrThread>(thread, () => item, () => item.Setup()));
        }
Exemple #7
0
        public void Setup(ClrDump clrDump, ClrThread thread, UIClrDumpModule parentModule=null)
        {
            ClrDump = clrDump;
            Thread = thread;
            Icon = Properties.Resources.formatting_dublicate_value_small;
            Name = $"#{clrDump.Id} - Stack - Id: {Thread?.ManagedThreadId}";

            dlvStack.InitColumns<StackInstanceInformation>();
            dlvStack.SetUpAddressColumn<StackInstanceInformation>(parentModule ?? this);
            dlvStack.SetUpTypeColumn<StackInstanceInformation>(parentModule ?? this);
            dlvStack.AddSimpleValueColumn(o => ((StackInstanceInformation)o).Address, ClrDump, o => ((StackInstanceInformation)o).Type);
            dlvStack.RebuildColumns();
            dlvStack.SetTypeNameFilter<StackInstanceInformation>(regexFilterControl);
        }
Exemple #8
0
        private void DisplayChainForThreadAux(ClrThread thread, int depth, HashSet<int> visitedThreadIds)
        {
            _context.WriteLink(
                String.Format("{0}+ Thread {1}", new string(' ', depth*2), thread.ManagedThreadId),
                String.Format("~ {0}; !clrstack", thread.ManagedThreadId));
            _context.WriteLine();
            
            if (visitedThreadIds.Contains(thread.ManagedThreadId))
            {
                _context.WriteLine("{0}*** DEADLOCK!", new string(' ', depth * 2));
                return;
            }
            visitedThreadIds.Add(thread.ManagedThreadId);

            foreach (var blockingObject in thread.BlockingObjects)
            {
                _context.Write("{0}| {1} ", new string(' ', (depth+1) * 2), blockingObject.Reason);
                var type = _context.Heap.GetObjectType(blockingObject.Object);
                if (type != null && !String.IsNullOrEmpty(type.Name))
                {
                    _context.WriteLink(
                        String.Format("{0:x16} {1}", blockingObject.Object, type.Name),
                        String.Format("!do {0:x16}", blockingObject.Object));
                }
                else
                {
                    _context.Write("{0:x16}", blockingObject.Object);
                }
                _context.WriteLine();
                foreach (var owner in blockingObject.Owners)
                {
                    if (owner == null) // ClrMD sometimes reports this nonsense
                        continue;

                    DisplayChainForThreadAux(owner, depth + 2, visitedThreadIds);
                }
            }
        }
        public ThreadInformation(ClrDump clrDump, ClrThread thread)
        {
            ClrDump = clrDump;
            Thread = thread;

            clrDump.Run(() =>
           {
               OSThreadId = thread.OSThreadId;
               ManagedThreadId = thread.ManagedThreadId;
               CurrentException = thread.CurrentException?.Type?.Name;
               GcMode = thread.GcMode;
               IsAborted = thread.IsAborted;
               IsAbortRequested = thread.IsAbortRequested;
               IsAlive = thread.IsAlive;

               IsBackground = thread.IsBackground;
               IsCoInitialized = thread.IsCoInitialized;
               IsDebuggerHelper = thread.IsDebuggerHelper;
               IsDebugSuspended = thread.IsDebugSuspended;
               IsFinalizer = thread.IsFinalizer;
               IsGC = thread.IsGC;
               IsGCSuspendPending = thread.IsGCSuspendPending;
               IsMTA = thread.IsMTA;
               IsShutdownHelper = thread.IsShutdownHelper;
               IsSTA = thread.IsSTA;
               IsSuspendingEE = thread.IsSuspendingEE;
               IsThreadpoolCompletionPort = thread.IsThreadpoolCompletionPort;
               IsThreadpoolGate = thread.IsThreadpoolGate;
               IsThreadpoolTimer = thread.IsThreadpoolTimer;
               IsThreadpoolWait = thread.IsThreadpoolWait;
               IsThreadpoolWorker = thread.IsThreadpoolWorker;
               IsUnstarted = thread.IsUnstarted;
               IsUserSuspended = thread.IsUserSuspended;
               LockCount = thread.LockCount;
               var gcThreads = clrDump.Runtime.EnumerateGCThreads().ToList();
               IsGCThread = gcThreads.Any(gcThreadId => gcThreadId == OSThreadId);
           });
        }
Exemple #10
0
 public UnifiedThread GetThreadWithBlockingObjects(ClrThread thread)
 {
     var blockingObjects = GetUnmanagedBlockingObjects(thread.OSThreadId);
     blockingObjects.AddRange(GetManagedBlockingObjects(thread.OSThreadId));
     return new UnifiedThread(thread, blockingObjects);
 }
Exemple #11
0
 public ClrDumpThread(ClrDump clrDump, ClrThread thread, string name)
 {
     ClrDump = clrDump;
     ClrThread = thread;
     Name = name;
 }
 public virtual List<UnifiedBlockingObject> GetManagedBlockingObjects(ClrThread thread, List<UnifiedStackFrame> unmanagedStack, ClrRuntime runtime)
 {
     return _unmanagedBlockingObjectsHandler.GetManagedBlockingObjects(thread, unmanagedStack, runtime);
 }
Exemple #13
0
 private List<UnifiedStackFrame> GetManagedStackTrace(ClrThread thread)
 {
     return (from frame in thread.StackTrace
             let sourceLocation = _context.SymbolCache.GetFileAndLineNumberSafe(frame)
             select new UnifiedStackFrame(frame, sourceLocation)
             ).ToList();
 }
Exemple #14
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, ClrThread thread);
Exemple #15
0
 virtual public Address GetFieldAddress(ClrAppDomain domain, ClrThread thread)
 {
     return GetAddress(domain, thread);
 }
		private void DumpThreadStackTrace(ClrThread thread)
		{
			foreach(ClrStackFrame frame in thread.StackTrace)
			{
				this.outputWriter.WriteLine("  {0,12:X} {1,12:X} {2}", frame.InstructionPointer, frame.StackPointer, frame.DisplayString);
			}
		}
Exemple #17
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <param name="convertStrings">When true, the value of a string field will be
 /// returned as a System.String object; otherwise the address of the String object will be returned.</param>
 /// <returns>The value of the field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, ClrThread thread, bool convertStrings);
Exemple #18
0
 /// <summary>
 /// Gets the address of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <param name="thread">The thread on which to get the field's address.</param>
 /// <returns>The address of the field.</returns>
 abstract public ulong GetAddress(ClrAppDomain appDomain, ClrThread thread);
Exemple #19
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <param name="convertStrings">When true, the value of a string field will be 
 /// returned as a System.String object; otherwise the address of the String object will be returned.</param>
 /// <returns>The value of the field.</returns>
 abstract public object GetValue(ClrAppDomain appDomain, ClrThread thread, bool convertStrings);
 public MDThread(ClrThread thread)
 {
     m_thread = thread;
 }
 private List<UnifiedStackFrame> GetManagedStackTrace(ClrThread thread, ThreadInfo info)
 {
     return (from frame in thread.StackTrace
             let sourceLocation = SymbolCache.GetFileAndLineNumberSafe(frame)
             select _processQuerierStrategy.ConvertToUnified(frame, sourceLocation, info)
             ).ToList();
 }
Exemple #22
0
 private void DisplayChainForThread(ClrThread thread)
 {
     DisplayChainForThreadAux(thread, 0, new HashSet<int>());
 }
 public void PrintStackTrace(ClrThread thread )
 {
     _console.WriteLine(String.Format("Stacktrace for ThreadId={0:X}", thread.OSThreadId),
         ConsoleColor.DarkYellow);
     foreach (ClrStackFrame frame in thread.StackTrace)
     {
         _console.WriteLine(String.Format("{0,12:X} {1,12:X} {2}", frame.InstructionPointer, frame.StackPointer,
                            frame.DisplayString));
     }
 }
Exemple #24
0
            public FrameArgumentsAndLocalsRetriever(ClrThread thread,
                IList<ClrStackFrame> stackTrace, CommandExecutionContext context)
            {
                _context = context;
                _stackTrace = stackTrace;

                _isOnCLRv2 = _context.ClrVersion.Version.Major == 2;

                ProcessStackWalk(thread.OSThreadId);
            }
Exemple #25
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain, ClrThread thread)
 {
     return(GetValue(appDomain, thread, true));
 }
Exemple #26
0
 virtual public object GetFieldValue(ClrAppDomain domain, ClrThread thread)
 {
     return GetValue(domain, thread);
 }
Exemple #27
0
 public UnifiedThread(ClrThread thread, IEnumerable<UnifiedBlockingObject> blockingObjects)
 {
     IsManagedThread = true;
     ManagedThreadId = thread.ManagedThreadId;
     OSThreadId = thread.OSThreadId;
     BlockingObjects.AddRange(blockingObjects);
 }
Exemple #28
0
 /// <summary>
 /// Gets the value of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's value.</param>
 /// <param name="thread">The thread on which to get the field's value.</param>
 /// <returns>The value of the field.</returns>
 virtual public object GetValue(ClrAppDomain appDomain, ClrThread thread)
 {
     return GetValue(appDomain, thread, true);
 }
Exemple #29
0
 private bool ThreadMatchesFilter(ClrThread thread)
 {
     return thread.StackTrace.Any(frame => _searchRegex.IsMatch(frame.DisplayString));
 }
Exemple #30
0
 /// <summary>
 /// Gets the address of the field.
 /// </summary>
 /// <param name="appDomain">The AppDomain in which to get the field's address.</param>
 /// <param name="thread">The thread on which to get the field's address.</param>
 /// <returns>The address of the field.</returns>
 abstract public Address GetAddress(ClrAppDomain appDomain, ClrThread thread);
 public StackFrameInformation(ClrDump clrDump, ClrThread thread)
 {
     this.clrDump = clrDump;
 }