5

I am trying to figure out a problem in my c++ code and have DDD to debug with on a Sun machine. I am required to use strings per some standard we have. But whenever DDD encounters a string variable, it always comes up as being empty. I want to remember having the same trouble using CVD before on an SGI.
Short of re-writing my code to remove string is there anything else I could try/use?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
mdeliota
  • 51
  • 1

3 Answers3

1

Have a look here

They solve it by implementing a helper function that can be used by gdb (should also work for DDD as it uses gdb)

epatel
  • 45,805
  • 17
  • 110
  • 144
1
p variablename.c_str()

or

display variablename.c_str()
Steve Lazaridis
  • 2,210
  • 1
  • 15
  • 15
0

Basically, you need to create a wrapper function that prints out your string, by passing it a memory address:

void gs(string &s) { cout << s << endl; }

and then in gdb:

call gs(somevariable)

Reference

Seamus Connor
  • 1,765
  • 1
  • 18
  • 24