Use Deblector to debug application to get pseudo source debugging experience

 

有的时候,你可能需要调试一段没有源代码的程序,或者说你有的时候想单步跟踪到.NET Framework里面的一些函数去看看为什么调用会失败。如果你这个需要的话,可以试一下Deblector,它将Reflectormdbg.exe的威力结合起来为你提供次源代码级别的调试体验。

 

You may already have experiences with debugging an application without source code available, or failed to step into .NET framework code whiling debugging your program’s defects. In this case, you may try deblector, it combines the power of Reflector and mdbg.exe to supply pseudo source debugging experience.

你可以去下面这个地方下载deblectorReflector

Please download deblector and reflector from the following place:

Deblector:  http://www.codeplex.com/deblector

Reflector: http://reflector.red-gate.com/

 

这里,我向你演示如何使用Deblector调试XamlPad.exe,假设你把Deblector解压到C:/Deblector文件夹。

In this article, I’ll try to show you how to debug XamlPad.exe by using Deblector. Let’s assume that you extract Deblector and save the bits in C:/Deblector folder.

1.       启动Reflector,单击菜单栏里面的“ViewAdd Ins”。

1.       Launch reflector, and click “View” – “Add Ins” commands in the menu bar, which brings up “Add-Ins” dialog.

2.       在弹出的“Add Ins”对话框里面单击“Add”来加载Deblector插件。

2.       Click “Add” button and select file “C:/Deblector/DeblectorAddIn/DeblectorAddIn/bin/Debug/DeblectorAddIn.dll”.

3.       下面是加载后的效果图:

3.       The result should look like the following picture:

 

 

4.       关闭“Add Ins”对话框,接着单击Reflector菜单栏里面的“ToolsDeblector”来打开Deblector插件。

4.       Close “Add-Ins” dialog. And click “Tools” – “Deblector” on Reflector’s menu bar. This will display Deblector’s UI.    

5.       Deblector里面的“Command”文本框里面输入mdbg命令r “C:/Program Files/Microsoft SDKs/Windows/v6.0A/bin/XamlPad.exe”。千万不要忘记命令里面的r和引号,J

5.       Enter command r “C:/Program Files/Microsoft SDKs/Windows/v6.0A/bin/XamlPad.exe” in “Command” text box. DO NOT miss the leading “r” mdbg command and quotes. And then press enter.

6.       XamlPad.exe启动以后,在Reflector左边的Class Members树里面找到XamlPad.XamlPadPage.RefreshButtonClicked函数双击参看它的代码。

6.       After the XamlPad.exe is launched, navigate to Main method of XamlPad.exe in “Class Members” tree view in the left side of Reflector. Find “XamlPad.XamlPadPage.RefreshButtonClicked” method and double click it.

7.       Deblector里面点击Pause按钮中断XamlPad的执行。

7.       Click “Pause” button in “Deblector” window.

8.       切换到IL View窗口,在里面找到一行IL代码,通过按红色按钮,或者点击F9设置一个断点。现在你还只能在IL代码里面设置断点,不能直接在返回编出来的C#代码里面设置断点,因此你需要通过阅读Reflector反汇编的C#代码来猜测设置IL断点的位置。

8.       In “IL view” tab in Deblector window, set a breakpoint in an appropriate position by clicking the red cycle button (or press F9 on keyboard), you can view the decompiled C# source code from “Disassembly” tab and guess while to set the breakpoint in “IL view” tab.      

9.       断点设置好了以后,切断到XamlPad程序,点击Refresh按钮,这时触发断点,你可以在DeblectorAuto窗口查看一些局部变量的值,在Call Stack里面查看堆栈信息,通过Module窗口查看加载进来的Assembly,而Quick View窗口的功能和Visual Studio“监视”窗口的功能是一样的。

9.       Switch back to XamlPad.exe and click “Refresh” button. Then you can examine values of some variables in “Auto” window, call stacks in “Calls” window, and check the loaded modules in “Modules” window. The “Quick View” window provides similar functionalities like “Watch” window in visual studio 2008.

     

 

Enjoy it. :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值