Example #1
0
        public static ParallelStack Build(ClrRuntime runtime)
        {
            var ps          = new ParallelStack();
            var stackFrames = new List <ClrStackFrame>(64);

            foreach (var thread in runtime.Threads)
            {
                stackFrames.Clear();

                foreach (var stackFrame in thread.StackTrace.Reverse())
                {
                    if (stackFrame.Kind != ClrStackFrameType.ManagedMethod)
                    {
                        continue;
                    }

                    stackFrames.Add(stackFrame);
                }

                if (stackFrames.Count == 0)
                {
                    continue;
                }

                ps.AddStack(thread.OSThreadId, stackFrames.ToArray());
            }

            return(ps);
        }
        public static ParallelStack Build(ClrRuntime runtime)
        {
            var ps          = new ParallelStack();
            var stackFrames = new List <ClrStackFrame>(64);

            foreach (var thread in runtime.Threads)
            {
                stackFrames.Clear();
#if ClrMD1
                foreach (var stackFrame in thread.StackTrace.Reverse())
#else
                foreach (var stackFrame in thread.EnumerateStackTrace().Reverse())
#endif
                {
#if ClrMD1
                    if (stackFrame.Kind != ClrStackFrameType.ManagedMethod)
#else
                    if ((stackFrame.Kind != ClrStackFrameKind.ManagedMethod) || (stackFrame.Method == null))
#endif
                    { continue; }

                    stackFrames.Add(stackFrame);
                }

                if (stackFrames.Count == 0)
                {
                    continue;
                }

                ps.AddStack(thread.OSThreadId, stackFrames.ToArray());
            }

            return(ps);
        }