Debug C ++ Custom Type Renderer 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 helpful articles on how to edit the 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 easily add a renderer because _cbuf is a member variable. I'm just writing
String{
preview (
[$c._cbuf]
)
}
at the beginning of the section [Visualizer]
in the autoexp.dat file and it works.
But suppose I want to map a more complex type that has no useful member variables, but has very useful methods. For example:.
class Date {
//...
String asString() const;
private:
long _someReallyStrangeAndUnusefulDateRepresentation;
}
And I want to display a string, not a long one. How to do it? Recording
Date{
preview (
[$c.asString()]
)
}
in autoexp.dat doesn't work.
source to share
Ok, after some research it seems that this is generally possible, but not directly, just by editing autoexp.dat.
The 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 could use a built-in function, as in the comment by Lucien Murray-Pitts on this page: http://www.virtualdub.org/blog/pivot/entry.php?id=120 which is inspired by the enhancement of debug renderers.
However, I have not tried any of them yet.
source to share