This is the mail archive of the gdb-prs@sources.redhat.com 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]

gdb/620: instance member (added in extending class) shown incorrectly


>Number:         620
>Category:       gdb
>Synopsis:       instance member (added in extending class) shown incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 29 07:08:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     tomas.sieger@seznam.cz
>Release:        gdb+dejagnu-20020729
>Organization:
>Environment:
PC Intel Pentium 4, Red Hat Linux 7.2, kernel 2.4.9-31, libc 2.2.4, gcc 2.96
>Description:
class AA extends class A, it adds new member 'q'
A *a=new AA()

gdb correctly displays a->p using 
	p ((AA*)a)->q
but it does not correctly displays the whole instance using 
	p *(AA*)a
gdb prints something like:

(gdb) p *(AA*)a
$1 = {<A> = {p = 0x1}, q = 0x401c2c28}
(gdb) p *(AA*)a
$2 = {<A> = {p = 0x1}, q = 0x10}
(gdb) p *(AA*)a
$3 = {<A> = {p = 0x1}, q = 0x0}
...

#include <stdio.h>
class A {
public:
    void *p;
};
class AA:public A {
public:
    void *q;
    AA() {
        p=(void*)1;
        q=(void*)2;
    }
};
void main(int argc,char *argv[]) {
    A *a=new AA();
    /* now type in gdb several times:
     *      p *(AA*)a
     * value of 'q' field is not correct and changes magically
     */
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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