예제 #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 TimestampPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Timestamp)
        {
            ulong l = (ulong)ReadAndUnpackBits(stream) << Packets.Commands.Bits.TimestampShift;

            m_time = l / TimeSpan.TicksPerMillisecond;
            Tracing.PacketTrace("time {0}", m_time);
        }
예제 #3
0
        static protected uint ReadMethodDefIndex(_DBG.BitStream stream)
        {
            uint assembly = ReadAndUnpackBits(stream);
            uint method   = ReadAndUnpackBits(stream);

            return(assembly << ASSEMBLY_BIT_OFFSET | method);
        }
예제 #4
0
        static protected uint ReadTypeDefIndex(_DBG.BitStream stream)
        {
            uint assembly = ReadAndUnpackBits(stream);
            uint type     = ReadAndUnpackBits(stream);

            return(assembly << ASSEMBLY_BIT_OFFSET | type);
        }
예제 #5
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));
            }
        }
예제 #6
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.");
            }
        }
예제 #7
0
 public CallPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_Calls_Call)
 {
     if (ReadBoolean(stream))
     {
         m_assembly = ReadAndUnpackBits(stream);
         Debug.Assert(m_assembly != 0);
     }
     m_method = ReadAndUnpackBits(stream);
 }
예제 #8
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);
 }
예제 #9
0
        public ObjectRelocationPacket(_DBG.BitStream stream)
            : base(Commands.c_Profiling_Allocs_Relloc)
        {
            uint count = ReadAndUnpackBits(stream);

            reloc = new ObjectRelocation.RelocationRegion[count];

            for (uint i = 0; i < count; i++)
            {
                reloc[i]          = new ObjectRelocation.RelocationRegion();
                reloc[i].m_start  = ReadAndUnpackBits(stream);
                reloc[i].m_end    = ReadAndUnpackBits(stream);
                reloc[i].m_offset = ReadAndUnpackBits(stream);
            }
        }
예제 #10
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;
     }
 }
예제 #11
0
        public ProfilerSession(_DBG.Engine engine)
        {
            if (engine == null)
            {
                throw new ArgumentNullException();
            }

            m_connected = true;
            m_engine = engine;
            m_engine.OnCommand += new _DBG.CommandEventHandler(OnDeviceCommand);
            m_incomingStream = new _DBG.BitStream(true);

            m_startTime = 0;
            m_lastKnownTime = 0;
            m_currentHeapDump = null;
            m_threadCallStacks = new Dictionary<uint, Stack<uint>>();

            m_liveObjectTable = new List<uint>();

            m_firstPacket = true;

            m_receiverThread = new Thread(WorkerThread);
            m_receiverThread.Start();
        }
예제 #12
0
        public ProfilerSession(_DBG.Engine engine)
        {
            if (engine == null)
            {
                throw new ArgumentNullException();
            }

            m_connected         = true;
            m_engine            = engine;
            m_engine.OnCommand += new _DBG.CommandEventHandler(OnDeviceCommand);
            m_incomingStream    = new _DBG.BitStream(true);

            m_startTime        = 0;
            m_lastKnownTime    = 0;
            m_currentHeapDump  = null;
            m_threadCallStacks = new Dictionary <uint, Stack <uint> >();

            m_liveObjectTable = new List <uint>();

            m_firstPacket = true;

            m_receiverThread = new Thread(WorkerThread);
            m_receiverThread.Start();
        }
예제 #13
0
		private void InitializeForDeserialization(Type t, byte[] data, int pos, int len)
		{
			m_stream = new BitStream(data, pos, len);            
			m_value = null;
			Initialize(t, true);
		}
예제 #14
0
		private void InitializeForSerialization(Type t, object o)
		{
			m_stream = new BitStream();
			m_value = o;
			Initialize(t, false);
		}
예제 #15
0
 public GarbageCollectionEndPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_GarbageCollect_End)
 {
     m_freeBytes = ReadAndUnpackBits(stream);
 }
예제 #16
0
 public HeapCompactionEndPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_HeapCompact_End)
 {
     m_freeBytes = ReadAndUnpackBits(stream);
 }
예제 #17
0
 static protected bool ReadBoolean(_DBG.BitStream stream)
 {
     return(stream.ReadBits(1) == 1);
 }
예제 #18
0
 public ObjectDeletionPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_Allocs_Delete)
 {
     m_address = ReadAndUnpackBits(stream);
 }
예제 #19
0
 public MemoryLayoutPacket(_DBG.BitStream stream) : base(Commands.c_Profiling_Memory_Layout)
 {
     m_heapAddress = ReadAndUnpackBits(stream);
     m_heapLength  = ReadAndUnpackBits(stream);
     Tracing.PacketTrace("layout {0}:{1}", m_heapAddress, m_heapLength);
 }
예제 #20
0
 public ContextSwitchPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_Calls_Call)
 {
     m_thread = ReadAndUnpackBits(stream);
 }
예제 #21
0
 public ReturnPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_Calls_Call)
 {
     m_duration = (ulong)ReadAndUnpackBits(stream) << Packets.Commands.Bits.CallTimingShift;
 }
예제 #22
0
 public HeapDumpStartPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_HeapDump_Start)
 {
 }
예제 #23
0
 public HeapDumpStopPacket(_DBG.BitStream stream)
     : base(Commands.c_Profiling_HeapDump_Stop)
 {
     m_heapBytesUsed = ReadAndUnpackBits(stream);
 }