How can I debug an unmanaged BCL (InternalCall) method?

I want to debug the implementation of the [MethodImpl(MethodImplOptions.InternalCall)]BCL method , which is supposedly implemented in C ++. (In this particular case, I look at System.String.nativeCompareOrdinal.) This is mainly because I'm new and want to know how it is implemented.

However, the Visual Studio debugger refuses to enter this method. I can set a breakpoint on this call:

"Hello".Equals("hello", StringComparison.OrdinalIgnoreCase);

then go to Debug> Windows> Disassembly, go to the Equals call and bring up the callx86 instruction . But when I try to use "Step Into" on this call(which, as I know from Reflector, is a call to nativeCompareOrdinal), it does not go to the first instruction inside nativeCompareOrdinal as I want - instead, it goes and goes directly to the next x86 instruction in equals.

I am creating x86, as mixed mode debugging is not supported for x64 applications. I unchecked "Only my code" in "Tools"> "Options"> "Debug", and I have the option "Enable unmanaged code debugging", noted in the project properties> Debug tab, but it still works on call. I also tried to start the process and then connect the debugger and explicitly bind both managed and my own debuggers, but it still won’t go into this InternalCall method.

How can I get the Visual Studio debugger to switch to an unmanaged method?

+5
source share
1 answer

, . , CALL, . , , .

. , Debug + Windows + :

            "Hello".Equals("hello", StringComparison.OrdinalIgnoreCase);
00000025  call        6E53D5D0 
0000002a  nop              

, , . : 0x6E53D5D0 - 0x2A = 0x6E53D5A6.

. Debug + Windows + EIP. 0x009A0095 . 5, nop, : 0x9A0095 + 5 + 0x6E53D5A6 = 0x6EEDD640. .

+ Windows + . , 0x.

6EEDD640  push        ebp  
6EEDD641  mov         ebp,esp 
6EEDD643  push        edi  
6EEDD644  push        esi  
6EEDD645  push        ebx  
6EEDD646  sub         esp,18h 
etc...

, , , . F5.


, , . , , SSCLI20. , CLR, , , 1.0, . clr\src\classlibnative\nls, , . "nativeCompareOrdinal", , ecall.cpp.

+5

All Articles