I've created a new little project now which hopefully fill a small niche.
Basically, at my work I'm currently debugging an issue where subtle IL changes(such as adding a
nop or slightly reordering a switch) exposes a bug in Microsoft's JIT compiler for .Net 4.5. I have two assemblies. One that works, and one that crashes. The only difference between them is subtle IL changes. They both do the same thing, have the same methods, etc.. and they work fine on a JIT compiler that isn't 4.5.
So far, my attempts at figuring out what's going on has been going very poorly. The main reason is that there aren't a ton of tools out there for working with IL. I know, I could dump the IL as C# or something with ILSpy, but the IL is so similar that it turns into the same C# code. Attempts to reproduce it in a smaller test case have went poorly so far as well.
My options were as such:
- Use ILDasm and then a diff program to figure out the difference between the programs
- Use Reflector to dump out IL like ILDasm, but also put it in separate files.
- Pound my head against the wall
So far, option 3 has been showing the most promise. The problem with dumping IL and then trying to diff it is that current disassemblers will prefix a label for the address of every line... this is fine except for when you prefer that every line doesn't have a difference when a
nop is added that changes the address.
So, how does ILDump solve this problem? Well, first off it won't print out labels on each line unless another instruction "points" to that label. Also, because addresses don't stay constant, it can rename labels to something like
Label1 instead of
IL_0012, to make less false differences. Also, it includes a small option for trimming out NOPs, sorting by method name, and constraining it's output to a class/namespace.
Anyway, ILDump is BSD licensed over at BitBucket. It uses Mono.Cecil for it's IL parsing, and compiles/works on Mono and Microsoft .Net. Also, if you want to download a precompiled version, try out ildump.zip
It's a very simple tool, so there hasn't been a whole lot to do on it, but it's still improving by the day(hour).