Getting a list of all the subscribers to an event with WinDbg and SOS

I was wondering and Lee Culver from the CLR Quick Response Team was kind enough to give me an answer. The output below is for CLR V4 so the format might be a bit different than V2. "The debugging session below was identical in v2 except for SOS formatting differences."

Enjoy and thanks Lee! 

There’s no magic to it, you just walk the object until you find what you are looking for.  This object has an event called Foo:


0:000> !do 0000000002dabe68

Name:        Test

MethodTable: 000007ff00044700

EEClass:     000007ff00162510

Size:        24(0x18) bytes

File:        D:\dd\clr\src\binaries\AMD64chk\events.exe


              MT    Field   Offset                 Type VT     Attr            Value Name

000007ff00044b48  4000001        8               Test+T  0 instance 0000000002dabf48 Foo


0:000> !do 0000000002dabf48

Name:        Test+T

MethodTable: 000007ff00044b48

EEClass:     000007ff001629e8

Size:        64(0x40) bytes

File:        D:\dd\clr\src\binaries\AMD64chk\events.exe


              MT    Field   Offset                 Type VT     Attr            Value Name

000007feef8b3bc0  4000046        8        System.Object  0 instance 0000000002dabf48 _target

000007feef8b3bc0  4000047       10        System.Object  0 instance 0000000000000000 _methodBase

000007feef8b7388  4000048       18        System.IntPtr  1 instance      7ff0003aca8 _methodPtr

000007feef8b7388  4000049       20        System.IntPtr  1 instance      7ff00044a10 _methodPtrAux

000007feef8b3bc0  400004a       28        System.Object  0 instance 0000000002dabf18 _invocationList

000007feef8b7388  400004b       30        System.IntPtr  1 instance                2 _invocationCount


This has the object (_target), a method pointer (!dumpmd on _methodPtrAux or if it’s null, ln on _methodPtr), and an optional invocation list.  If the event has multiple subscribers, then _invocationList will be non-null:

0:000> !da -details 0000000002dabf18

Name:        System.Object[]

MethodTable: 000007feef89b3c8

EEClass:     000007feeef17718

Size:        48(0x30) bytes

Array:       Rank 1, Number of elements 2, Type CLASS

Element Methodtable: 000007feef8b3bc0

[snip tons of output, all of your subscribers here]


Comments (0)

Skip to main content