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