Why does the value of strings
in Eclipse Mars CDT not appear in the expression or variables
windows?
It appears {...}
but i want to see the value itself under the value tab.
How can i do this?
Why does the value of strings
in Eclipse Mars CDT not appear in the expression or variables
windows?
It appears {...}
but i want to see the value itself under the value tab.
How can i do this?
What is going on here is CDT is showing the information that GDB is providing to it.
For a trivial program, with the debugger stopped on the line with return 0;
#include <string>
using namespace std;
int main() {
string mystring = "my string here";
return 0;
}
this is what I see in the CDT variable view:
which matches what I see in GDB:
(gdb) p mystring
$1 = {static npos = <optimised out>,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
_M_p = 0x602028 "my string here"}}
However, what I suspect you want is the pretty printers for libstdc++ which makes the variables view look like this:
Create a ~/.gdbinit file with the following contents (updating the path for your machine)
python
import sys
sys.path.insert(0, '/usr/share/gcc-4.8/python/')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
Then point your launch configuration at that gdbinit file and start debugging.