Thread View: gnu.gdb.bug
1 messages
1 total messages
Started by LiuFeng
Wed, 06 Mar 2002 11:01
Cannot print the content of a object
Author: LiuFeng
Date: Wed, 06 Mar 2002 11:01
Date: Wed, 06 Mar 2002 11:01
65 lines
2596 bytes
2596 bytes
Today, I found a interesting bug of gdb, (
maybe of gcc ), the code is as following,
// Begin of the test code
struct S {
int a;
int b;
};
class Fl_Widget {
/*
char parent_;
char user_data_;
char x_,y_,w_,h_;
char label_;
char type_;
char flags_;
char damage_;
char box_;
char color_;
char color2_;
char align_;
char when_;
char callback_;
*/
char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;
S s;
public:
Fl_Widget(int,int,int,int,const char* =0){};
virtual ~Fl_Widget(){};
};
class Test: Fl_Widget {
//char a, b, c;
int d;
public:
Test (): Fl_Widget (0,0,10,10) {};
};
main () {
Test * o = new Test ();
}
// End of the test code
when the following conditions are all fullfilled,
gdb will "print cannot access memory at address
XXXXXXXX" when do "p *o" after the line "Test *o =
new Test();":
1, there're 16 data member in the parent
class, more or less will not do.
2, the parent has a virtual destructor;
3, the child class has 1~3 private data
member, more or less will not do, public data
member will not do.
4, the object should be create on the heap
by new, not on the stack.
It's really funny. To check the fltk
ojects' content, I just could add a dmp data
member to the Fl_Widget class. But Why ?
My develop environment is redhat 7.2, gcc
version is 2.96 20000731, gdb version is 5.0, I
upgrade to 5.1.1 and got the same result.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads