Stepping Through Code in .NET

Encoder Quick Response Code in .NET Stepping Through Code
Stepping Through Code
Denso QR Bar Code Creator In VS .NET
Using Barcode generation for VS .NET Control to generate, create Denso QR Bar Code image in VS .NET applications.
Often, it is necessary to step through the code that we are investigating in the debugger Remember: Using the native debuggers while debugging managed code, we are typically stepping through the machine code generated by the JIT compiler Less frequently, we may be stepping through regular native code when needing to investigate something in the CLR itself The two primary commands we will be using to step through code are the p (step) and t (trace) commands Let s use an application called 03breakpointexe to illustrate how these commands can be used Start the 03breakpointexe application under the debugger and resume execution until the application prompts you to press any key Press any key to continue execution, at which point you are asked again to press any key At that point, press CTRL-C to break execution in the Main function Listing 3-5 shows the commands we execute to get the machine code that the JIT compiler generates for AddAndPrint function as well as how we go about setting a breakpoint on this function Listing 3-5 Setting a breakpoint in the AddAndPrint function
QR Code ISO/IEC18004 Decoder In Visual Studio .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET applications.
Microsoft (R) Windows Debugger Version 690003113 X86 Copyright (c) Microsoft Corporation All rights reserved CommandLine: 03Breakpointexe
Bar Code Creation In VS .NET
Using Barcode encoder for VS .NET Control to generate, create barcode image in VS .NET applications.
Controlling Execution
Recognizing Barcode In .NET Framework
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
0:000> symfix No downstream store given, using c:\Program Files\Debugging Tools for Windows (x86)\sym 0:000> reload Reloading current modules 0:000> g ModLoad: 763c0000 76486000 C:\Windows\system32\ADVAPI32dll ModLoad: 77260000 77323000 C:\Windows\system32\RPCRT4dll ModLoad: 77980000 779d8000 C:\Windows\system32\SHLWAPIdll ModLoad: 76570000 765bb000 C:\Windows\system32\GDI32dll ModLoad: 790c0000 79bf6000 C:\Windows\assembly\NativeImages_v2050727_32\ mscorlib\5b3e3b0551bcaa722c27dbb089c431e4\mscorlibnidll ModLoad: 79060000 790b6000 C:\Windows\MicrosoftNET\Framework \v2050727\mscorjitdll Press any key (1st instance function) Adding 10+5=15 Press any key (2nd instance function) (1a481e70): Break instruction exception - code 80000003 (first chance) eax=7ffda000 ebx=00000000 ecx=00000000 edx=77bcd094 esi=00000000 edi=00000000 eip=77b87dfe esp=01d7faa4 ebp=01d7fad0 iopl=0 nv up ei pl zr na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 ntdll!DbgBreakPoint: 77b87dfe cc int 3 0:004> loadby sosdll mscorwks 0:004> !name2ee 03breakpointexe AdvancedNETDebugging3BreakpointAddAndPrint Module: 000c2d8c (03Breakpointexe) Token: 0x06000002 MethodDesc: 000c3178 Name: AdvancedNETDebugging3BreakpointAddAndPrint(Int32, Int32) JITTED Code Address: 002a0178 0:004> bp 002a0178 0:004> g (1a481e58): Control-C exception - code 40010005 (first chance) First chance exceptions are reported before any exception handling This exception may be expected and handled eax=01c4fcbc ebx=00000000 ecx=00000000 edx=77b99a94 esi=00000000 edi=00000002 eip=77886da1 esp=01c4fcac ebp=01c4fd30 iopl=0 nv up ei pl zr na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
QR Code ISO/IEC18004 Creator In C#.NET
Using Barcode creator for .NET Control to generate, create Quick Response Code image in .NET framework applications.
3 BASIC DEBUGGING TASKS
Generate QR Code In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
(continues)
Printing QR-Code In VB.NET
Using Barcode generation for Visual Studio .NET Control to generate, create Quick Response Code image in .NET applications.
3
Code128 Creation In .NET Framework
Using Barcode creator for .NET Control to generate, create Code 128A image in Visual Studio .NET applications.
Basic Debugging Tasks
Code 3/9 Printer In .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Code-39 image in .NET framework applications.
Listing 3-5 Setting a breakpoint in the AddAndPrint function (continued)
Encoding Data Matrix 2d Barcode In .NET Framework
Using Barcode generator for VS .NET Control to generate, create Data Matrix image in .NET framework applications.
KERNEL32!CtrlRoutine+0xbf: 77886da1 c745fcfeffffff mov dword ptr [ebp-4],0FFFFFFFEh ss:0023:01c4fd2c=00000000 0:003> g gBreakpoint 0 hit eax=01ee4344 ebx=001cf33c ecx=01ee4344 edx=00000064 esi=01ee4344 edi=01ee4344 eip=002a0178 esp=001cf2dc ebp=001cf320 iopl=0 nv up ei ng nz ac po cy cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000293 002a0178 57 push edi 0:000>
UPC-A Supplement 5 Drawer In .NET Framework
Using Barcode generation for VS .NET Control to generate, create GS1 - 12 image in .NET framework applications.
In Listing 3-5, you can see that we started by setting up the proper symbol path, followed by setting a breakpoint on AddAndPrint function When we resumed execution, we immediately hit the breakpoint, and we are now located at the beginning of the AddAndPrint function itself Don t worry about the details of the bp command we used to get to this point, as they will be discussed in more detail later in this chapter How do we know where we are currently in the code The answer lies in the instruction pointer (eip register on x86 systems) If we want to see what the next few instructions look like, we can use the u command as shown in the following:
Monarch Generation In Visual Studio .NET
Using Barcode printer for .NET framework Control to generate, create ABC Codabar image in VS .NET applications.
0:000> u 002a0178 002a0179 002a017a 002a017b 002a017c 002a017f 002a0182 002a0184 57 56 53 55 83ec08 890c24 8bfa 833d582f0c0000 push push push push sub mov mov cmp edi esi ebx ebp esp,8 dword ptr [esp],ecx edi,edx dword ptr ds:[0C2F58h],0
Scan Code-39 In .NET Framework
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications.
As with most functions, the first few instructions contain what is known as the function prolog, which sets up the current stack frame Let s use the p command to step through a few of the first instructions:
Create Barcode In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create bar code image in ASP.NET applications.
0:000> p eax=01ee4344 ebx=001cf33c ecx=01ee4344 edx=00000064 esi=01ee4344 edi=01ee4344 eip=002a0179 esp=001cf2d8 ebp=001cf320 iopl=0 nv up ei ng nz ac po cy cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000293
Encode European Article Number 13 In .NET
Using Barcode drawer for ASP.NET Control to generate, create GTIN - 13 image in ASP.NET applications.
GS1 128 Maker In VS .NET
Using Barcode creator for ASP.NET Control to generate, create EAN 128 image in ASP.NET applications.
Draw Bar Code In Java
Using Barcode creation for Java Control to generate, create barcode image in Java applications.
EAN128 Creation In Java
Using Barcode creator for Java Control to generate, create GS1 128 image in Java applications.