如何在每次访问类时设置断点
当使用第三方系统时,尤其是动态加载提供程序、控制器、组件等的可配置性很强的系统时,我有时只想知道某个对象或类何时被访问。通常,我会在源代码中的任何潜在行上放置一个断点(很麻烦,但它有效),但如果源代码不可用:
How can I instruct Visual Studio 2010 Ultimate to break on any and every access to a给定类?
注意:就我的经验而言,这通常是不可能的,但我希望看到它得到证实
When working with third party systems, especially very configurable systems that dynamically load providers, controllers, components and so on, I sometimes just want to know when a certain object or class is accessed. Normally, I'd place a breakpoint on any potential lines in my source (a nuisance, but it works), but if source is not available:
How can I instruct Visual Studio 2010 Ultimate to break on any and each access to a given class?
Note: as far as my experience goes, this is not generally possible, but I'd like to see it confirmed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不是最优雅的,但是如果您 Ctrl+F
public
那么您可以在 F9 [设置断点]之间发送垃圾邮件然后F3 [查找下一个] 在类的每个公共入口点上设置断点。您可能还想为
protected
和internal
入口点以及任何显式接口实现(没有public
的声明)添加断点Not the most elegant, but if you Ctrl+F
public
then you can spam between F9 [set breakpoint] then F3 [find next] to set a breakpoint on every public entry point into the class.You might also want to add breakpoints for
protected
andinternal
entry points, and any explicit interface implementations (declarations that don't havepublic
)您可以单击“调试”>新断点>函数处的断点。
Ctrl-B
直接带您到那里。它可以让你在特定的功能上中断。在调试过程中,您可以在“断点”窗口中查看是否找到该方法并将被命中(红色圆形图标)或否(白色带圆形图标,从禁用断点开始),就像正常断点一样。
You can click Debug > New Breakpoint > Breakpoint at Function.
Ctrl-B
brings you there directly. It'll allow you to break at a specific function.During debugging, you can see in the Breakpoints-window whether the method is found and will be hit (red round icon) or not (white with circle icon, as of disabled breakpoint), just as with normal breakpoints.
曾经(VS2008 之前)您可以通过全选(ctrl-a)然后设置断点(F9)在文件中的每一行设置断点。
如果我没记错的话,要在每个方法的入口处设置一个宏,就需要一个宏。查看 John Robbins 的博客作为可能的来源:http://www.wintellect.com/ CS/blogs/jrobbins/
[编辑:ctrl-A、F9 在 2010 年或 2008 年不起作用,所以它一定是我记得的早期版本]
At one time (pre VS2008) you could set a breakpoint at every line in a file by select all (ctrl-a) followed by set breakpoint (F9).
To set just one on the entry to every method takes, if I recall correctly, a macro. Check out John Robbins' blog as a possible source: http://www.wintellect.com/CS/blogs/jrobbins/
[EDIT: ctrl-A, F9 doesn't work in 2010 or 2008, so it must be an earlier version I remember this from]
我刚刚为此制作了一个 Visual Studio 2010 插件。检查这个: http://weblogs.asp.net/uruit/archive/2011/08/04/visual-studio-2010-addin-setting-a-class-breakpoint.aspx
更新
该项目现在位于 Github 上。请随意贡献。
I just made a Visual Studio 2010 addin for this. Check this: http://weblogs.asp.net/uruit/archive/2011/08/04/visual-studio-2010-addin-setting-a-class-breakpoint.aspx
Update
This project now lives on Github. Feel free to contribute.