在Visual Studio中,我可以在断点中绘制我的变量吗? [英] In Visual Studio can i plot my variable in breakpoint ?

查看:128
本文介绍了在Visual Studio中,我可以在断点中绘制我的变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中为我的本机C ++程序,我想在调试期间得到一些变量的图。大多数情况下,我通过编辑autoexp.dat来使用对象的文本表示。但是对于一些变量,最好是用一个情节,而不是以文本形式的值。



到目前为止,我已经使用了一个函数 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