This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13342] insufficient memory is fetched from the inferior forpartially destroyed C++ objects


http://sourceware.org/bugzilla/show_bug.cgi?id=13342

--- Comment #3 from Eric van Gyzen <eric+sourceware at vangyzen dot net> 2011-11-02 15:22:31 UTC ---
Thanks for looking into this, Tom.

(In reply to comment #2)
> (gdb) up
> #1  0x000000000040078d in Apple::~Apple (this=0x7fffffffe450, 
>     __in_chrg=<value optimized out>) at pr.cc:34
> 34        ~Apple(void) { }
> (gdb) p *this
> $7 = (Fruit) {
>   _vptr.Fruit = 0x400910, 
>   fruit1 = 1, 
>   fruit2 = 2, 
>   fruit3 = 3, 
>   fruit4 = 4
> }

I did exactly what you did.  However, when I did it, $7 was an Apple:

(gdb) p *this
$3 = {
  <Fruit> = {
    _vptr$Fruit = 0x400a10, 
    fruit1 = 1, 
    fruit2 = 2, 
    fruit3 = 3, 
    fruit4 = 4
  }, 
  members of Apple: 
  apple1 = 0, 
  apple2 = 0, 
  apple3 = 0, 
  apple4 = 0
}

(gdb) ptype *this
type = struct Apple : public Fruit {
[snip]

> At the end here I think the dynamic type has changed to Fruit, so this
> is still correct.

True, but the compile-time type in ~Apple is Apple, so I would expect gdb to
show me the whole Apple.  It does this in my case (v7.2), and it shows
incorrect data for the appleN members.

I wonder why it only shows you the Fruit.  Is this a difference between 7.2 and
HEAD?  What happens when you "p *(class Apple *)this" in ~Apple?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]