Get-DbgArray

Extracts the contents of a managed array at a given address, and returns them as a series of PSObjects. This command is equivilent to SOS's !dumparray command.

Example

In this example the backing array of a List<T> is examined. The array items are returned as objects that can be piped directly to Get-DbgObject (the output is limited for brevity here):

PowerDbg 0:000> Get-DbgArray 00000000023aeb38 | format-table Index,Address,"Element Methodtable" -AutoSize

Index Address          Element Methodtable
----- -------          -------------------
0     00000000023ae7a0 000007ff00044a18
1     00000000023ae7c0 000007ff00044a18

(NB: Much of the metadata relating to the array itself is discarded. Use the -raw flag if you need to see this data, like the Array size in bytes)

More commonly, the -details paramter is used to expand the items before returning:

PowerDbg 0:000> Get-DbgArray 00000000023aeb38 -details

__Fields             : {...}
__Address            : 00000000023ae7a0
__Name               : ManagedScenarios.ADataStructure
__MethodTable        : 000007ff00044a18
__EEClass            : 000007ff00183630
__Size               : 32(0x20) bytes
_privateStringField  : 00000000023ad640
IsEnabled            : 1
IntAutoProperty      : 1
StaticIntField       : 22
ThreadStaticIntField :

__Fields             : {...}
__Address            : 00000000023ae7c0
__Name               : ManagedScenarios.ADataStructure
__MethodTable        : 000007ff00044a18
__EEClass            : 000007ff00183630
__Size               : 32(0x20) bytes
_privateStringField  : 00000000023ad670
IsEnabled            : 0
IntAutoProperty      : 2
StaticIntField       : 22
ThreadStaticIntField :


See also Get-DbgListContents and Get-DbgDictionaryContents, which implement this for higher level collection structures like List<T>

Last edited Aug 10, 2010 at 3:14 PM by piers7, version 31

Comments

No comments yet.