在Visual Studio中我可以绘制我的变量在断点? [英] In Visual Studio can i plot my variable in breakpoint ?
问题描述
在Visual Studio中,对于我的本地C ++程序,我想在调试期间得到一些变量的图。我通常通过编辑autoexp.dat来使用对象的文本表示。但对于一些变量,最好是有一个情节,而不是以文本形式的值。
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.
到目前为止,我使用了一个函数 plot (const void * address,const char * type)
,并从立即窗口中调用它给出变量地址&
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:
- 首先是,从调试器调用函数时,函数重载几乎从不起作用(因此我必须传递类型作为第二个参数),并且函数调用偶尔崩溃,尽管它在代码中调用时工作正常。
- 其次,我不想为绘图编写C ++函数,而是有一种脚本语言(如autoexp.dat或VBScript)来提供C ++对象的内部数据< 任何包装器,以便我可以使用脚本将数据存储在文件中或绘制它。
- 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.
一般来说,我有兴趣有像 Matlab 或 Ch IDE 这样的东西,当程序在调试中断时,我可以在外部绘制某些变量。
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.
推荐答案
自VS 2005开始,Visual Studio已包含 Visualizers ,几乎可以专门为您的问题设计。 MSDN更好地解释了这个概念:
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:
Visualizer是
Visual Studio调试器用户界面的一个新组件。
一个可视化工具创建一个对话框或
其他界面以一种有意义的方式显示一个变量
或对象,它的
适用于它的数据类型。对于
示例,HTML可视化器解释
一个HTML字符串并显示结果
,因为它将出现在浏览器
窗口中,位图可视化器解释
a位图结构,显示它代表的
图形,等等。
可视化程序允许您编辑
以查看数据。
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.
这篇关于在Visual Studio中我可以绘制我的变量在断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!