Data breakpoints in practice
Now you know what data breakpoints are, but how can you use them in practice?
In Visual Studio (C++ or C#), you can set a breakpoint early in the execution of your program, where the variable you want to break on is created. Run it and get there. You can right-click on the variable in the Locals panel and click “Break When Value Changes.” Then continue, and the next time it’s changed, it will break and look something like this.
In Xcode (C++), it’s very similar. It’s called “watching.” You right-click the variable and click “Watch <your variable name>”. Then continue, and execution will break on changes, and it will even write “old value:” and “new value:” in the console.
In Google Chrome (DevTools, for JavaScript), I wasn’t able to find equivalent functionality. I did find some techniques where you can override the “setter” and break within that, achieving a similar result. Related approaches for Python as well.
I’ve only used these with compiled languages like C and C++. What has your experience been?