简体   繁体   中英

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. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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