In Visual Studio, can I build my variable at a breakpoint?

In Visual Studio for my native C ++ program, I want to get a graph of some variables during debugging. I mainly use the text representation of objects by editing autoexp.dat. But for some variables, it is better to have a graph, and not to matter in text form.

So far I have used the plot(const void* address,const char* type) function plot(const void* address,const char* type) and called it from the Immediate Window, specifying the variable address and type, and internally applying it to the corresponding type.

But this method has two drawbacks:

  • Firstly, the overload function almost never works when the function is called from the debugger (therefore, I had to pass the type as the second parameter), and the function call sometimes fails, although it works fine when called from code.
  • Secondly, instead of writing a C ++ function to plot, I am interested in having a scripting language (e.g. autoexp.dat or VBScript) to provide the internal data of a C ++ object without writing any wrapper so that I can use a script to store data in a file or plotting.

In general, I am interested in having something like Matlab or Ch IDE, where I can display a certain variable from the outside when the program is on a debug break.

+6
c ++ debugging visual-studio-2008 visual-studio
source share
4 answers

Starting with VS 2005, Visual Studio has included Visualizer , which could almost be designed specifically for your problem. MSDN explains the concept better than I can:

Portholes is a new component of the Visual Studio Debugger User Interface. The visualizer creates a dialog box or other interface for displaying a variable or object in a meaningful way that matches its data type. For example, an HTML visualizer interprets an HTML string and displays the result as it would in a browser window, a bitmap visualizer has a bitmap structure and displays a graphic image, etc. Some visualizers also allow you to edit how to view data.

See here for a tutorial on how to write it.

+3
source share

You can display variables in real-time charts using NetDebugPlot and NetDebugLog .

 #include "NetDebugLog.h" NetLog(myvar); NetLog("test", myvar2); 

NetDebugPlot

+2
source share

As others have noted, I don’t know exactly what you want to talk about. Usually I understand when someone says that he wants to "speak something", he usually means some array with numerical values. If this is true in your case, Intel Array Visualizer may be useful. It can be downloaded freely, it integrates into the visual studio, and you can use it in two ways: as a stand-alone application or when debugging ("while at some breakpoint") so that you can display the values ​​of the array "while the program is running "

+1
source share

Could you use gnuplot for this? Select the data that you want to display as debugging prints, and then while you are sitting at the breakpoint, copy it to an external file and run it through the plotter.

0
source share

All Articles