I am watching a variable that gets assigned thousands of values during a single run. It is being set several times and is hard to keep track of the code workflow just by setting breakpoints where it is being reassigned. Is there a way to output all the values the variable had to a .txt file? I want to achive this without modifying the actual C++ code, just using the debugging tools.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
相关文章
- How to show location of errors, references to memb
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- How to track MongoDB requests from a console appli
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
To get really close to what you're looking for, you need to combine two features of Visual Studio: Data breakpoints and trace points. Data breakpoints allow you to notify the debugger, whenever the store value in memory changes. To set a data breakpoint, launch the debugger, and select Debug → New Breakpoint → Data Breakpoint...:
Since we are interested in the variable
myValue
, we're setting the address to&myValue
, and set the size to 4 bytes (since that's what anint
is on Windows):Now that would be pretty cool as-is already. But for non-intrusive logging, we'll set the Actions as well:
The important settings are the log message (
[MYSIG]
is an arbitrary signature, so that the interesting log entries can later be filtered), that dumps the value of the variable, as well as the Continue execution check box. The latter makes this non-intrusive (or low-intrusive; logging lots of information does have a noticeable impact on runtime performance).With that in place, running this code
produces the following output in the Debug output pane:
This output can then be easily analyzed in your favorite text processor.