سؤال

Is it possible to disassemble / inspect the native code produced by the .Net JITer / ngen? (for purely academic purposes)

In attempting to answer this question I became intrigued about what sort of optimisations the JITer would perform - rather than speculate wildly I'd really like to be able to see for myself what is really hapenning.

So far I've:

  1. Installed a native image of my candidate assembly using ngen (is the output of this potentially different from the output of the JIT compiler?)
  2. Copied the native image out of the GAC

But now I'm a bit stuck - as far as I was aware .Net assemblies are in the portable execuable format, but the normal tools that I might use to disassemble such a file (objdump) just barf:

C:\Users\justin\Desktop>objdump -d ConsoleApplication1.ni.exe
objdump: ConsoleApplication1.ni.exe: File format not recognized

Is it feasible to peek inside a native image in this way? Failing that is there some alternative way that I might be able to satisfy my curiosity? (for example disassembling the code in a running process)

هل كانت مفيدة؟

المحلول

I've had some success with windbg and dumpbin in the past, when trying this sort of thing.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top