Debug Visualizer use member method / function call in preview?

Using Visual Studio 2010 with native C++. When editing autoexp.dat, is it possible to use the results of a method call in a debug visualizer preview?

For example, if my class is Person how can I do something like:

MyNamespace::Person{
  preview(
    #("FirstName=", $e->GetFirstName())
  )
}

(You may ask why I don't just get the private member variable data and that is because GetFirstName() delegates to a 3rd party library method call, so I do not have access to the data member. Another reason could be the method performs some calculation.)


You might want to look at the following:

  • https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/boost__DateTime.msvc8.vis.txt
  • https://svn.boost.org/svn/boost/sandbox/boost_docs/subprojects/DebuggerVisualizers/date_time_visualizer.hpp
  • See comments about user custom functions here for some people's experience with this:

  • http://www.virtualdub.org/blog/pivot/entry.php?id=120

  • No the Visual Studio debugger only supports directly reading virtual memory. Supporting e->GetFirstName() would require doing introspection into the GetFirstName() function, which could be very complicated if GetFirstName() is non-trivial or virtual (worse yet GetFirstName() could have side-effects or crash). Changing autoexp.dat won't let you get around this problem.

    If you really want to get this functionality, you could add a new debug-only member function like std::string *_firstName and point it to GetFirstName() on construction of Person, then have autoexp.dat dereference and display this variable for you.

    链接地址: http://www.djcxy.com/p/52920.html

    上一篇: 序列化包含列表<T>的列表<T>

    下一篇: 调试可视化器在预览中使用成员方法/函数调用?