Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view the disassembly of a delegate created by compiling an expression tree?

I want to see the x86 assembly being generated by .Net's just-in-time compiler. I know how to do this for "normal" code, compiled ahead of time, but don't know how to do it for code generated dynamically at runtime (which I'm doing with expression trees).

I'm not even really sure what to try. For example, the delegate created by compiling the expression tree points at an address, but I don't know what to use to view what's at that address.

like image 729
Craig Gidney Avatar asked Oct 06 '22 00:10

Craig Gidney


1 Answers

Use LambdaExpression.CompileToMethod(MethodBuilder).

You can then save the AssemblyBuilder to a file which you can examine in your favorite ,NET disassembler.

like image 65
leppie Avatar answered Oct 10 '22 00:10

leppie