本文介绍了调试Visual Studio的C ++自定义类型的可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与一个有些尴尬类型的图书馆工作。在Visual Studio中调试时,我想以可读的形式显示它们。我发现一些关于如何编辑autoexp.dat文件的真正有用的文章。









假设我有一个String类:

  class String {
// ...
private:
char * _cbuf;
}

那么我可以轻松添加可视化,因为_cbuf是一个成员变量。我只写了

  String {
preview(
[$ c._cbuf]

}

开始[Visualizer] 部分在autoexp.dat文件,它的工作原理。



但是,我想显示一个更复杂的类型,它没有任何有用的成员变量,但它有非常有用的方法。例如:

  class Date {
// ...
String asString()const;
private:
long _someReallyStrangeAndUnusefulDateRepresentation;
}

我想显示字符串而不是无用的长。怎么做?写入

 日期{
preview(
[$ c.asString()]

}

在autoexp.dat中不起作用。

解决方案

好的,经过一番研究,似乎通常只是编辑autoexp.dat可能而不是直接。



第一个解决方案是使用EEAddIn.dll,如下所述:



另一个解决方案可能是使用内联函数,如Lucien Murray-Pitts在此页面上的注释:,它受到升级调试可视化的启发。



但是我还没有尝试过这些。


I am working with a library with some awkward types. When debugging in Visual Studio, I would like to display them in a readable form. I found some really useful articles about how to edit autoexp.dat file.

http://www.idigitalhouse.com/Blog/?p=83

or

http://mariusbancila.ro/blog/2007/04/06/tweaking-autoexpdat-for-custom-types-in-vs2005/

Suppose I have a String class:

class String {
//...
private:
    char *_cbuf;
}

then I can add the visualizer easily because _cbuf is a member variable. I just write

String{
preview (
[$c._cbuf]
)
}

at the beginning of [Visualizer] section in autoexp.dat file and it works.

But suppose that I want to display a more complex type which does not have any useful member variables but it has very useful methods. E.g.:

class Date {
    //...
    String asString() const;
private:
    long _someReallyStrangeAndUnusefulDateRepresentation;
}

And I want to display the string rather than the unuseful long. How to do that? Writing

Date{
preview (
[$c.asString()]
)
}

in autoexp.dat does not work.

解决方案

OK, after some research it seems it is generally possible but not directly by just editing of autoexp.dat.

First solution is to use EEAddIn.dll as described here: http://msdn.microsoft.com/en-us/library/8fwk67y3%28v=VS.90%29.aspx

another solution might be using inlined function as in Lucien Murray-Pitts' comment down on this page: http://www.virtualdub.org/blog/pivot/entry.php?id=120 which is inspired by boost debug visualizers.

However I have not yet tried any of these.

这篇关于调试Visual Studio的C ++自定义类型的可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 03:56