Q:

How to inspect WeakReference values with WinDBG/SOS and ClrMD?

I'm investigating a memory leak issue from production and retrieved a memory dump. I'm trying to dump the values of the accumulated object, the I met WeakReference. Here's what I got in WinDBG:
0:000> !do 000000011a306510 
Name:        System.WeakReference
MethodTable: 000007feeb3f9230
EEClass:     000007feeadda218
Size:        24(0x18) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007feeb3f4a00  400068d        8        System.IntPtr  1 instance         343620e0 m_handle
0:000> !do 343620e0 
<Note: this object has an invalid CLASS field>
Invalid object

We can find out that we cannot use the m_handle value as the object address. I've check the code of WeakReference and it's fully extern codes.
My question is, how can we inspect the value of it using WinDBG/SOS? Also, I'm writing ad-hoc analyzer for the problem with ClrMD, so how should I check the object references by the WeakReference object with it?

A:

m_handle is an IntPtr which is a value type, so get the method table for IntPtrusing !name2ee *!System.IntPtr, then do
!dumpvc <method table of IntPtr> <value of m_handle>

This will give you the value the IntPtr points to. Since it points to an object, just dump that
!do <value of IntPtr>

