I wrote a simple test.cc as follows:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world" << endl;
return 0;
}
And I compiled with:
g++ -g test.cc -o test.o
I ran gdb and put a breakpoint at the "Hello world" line:
$ gdb test.o
(gdb) b 7
(gdb) c
Then gdb stops at the "Hello world" line, but when I run
(gdb) s
It fails to step into the cout function. So my question is, how can I step into the cout function?
If it wasn’t linked against a version of the standard library with debugging information, it doesn’t know how to step into the library; it can only step over it (that is, run until control returns to the code with the debugging information).
Consult the documentation for your system to find out how to install the debug version of the standard C and C++ libraries.