Inheritance: IDisposable
Example #1
0
        public static Header Read(LogFileReader reader)
        {
            if (!reader.LoadData (32))
                return null;

            return new Header (reader);
        }
        public void Read(IProgressListener progress)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            try {
                if (!File.Exists(name))
                {
                    return;
                }

                DateTime tim = File.GetLastWriteTime(name);
                if (tim == timestamp)
                {
                    return;
                }
                timestamp = tim;

                if (reader == null)
                {
                    reader = new LogFileReader(name);
                }

                ReadLogFile(progress);
            } catch (Exception ex) {
                Console.WriteLine(ex);
            } finally {
                watch.Stop();
                Console.WriteLine("ObjectMapFileReader.Read (): Completed in {0} s", watch.ElapsedMilliseconds / (double)1000);
            }
        }
Example #3
0
 LogBuffer(LogFileReader reader)
 {
     this.Header = Header.Read (reader);
     while (reader.Position < reader.Length) {
         buffers.Add (Buffer.Read (reader));
     }
 }
Example #4
0
 Buffer(LogFileReader reader)
 {
     Header = BufferHeader.Read (reader);
     var endPos = reader.Position + Header.Length;
     while (reader.Position < endPos) {
         Events.Add (Event.Read (reader));
     }
 }
Example #5
0
        public readonly ulong Size; // size of the object in the heap

        #endregion Fields

        #region Constructors

        AllocEvent(LogFileReader reader, byte extendedInfo)
        {
            TimeDiff = reader.ReadULeb128 ();
            Ptr = reader.ReadSLeb128 ();
            Obj = reader.ReadSLeb128 ();
            Size = reader.ReadULeb128 ();
            if ((extendedInfo & TYPE_ALLOC_BT) != 0)
                Backtrace = new Backtrace (reader);
        }
Example #6
0
 Header(LogFileReader reader)
 {
     Id = reader.ReadInt32 ();
     if (Id != LogHeaderId)
         throw new InvalidOperationException ("Id doesn't match.");
     Major = reader.ReadByte ();
     Minor = reader.ReadByte ();
     Format = reader.ReadByte ();
     PtrSize = reader.ReadByte ();
     StartupTime = reader.ReadInt64 ();
     TimerOverhead = reader.ReadInt32 ();
     Flags = reader.ReadInt32 ();
     Pid = reader.ReadInt32 ();
     Port = reader.ReadUInt16 ();
     SysId = reader.ReadUInt16 ();
 }
Example #7
0
 public static Event Read(LogFileReader reader, byte exinfo)
 {
     return new MonitiorEvent (reader, exinfo);
 }
Example #8
0
        public readonly long Object; //  the lock object as a difference from obj_base

        #endregion Fields

        #region Constructors

        MonitiorEvent(LogFileReader reader, byte exinfo)
        {
            TimeDiff = reader.ReadULeb128 ();
            Object = reader.ReadSLeb128 ();
            byte ev = (byte)((exinfo >> 4) & 0x3);
            if (ev == MONO_PROFILER_MONITOR_CONTENTION && (exinfo & TYPE_MONITOR_BT) == TYPE_MONITOR_BT) {
                Backtrace = new Backtrace (reader);
            }
        }
Example #9
0
 MethodEvent(LogFileReader reader, byte exinfo)
 {
     TimeDiff = reader.ReadULeb128 ();
     Method = reader.ReadSLeb128 ();
     Type = (MethodType)exinfo;
     if (Type == MethodType.Jit) {
         CodeAddress = reader.ReadSLeb128 ();
         CodeSize = reader.ReadULeb128 ();
         Name = reader.ReadNullTerminatedString ();
     }
 }
Example #10
0
 public static Event Read(LogFileReader reader)
 {
     byte info = reader.ReadByte ();
     EventType type = (EventType)(info & 0xF);
     byte extendedInfo = (byte)(info & 0xF0);
     return CreateEvent (reader, type, extendedInfo);
 }
Example #11
0
 public CounterValue(LogFileReader reader, ulong index)
 {
     Index = index;
     Type = (uint)reader.ReadULeb128 ();
     switch ((CounterValueType)Type) {
     case CounterValueType.MONO_COUNTER_STRING:
         if (reader.ReadULeb128 () == 1)
             reader.ReadNullTerminatedString ();
         break;
     case CounterValueType.MONO_COUNTER_WORD:
     case CounterValueType.MONO_COUNTER_INT:
     case CounterValueType.MONO_COUNTER_LONG:
         reader.ReadSLeb128 ();
         break;
     case CounterValueType.MONO_COUNTER_UINT:
     case CounterValueType.MONO_COUNTER_ULONG:
         reader.ReadULeb128 ();
         break;
     case CounterValueType.MONO_COUNTER_DOUBLE:
         reader.ReadUInt64 ();
         break;
     default:
         throw new ArgumentException (String.Format("Unknown Counter Value type {0} [0x{0:x8}], for counter at index {3}, near byte {1} [0x{1:x8}] of {2}.", Type, reader.Position, reader.Length, Index));
     }
 }
