Dump-Dictionary

Dumps the contents of a dictionary as a key,value list of addresses.

This is a 'higher level' function that consists of extracting the address for the dictionary's backing array, traversing the array contents to extract the individual dictionary entries and extracting the key and value addresses, all of which would otherwise be done 'by hand'.

PowerDbg > $types = Dump-Heap -type Dictionary
PowerDbg > $values = ($types[0].instances | % { dump-dictionary $_.Address })
PowerDbg > $values

key                                                         value
---                                                         -----
000000000275d7f8                                            000000000275e948
000000000275d820                                            000000000275e968


PowerDbg > $values | % { $_.key } | dump-object

__Fields        : {System.Object, System.Object, System.Object, System.Object...}
__Name          : System.String
__MethodTable   : 000007fee876ec90
__EEClass       : 000007fee837b038
__Size          : 36(0x24) bytes
__String        : Test1
m_arrayLength   : 6
m_stringLength  : 5
m_firstChar     : 54
Empty           : static
WhitespaceChars : static

__Fields        : {System.Object, System.Object, System.Object, System.Object...}
__Name          : System.String
__MethodTable   : 000007fee876ec90
__EEClass       : 000007fee837b038
__Size          : 36(0x24) bytes
__String        : Test2
m_arrayLength   : 6
m_stringLength  : 5
m_firstChar     : 54
Empty           : static
WhitespaceChars : static

PowerDbg > $values | % { $_.key } | dump-object | % { $_.__String }
Test1
Test2


In a future release we will probably auto-expand the key and value addresses, and possibly even detect string keys and expand them all the way to the string literal.

Last edited May 22, 2010 at 3:10 PM by piers7, version 1

Comments

No comments yet.