Exemple #1
0
    static void Main(string[] args)
    {
        Helpers.TestWorkingDirectory = Environment.CurrentDirectory;

        using (DataTarget dt = TestTargets.NestedException.LoadFullDump())
        {
            dt.SymbolLocator.SymbolPath += ";" + Environment.CurrentDirectory;
            ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();

            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);
                    }
                }
            }
        }
    }
Exemple #2
0
        private FileAndLineNumber FindNearestLine(IEnumerable <SymUnmanagedSequencePoint> sequences, int ilOffset)
        {
            int distance = int.MaxValue;
            FileAndLineNumber nearest = default(FileAndLineNumber);

            foreach (var point in sequences)
            {
                int dist = (int)Math.Abs(point.Offset - ilOffset);
                if (dist < distance)
                {
                    nearest.File = Path.GetFileName(point.Document.GetName());
                    nearest.Line = (int)point.StartLine;
                }

                distance = dist;
            }

            return(nearest);
        }
Exemple #3
0
        private StackTraceElement GetStackTraceElement(ClrStackFrame frame)
        {
            if (frame == null || frame.Method == null)
            {
                return(null);
            }

            FileAndLineNumber info   = GetSourceLocation(frame);
            StackTraceElement result = new StackTraceElement()
            {
                MethodName     = frame.Method.Name,
                IsNativeMethod = frame.Method.IsInternal || frame.Method.IsPInvoke,
                LineNumber     = info.Line,
                FileName       = info.File,
                ClassName      = frame.Method.Type != null ? frame.Method.Type.Name : "Unknown"
            };

            return(result);
        }
Exemple #4
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);
    }
Exemple #5
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;
    }