Example #12
0
 public static Event Read(LogFileReader reader, byte extendedInfo)
 {
     if (extendedInfo == TYPE_JITHELPER)
         return new RuntimeJitHelperEvent (reader);
     throw new ArgumentException ("Unknown `RuntimeEventType`: " + extendedInfo);
 }
Example #13
0
 public static new Event Read(LogFileReader reader)
 {
     return new ResizeGcEvent (reader);
 }
Example #14
0
 HeapEvent(LogFileReader reader, byte exinfo)
 {
     if (exinfo == TYPE_HEAP_START) {
         Type = EventType.Start;
         TimeDiff = reader.ReadULeb128 ();
     } else if (exinfo == TYPE_HEAP_END) {
         Type = EventType.End;
         TimeDiff = reader.ReadULeb128 ();
     } else if (exinfo == TYPE_HEAP_ROOT) {
         Type = EventType.Root;
         ulong nroots = reader.ReadULeb128 ();
         reader.ReadULeb128 (); // gcs
         RootRefs = new long [nroots];
         RootRefTypes = new RootType [nroots];
         RootRefExtraInfos = new ulong [nroots];
         for (ulong n=0; n<nroots; n++) {
             RootRefs [n] = reader.ReadSLeb128 ();
             RootRefTypes [n] = (RootType) reader.ReadULeb128 ();
             RootRefExtraInfos [n] = reader.ReadULeb128 ();
         }
     } else if (exinfo == TYPE_HEAP_OBJECT) {
         Type = EventType.Object;
         Object = reader.ReadSLeb128 ();
         Class = reader.ReadSLeb128 ();
         Size = reader.ReadULeb128 ();
         ulong num = reader.ReadULeb128 ();
         ObjectRefs = new long[num];
         RelOffset = new ulong[num];
         for (ulong i = 0; i < num; i++) {
             RelOffset [i] = reader.ReadULeb128 ();
             ObjectRefs [i] = reader.ReadSLeb128 ();
         }
     }
 }
Example #15
0
 public static new Event Read(LogFileReader reader)
 {
     return new HandleDestroyedGcEvent (reader);
 }
Example #16
0
        public readonly ulong HandleType; // GC handle type (System.Runtime.InteropServices.GCHandleType)

        #endregion Fields

        #region Constructors

        HandleDestroyedGcEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            HandleType = reader.ReadULeb128 ();
            Handle = reader.ReadULeb128 ();
        }
Example #17
0
        public readonly long ObjAddr; // object pointer differences from obj_base

        #endregion Fields

        #region Constructors

        HandleCreatedGcEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            HandleType = reader.ReadULeb128 ();
            Handle = reader.ReadULeb128 ();
            ObjAddr = reader.ReadSLeb128 ();
        }
Example #18
0
        public readonly ulong Generation; // GC generation event refers to

        #endregion Fields

        #region Constructors

        GcEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            EventType = (GcEventType) reader.ReadULeb128 ();
            Generation = reader.ReadULeb128 ();
        }
Example #19
0
 public static Event Read(LogFileReader reader, byte exinfo)
 {
     return new ExceptionEvent (reader, exinfo);
 }
Example #20
0
        public readonly long Object; // the object that was thrown as a difference from obj_base If the TYPE_EXCEPTION_BT flag is set, a backtrace follows.

        #endregion Fields

        #region Constructors

        ExceptionEvent(LogFileReader reader, byte exinfo)
        {
            TimeDiff = reader.ReadULeb128 ();
            byte subtype = (byte)(exinfo & 0x70);
            if (subtype == TYPE_CLAUSE) {
                ClauseType = reader.ReadULeb128 ();
                ClauseNum = reader.ReadULeb128 ();
                Method = reader.ReadSLeb128 ();
            } else if (subtype == TYPE_THROW) {
                Object = reader.ReadSLeb128 ();
                if ((exinfo & TYPE_EXCEPTION_BT) == TYPE_EXCEPTION_BT)
                    Backtrace = new Backtrace (reader);
            }
        }
