VS 中的条件断点 - 值已更改。如何使用?

发布于 2024-08-16 08:49:24 字数 276 浏览 5 评论 0原文

在 Visual Studio (2005/2008) 中,我们可以在条件为 True 时设置条件断点。 现在,还有另一个选项 - 何时“更改”。

这是什么意思以及我应该如何/何时使用它。

我已经在 MSDN 上看到相关页面但是这个“改变”对我来说仍然不清楚......

谢谢。

In Visual Studio (2005/2008) we can set a conditional breackpoint when the condition is True.
Now, there is an other option - when is "Changed".

What does this mean and how/when should I use it.

I saw already related page on MSDN but this "changed" it still not clear for me...

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

明明#如月 2024-08-23 08:49:24

最好通过示例进行解释:

  for (int ix = 0; ix < 10; ++ix) {
    Console.WriteLine(ix);  // Break here
  }

在断点对话框中键入一个表达式,其计算结果为简单的布尔值或整数值。例如:“ix/2”。当您运行它时,执行将在第一次循环时中断,并且仅当 ix 为偶数时才会中断。

顺便说一句,这不是另一个帖子中提到的数据断点。托管代码不支持这些。调试器实际上会暂时中断程序执行并每次都会计算表达式。仅当表达式值发生更改时才停止执行。作为副作用,这可能会使您的代码运行速度变慢很多

Best explained with an example:

  for (int ix = 0; ix < 10; ++ix) {
    Console.WriteLine(ix);  // Break here
  }

Type an expression in the breakpoint dialog that evaluates to a simple bool or integral value. For example: "ix / 2". When you run it, execution will break on the first pass through the loop and only whenever ix is an even value.

This is not a data breakpoint btw, alluded to in another post. Those are not supported in managed code. The debugger actually breaks program execution temporarily and evaluates the expression every time. Only to stop execution when the expression value has changed. This can make your code run a lot slower as a side-effect.

苍暮颜 2024-08-23 08:49:24

这意味着每当表达式的值发生变化时,断点就会激活。

用例是当您希望命中断点,但前提是代码中发生了一些有趣的变化。例如,在循环中,您可能只想在某个值增加时中断,而不是在循环的每次迭代时中断。

It means that every time the value of the expression changes the breakpoint will activate.

The use case is when you want a breakpoint to be hit but only if something interesting has changed in the code. In a loop, for example, you might want to break only when some value has been incremented and not on every iteration of the loop.

小草泠泠 2024-08-23 08:49:24

首次运行时不会评估已更改。当断点表达式的计算发生更改时,它会中断。

Has Changed does not get evaluated on the first run. It breaks when the evaluation of the expression for the breakpoint has changed.

寄居者 2024-08-23 08:49:24

此“更改的”条件断点仅适用于内存的几个字节(1、2、4 或 8),其地址和计数在断点设置中指定。在程序执行期间,如果某些内容更改了这些字节,则程序执行将在发生更改的位置中断。
通常,当您不知道谁以及如何更改您的内容时,它通常用于调试无意的内存/变量更改的情况。

This "changed" conditional breakpoint applies only to several bytes of memory (1, 2, 4 or 8), whose address and count you specify in the breakpoint settings. When, during the program execution, something changes these bytes, the program execution breaks at the point where the change was made.
Usually it is used for debugging cases of unintentional memory/variable changes when you don't know who and how exactly changes your stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文