Question

Is there a tool for C++ that can log function calls and what was passed?

Ex:

Display::Resize(1024,768)
Player::Jump()
...

Or anything somewhat like this to linearly see the flow of execution without having a Log call in every method of every class?

I use Visual Studio as an IDE, but any external tool or plugin that could do this would be great. Are there any?

Thanks

Was it helpful?

Solution 2

A more exotic solution could be to have a look a Aspect-Oriented Programming. One fundamental example is to log function call.

See this for C++ examples.

Edit : a small example from AspectC++ to trace a call from a member function (Iter::Reset in that case)

aspect Tracer
{ 
   advice call("% %Iter::Reset(...)") : before()
   {
      cerr << "about to call Iter::Reset for " << JoinPoint::signature() << endl;
   }
};

OTHER TIPS

this might be helpful: _penter hook

and here is an example:

You could set up breakpoints that automatically print a backtrace when the functions you're interested in are called with your debugger, or use a specialized tool like xtrace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top