Example #21
0
        public readonly long[] ObjAddr; //  num_objects object pointer differences from obj_base

        #endregion Fields

        #region Constructors

        MoveGcEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            ulong num = reader.ReadULeb128 ();
            ObjAddr = new long[num];
            for (ulong i = 0; i < num; i++) {
                ObjAddr [i] = reader.ReadSLeb128 ();
            }
        }
Example #22
0
        public readonly ulong HeapSize; // new heap size

        #endregion Fields

        #region Constructors

        ResizeGcEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            HeapSize = reader.ReadULeb128 ();
        }
Example #23
0
 public static Event Read(LogFileReader reader, byte exinfo)
 {
     return new HeapEvent (reader, exinfo);
 }
Example #24
0
 public RuntimeEvent(LogFileReader reader)
 {
     Time = reader.ReadULeb128 ();
 }
Example #25
0
 public CountersEvent(LogFileReader reader)
 {
     Timestamp = reader.ReadULeb128 ();
     var index = reader.ReadULeb128 ();
     while (index != 0) {
         new CounterValue (reader, index);
         index = reader.ReadULeb128 ();
     }
 }
Example #26
0
 public RuntimeJitHelperEvent(LogFileReader reader)
     : base(reader)
 {
     Type = reader.ReadULeb128 ();
     BufferAddress = reader.ReadSLeb128 ();
     BufferSize = reader.ReadULeb128 ();
     if (Type == (ulong)MonoProfilerCodeBufferType.MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE) {
         Name = reader.ReadNullTerminatedString ();
     }
 }
Example #27
0
 public static new Event Read(LogFileReader reader)
 {
     return new MetadataEvent (reader);
 }
Example #28
0
 public static LogBuffer Read(string fileName)
 {
     using (var reader = new LogFileReader (fileName)) {
         return new LogBuffer (reader);
     }
 }
Example #29
0
 public static Event CreateEvent(LogFileReader reader, EventType type, byte extendedInfo)
 {
     switch (type) {
     case EventType.Alloc:
         return AllocEvent.Read (reader, extendedInfo);
     case EventType.Exception:
         return ExceptionEvent.Read (reader, extendedInfo);
     case EventType.Gc:
         switch (extendedInfo) {
         case TYPE_GC_EVENT:
             return GcEvent.Read (reader);
         case TYPE_GC_RESIZE:
             return ResizeGcEvent.Read (reader);
         case TYPE_GC_MOVE:
             return MoveGcEvent.Read (reader);
         case TYPE_GC_HANDLE_CREATED:
             return HandleCreatedGcEvent.Read (reader);
         case TYPE_GC_HANDLE_DESTROYED:
             return HandleDestroyedGcEvent.Read (reader);
         }
         throw new InvalidOperationException ("unknown gc type:" + extendedInfo);
     case EventType.Heap:
         return HeapEvent.Read (reader, extendedInfo);
     case EventType.Metadata:
         return MetadataEvent.Read (reader);
     case EventType.Method:
         return MethodEvent.Read (reader, extendedInfo);
     case EventType.Monitor:
         return MonitiorEvent.Read (reader, extendedInfo);
     case EventType.Sample:
         return SampleEvent.Read (reader, extendedInfo);
     case EventType.Runtime:
         return RuntimeEvent.Read (reader, extendedInfo);
     }
     throw new InvalidOperationException ("invalid event type " + type);
 }
Example #30
0
 public HitSampleEvent(LogFileReader reader)
 {
     SampleType = (SampleType) reader.ReadULeb128 ();
     Timestamp = reader.ReadULeb128 ();
     ulong count = reader.ReadULeb128 ();
     InstructionPointers = new long [count];
     for (uint n=0; n<count; n++)
         InstructionPointers [n] = reader.ReadSLeb128 ();
 }
Example #31
0
        public readonly long Pointer; // pointer of the metadata type depending on mtype

        #endregion Fields

        #region Constructors

        MetadataEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128 ();
            MType = (MetaDataType)reader.ReadByte ();
            Pointer = reader.ReadSLeb128 ();
            switch (MType) {
            case MetaDataType.Class:
                Image = reader.ReadSLeb128 ();
                Flags = reader.ReadULeb128 ();
                Name = reader.ReadNullTerminatedString ();
                break;
            case MetaDataType.Image:
                Flags = reader.ReadULeb128 ();
                Name = reader.ReadNullTerminatedString ();
                break;
            case MetaDataType.Thread:
                Flags = reader.ReadULeb128 ();
                Name = reader.ReadNullTerminatedString ();
                break;
            }
        }