当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - View most derived type in debugger

问题描述:

I'm writing a C++ project and building a DAG of various inheritance-related types. I've placed a breakpoint after construction and I'd like to view the DAG. The debugger however will only show the base class. It will name the most derived type next to the __vfptr entry, but I can't actually view it's contents and verify that they are what I expect them to be. Is there any way to view the most derived type in the Locals window directly?

I am targetting x64, if that's relevant.

网友答案:

The only way that seem to work for me is to tell debugger to properly show objects with help of autoexp.dat. Not sure what's how well it will work in vs2010, I'm still using 2008. This method is very suitable for smart pointers. If you are trying to look inside raw pointers then, I guess, you need to manually cast pointer in the watch/quick watch window. If it's some sort of smartpointer or a class that store that raw base pointer then you can simply get it done with autoexp.dat this way (assuming that your base ptr is called m_ptr):

smart_ptr<*>{
preview
(
    #if (($e.m_ptr)!=0)
    (
    #(
        "smart_ptr ",
        (*(($T1 *)$e.m_ptr))
    )
    )
    #else
    (
        #("<Bad Ptr>")
    )
)
children
(
    #(
        ptr: (*(($T1 *)$e.m_ptr))
    )
)

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: