Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Visual Studio can i plot my variable in breakpoint ?

In Visual Studio for my native C++ program I want to get a plot of some variables during debug. Mostly I use textual representation of the objects by editing autoexp.dat. But for some of the variables it is better to have a plot rather than having values in textual form.

So far I have used a function plot(const void* address,const char* type) , and called it from Immediate Window giving the variable address & the type, and internally casting it to proper type.

But this method has two disadvantages:

  • First is that, function overloading almost never works when calling a function from debugger (so I had to pass type as a second parameter), and the function call occasionally crashes, though it works perfectly when called from within code.
  • Second is, instead of writing a C++ function for plotting, I am interested to have a scripting language (like autoexp.dat or a VBScript) to give the internal data of the C++ object without writing any wrapper, so that I can use the script to store the data in a file or plot it.

In general I am interested to have something like Matlab or Ch IDE, where I can plot certain variable externally when the program is at a debug break.

like image 440
abir Avatar asked Jan 30 '09 08:01

abir


People also ask

How can I see the variable value while debugging in Visual Studio?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do I pin a variable in Visual Studio?

To open the Locals window, while debugging, select Debug > Windows > Locals, or press Alt+4. This topic applies to Visual Studio on Windows.

Is it possible to change the value of a variable while debugging?

Yes u can if you have the authorization: while debugging do a doubleclick on the variable, the system'll show the name and the value of the variable, change the value and press CHANGE icon.


1 Answers

Since VS 2005, Visual Studio has included Visualizers, which could almost have been designed specifically for your problem. MSDN explains the concept better than I can:

Visualizers are a new component of the Visual Studio debugger user interface. A visualizer creates a dialog box or other interface to displays a variable or object in a meaningful way that is appropriate to its data type. For example, an HTML visualizer interprets an HTML string and displays the result as it would appear in a browser window, a bitmap visualizer interprets a bitmap structure and displays the graphic it represents, and so on. Some visualizers allow you to edit as well as view the data.

See here for a tutorial on how to write one.

like image 156
Stu Mackellar Avatar answered Oct 20 '22 16:10

Stu Mackellar