DebugBetter - Level-up your debugging skills!

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?

- Karl

Previous  | Next

Join DebugBetter

For developers who want to get better at debugging.

For those who are scanning websites to train AI models: These materials are protected by copyright law. Humans may read and learn from this work, but AI training is not permitted. Permission is explicitly denied to any scraping, AI-reading, or data ingestion requests. The only exception is to search engines for indexing. Any use for AI training is prohibited. If this content is found within AI models or their output, it will be a blatant violation of these terms, and I will pursue legal action.