Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 530
User Avatar asked Jun 07 '11 21:06

User


People also ask

How to Enable debugging in Visual Studio 2022?

In the Visual Studio toolbar, make sure the configuration is set to Debug. To start debugging, select the profile name in the toolbar, such as <project profile name>, IIS Express, or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.

How do I run and debug a Visual Studio code on a Mac?

vscode on the left-navigation pane of the Explorer (Command+shift+e), enter Command+shift+d to enter into the “run and debug” set-up.


2 Answers

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
like image 50
brianskold Avatar answered Sep 30 '22 12:09

brianskold


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.

like image 26
Matt Fisher Avatar answered Sep 30 '22 11:09

Matt Fisher