コード例 #1
0
        /// <summary>
        /// based on <a href="https://github.com/dotnet/coreclr/blob/master/src/gcdump/i386/gcdumpx86.cpp">GCDump::DumpGCTable</a>
        /// </summary>
        private void DecodeUntracked(byte[] image, InfoHdrSmall header, ref int offset)
        {
            uint calleeSavedRegs = 0;

            if (header.DoubleAlign)
            {
                calleeSavedRegs = 0;
                if (header.EdiSaved)
                {
                    calleeSavedRegs++;
                }
                if (header.EsiSaved)
                {
                    calleeSavedRegs++;
                }
                if (header.EbxSaved)
                {
                    calleeSavedRegs++;
                }
            }

            uint count       = header.UntrackedCnt;
            int  lastStkOffs = 0;

            while (count-- > 0)
            {
                int stkOffsDelta;
                int lowBits;

                char reg = header.EbpFrame ? 'B' : 'S';

                stkOffsDelta = NativeReader.DecodeSignedGc(image, ref offset);
                int stkOffs = lastStkOffs - stkOffsDelta;
                lastStkOffs = stkOffs;

                lowBits = (int)OFFSET_MASK & stkOffs;
                stkOffs = (int)((uint)stkOffs & ~OFFSET_MASK);

                if (header.DoubleAlign &&
                    (uint)stkOffs >= sizeof(int) * (header.FrameSize + calleeSavedRegs))
                {
                    reg      = 'B';
                    stkOffs -= sizeof(int) * (int)(header.FrameSize + calleeSavedRegs);
                }

                GcSlots.Add(new GcSlot(GcSlots.Count, $"E{reg}P", stkOffs, lowBits, GcSlotFlags.GC_SLOT_UNTRACKED));
            }
        }