예제 #1
0
        static protected uint ReadAndUnpackBits(_DBG.BitStream stream)
        {
            const int SHIFT_PER_NIBBLE = 2; //2^2 = 4 bits per nibble
            uint      nibbles          = stream.ReadBits(Packets.Commands.Bits.NibbleCount) + 1;

            return(stream.ReadBits((int)nibbles << SHIFT_PER_NIBBLE));
        }
예제 #2
0
        public HeapDumpObjectPacket(_DBG.BitStream stream)
            : base(Commands.c_Profiling_HeapDump_Object)
        {
            m_address = ReadAndUnpackBits(stream);
            m_size    = ReadAndUnpackBits(stream) * ProfilerSession.HeapBlockSize;
            m_dt      = (_DBG.RuntimeDataType)stream.ReadBits(Commands.Bits.DataType);
            if (m_dt == _DBG.RuntimeDataType.DATATYPE_CLASS || m_dt == _DBG.RuntimeDataType.DATATYPE_VALUETYPE)
            {
                m_typedef = ReadTypeDefIndex(stream);
            }
            else if (m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY)
            {
                m_arrayElementType = ReadTypeDefIndex(stream);
                m_arrayLevels      = (ushort)ReadAndUnpackBits(stream);
            }

            m_refs = new List <uint>();

            bool moreRefs;

            while (moreRefs = ReadBoolean(stream))
            {
                m_refs.Add(ReadAndUnpackBits(stream));
            }
        }
예제 #3
0
        internal static Packets.ProfilerPacket Decode(_DBG.BitStream stream)
        {
            uint type = stream.ReadBits(Packets.Commands.Bits.CommandHeader);

            Tracing.PacketTrace("New Packet {0}", type);
            switch (type)
            {
            case Packets.Commands.c_Profiling_Timestamp:
                return(new Packets.TimestampPacket(stream));

            case Packets.Commands.c_Profiling_Memory_Layout:
                return(new Packets.MemoryLayoutPacket(stream));

            case Packets.Commands.c_Profiling_HeapDump_Start:
                return(new Packets.HeapDumpStartPacket(stream));

            case Packets.Commands.c_Profiling_HeapDump_Stop:
                return(new Packets.HeapDumpStopPacket(stream));

            case Packets.Commands.c_Profiling_HeapDump_Root:
                return(new Packets.HeapDumpRootPacket(stream));

            case Packets.Commands.c_Profiling_HeapDump_Object:
                return(new Packets.HeapDumpObjectPacket(stream));

            case Packets.Commands.c_Profiling_Calls_Call:
                return(new Packets.CallPacket(stream));

            case Packets.Commands.c_Profiling_Calls_Return:
                return(new Packets.ReturnPacket(stream));

            case Packets.Commands.c_Profiling_Calls_CtxSwitch:
                return(new Packets.ContextSwitchPacket(stream));

            case Packets.Commands.c_Profiling_Allocs_Alloc:
                return(new Packets.ObjectAllocationPacket(stream));

            case Packets.Commands.c_Profiling_Allocs_Relloc:
                return(new Packets.ObjectRelocationPacket(stream));

            case Packets.Commands.c_Profiling_Allocs_Delete:
                return(new Packets.ObjectDeletionPacket(stream));

            case Packets.Commands.c_Profiling_GarbageCollect_Begin:
                return(new Packets.GarbageCollectionBeginPacket(stream));

            case Packets.Commands.c_Profiling_GarbageCollect_End:
                return(new Packets.GarbageCollectionEndPacket(stream));

            case Packets.Commands.c_Profiling_HeapCompact_Begin:
                return(new Packets.HeapCompactionBeginPacket(stream));

            case Packets.Commands.c_Profiling_HeapCompact_End:
                return(new Packets.HeapCompactionEndPacket(stream));

            default:
                throw new ApplicationException("Unable to decode packet.");
            }
        }
예제 #4
0
 public HeapDumpRootPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_HeapDump_Root)
 {
     m_address = ReadAndUnpackBits(stream);
     m_source  = stream.ReadBits(Packets.Commands.Bits.RootTypes);
     switch (m_source)
     {
     case Packets.Commands.RootTypes.Root_Stack:
         m_method = ReadMethodDefIndex(stream);
         break;
     }
     Tracing.PacketTrace("root type:{0} at {1}", m_source, m_address);
 }
예제 #5
0
 public ObjectAllocationPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_Allocs_Alloc)
 {
     m_address = ReadAndUnpackBits(stream);
     m_size    = ReadAndUnpackBits(stream) * ProfilerSession.HeapBlockSize;
     m_dt      = (_DBG.RuntimeDataType)stream.ReadBits(Commands.Bits.DataType);
     if (m_dt == _DBG.RuntimeDataType.DATATYPE_CLASS || m_dt == _DBG.RuntimeDataType.DATATYPE_VALUETYPE ||
         m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY)
     {
         m_type = ReadTypeDefIndex(stream);
         if (m_dt == _DBG.RuntimeDataType.DATATYPE_SZARRAY)
         {
             m_rank = (ushort)ReadAndUnpackBits(stream);
         }
     }
     else
     {
         m_type = (uint)m_dt;
     }
 }
예제 #6
0
 static protected bool ReadBoolean(_DBG.BitStream stream)
 {
     return(stream.ReadBits(1) == 1);
 }