Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkrueger <mkrueger@novell.com>2011-02-22 16:15:43 +0300
committermkrueger <mkrueger@novell.com>2011-02-22 16:15:43 +0300
commit538a21284c65b6dd9092713fdbe001d48c421e95 (patch)
treef25d5ec8e8c9551bd7cca2e0056e051aa703956d /main/src/addins/MonoDevelop.ProfilerGui
parent72e948e57f9c8716ba128950137a6f9d84ee84f6 (diff)
Overworked the profiler data layer. The data layer is now updated to
the latest github version of the logging profiler & the c# representation now takes much less memory space and loads faster.
Diffstat (limited to 'main/src/addins/MonoDevelop.ProfilerGui')
-rw-r--r--main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/ProfileDialog.cs128
-rw-r--r--main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/TimeLineWidget.cs2
-rw-r--r--main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.csproj37
-rw-r--r--main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/Event.cs739
-rw-r--r--main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/EventVisitor.cs78
5 files changed, 790 insertions, 194 deletions
diff --git a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/ProfileDialog.cs b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/ProfileDialog.cs
index 64d473fd5e..23e166c69b 100644
--- a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/ProfileDialog.cs
+++ b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/ProfileDialog.cs
@@ -470,32 +470,44 @@ namespace MonoDevelop.Profiler
threadDictionary.Clear ();
}
- public override object Visit (MethodEvent methodEvent)
+ public override object Visit (MethodEnterEvent methodEvent)
+ {
+ methodBase += methodEvent.Method;
+ TimeBase += methodEvent.TimeDiff;
+ if (ShouldLog) {
+ eventCount++;
+ if (!nameDictionary.ContainsKey (methodBase))
+ nameDictionary [methodBase] = "[Unknown method]";
+
+ currentThread.PushMethod (methodBase, TimeBase);
+ }
+ return null;
+ }
+
+ public override object Visit (MethodJitEvent methodEvent)
+ {
+ methodBase += methodEvent.Method;
+ TimeBase += methodEvent.TimeDiff;
+ nameDictionary [methodBase] = methodEvent.Name;
+ return null;
+ }
+
+ public override object Visit (MethodExcLeaveEvent methodEvent)
+ {
+ methodBase += methodEvent.Method;
+ TimeBase += methodEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MethodLeaveEvent methodEvent)
{
methodBase += methodEvent.Method;
TimeBase += methodEvent.TimeDiff;
- switch (methodEvent.Type) {
- case MethodEvent.MethodType.Jit:
- nameDictionary [methodBase] = methodEvent.Name;
- break;
-
- case MethodEvent.MethodType.Enter:
- if (ShouldLog) {
- eventCount++;
- if (!nameDictionary.ContainsKey (methodBase))
- nameDictionary [methodBase] = "[Unknown method]";
-
- currentThread.PushMethod (methodBase, TimeBase);
- }
- break;
- case MethodEvent.MethodType.Leave:
- if (ShouldLog) {
- if (!nameDictionary.ContainsKey (methodBase))
- nameDictionary [methodBase] = "[Unknown method]";
- currentThread.PopMethod (methodBase, TimeBase);
- }
- break;
+ if (ShouldLog) {
+ if (!nameDictionary.ContainsKey (methodBase))
+ nameDictionary [methodBase] = "[Unknown method]";
+ currentThread.PopMethod (methodBase, TimeBase);
}
return null;
}
@@ -508,13 +520,19 @@ namespace MonoDevelop.Profiler
}
}
- public override object Visit (ExceptionEvent exceptionEvent)
+ public override object Visit (ExceptionClauseEvent exceptionEvent)
{
methodBase += exceptionEvent.Method;
TimeBase += exceptionEvent.TimeDiff;
return null;
}
+ public override object Visit (ExceptionThrowEvent exceptionEvent)
+ {
+ TimeBase += exceptionEvent.TimeDiff;
+ return null;
+ }
+
public override object Visit (AllocEvent allocEvent)
{
TimeBase += allocEvent.TimeDiff;
@@ -539,25 +557,59 @@ namespace MonoDevelop.Profiler
return null;
}
- public override object Visit (HeapEvent heapEvent)
+ public override object Visit (HeapEndEvent heapEvent)
{
TimeBase += heapEvent.TimeDiff;
return null;
}
- public override object Visit (MetadataEvent metadataEvent)
+ public override object Visit (HeapStartEvent heapEvent)
{
- TimeBase += metadataEvent.TimeDiff;
- switch (metadataEvent.MType) {
- case MetadataEvent.MetaDataType.Thread:
- ThreadContext ctx;
- long threadId = currentBuffer.Header.PtrBase * metadataEvent.Pointer;
- if (!threadDictionary.TryGetValue (threadId, out ctx)) {
- threadDictionary [threadId] = ctx = new ThreadContext () { ThreadId = threadId };
- }
- ctx.Name = metadataEvent.Name;
- break;
+ TimeBase += heapEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (HeapObjectEvent heapEvent)
+ {
+ TimeBase += heapEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MetaDataAssemblyEvent metaDataEvent)
+ {
+ TimeBase += metaDataEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MetaDataClassEvent metaDataEvent)
+ {
+ TimeBase += metaDataEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MetaDataDomainEvent metaDataEvent)
+ {
+ TimeBase += metaDataEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MetaDataImageEvent metaDataEvent)
+ {
+ TimeBase += metaDataEvent.TimeDiff;
+ return null;
+ }
+
+ public override object Visit (MetaDataThreadEvent metaDataEvent)
+ {
+ TimeBase += metaDataEvent.TimeDiff;
+
+ ThreadContext ctx;
+ long threadId = currentBuffer.Header.PtrBase * metaDataEvent.Pointer;
+ if (!threadDictionary.TryGetValue (threadId, out ctx)) {
+ threadDictionary [threadId] = ctx = new ThreadContext () { ThreadId = threadId };
}
+ ctx.Name = metaDataEvent.Name;
+
return null;
}
@@ -578,6 +630,12 @@ namespace MonoDevelop.Profiler
TimeBase += resizeGcEvent.TimeDiff;
return null;
}
+
+ public override object Visit (SampleUBinEvent sampleUBinEvent)
+ {
+ TimeBase += sampleUBinEvent.TimeDiff;
+ return null;
+ }
}
}
}
diff --git a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/TimeLineWidget.cs b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/TimeLineWidget.cs
index 59491f7754..7897df3299 100644
--- a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/TimeLineWidget.cs
+++ b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.Gui/TimeLineWidget.cs
@@ -90,7 +90,7 @@ namespace MonoDevelop.Profiler
{
if (x >= boxWidth) {
double length = Allocation.Width - boxWidth;
- double displayLength = length / 2;
+ //double displayLength = length / 2;
slider = Math.Max (0, (int)((dialog.visitor.TimeBase - dialog.T0) / 100000.0 * (x - boxWidth) / length));
QueueDraw ();
diff --git a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.csproj b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.csproj
index 015303e699..b462f565a0 100644
--- a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.csproj
+++ b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler.csproj
@@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MonoDevelop.Profiler</RootNamespace>
<AssemblyName>MonoDevelop.Profiler</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@@ -46,25 +46,8 @@
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="System.Core" />
- <Reference Include="MonoDevelop.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\build\bin\MonoDevelop.Core.dll</HintPath>
- <Private>False</Private>
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\build\bin\MonoDevelop.Ide.dll</HintPath>
- <Private>False</Private>
- <Package>monodevelop</Package>
- </Reference>
- <Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<Reference Include="Mono.Cairo" />
- <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\build\bin\Mono.TextEditor.dll</HintPath>
- <Package>monodevelop</Package>
- </Reference>
+ <Reference Include="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
@@ -93,7 +76,7 @@
<MonoDevelop>
<Properties>
<Policies>
- <StandardHeader inheritsSet="MITX11License" />
+ <StandardHeader Text="&#xA;${FileName}&#xA; &#xA;Author:&#xA; ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Copyright (c) ${Year} ${CopyrightHolder}&#xA;&#xA;Permission is hereby granted, free of charge, to any person obtaining a copy&#xA;of this software and associated documentation files (the &quot;Software&quot;), to deal&#xA;in the Software without restriction, including without limitation the rights&#xA;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&#xA;copies of the Software, and to permit persons to whom the Software is&#xA;furnished to do so, subject to the following conditions:&#xA;&#xA;The above copyright notice and this permission notice shall be included in&#xA;all copies or substantial portions of the Software.&#xA;&#xA;THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&#xA;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&#xA;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE&#xA;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&#xA;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&#xA;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&#xA;THE SOFTWARE." IncludeInNewFiles="True" />
</Policies>
</Properties>
</MonoDevelop>
@@ -102,4 +85,18 @@
<Folder Include="MonoDevelop.Profiler\" />
<Folder Include="MonoDevelop.Profiler.Gui\" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
+ <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project>
+ <Name>MonoDevelop.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj">
+ <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project>
+ <Name>MonoDevelop.Ide</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\core\Mono.Texteditor\Mono.TextEditor.csproj">
+ <Project>{A2329308-3751-4DBD-9A75-5F7B8B024625}</Project>
+ <Name>Mono.TextEditor</Name>
+ </ProjectReference>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/Event.cs b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/Event.cs
index 8f5f2c7d3d..6e68c76ecd 100644
--- a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/Event.cs
+++ b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/Event.cs
@@ -39,7 +39,8 @@ namespace MonoDevelop.Profiler
Method = 3,
Exception = 4,
Monitor = 5,
- Heap = 6
+ Heap = 6,
+ Sample = 7
}
public class Backtrace
@@ -71,19 +72,49 @@ namespace MonoDevelop.Profiler
protected set;
}
+ // extended type for TYPE_HEAP
+ public const byte TYPE_HEAP_START = 0 << 4;
+ public const byte TYPE_HEAP_END = 1 << 4;
+ public const byte TYPE_HEAP_OBJECT = 2 << 4;
+ public const byte TYPE_HEAP_ROOT = 3 << 4;
+
+ // extended type for TYPE_GC
public const byte TYPE_GC_EVENT = 1 << 4;
public const byte TYPE_GC_RESIZE = 2 << 4;
public const byte TYPE_GC_MOVE = 3 << 4;
public const byte TYPE_GC_HANDLE_CREATED = 4 << 4;
public const byte TYPE_GC_HANDLE_DESTROYED = 5 << 4;
+ // extended type for TYPE_METHOD
+ public const byte TYPE_LEAVE = 1 << 4;
+ public const byte TYPE_ENTER = 2 << 4;
+ public const byte TYPE_EXC_LEAVE = 3 << 4;
+ public const byte TYPE_JIT = 4 << 4;
+
+ // extended type for TYPE_EXCEPTION
+ public const byte TYPE_THROW = 0 << 4;
+ public const byte TYPE_CLAUSE = 1 << 4;
+ public const byte TYPE_EXCEPTION_BT = 1 << 7;
+
+ // extended type for TYPE_SAMPLE
+ public const byte TYPE_SAMPLE_HIT = 0 << 4;
+ public const byte TYPE_SAMPLE_USYM = 1 << 4;
+ public const byte TYPE_SAMPLE_UBIN = 2 << 4;
+
public static Event CreateEvent (BinaryReader reader,EventType type, byte extendedInfo)
{
switch (type) {
case EventType.Alloc:
return AllocEvent.Read (reader, extendedInfo);
case EventType.Exception:
- return ExceptionEvent.Read (reader, extendedInfo);
+ switch (extendedInfo & (TYPE_EXCEPTION_BT - 1)) {
+ case TYPE_CLAUSE:
+ return new ExceptionClauseEvent (reader);
+ case TYPE_THROW:
+ return new ExceptionThrowEvent (reader);
+ default:
+ throw new InvalidOperationException ("Unknown exception event type:" + (extendedInfo & (TYPE_EXCEPTION_BT - 1)));
+ }
case EventType.Gc:
switch (extendedInfo) {
case TYPE_GC_EVENT:
@@ -99,13 +130,46 @@ namespace MonoDevelop.Profiler
}
throw new InvalidOperationException ("unknown gc type:" + extendedInfo);
case EventType.Heap:
- return HeapEvent.Read (reader, extendedInfo);
+ switch (extendedInfo) {
+ case TYPE_HEAP_START:
+ return new HeapStartEvent (reader);
+ case TYPE_HEAP_END:
+ return new HeapEndEvent (reader);
+ case TYPE_HEAP_OBJECT:
+ return new HeapObjectEvent (reader);
+ case TYPE_HEAP_ROOT:
+ return new HeapRootEvent (reader);
+ default:
+ throw new InvalidOperationException ("Unknown heap event type:" + extendedInfo);
+ }
case EventType.Metadata:
return MetadataEvent.Read (reader);
case EventType.Method:
- return MethodEvent.Read (reader, extendedInfo);
+ switch (extendedInfo) {
+ case TYPE_LEAVE:
+ return new MethodLeaveEvent (reader);
+ case TYPE_ENTER:
+ return new MethodEnterEvent (reader);
+ case TYPE_EXC_LEAVE:
+ return new MethodExcLeaveEvent (reader);
+ case TYPE_JIT:
+ return new MethodJitEvent (reader);
+ default:
+ throw new InvalidOperationException ("Unknown method event type:" + extendedInfo);
+ }
case EventType.Monitor:
return MonitiorEvent.Read (reader, extendedInfo);
+ case EventType.Sample:
+ switch (extendedInfo) {
+ case TYPE_SAMPLE_HIT:
+ return new SampleHitEvent (reader);
+ case TYPE_SAMPLE_USYM:
+ return new SampleUSymEvent (reader);
+ case TYPE_SAMPLE_UBIN:
+ return new SampleUBinEvent (reader);
+ default:
+ throw new InvalidOperationException ("Unknown sample event:" + extendedInfo);
+ }
}
throw new InvalidOperationException ("invalid event type " + type);
}
@@ -121,13 +185,26 @@ namespace MonoDevelop.Profiler
public abstract object Accept (EventVisitor visitor);
}
- // type == Alloc
+ #region Alloc
public class AllocEvent : Event
{
public const byte TYPE_ALLOC_BT = 1 << 4;
- public readonly long Ptr; // class as a byte difference from ptr_base
- public readonly long Obj; // object address as a byte difference from obj_base
- public readonly ulong Size; // size of the object in the heap
+
+ /// <summary>
+ /// The class as a byte difference from ptr_base.
+ /// </summary>
+ public readonly long Ptr;
+
+ /// <summary>
+ /// The object address as a byte difference from obj_base.
+ /// </summary>
+ public readonly long Obj;
+
+ /// <summary>
+ /// The size of the object in the heap.
+ /// </summary>
+ public readonly ulong Size;
+
public readonly Backtrace Backtrace;
AllocEvent (BinaryReader reader, byte extendedInfo)
@@ -150,11 +227,15 @@ namespace MonoDevelop.Profiler
return visitor.Visit (this);
}
}
+ #endregion
- // type == Gc
+ #region Gc
public class ResizeGcEvent : Event
{
- public readonly ulong HeapSize; // new heap size
+ /// <summary>
+ /// The new heap size.
+ /// </summary>
+ public readonly ulong HeapSize;
ResizeGcEvent (BinaryReader reader)
{
@@ -175,13 +256,30 @@ namespace MonoDevelop.Profiler
public class GcEvent : Event
{
- public readonly ulong GcEventType; // GC event (MONO_GC_EVENT_* from profiler.h)
+ public enum MonoGCEvent
+ {
+ Start,
+ MarkStart,
+ MarkEnd,
+ ReclaimStart,
+ ReclaimEnd,
+ End,
+ PreStopWorld,
+ PostStopWorld,
+ PreStartWorld,
+ PostStartWorld
+ }
+
+ /// <summary>
+ /// The GC event.
+ /// </summary>
+ public readonly MonoGCEvent GcEventType;
public readonly ulong Generation; // GC generation event refers to
GcEvent (BinaryReader reader)
{
TimeDiff = reader.ReadULeb128 ();
- GcEventType = reader.ReadULeb128 ();
+ GcEventType = (MonoGCEvent)reader.ReadULeb128 ();
Generation = reader.ReadULeb128 ();
}
@@ -198,7 +296,10 @@ namespace MonoDevelop.Profiler
public class MoveGcEvent : Event
{
- public readonly long[] ObjAddr; // num_objects object pointer differences from obj_base
+ /// <summary>
+ /// The num_objects object pointer differences from obj_base.
+ /// </summary>
+ public readonly long[] ObjAddr;
MoveGcEvent (BinaryReader reader)
{
@@ -223,14 +324,25 @@ namespace MonoDevelop.Profiler
public class HandleCreatedGcEvent : Event
{
- public readonly ulong HandleType; // GC handle type (System.Runtime.InteropServices.GCHandleType)
- public readonly ulong Handle; // GC handle value
- public readonly long ObjAddr; // object pointer differences from obj_base
+ /// <summary>
+ /// The GC handle type (System.Runtime.InteropServices.GCHandleType).
+ /// </summary>
+ public readonly System.Runtime.InteropServices.GCHandleType HandleType;
+
+ /// <summary>
+ /// The GC handle value.
+ /// </summary>
+ public readonly ulong Handle;
+
+ /// <summary>
+ /// The object pointer differences from obj_base.
+ /// </summary>
+ public readonly long ObjAddr;
HandleCreatedGcEvent (BinaryReader reader)
{
TimeDiff = reader.ReadULeb128 ();
- HandleType = reader.ReadULeb128 ();
+ HandleType = (System.Runtime.InteropServices.GCHandleType)reader.ReadULeb128 ();
Handle = reader.ReadULeb128 ();
ObjAddr = reader.ReadSLeb128 ();
}
@@ -248,13 +360,20 @@ namespace MonoDevelop.Profiler
public class HandleDestroyedGcEvent : Event
{
- public readonly ulong HandleType; // GC handle type (System.Runtime.InteropServices.GCHandleType)
- public readonly ulong Handle; // GC handle value
+ /// <summary>
+ /// GC handle type (System.Runtime.InteropServices.GCHandleType).
+ /// </summary>
+ public readonly System.Runtime.InteropServices.GCHandleType HandleType;
+
+ /// <summary>
+ /// GC handle value
+ /// </summary>
+ public readonly ulong Handle;
HandleDestroyedGcEvent (BinaryReader reader)
{
TimeDiff = reader.ReadULeb128 ();
- HandleType = reader.ReadULeb128 ();
+ HandleType = (System.Runtime.InteropServices.GCHandleType)reader.ReadULeb128 ();
Handle = reader.ReadULeb128 ();
}
@@ -268,148 +387,308 @@ namespace MonoDevelop.Profiler
return visitor.Visit (this);
}
}
+ #endregion
- // type == Methadata
- public class MetadataEvent : Event
+ #region MetaData
+ public abstract class MetadataEvent : Event
{
- public enum MetaDataType : byte
- {
- Class = 1,
- Image = 2,
- Assembly = 3,
- Domain = 4,
- Thread = 5
- }
+ const byte TYPE_CLASS = 1;
+ const byte TYPE_IMAGE = 2;
+ const byte TYPE_ASSEMBLY = 3;
+ const byte TYPE_DOMAIN = 4;
+ const byte TYPE_THREAD = 5;
- public readonly MetaDataType MType; // metadata type, one of: TYPE_CLASS, TYPE_IMAGE, TYPE_ASSEMBLY, TYPE_DOMAINTYPE_THREAD
- public readonly long Pointer; // pointer of the metadata type depending on mtype
-
- public readonly ulong Flags; // must be 0
- public readonly string Name; // full class/image file or thread name
+ /// <summary>
+ /// The pointer of the metadata type depending on mtype.
+ /// </summary>
+ public long Pointer { get; private set; }
- public readonly long Image; // MonoImage* as a pointer difference from ptr_base
-
- MetadataEvent (BinaryReader reader)
+ public static new Event Read (BinaryReader 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 ();
+ ulong timeDiff = reader.ReadULeb128 ();
+ byte type = reader.ReadByte ();
+ long pointer = reader.ReadSLeb128 ();
+
+ MetadataEvent result;
+ switch (type) {
+ case TYPE_CLASS:
+ result = new MetaDataClassEvent (reader);
+ break;
+ case TYPE_IMAGE:
+ result = new MetaDataImageEvent (reader);
break;
- case MetaDataType.Image:
- Flags = reader.ReadULeb128 ();
- Name = reader.ReadNullTerminatedString ();
+ case TYPE_ASSEMBLY:
+ result = new MetaDataAssemblyEvent ();
break;
- case MetaDataType.Thread:
- Flags = reader.ReadULeb128 ();
- Name = reader.ReadNullTerminatedString ();
+ case TYPE_DOMAIN:
+ result = new MetaDataDomainEvent ();
break;
+ case TYPE_THREAD:
+ result = new MetaDataThreadEvent (reader);
+ break;
+ default:
+ throw new InvalidOperationException ("Unknown metadata event type:" + type);
}
+ result.TimeDiff = timeDiff;
+ result.Pointer = pointer;
+ return result;
}
-
- public static new Event Read (BinaryReader reader)
+ }
+
+ public class MetaDataClassEvent : MetadataEvent
+ {
+ /// <summary>
+ /// MonoImage* as a pointer difference from ptr_base
+ /// </summary>
+ public readonly long Image;
+
+ /// <summary>
+ /// must be 0
+ /// </summary>
+ public readonly ulong Flags;
+
+ /// <summary>
+ /// full class/image file or thread name
+ /// </summary>
+ public readonly string Name;
+
+ internal MetaDataClassEvent (BinaryReader reader)
{
- return new MetadataEvent (reader);
+ Image = reader.ReadSLeb128 ();
+ Flags = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
}
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class MetaDataAssemblyEvent : MetadataEvent
+ {
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class MetaDataDomainEvent : MetadataEvent
+ {
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+ public class MetaDataImageEvent : MetadataEvent
+ {
+ /// <summary>
+ /// must be 0
+ /// </summary>
+ public readonly ulong Flags;
+
+ /// <summary>
+ /// full class/image file or thread name
+ /// </summary>
+ public readonly string Name;
+
+ internal MetaDataImageEvent (BinaryReader reader)
+ {
+ Flags = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
+ }
+
public override object Accept (EventVisitor visitor)
{
return visitor.Visit (this);
}
}
- // type == Method
- public class MethodEvent : Event
+ public class MetaDataThreadEvent : MetadataEvent
{
- public enum MethodType
+ /// <summary>
+ /// must be 0
+ /// </summary>
+ public readonly ulong Flags;
+
+ /// <summary>
+ /// full class/image file or thread name
+ /// </summary>
+ public readonly string Name;
+
+ internal MetaDataThreadEvent (BinaryReader reader)
{
- Leave = 1 << 4,
- Enter = 2 << 4,
- ExcLeave = 3 << 4,
- Jit = 4 << 4
- };
+ Flags = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
+ }
- public readonly long Method; // MonoMethod* as a pointer difference from the last such pointer or the buffer method_base
- public readonly MethodType Type;
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+ #endregion
+
+ #region Method
+ public class MethodLeaveEvent : Event
+ {
+ /// <summary>
+ /// The MonoMethod* as a pointer difference from the last such pointer or the buffer method_base.
+ /// </summary>
+ public readonly long Method;
+
+ public MethodLeaveEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ Method = reader.ReadSLeb128 ();
+ }
- public readonly long CodeAddress; // pointer to the native code as a diff from ptr_base
- public readonly ulong CodeSize; // size of the generated code
- public readonly string Name; // full method name
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class MethodEnterEvent : Event
+ {
+ /// <summary>
+ /// The MonoMethod* as a pointer difference from the last such pointer or the buffer method_base.
+ /// </summary>
+ public readonly long Method;
- MethodEvent (BinaryReader reader, byte exinfo)
+ public MethodEnterEvent (BinaryReader reader)
{
TimeDiff = reader.ReadULeb128 ();
Method = reader.ReadSLeb128 ();
- Type = (MethodType)exinfo;
- if (Type == MethodType.Jit) {
- CodeAddress = reader.ReadSLeb128 ();
- CodeSize = reader.ReadULeb128 ();
- Name = reader.ReadNullTerminatedString ();
- }
}
-
- public static Event Read (BinaryReader reader, byte exinfo)
+
+ public override object Accept (EventVisitor visitor)
{
- return new MethodEvent (reader, exinfo);
+ return visitor.Visit (this);
}
-
+ }
+
+ public class MethodExcLeaveEvent : Event
+ {
+ /// <summary>
+ /// The MonoMethod* as a pointer difference from the last such pointer or the buffer method_base.
+ /// </summary>
+ public readonly long Method;
+
+ public MethodExcLeaveEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ Method = reader.ReadSLeb128 ();
+ }
+
public override object Accept (EventVisitor visitor)
{
return visitor.Visit (this);
}
}
- // type == Exception
- public class ExceptionEvent : Event
+ public class MethodJitEvent : Event
{
- public const byte TYPE_THROW = 0 << 4;
- public const byte TYPE_CLAUSE = 1 << 4;
- public const byte TYPE_EXCEPTION_BT = 1 << 7;
+ /// <summary>
+ /// The MonoMethod* as a pointer difference from the last such pointer or the buffer method_base.
+ /// </summary>
+ public readonly long Method;
- // Type clause
- public readonly ulong ClauseType; // finally/catch/fault/filter
- public readonly ulong ClauseNum; // the clause number in the method header
- public readonly long Method; // MonoMethod* as a pointer difference from the last such pointer or the buffer method_base
+ /// <summary>
+ /// The pointer to the native code as a diff from ptr_base.
+ /// </summary>
+ public readonly long CodeAddress;
- // Type throw
- 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.
+ /// <summary>
+ /// The size of the generated code.
+ /// </summary>
+ public readonly ulong CodeSize;
- ExceptionEvent (BinaryReader reader, byte exinfo)
+ /// <summary>
+ /// The full method name.
+ /// </summary>
+ public readonly string Name;
+
+ public MethodJitEvent (BinaryReader reader)
{
TimeDiff = reader.ReadULeb128 ();
- exinfo &= TYPE_EXCEPTION_BT - 1;
- if (exinfo == TYPE_CLAUSE) {
- ClauseType = reader.ReadULeb128 ();
- ClauseNum = reader.ReadULeb128 ();
- Method = reader.ReadSLeb128 ();
- } else if (exinfo == TYPE_THROW) {
- Object = reader.ReadSLeb128 ();
- }
+ Method = reader.ReadSLeb128 ();
+ CodeAddress = reader.ReadSLeb128 ();
+ CodeSize = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
}
-
- public static Event Read (BinaryReader reader, byte exinfo)
+
+ public override object Accept (EventVisitor visitor)
{
- return new ExceptionEvent (reader, exinfo);
+ return visitor.Visit (this);
}
-
+ }
+ #endregion
+
+ #region Exception
+ public class ExceptionClauseEvent : Event
+ {
+ /// <summary>
+ /// finally/catch/fault/filter
+ /// </summary>
+ public readonly ulong ClauseType;
+
+ /// <summary>
+ /// the clause number in the method header
+ /// </summary>
+ public readonly ulong ClauseNum;
+
+ /// <summary>
+ /// MonoMethod* as a pointer difference from the last such pointer or the buffer method_base
+ /// </summary>
+ public readonly long Method;
+
+ internal ExceptionClauseEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ ClauseType = reader.ReadULeb128 ();
+ ClauseNum = reader.ReadULeb128 ();
+ Method = reader.ReadSLeb128 ();
+ }
+
public override object Accept (EventVisitor visitor)
{
return visitor.Visit (this);
}
}
- // type == Monitor
+ public class ExceptionThrowEvent : Event
+ {
+ /// <summary>
+ /// the object that was thrown as a difference from obj_base If the TYPE_EXCEPTION_BT flag is set, a backtrace follows.
+ /// </summary>
+ public readonly long Object;
+
+ internal ExceptionThrowEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ Object = reader.ReadSLeb128 ();
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+ #endregion
+
+ #region Monitor
public class MonitiorEvent : Event
{
public const int MONO_PROFILER_MONITOR_CONTENTION = 1;
public const int MONO_PROFILER_MONITOR_DONE = 2;
public const int MONO_PROFILER_MONITOR_FAIL = 3;
- public readonly long Object; // the lock object as a difference from obj_base
+ /// <summary>
+ /// the lock object as a difference from obj_base
+ /// </summary>
+ public readonly long Object;
public readonly Backtrace Backtrace;
MonitiorEvent (BinaryReader reader, byte exinfo)
@@ -431,43 +710,234 @@ namespace MonoDevelop.Profiler
return visitor.Visit (this);
}
}
+ #endregion
- // type == Heap
- public class HeapEvent : Event
+ #region Heap
+ public class HeapStartEvent : Event
{
- public const byte TYPE_HEAP_START = 0 << 4;
- public const byte TYPE_HEAP_END = 1 << 4;
- public const byte TYPE_HEAP_OBJECT = 2 << 4;
+ public HeapStartEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class HeapEndEvent : Event
+ {
+ public HeapEndEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class HeapObjectEvent : Event
+ {
+ /// <summary>
+ /// the object as a difference from obj_base
+ /// </summary>
+ public readonly long Object;
+
+ /// <summary>
+ /// the object MonoClass* as a difference from ptr_base
+ /// </summary>
+ public readonly long Class;
- public readonly long Object; // the object as a difference from obj_base
- public readonly long Class; // the object MonoClass* as a difference from ptr_base
- public readonly ulong Size; // size of the object on the heap
+ /// <summary>
+ /// size of the object on the heap
+ /// </summary>
+ public readonly ulong Size;
+
+ /// <summary>
+ /// The relative offsets.
+ /// </summary>
public readonly ulong[] RelOffset;
- public readonly long[] ObjectRefs; // object referenced as a difference from obj_base
-
- HeapEvent (BinaryReader reader, byte exinfo)
- {
- if (exinfo == TYPE_HEAP_START) {
- TimeDiff = reader.ReadULeb128 ();
- } else if (exinfo == TYPE_HEAP_END) {
- TimeDiff = reader.ReadULeb128 ();
- } else if (exinfo == TYPE_HEAP_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 ();
- }
+
+ /// <summary>
+ /// object referenced as a difference from obj_base
+ /// </summary>
+ public readonly long[] ObjectRefs;
+
+ public HeapObjectEvent (BinaryReader reader)
+ {
+ 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 ();
+ }
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+
+ public class HeapRootEvent : Event
+ {
+ /// <summary>
+ /// The number of major gcs.
+ /// </summary>
+ public readonly ulong NumGc;
+
+ /// <summary>
+ /// The object as a difference from obj_base.
+ /// </summary>
+ public readonly long[] Object;
+
+ /// <summary>
+ /// The root_type: MonoProfileGCRootType (profiler.h).
+ /// </summary>
+ public readonly ulong[] RootType;
+
+ /// <summary>
+ /// The extra info value.
+ /// </summary>
+ public readonly ulong[] ExtraInfo;
+
+ public HeapRootEvent (BinaryReader reader)
+ {
+ ulong numRoots = reader.ReadULeb128 ();
+ NumGc = reader.ReadULeb128 ();
+
+ Object = new long [numRoots];
+ RootType = new ulong [numRoots];
+ ExtraInfo = new ulong [numRoots];
+
+ for (ulong i = 0; i < numRoots; i++) {
+ Object[i] = reader.ReadSLeb128 ();
+ RootType[i] = reader.ReadULeb128 ();
+ ExtraInfo[i] = reader.ReadULeb128 ();
+ }
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+
+ #endregion
+
+ #region Sample
+ public class SampleHitEvent : Event
+ {
+ public enum SampleType {
+ Cycles = 1,
+ Instructions = 2,
+ CacheMisses = 3,
+ CacheRefs = 4,
+ Branches = 5,
+ BranchMisses = 6
+ }
+
+ /// <summary>
+ /// The type of sample (SAMPLE_*).
+ /// </summary>
+ public SampleType Type { get; private set; }
+
+ /// <summary>
+ /// Nanoseconds since startup (note: different from other timestamps!).
+ /// </summary>
+ public readonly ulong TimeStamp;
+
+ /// <summary>
+ /// The instruction pointer as difference from ptr_base.
+ /// </summary>
+ public readonly long[] Ip;
+
+
+ public SampleHitEvent (BinaryReader reader)
+ {
+ Type = (SampleType)reader.ReadULeb128 ();
+ TimeStamp = reader.ReadULeb128 ();
+ ulong num = reader.ReadULeb128 ();
+ Ip = new long[num];
+ for (ulong i = 0; i < num; i++) {
+ Ip[i] = reader.ReadSLeb128 ();
}
}
- public static Event Read (BinaryReader reader, byte exinfo)
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class SampleUSymEvent : Event
+ {
+ /// <summary>
+ /// The symbol address as a difference from ptr_base.
+ /// </summary>
+ public readonly long Address;
+
+ /// <summary>
+ /// The symbol size (may be 0 if unknown).
+ /// </summary>
+ public readonly ulong Size;
+
+ /// <summary>
+ /// The symbol name.
+ /// </summary>
+ public readonly string Name;
+
+ public SampleUSymEvent (BinaryReader reader)
{
- return new HeapEvent (reader, exinfo);
+ Address = reader.ReadSLeb128 ();
+ Size = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
+ }
+
+ public override object Accept (EventVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+ }
+
+ public class SampleUBinEvent : Event
+ {
+ /// <summary>
+ /// The address where binary has been loaded.
+ /// </summary>
+ public readonly long Address;
+
+ /// <summary>
+ /// The file offset of mapping (the same file can be mapped multiple times).
+ /// </summary>
+ public readonly ulong Offset;
+
+ /// <summary>
+ /// The memory size.
+ /// </summary>
+ public readonly ulong Size;
+
+ /// <summary>
+ /// The binary name.
+ /// </summary>
+ public readonly string Name;
+
+ public SampleUBinEvent (BinaryReader reader)
+ {
+ TimeDiff = reader.ReadULeb128 ();
+ Address = reader.ReadSLeb128 ();
+ Offset = reader.ReadULeb128 ();
+ Size = reader.ReadULeb128 ();
+ Name = reader.ReadNullTerminatedString ();
}
public override object Accept (EventVisitor visitor)
@@ -475,4 +945,5 @@ namespace MonoDevelop.Profiler
return visitor.Visit (this);
}
}
+ #endregion
}
diff --git a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/EventVisitor.cs b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/EventVisitor.cs
index fdf589c7f8..e2ea2f8c00 100644
--- a/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/EventVisitor.cs
+++ b/main/src/addins/MonoDevelop.ProfilerGui/MonoDevelop.Profiler/EventVisitor.cs
@@ -64,17 +64,57 @@ namespace MonoDevelop.Profiler
return null;
}
- public virtual object Visit (MetadataEvent metadataEvent)
+ public virtual object Visit (MetaDataClassEvent metaDataClassEvent)
{
return null;
}
- public virtual object Visit (MethodEvent methodEvent)
+ public virtual object Visit (MetaDataAssemblyEvent metaDataAssemblyEvent )
{
return null;
}
- public virtual object Visit (ExceptionEvent exceptionEvent)
+ public virtual object Visit (MetaDataDomainEvent metaDataDomainEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MetaDataImageEvent metaDataImageEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MetaDataThreadEvent metaDataThreadEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MethodLeaveEvent methodLeaveEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MethodEnterEvent methodEnterEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MethodExcLeaveEvent methodExcLeaveEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (MethodJitEvent methodJitEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (ExceptionClauseEvent exceptionClauseEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (ExceptionThrowEvent exceptionThrowEvent)
{
return null;
}
@@ -84,7 +124,37 @@ namespace MonoDevelop.Profiler
return null;
}
- public virtual object Visit (HeapEvent heapEvent)
+ public virtual object Visit (HeapStartEvent heapStartEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (HeapEndEvent heapEndEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (HeapObjectEvent heapObjectEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (HeapRootEvent heapRootEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (SampleUSymEvent sampleUSymEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (SampleHitEvent sampleHitEvent)
+ {
+ return null;
+ }
+
+ public virtual object Visit (SampleUBinEvent sampleUBinEvent)
{
return null;
}