[Converted from Gnats 1619] I have a class which defines an operator<< so that it can be dumped to cout or cerr. I cannot call this function from gdb. I have searched the bug database and while this problem has been reported before and some solutions were presented, none of them worked using gdb 6.0, gcc 2.95.3 class MyClass { public: int mInteger; double mDouble; }; ostream & operator<< (ostream & s, const MyClass & o) { s << o.mInteger << " " << o.mDouble << endl; return s; } Release: 6.0 Environment: Linux, gcc 2.95.3 How-To-Repeat: Put a breakpoint on the attached file @ line 22. Then try to call the operator<< function defined on line 12. compile with g++ -g -o test deleteme.cpp
Fix: Don't know.
Calling operator<< works just fine for me since at least gdb-8.1: (gdb) p operator<< (cout, obj) $1 = (std::ostream &) @0x13f2e3980: <incomplete type>
How about "p cout << obj" ?
(In reply to Tom Tromey from comment #3) > How about "p cout << obj" ? Right, forgot to test the obvious, that works for me since gdb-8.2.1: ``` (gdb) p cout << obj 1 4.57307e-318 $1 = (std::ostream &) @0x13fa33980: <incomplete type> ```