GDB - How to break on “something is written to cout”?


simply use rbreak as follows:

gdb> rbreak std::ostream::operator<<

you can write every regular expression which matches your function name. This is the easiest way to catch all template instances for example. If the regex I wrote in the example is not strong enough, feel free to write a more specialized one. I hope that I could provide a start point.


I would like to set a breakpoint that triggers every time something is written to stdout via the cout stream, but I'm having trouble finding a possible position for this breakpoint.

How can I do this in gdb?