Dumping Arrays in .NET

Print Quick Response Code in .NET Dumping Arrays
Dumping Arrays
QR Code ISO/IEC18004 Generation In .NET
Using Barcode printer for .NET Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
The CLR treats arrays as first class reference types (all arrays derive from the SystemArray type) and, as such, dumping the contents of an array can be
Scanning QR Code 2d Barcode In VS .NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
Object Inspection
Bar Code Generator In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create bar code image in Visual Studio .NET applications.
accomplished by using the DumpObj command Again, let s turn to our 03ObjTypesexe application to illustrate the process of dumping out arrays Start by running 03ObjTypesexe under the debugger and continue execution until asked to Press any key to continue (Arrays) At this point, manually break execution and issue the ClrStack a command, which serves as our starting point for this discussion:
Barcode Reader In VS .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET framework applications.
0:000> !ClrStack -a OS Thread Id: 0xff8 (0) ESP EIP 001af3a8 77b99a94 [NDirectMethodFrameSlim: 001af3a8] MicrosoftWin32Win32NativeReadConsoleInput(IntPtr, InputRecord ByRef, Int32, Int32 ByRef) 001af3c0 793e8f28 SystemConsoleReadKey(Boolean) PARAMETERS: intercept = 0x00000000 LOCALS: <no data> 0x001af3d0 = 0x00000001 <no data> <no data> <no data> <no data> <no data> <no data> <no data> <no data> 001af400 793e8e33 SystemConsoleReadKey() 001af404 0097010c AdvancedNETDebugging3ObjTypesMain(SystemString[]) PARAMETERS: args = 0x01c758ac LOCALS: 0x001af408 = 0x00000064 <CLR reg> = 0x01c76c84
Drawing QR Code In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications.
3 BASIC DEBUGGING TASKS
QR-Code Printer In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
001af64c 79e7c74b [GCFrame: 001af64c] 0:000>
Printing QR Code JIS X 0510 In Visual Basic .NET
Using Barcode creator for VS .NET Control to generate, create Quick Response Code image in .NET applications.
The primary frame of interest is the Main function frame, which lists a <CLR reg> pointer value of 0x01c76c84 If we run the DumpObj on this pointer (as shown in Listing 3-13), we quickly see that it corresponds to an instance of type ObjTypes, which also happens to be a type that has two array fields defined
Code 128 Creator In Visual Studio .NET
Using Barcode maker for .NET framework Control to generate, create Code 128C image in VS .NET applications.
3
Print European Article Number 13 In Visual Studio .NET
Using Barcode printer for .NET Control to generate, create EAN 13 image in VS .NET applications.
Basic Debugging Tasks
Paint Code 3/9 In Visual Studio .NET
Using Barcode drawer for .NET framework Control to generate, create ANSI/AIM Code 39 image in .NET framework applications.
Listing 3-13 Dumping out the ObjTypes type
Bar Code Generator In VS .NET
Using Barcode creation for .NET framework Control to generate, create bar code image in .NET framework applications.
0:000> !DumpObj 0x01c76c84 Name: AdvancedNETDebugging3ObjTypes MethodTable: 002a3114 EEClass: 002a129c Size: 28(0x1c) bytes (C:\ADNDBin\03ObjTypesexe) Fields: MT Field Offset Type VT Attr Value Name 002a30c0 4000001 c jTypes+Coordinate 1 instance 01c76c90 coordinate 7912d7c0 4000002 4 SystemInt32[] 0 instance 01c76d3c intArray 7912d8f8 4000003 8 SystemObject[] 0 instance 01c76d5c strArray
EAN-8 Supplement 2 Add-On Printer In .NET
Using Barcode maker for .NET framework Control to generate, create EAN / UCC - 8 image in VS .NET applications.
From the output, we can see that the first array field (intArray) is of type SystemInt32[] and the second (strArray) is of type SystemObject[] In essence, the first is an array of integers and the second is an array of objects From our previous discussion on dumping basic reference types, we know we can continue using the DumpObj command on each of the reference type fields (such as our array fields) to get further information on each field Running the DumpObj command on the integer array yields the following:
Bar Code Generator In C#
Using Barcode creation for .NET framework Control to generate, create bar code image in Visual Studio .NET applications.
0:000> !DumpObj 01c76d3c Name: SystemInt32[] MethodTable: 7912d7c0 EEClass: 7912d878 Size: 32(0x20) bytes Array: Rank 1, Number of elements 5, Type Int32 Element Type: SystemInt32 Fields: None
Bar Code Reader In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Although the output of the DumpObj command yields some useful information such as the array rank, number of elements, and the type of each element, it does not tell us what each of the array slots actually contains To get that information, we can use the raw memory dump commands, such as dd, on the array pointer itself, as illustrated in Listing 3-14 Listing 3-14 Raw memory dump of a value type array
Barcode Generation In Java
Using Barcode generation for Java Control to generate, create bar code image in Java applications.
0:000> dd 01c76d3c 01c76d3c 7912d7c0 00000005 00000001 00000002 01c76d4c 00000003 00000004 00000005 00000000
Code 39 Extended Creation In Java
Using Barcode drawer for Java Control to generate, create Code 3 of 9 image in Java applications.
Object Inspection
Bar Code Encoder In VB.NET
Using Barcode drawer for .NET Control to generate, create barcode image in Visual Studio .NET applications.
01c76d5c 01c76d6c 01c76d7c 01c76d8c 01c76d9c 01c76dac
Draw Bar Code In Visual C#
Using Barcode creator for .NET framework Control to generate, create bar code image in .NET framework applications.
7912d8f8 01c76cc0 80000000 003a0078 007b003a 0032007b
Code 128 Code Set A Printer In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create Code 128B image in ASP.NET applications.
00000005 01c76cd8 790fd8c4 0030007b 007d0031 0000007d
EAN / UCC - 13 Creation In Java
Using Barcode drawer for Java Control to generate, create EAN 13 image in Java applications.
790fd8c4 01c76cfc 00000014 002c007d 0020002c 00000000
01c76ca0 01c76d18 00000013 00790020 003a007a 79102290
The first value in the memory output of any array is the method table of the array type itself Passing this method table pointer to the DumpMT command displays more information about the type, as shown in the following:
0:000> !DumpMT 7912d7c0 EEClass: 7912d878 Module: 790c2000 Name: SystemInt32[] mdToken: 02000000 (C:\Windows\assembly\GAC_32\mscorlib\2000__ b77a5c561934e089\mscorlibdll) BaseSize: 0xc ComponentSize: 0x4 Number of IFaces in IFaceMap: 4
The output tells us that the type itself is an integer array (Int32) but still doesn t display the individual elements of the array The next value of interest from Listing 3-14 is what follows the method table pointer, namely the size of the array itself In Listing 3-14, we can see that the size of the array is 5 Following the array size are the elements (1, 2, 3, 4, 5) That sums up how we can go about displaying arrays of value types The key is the memory layout for an array of value types, shown in Figure 3-2 What about arrays of reference types Can we use the same method Absolutely The key difference in the memory layout, however, is that in addition to the method table for the array itself, there will also be a method table pointer corresponding to the type of element that the array contains Figure 3-3 illustrates the memory layout of an array of reference types