简体   繁体   English

调试Visual Studio的C ++自定义类型的可视化工具

[英]debug visualizer of C++ custom types for Visual Studio

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. 在Visual Studio中进行调试时,我希望以可读的形式显示它们。 I found some really useful articles about how to edit autoexp.dat file. 我找到了一些关于如何编辑autoexp.dat文件的非常有用的文章。

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

or 要么

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

Suppose I have a String class: 假设我有一个String类:

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

then I can add the visualizer easily because _cbuf is a member variable. 然后我可以轻松添加可视化工具,因为_cbuf是一个成员变量。 I just write 我只是写

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

at the beginning of [Visualizer] section in autoexp.dat file and it works. 在autoexp.dat文件的[Visualizer]部分的开头,它可以工作。

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. 但是假设我想显示一个更复杂的类型,它没有任何有用的成员变量,但它有非常有用的方法。 Eg: 例如:

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. 在autoexp.dat中不起作用。

OK, after some research it seems it is generally possible but not directly by just editing of autoexp.dat. 好的,经过一些研究似乎通常可以,但不是直接编辑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 第一种解决方案是使用EEAddIn.dll,如下所述: 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. 另一个解决方案可能是使用内联函数,如Lucien Murray-Pitts在此页面上的评论: http//www.virtualdub.org/blog/pivot/entry.php?id = 120,其灵感来自boost调试可视化工具。

However I have not yet tried any of these. 但是我还没有尝试过这些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM