Debug stringstream with GDB in general

A

ademirzanetti

Does anyone know how to debug objects of the type stream in general
using GDB ? I am currently using GDB version 6.4.

There is no much usefull information about it througout the internet.
I am using the tips of the sites below to debug STL containers but I
found nothing about stream.

http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF

Basically I need to see the contents on a stringstream as the one on
the program below, but I can not use call either print on a
stringstream object.

#include <iostream>
#include <sstream>

using namespace std;

int main ( int argc, char* argv[] ) {

cout << "Starting Processing" << endl;

stringstream l_Str;
l_Str << "foo";

cout << "Process finished" << endl;

return 0;
}

g++ -ggdb -o test test.cpp

gdb ./test

(gdb) break test.cpp:12
(gdb) run

(gdb) call l_Str.str()
Couldn't find method stringstream::str
(gdb) print l_Str.str()
Couldn't find method stringstream::str
(gdb) print l_Str
$1 = <incomplete type>
 
U

utab

Does anyone know how to debug objects of the type stream in general
using GDB ? I am currently using GDB version 6.4.

There is no much usefull information about it througout the internet.
I am using the tips of the sites below to debug STL containers but I
found nothing about stream.

http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF

Basically I need to see the contents on a stringstream as the one on
the program below, but I can not use call either print on a
stringstream object.

#include <iostream>
#include <sstream>

using namespace std;

int main ( int argc, char* argv[] ) {

cout << "Starting Processing" << endl;

stringstream l_Str;
l_Str << "foo";

cout << "Process finished" << endl;

return 0;

}

g++ -ggdb -o test test.cpp

gdb ./test

(gdb) break test.cpp:12
(gdb) run

(gdb) call l_Str.str()
Couldn't find method stringstream::str
(gdb) print l_Str.str()
Couldn't find method stringstream::str
(gdb) print l_Str
$1 = <incomplete type>

Do not know the direct answer but why not try putting a

cout << l_Str.str() << endl;

after the line

l_Str << "foo"
 
I

Ian Collins

ademirzanetti said:
Does anyone know how to debug objects of the type stream in general
using GDB ? I am currently using GDB version 6.4.
Probably, but the best place to find them would be on a gnu/gdb forum,
rather then here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top