@@ -4123,16 +4123,54 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41234123 }
41244124 else if ( streamName == "CCW Ref Count" )
41254125 {
4126+ // TODO use the callback model. We seem to have an issue getting the names however.
4127+ foreach ( var data in events . ByEventType < CCWRefCountChangeTraceData > ( ) )
4128+ {
4129+ sample . Metric = 1 ;
4130+ sample . TimeRelativeMSec = data . TimeStampRelativeMSec ;
4131+ var stackIndex = stackSource . GetCallStack ( data . CallStackIndex ( ) , data ) ;
4132+
4133+ var operation = data . Operation ;
4134+ if ( operation . StartsWith ( "Release" , StringComparison . OrdinalIgnoreCase ) )
4135+ sample . Metric = - 1 ;
4136+
4137+ var ccwRefKindName = "CCW " + operation ;
4138+ var ccwRefKindIndex = stackSource . Interner . FrameIntern ( ccwRefKindName ) ;
4139+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefKindIndex , stackIndex ) ;
4140+
4141+ var ccwRefCountName = "CCW NewRefCnt " + data . NewRefCount . ToString ( ) ;
4142+ var ccwRefCountIndex = stackSource . Interner . FrameIntern ( ccwRefCountName ) ;
4143+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefCountIndex , stackIndex ) ;
4144+
4145+ var ccwInstanceName = "CCW Instance 0x" + data . COMInterfacePointer . ToString ( "x" ) ;
4146+ var ccwInstanceIndex = stackSource . Interner . FrameIntern ( ccwInstanceName ) ;
4147+ stackIndex = stackSource . Interner . CallStackIntern ( ccwInstanceIndex , stackIndex ) ;
4148+
4149+ var ccwTypeName = "CCW Type " + data . NameSpace + "." + data . ClassName ;
4150+ var ccwTypeIndex = stackSource . Interner . FrameIntern ( ccwTypeName ) ;
4151+ stackIndex = stackSource . Interner . CallStackIntern ( ccwTypeIndex , stackIndex ) ;
4152+
4153+ sample . StackIndex = stackIndex ;
4154+ stackSource . AddSample ( sample ) ;
4155+ }
4156+ }
4157+ else if ( streamName == ".NET Native CCW Ref Count" )
4158+ {
4159+ var objectTypeMap = new Dictionary < long , long > ( 1000 ) ;
41264160 var interopTraceEventParser = new InteropTraceEventParser ( eventSource ) ;
4161+ interopTraceEventParser . AddCallbackForEvent < TaskCCWCreationArgs > ( null , args =>
4162+ {
4163+ if ( ! objectTypeMap . ContainsKey ( args . objectID ) )
4164+ objectTypeMap . Add ( args . objectID , args . targetObjectIDType ) ;
4165+ } ) ;
41274166 interopTraceEventParser . AddCallbackForEvents < TaskCCWQueryRuntimeClassNameArgs > ( args =>
41284167 {
4129- sample . Metric = 1 ;
41304168 sample . TimeRelativeMSec = args . TimeStampRelativeMSec ;
41314169 var stackIndex = stackSource . GetCallStack ( args . CallStackIndex ( ) , args ) ;
41324170
41334171 var ccwRefKindName = "CCW QueryRuntimeClassName" ;
41344172 var ccwRefKindNameIndex = stackSource . Interner . FrameIntern ( ccwRefKindName ) ;
4135- stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
4173+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
41364174
41374175 sample . StackIndex = stackIndex ;
41384176 stackSource . AddSample ( sample ) ;
@@ -4141,14 +4179,24 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41414179 sample . Metric = 1 ;
41424180 sample . TimeRelativeMSec = args . TimeStampRelativeMSec ;
41434181 var stackIndex = stackSource . GetCallStack ( args . CallStackIndex ( ) , args ) ;
4144-
4182+
41454183 var ccwRefKindName = "CCW RefCountInc" ;
41464184 var ccwRefKindNameIndex = stackSource . Interner . FrameIntern ( ccwRefKindName ) ;
4147- stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
4185+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
4186+
4187+ var objectId = "Object ID " + args . objectID ;
4188+ var objectIdIndex = stackSource . Interner . FrameIntern ( objectId ) ;
4189+ stackIndex = stackSource . Interner . CallStackIntern ( objectIdIndex , stackIndex ) ;
41484190
4191+ if ( objectTypeMap . ContainsKey ( args . objectID ) )
4192+ {
4193+ var objectType = "Object Type " + objectTypeMap [ args . objectID ] ;
4194+ var objectTypeIndex = stackSource . Interner . FrameIntern ( objectType ) ;
4195+ stackIndex = stackSource . Interner . CallStackIntern ( objectTypeIndex , stackIndex ) ;
4196+ }
41494197 var ccwRefCount = "CCW NewRefCnt " + args . refCount ;
41504198 var ccwRefCountIndex = stackSource . Interner . FrameIntern ( ccwRefCount . ToString ( ) ) ;
4151- stackSource . Interner . CallStackIntern ( ccwRefCountIndex , stackIndex ) ;
4199+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefCountIndex , stackIndex ) ;
41524200
41534201 sample . StackIndex = stackIndex ;
41544202 stackSource . AddSample ( sample ) ;
@@ -4161,11 +4209,11 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41614209
41624210 var ccwRefKindName = "CCW RefCountDec" ;
41634211 var ccwRefKindNameIndex = stackSource . Interner . FrameIntern ( ccwRefKindName ) ;
4164- stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
4212+ stackIndex = stackSource . Interner . CallStackIntern ( ccwRefKindNameIndex , stackIndex ) ;
41654213
41664214 var ccwRefCount = "CCW NewRefCnt " + args . refCount ;
41674215 var ccwRefCountIndex = stackSource . Interner . FrameIntern ( ccwRefCount . ToString ( ) ) ;
4168- stackSource . Interner . CallStackIntern ( ccwRefCountIndex , stackIndex ) ;
4216+ stackIndex = stackIndex = stackSource . Interner . CallStackIntern ( ccwRefCountIndex , stackIndex ) ;
41694217
41704218 sample . StackIndex = stackIndex ;
41714219 stackSource . AddSample ( sample ) ;
@@ -5781,6 +5829,7 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
57815829 bool hasDotNetHeapDumps = false ;
57825830 bool hasWCFRequests = false ;
57835831 bool hasCCWRefCountStacks = false ;
5832+ bool hasNetNativeCCWRefCountStacks = false ;
57845833 bool hasWindowsRefCountStacks = false ;
57855834 bool hasPinObjectAtGCTime = false ;
57865835 bool hasObjectUpdate = false ;
@@ -5823,8 +5872,10 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
58235872 hasMemAllocStacks = true ;
58245873 if ( name . StartsWith ( "GC/SampledObjectAllocation" ) )
58255874 hasMemAllocStacks = true ;
5826- if ( name . StartsWith ( "GC/CCWRefCountChange" ) || name . StartsWith ( "TaskCCWRef" ) )
5875+ if ( name . StartsWith ( "GC/CCWRefCountChange" ) )
58275876 hasCCWRefCountStacks = true ;
5877+ if ( name . StartsWith ( "TaskCCWRef" ) )
5878+ hasNetNativeCCWRefCountStacks = true ;
58285879 if ( name . StartsWith ( "Object/CreateHandle" ) )
58295880 hasWindowsRefCountStacks = true ;
58305881 if ( name . StartsWith ( "Image" ) )
@@ -5923,6 +5974,9 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
59235974 if ( hasCCWRefCountStacks )
59245975 advanced . Children . Add ( new PerfViewStackSource ( this , "CCW Ref Count" ) ) ;
59255976
5977+ if ( hasNetNativeCCWRefCountStacks )
5978+ advanced . Children . Add ( new PerfViewStackSource ( this , ".NET Native CCW Ref Count" ) ) ;
5979+
59265980 if ( hasWindowsRefCountStacks )
59275981 advanced . Children . Add ( new PerfViewStackSource ( this , "Windows Handle Ref Count" ) ) ;
59285982
0 commit comments