Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, July 30, 2018 3:03 PM
I want to break when a value in a structure, changes.
All replies (4)
Monday, July 30, 2018 3:32 PM
Debugging a native application, you can use 'Data Breakpoints':
Setting a Data Breakpoint (native C++ only)
https://docs.microsoft.com/en-us/visualstudio/debugger/using-breakpoints#BKMK_set_a_data_breakpoint_native_cplusplus_only
Wit kind regards
Monday, July 30, 2018 7:44 PM
I believe the feature only exists for C++, perhaps only unmanaged C++. I know I was quite surprised when I learned that.
Sam Hobbs
SimpleSamples.Info
Tuesday, July 31, 2018 2:18 AM
Hi Ron Guerrero,
Welcome to the MSDN forum.
Like MaybeCompletelyW and Sam said, we can set a Data Breakpoints, but it only applies for native C++ only. Data breakpoints break execution when a value that is stored at a specified memory address changes. If the value is read but not changed, execution doesn't break. To set data breakpoints, the debugger must be in break mode.
- Start debugging the application, and wait until a breakpoint is reached. On the Debug menu, choose New Breakpoint > Data Breakpoint (or open the Breakpoints window and choose New > Data Breakpoint.
- In the Address box, type a memory address or an expression that evaluates to a memory address. For example, type &avar to break when the contents of the variable avar changes.
- In the Byte Count dropdown, select the number of bytes you want the debugger to watch. For example, if you select 4, the debugger will watch the four bytes starting at &avar and break if any of those bytes change value
Keep in mind that data breakpoints depend on the applicability of specific memory addresses.
- The address of a variable changes from one debugging session to the next. Data breakpoints are automatically disabled at the end of each debugging session.
- If you set a data breakpoint on a local variable, the breakpoint remains enabled when the function ends, but the memory address is no longer applicable, and the behavior of the breakpoint is unpredictable. If you set a data breakpoint on a local variable, you should remove or disable the breakpoint before the function ends.
Data breakpoints don't work under these conditions:
- A process that is not being debugged writes to the memory location
- The memory location is shared between two or more processes
- The memory location is updated within the kernel. For example, if memory is passed to the 32-bit Windows ReadFile function, the memory will be updated from kernel mode and the debugger doesn't break on the memory write.
Best regards,
Sara
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]
Friday, August 3, 2018 9:26 AM
Hi Ron,
Do you have any updates? If your issue persists, please feel free to let us know.
If it is solved, we are welcome you share the solution in here or mark the helpful reply as answer, that will help other community members, then we can also close this thread for you.
Best regards,
Sara
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]