Esempio n. 1
0
        public static StackSample GetThreadStacks(MDbgThread t, bool withArgs = false, bool originFirst = false)
        {
            //Console.WriteLine("Callstack for Thread {0}", t.Id.ToString());
            StackSample sample = new StackSample { ThreadId = t.Id, Time = DateTime.Now };
            MDbgFrame[] frames = new MDbgFrame[0];
            try
            {
                frames = t.Frames.ToArray();
            }
            catch (Exception ex)
            {
                DebuggerUtils.HandleExceptionSilently(ex);
            }

            foreach (MDbgFrame f in frames)
            {
                try
                {
                    string frame = GetFrameString(f, withArgs).Trim();
                    if (string.IsNullOrWhiteSpace(frame))
                        frame = "[Missing frame]";

                    if (originFirst)
                        sample.CallStack.Insert(0, frame);
                    else
                        sample.CallStack.Add(frame);
                }
                catch (Exception ex)
                {
                    DebuggerUtils.HandleExceptionSilently(ex);
                }
            }

            return sample;
        }