Earlier in this series, I mentioned I would talk about cordbg, NetCF and IL...
While source level debugging is ideal, there are times that you may need to dig a little deeper to find the source of a particular problem. Maybe you do not have symbols (pdb files) for a piece of code. Or possibly, like me, you enjoy taking a look under the hood to see what the engine is up to... If so, hopefully, you will find today's installment helpful.
Let's start with the dis[assemble] command. The examples below are from debugging the same, very simple application.
When debugging .NET Framework (desktop PC) applications, this command gives you native (x86) assembly code.
 mov ecx,1Bh
[047c] mov eax,esi
[047f] idiv eax,ecx
 mov dword ptr [ebp-14h],edx
* mov edx,dword ptr [ebp-14h]
 mov ecx,dword ptr [ebp-4Ch]
[048a] call dword ptr ds:[03210014h]
 mov esi,eax
 mov dword ptr [ebp-20h],esi
 mov ecx,dword ptr [ebp-20h]
On the .NET Compact Framework, dis[assemble] displays IL assembly code.
[IL:0261] 11:0d ldloc.s 13
[IL:0263] 28:0900000a call System.Math::Abs
[IL:0268] 1f:1b ldc.i4.s 27
[IL:026a] 5d: rem
[IL:026b] 0a: stloc.0
*[IL:026c] 11:0e ldloc.s 14
[IL:026e] 06: ldloc.0
[IL:026f] 6f:12000006 callvirt TestBaseClass::CallProtectedMethod
[IL:0274] 0b: stloc.1
[IL:0275] 07: ldloc.1
[IL:0276] 28:0300000a call System.Console::WriteLine
Please note: There is no mechanism, using cordbg, to view native processor assembly code for a NetCF application.
Once you have disassembled, you can use the sh[ow] command to return to source view (provided you have your pdb and source files).
097: i = Math.Abs(startVal) % 27;
098:* s = tbc.CallProtectedMethod(i);
Single stepping (whether in native or IL assembly mode) is as easy as in source view - use ns[ingle] to step over a native or IL instruction and ss[ingle] to step into a native or IL (ex: callvirt) instruction.
That's all for now. Until next time,
This posting is provided "AS IS" with no warranties, and confers no rights.
Some of the information contained within this post may be in relation to beta software. Any and all details are subject to change.