zoukankan      html  css  js  c++  java
  • vs2010 条件断点 has changed是什么意思?

    在vs2010 断点设置 condition里,有2个选项可以选择:

    一个是true,另个是has changed,true好理解,如果表达式为真则停止。但是has changed是什么意思。看了官网的说明:

    Choose is true if you want to break when the expression is satisfied or has changed if you want to break when the value of the expression has changed.

    NoteNote:

    The debugger does not evaluate the expression until the first time the breakpoint is reached. If you choose has changed, the debugger does not consider the first evaluation of the condition to be a change, so the breakpoint will not be hit on the first evaluation.

    转自;http://msdn.microsoft.com/en-us/library/7sye83ce(v=vs.90).aspx

    意思是第一次不考虑值是否改变,第一次只是来存储该表达式式的值,所以第一次不会名字

    我安照它的意思写了一个测试:

    int i=10;
    cout<<i<<endl; //断点 i  has changed

    i=20;
    cout<<i<<endl; //断点 i  has changed

    如上,我分别在上面2个位置设置了条件断点,第二个断点看i是否改变。运行F5,没有命中。为什么呢?是因为我把意思理解错误。

    has changed应该是同一个断点命中,如果运行到断点语句发现表达式的值与上次运行时不一样,就会停止在这里了。(第一次不会命中,因为没有前一次可以比较)。

    所有,has changed一般在循环里使用。如:

    for(int j=0;j<5;j++)
    {
    cout<<j<<endl; //设置 condition 为 j

    按F5,输出第一个0就停止了,因为第二次运行到断点语句时发现j=1与上次j=0不一样。

    如果理解了这个,has changed就可以明白了。

  • 相关阅读:
    HTML5边玩边学
    全面理解javascript的caller,callee,call,apply概念
    什么是HTTP Headers?
    Jquery的$命名冲突:
    jQuery 核心 noConflict() 方法
    js 两个小括号 ()() 的用法
    前端工程师的编码遭遇战
    Canvas之图像与文字
    Internet Explorer 9.0 新功能介绍
    firebug1.7调试实用技巧指南—web前端开发七武器
  • 原文地址:https://www.cnblogs.com/youxin/p/3267664.html
Copyright © 2011-2022 走看看