🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #2585

Cannot print the content of a object

#2585
From: LiuFeng
Date: Wed, 06 Mar 2002 11:01
65 lines
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.
Technical Details
Message-ID: <3C85F6EC.FB44848F@redflag-linux.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.stueberl.de!newsfeed.online.be!zur.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!bug-gdb

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,b06463671af95c55,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 2002-03-06 03:00:25 PST
x-uunet-gateway: dfw7sosrv11.alter.net from bug-gdb to gnu.gdb.bug; Wed, 6 Mar 2002 11:00:18 GMT
Sender: root@dns.rabbit.redflag-linux.com
Message-ID: <3C85F6EC.FB44848F@redflag-linux.com>
Date: Wed, 06 Mar 2002 19:01:00 +0800
From: fengliu@redflag-linux.com (LiuFeng)
Organization: Redflag
X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.7-10 i686)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Cannot print the content of a object
Content-Type: text/plain; charset=gb2312
Content-Transfer-Encoding: 7bit
Approved: bug-gdb-request@mail.gnu.org
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.stueberl.de!newsfeed.online.be!zur.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!bug-gdb
Lines: 65