locked
How to break if any variable gets a certain value? RRS feed

  • Question

  • Hi,

    is it possible to break if any variable in the program gets a certain value?
    e.g. I want to break if any string variable gets assigned the value "Green Tree", so I know the value I'm looking for but not the actual variable it is stored in.
    Is this somehow possible?

    Thx Dieter
    Friday, April 24, 2009 9:57 AM

Answers

  • Hello Dieter,

    1. I'm afraid whether such functionality is not available in Visual Studio debugger.
    2. But there is another concept called - Data Break Point , where debugger will break if the data is modified at the specified address(variable).
    3. If you are interested, this link will lead you further - How to: Set a Data Breakpoint (Native Only)

    Regards,
    Jijo.
    _____________________________________________________

    http://weseetips.com [^ ] Visual C++ tips and tricks. Updated daily.
    • Marked as answer by nobugz Saturday, April 25, 2009 2:42 PM
    Friday, April 24, 2009 12:43 PM

All replies

  • Put breakpoint at desired location using the hotkey F9.
    Now right click the breakpoint and click "Condition".
    Provide your condition there.
    Friday, April 24, 2009 10:34 AM
  • Albin,

    the problem is, that I don't even know where this variable exists, so I'm not able to set a  breakpoint there.
    My question is more like "Find the variable (and the location) which gets set to the value "Green Tree" somewhere in the program code.

    thx
    Friday, April 24, 2009 11:50 AM
  • Hello Dieter,

    1. I'm afraid whether such functionality is not available in Visual Studio debugger.
    2. But there is another concept called - Data Break Point , where debugger will break if the data is modified at the specified address(variable).
    3. If you are interested, this link will lead you further - How to: Set a Data Breakpoint (Native Only)

    Regards,
    Jijo.
    _____________________________________________________

    http://weseetips.com [^ ] Visual C++ tips and tricks. Updated daily.
    • Marked as answer by nobugz Saturday, April 25, 2009 2:42 PM
    Friday, April 24, 2009 12:43 PM