首页
社区
课程
招聘
[原创]Debuggervisualizer+ILReader+ Dynamically Generated Code
发表于: 2010-10-17 20:08 1777

[原创]Debuggervisualizer+ILReader+ Dynamically Generated Code

2010-10-17 20:08
1777
DebuggerVisualizer for DynamicMethod (Show me the IL)

+ all refering articles + sources + binaries

(1) DebuggerVisualizer for DynamicMethod (Show me the IL)
(2) Hello World - LCG (Lightweight Code Gen) style
(3) Latebound invocation CallVirt-Delegates-DynamicMethod-InvokeMember
(4) System.Reflection-based ILReader
(5) Read IL from MethodBody
(6) Turn MethodInfo to DynamicMethod
(7) Hello World with DynamicILInfo
(8.1) Take Two - IL Visualizer
(8.2) Debugger Visualizer for MethodInfo - DynamicMethod - MethodBase
(9) Debugging Dynamically Generated Code (Reflection.Emit)
(10) Hello World - Reflection.Emit style
(11) DebuggableAttribute and dynamic assemblies
(12) SignatureResolver (unfinished)
_SOURCES_

btw rename .pdf to rar !!!!

How to write a Virtualizer (msdn)

All Credz to : Haibo_Luo and Joel Pobar <---- amazing .NET guys !!!

Have you ever tried DynamicMethod, one of the coolest features in the .NET 2.0? Hope you have; otherwise, you can try it now with the examples 1, 2.

Like emitting IL to MethodBuilder, we first get ILGenerator from a DynamicMethod, and make a series of ILGenerator.Emit calls to emit the IL instructions. If the emit sequence/logic is complicated, we are likely to wanna check the on-the-fly IL content when debugging. (In fact, class DynamicILInfo provides an alternative way to set the IL code for dynamic method.)

It is not straightforward to find out this information and show it. Those instructions are stored in a byte array, so we need an ILReader to parse it; if the ILDasm-style output is preferred, we need to resolve type/field/method back from tokens (DynamicMethod has its own token management mechanism). By the way, Yiru wrote an excellent post "Debugging LCG", where windbg + SOS were used, and !dumpil was called with the DynamicMethod's MethodDesc (which is not available until jit'ting)

What if we want to live with the nice-looking Visual Studio 2005 environment, and still be able to see what has been emitted by far while we are debugging the dynamic method? Peli (our CLR team member and also an active Emit/LCG user) proposed that DebuggerVisualizer is a good solution. If you are interested in DebuggerVisualizer in general, some references can be found at Scott's blog (or msdn: how to write a visualizer)

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

上传的附件:
收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//