Brahim Brahim - 3 years ago 88
C++ Question

gdb pretty printer stops working if I rerun my program

If I use the command run inside gdb to rerun my program I can no longer pretty print my c++ objects like vectors:

$ gdb ./some_program
(gdb) br some_where
(gdb) run
(gdb) print some_vector # the vector is pretty printed
(gdb) run
(gdb) print some_vector # the vector is no longer pretty printed

Here's a sample code I used and its actual gdb session:

#include <vector>
#include <iostream> using namespace std;
int main()
vector<int> v{1};
cout << v[0] << endl;

enter image description here

Answer Source

This is most likely this libstdc++ pretty printers bug.

You can apply this patch to you currently installed pretty printers or update whole gcc to a more recent version.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download