How does one trace calls to std::cout?
The situation I run into every now and then is code (usually some 3rd party code) that will make a call to std::cout and the buffer is not immediately flushed.
Thus the data will is not printed to stdout immediately and shows up later when something else has called std::cout and flushed the buffer via std::endl or std::flush. I am thus left wondering who called std::cout? Now I have to chase it down C++ standard library function call. If the call to std::cout is deeply buried, it can be an annoyance to track down.
What are good ways to trace std::cout or any similar C++ standard library function to see where it is being called? My platform is Linux, though this could apply to any system.