Visual Studio:当成员变量被修改时,如何让调试器停止? [英] Visual Studio: how do I have the debugger stop when a member variable is modified?

查看:381
本文介绍了Visual Studio:当成员变量被修改时,如何让调试器停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,有一个不应该改变的变量。然而,不知何故,它正在改变。是否有一种方法让调试器在特定成员变量被修改时停止?

I have program that has a variable that should never change. However, somehow, it is being changed. Is there a way to have the debugger stop when that particular member variable is modified?

推荐答案

设置数据断点,一些变量更改。

Set a data breakpoint to stop execution whenever some variable changes.

中断对变量的初始化,或者您的变量可见的地方 - 您需要能够在内存中获取其地址。然后,从菜单中选择Debug - > New Breakpoint - > New Data Breakpoint。输入& var (用您的变量名称替换 var

Break on the initialization of your variable, or someplace where your variable is visible - you need to be able get its address in memory. Then, from the menus choose Debug -> New Breakpoint -> New Data Breakpoint. Enter "&var" (with var replaced by the name of your variable.)

这将在修改您的变量的代码行中打入调试器。

This will break into the debugger on the exact line of code that is modifying your variable.

更多文档:

http://msdn.microsoft.com/en-us /library/350dyxd0.aspx

这篇关于Visual Studio:当成员变量被修改时,如何让调试器停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