public UnifiedStackFrame ConvertToUnified(ClrStackFrame frame, SourceLocation sourceLocation, ThreadInfo info)
        {
            var result = new UnifiedStackFrame(frame, sourceLocation);
            result.ThreadContext = info.ContextStruct;

            return result;
        }
        public UnifiedStackFrame(ClrStackFrame frame, SourceLocation sourceLocation)
        {
            if (frame.Kind == ClrStackFrameType.ManagedMethod)
                Type = UnifiedStackFrameType.Managed;
            if (frame.Kind == ClrStackFrameType.Runtime)
                Type = UnifiedStackFrameType.Special;

            InstructionPointer = frame.InstructionPointer;
            StackPointer = frame.StackPointer;

            if (frame.Method == null)
                return;

            Method = frame.Method.GetFullSignature();
            if (frame.Method.Type != null)
                Module = Path.GetFileNameWithoutExtension(frame.Method.Type.Module.Name);

            OffsetInMethod = InstructionPointer - frame.Method.NativeCode;

            if (sourceLocation == null)
                return;

            SourceFileName = sourceLocation.FilePath;
            SourceLineNumber = (uint)sourceLocation.LineNumber;
            SourceLineNumberEnd = (uint)sourceLocation.LineNumberEnd;
            SourceColumnNumber = (uint)sourceLocation.ColStart;
            SourceColumnNumberEnd = (uint)sourceLocation.ColEnd;
        }
Exemplo n.º 3
0
 public ClrStackRoot(ulong address, ClrObject obj, ClrStackFrame stackFrame, bool pinned)
 {
     Address    = address;
     Object     = obj;
     StackFrame = stackFrame;
     IsPinned   = pinned;
 }
Exemplo n.º 4
0
        public SourceLocation GetFileAndLineNumberSafe(ClrStackFrame frame)
        {
            if (frame.Method == null || frame.Method.Type == null || frame.Method.Type.Module == null)
                return null;

            string moduleName = frame.Method.Type.Module.Name;
            if (_failedToLoadSymbols.Contains(moduleName))
                return null;

            // ClrStackFrame.GetFileAndLineNumber throws occasionally when something is wrong with the module.
            try
            {
                var location = frame.GetSourceLocation();
                if (location == null)
                    _failedToLoadSymbols.Add(moduleName);
                
                return location;
            }
            catch (ClrDiagnosticsException)
            {
                _failedToLoadSymbols.Add(moduleName);
                return null;
            }
            catch (InvalidOperationException)
            {
                _failedToLoadSymbols.Add(moduleName);
                return null;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="StackFrameAdapter" /> class.
 /// </summary>
 /// <param name="frame">The frame.</param>
 /// <exception cref="ArgumentNullException">frame</exception>
 /// <inheritdoc />
 public StackFrameAdapter(IConverter converter, ClrMd.ClrStackFrame frame) : base(converter)
 {
     Frame              = frame ?? throw new ArgumentNullException(nameof(frame));
     DisplayString      = Frame.DisplayString;
     InstructionPointer = Frame.InstructionPointer;
     ModuleName         = Frame.ModuleName;
     StackPointer       = Frame.StackPointer;
 }
Exemplo n.º 6
0
        public ClrStackInteriorRoot(ClrSegment seg, ulong address, ulong objAddr, ClrStackFrame stackFrame, bool pinned)
        {
            _segment      = seg;
            ObjectPointer = objAddr;

            Address    = address;
            StackFrame = stackFrame;
            IsPinned   = pinned;
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Converts the specified frame.
        /// </summary>
        /// <param name="frame">The frame.</param>
        /// <returns>IClrStackFrame.</returns>
        public IClrStackFrame Convert(ClrMd.ClrStackFrame frame)
        {
            if (frame == null)
            {
                return(null);
            }
            var item = new StackFrameAdapter(this, frame);

            return(Cache.GetOrAdd <IClrStackFrame>(frame, () => item, () => item.Setup()));
        }
Exemplo n.º 8
0
        public StackFrameInformation(ClrDump clrDump, ClrStackFrame frame)
        {
            this.clrDump = clrDump;
            this.frame = frame;
            DisplayString = frame.DisplayString;
            Kind = frame.Kind;
            Method = frame.Method;
            
#if LINE_AND_FILE
            if (frame.Kind != ClrStackFrameType.Runtime)
            {
                fileAndLineNumber = clrDump.Eval(() => frame.FileAndLineNumber());
            }
#endif
        }
Exemplo n.º 9
0
        private static int FindIlOffset(ClrStackFrame frame)
        {
            ulong ip = frame.InstructionPointer;
            int last = -1;
            foreach (ILToNativeMap item in frame.Method.ILOffsetMap)
            {
                if (item.StartAddress > ip)
                    return last;

                if (ip <= item.EndAddress)
                    return item.ILOffset;

                last = item.ILOffset;
            }

            return last;
        }
Exemplo n.º 10
0
        private static PdbReader GetReaderForFrame(ClrStackFrame frame)
        {
            ClrModule module = frame.Method?.Type?.Module;
            PdbInfo info = module?.Pdb;

            PdbReader reader = null;
            if (info != null)
            {
                if (!s_pdbReaders.TryGetValue(info, out reader))
                {
                    SymbolLocator locator = GetSymbolLocator(module);
                    string pdbPath = locator.FindPdb(info);
                    if (pdbPath != null)
                        reader = new PdbReader(pdbPath);

                    s_pdbReaders[info] = reader;
                }
            }

            return reader;
        }