I have a member variable struct in a C++ class I'm debugging in Visual Studio 2008 Professional. I would like to break any time the struct changes. Is it possible to do this, or must I look for every possible point in the code it could change, and set breakpoints there?
Asked
Active
Viewed 7,771 times
13
-
Do you want to break at changes for _any instance_ of that `struct` or for _one particular_ instance? – sbi Jul 12 '10 at 19:00
-
(You might want to properly @address people to whom you're replying in comments, so that your answers are shown as such to them. I only came across this one by accident.) Then [MSN's answer](http://stackoverflow.com/questions/3231149/visual-studio-break-on-variable-change/3231192#3231192) is what you need. – sbi Jul 17 '10 at 11:58
1 Answers
7
If you can determine the address of the member, you can set a data breakpoint on it:
-
-
+1. You need the address. And you cannot watch the entire structure. – Hans Passant Jul 12 '10 at 18:59
-
@rofly, strictly speaking, you can use a global symbol or an expression that evaluates to an address. But in the end, the processor can only set data breakpoints for addresses, so it has to be translatable to an address. – MSN Jul 12 '10 at 20:15
-
4Link updated to http://msdn.microsoft.com/en-us/library/5557y8b4.aspx#BKMK_Set_a_data_change_breakpoint__native_C___only_ – Wernight May 02 '13 at 08:48