Esempio n. 1
0
        private static FileAndLineNumber FindNearestLine(PdbFunction function, int ilOffset)
        {
            int distance = int.MaxValue;
            FileAndLineNumber nearest = new FileAndLineNumber();

            foreach (PdbSequencePointCollection sequenceCollection in function.SequencePoints)
            {
                foreach (PdbSequencePoint point in sequenceCollection.Lines)
                {
                    int dist = (int)Math.Abs(point.Offset - ilOffset);
                    if (dist < distance)
                    {
                        nearest.File = sequenceCollection.File.Name;
                        nearest.Line = (int)point.LineBegin;
                    }
                }
            }

            return(nearest);
        }
Esempio n. 2
0
        public static void Profile(ClrRuntime runtime)
        {
            {
                foreach (ClrThread thread in runtime.Threads)
                {
                    Console.WriteLine("Thread {0:x}:", thread.OSThreadId);

                    foreach (ClrStackFrame frame in thread.StackTrace)
                    {
                        if (frame.Kind == ClrStackFrameType.Runtime)
                        {
                            Console.WriteLine("{0,12:x} {1,12:x} {2}", frame.InstructionPointer, frame.StackPointer, frame.DisplayString);
                        }
                        else
                        {
                            FileAndLineNumber info = frame.GetSourceLocation();
                            Console.WriteLine("{0,12:x} {1,12:x} {2} [{3} @ {4}]", frame.InstructionPointer, frame.StackPointer, frame.DisplayString, info.File, info.Line);
                        }
                    }
                }
            }
        }