1

Similar to this question asking the same but in VS, I'd like to ask how can I use WinDbg to view diassembly of a JITted method?

Breaking this into two parts, in both cases there's the same SomeNamespace.SomeClass.Foo() method that I want to disassemble.

  1. We only have the executable program.exe, and want to run it via WinDbg's Open Executable.
  2. There's an already running process in which I want to inspect the same JITted method. (Say that we can't control how the process gets started)

Now from my understanding, JIT runs the first time a method is called. If this is true, in 2. it might be the case that the method wasn't JITted yet. Is there a way to force the JIT to run on the method in that case, so that we can inspect the result?

TL;DR: How do I disassemble a JITted method with WinDbg?

Community
  • 1
  • 1
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327

2 Answers2

1

You can force JIT compilation by calling PrepareMethod

You can view disassembly with u command in WinDbg and SOS. See example here.

Finally, maybe you can try DumpMiner. This UI tool, let you view disassembly of jitted method without knowing how to use WinDbg

Dudi Keleti
  • 2,946
  • 18
  • 33
1

I don't know a way of forcing the JIT compilation of a method, but ' command !sosex.mbp (set managed breakpoint) also works when the method has not been jitted yet and it will break as soon as it was JIT-compiled.

After that, the SOS commands !ip2md, !dumpil and !u may be helpful. If you know the JITted code address, you can also do a native u on it.

As mentioned by @Steve Johnson, author of SOSEX, in the comments, SOSEX also has commands !mu ("managed unassemble") and !muf ("managed unassemble function") that can help with already JITted functions.

Community
  • 1
  • 1
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • 1
    The question is ambiguous. The title and the tl;dr ask about disassembling a jitted method, but the core of your question asks about forcing jit on a non-jitted method. For a method that HAS been jitted, use !sosex.mu and !sosex.muf, on !sos.u. If the method has NOT been jitted, use Thomas' method. – Steve Johnson Oct 07 '16 at 15:42