Jump to content
Tuts 4 You

Create a debug mscorlib?


high6

Recommended Posts

Posted

Well I came across an interesting article.

http://www.codeproject.com/KB/dotnet/Debug...rk_Classes.aspx

It is a bit old but with some modifications it works.

I was reading about sequence points http://blogs.msdn.com/jmstall/archive/2004/10/03/237137.aspx.

Is there any ways with ilasm to maximize sequence points?

When debugging I stepped into Thread.Sleep() and got (from the il file I had created from that first link).

  .method public hidebysig static void  Sleep(int32 millisecondsTimeout) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call void System.Threading.Thread::SleepInternal(int32)
IL_0006: ret
} // end of method Thread::Sleep

Problem is that because of how it is sequenced ldarg.0 and the call are merged into 1(as you can see in the disassembly below).

  .method public hidebysig static void  Sleep(int32 millisecondsTimeout) cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
00000000 push ebp
00000001 mov ebp,esp
00000003 push eax
00000004 mov dword ptr [ebp-4],ecx
00000007 cmp dword ptr ds:[009F21C8h],0
0000000e je 00000015
00000010 call 76E2D1F9
00000015 mov ecx,dword ptr [ebp-4]
00000018 call 76CC60EB
IL_0006: ret
0000001d nop
0000001e mov esp,ebp
00000020 pop ebp
00000021 ret
}

So does anyone know how to build mscorlib as a debug dll with maximum sequence points(to prevent the instructions from being merged)?

Also how do you handle methods that have generated bodies? (for example Thread.SleepInterval)

  .method private hidebysig static void  SleepInternal(int32 millisecondsTimeout) cil managed internalcall
{
} // end of method Thread::SleepInternal

Any help/tips would be greatly appriciated.

On a side note

Can you build native instructions into a .net exe with ilasm? Like I noticed with MonoCecil that there is a "native" flag. What is the "native" flag for(asking this because I compiled a mixed mode assembly and it seemed to convert all the native instructions to msil(from the looks of it). Just wanna clear this all up)?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...