Creating a simple VS2008 visualizer inside autoexp.dat (problem with casting)

醉酒当歌 提交于 2019-12-07 07:49:21

问题


I have a large project of mixed C/C++. I've created a simple visualizer for the ICU UnicodeString class as follows...

[inside autoexp.dat]
icu_4_2::UnicodeString {
        preview     ([$c.fUnion.fFields.fArray,su])
}

...and that works fine. Inside the debugger wherever I see the object I now see the text inside in the preview line.

I then created a wrapper class containing one of these objects as follows...

class StringHandleData
{
public:
    icu_4_2::UnicodeString str;
};

...and then created another visualizer for this...

[inside autoexp.dat]
StringHandleData {
    preview     ([$c.str.fUnion.fFields.fArray,su])
}

...which again, works fine. Whenever I see a StringHandleData object in the debugger I see the text inside in the string.

However, my problem comes when I define a typedef I can use inside C code like this...

typedef void* StringHandle;

...which under the hood is actually just a ptr to a StringHandleData object. So when I try and create a visualizer for the StringHandle type like this...

[inside autoexp.dat]
StringHandle {
    preview     ([((StringHandleData)$c).str.fUnion.fFields.fArray,su])
}

...it doesn't work. I've tried lots of other ways of casting the object too but with no luck so far. If I go to my watch window and cast a StringHandle like this... (StringHandleData*)stringHandle then the debugger makes the cast and previews correctly - but I just can't seem to get it to do it automatically from inside autoexp.dat

Thanks for any help.


回答1:


Visual studio's visualiser is blind to typedefs and will think StringHandle is a void *.



来源:https://stackoverflow.com/questions/2584228/creating-a-simple-vs2008-visualizer-inside-autoexp-dat-problem-with-casting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!