From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21188 invoked by alias); 31 Dec 2003 11:16:09 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21134 invoked from network); 31 Dec 2003 11:15:57 -0000 Received: from unknown (HELO barry.mail.mindspring.net) (207.69.200.25) by sources.redhat.com with SMTP; 31 Dec 2003 11:15:57 -0000 Received: from user-119a90a.biz.mindspring.com ([66.149.36.10] helo=berman.michael-chastain.com) by barry.mail.mindspring.net with esmtp (Exim 3.33 #1) id 1AbeKO-0004b8-00; Wed, 31 Dec 2003 06:15:52 -0500 Received: by berman.michael-chastain.com (Postfix, from userid 502) id B0A5B4B35A; Wed, 31 Dec 2003 06:15:59 -0500 (EST) To: carlton@kealia.com, gdb-patches@sources.redhat.com Subject: [patch/testsuite/cp] classes.exp: rewrite Message-Id: <20031231111559.B0A5B4B35A@berman.michael-chastain.com> Date: Wed, 31 Dec 2003 11:16:00 -0000 From: mec.gnu@mindspring.com (Michael Elizabeth Chastain) X-SW-Source: 2003-12/txt/msg00530.txt.bz2 classes.exp has a problem with the new default gcc abi, gcc abi 2. I started fixing the problem and ended up rewriting most of the file. Here's a reminder: /* gcc abi 1 */ class Whatever { public: Whatever & operator=(const Whatever &); Whatever(const Whatever &); Whatever(); int method (); }; /* gcc abi 2*/ class Whatever { public: int method (); Whatever & operator=(const Whatever &); Whatever(const Whatever &); Whatever(); }; That is, with the new ABI, synthetic methods appear after the user-defined methods rather than before. This really is an ABI change: if a class has a synthetic virtual destructor, the vtable will be ordered differently than it was before. gdb prints the synthetic methods for stabs+, but not dwarf-2. There are about ten test scripts that get hit by this and need new patterns. I decided that classes.exp needed a lot of gdb_test_multiple and some other cleanup. There were several old patterns that don't match anything at all any more, plus some strange looking tests (some I changed, some I just documented). And the target program execution flow was strange: do_test kept restarting the target program instead of using breakpoints and continuing. Testing: I tested this with gcc 2.95.3, gcc 3.3.2, and gcc HEAD, with both dwarf-2 and stabs+. There is one new FAIL which indicates an existing bug in gdb or gcc. With gcc 2.95.3 -gstabs+, gdb prints: ... int operator int(); ... This is wrong; conversion operators do not have types. This bug was also in gdb 6.0. I need to KFAIL this before I commit. This is version 1, which is not mature enough yet. I'll put up version 2 in a day or two. Michael C Index: classes.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.exp,v retrieving revision 1.2 diff -c -3 -p -r1.2 classes.exp *** classes.exp 8 Sep 2003 02:00:11 -0000 1.2 --- classes.exp 31 Dec 2003 10:59:06 -0000 *************** *** 19,30 **** # bug-gdb@prep.ai.mit.edu # This file was written by Fred Fish. (fnf@cygnus.com) set ws "\[\r\n\t \]+" set nl "\[\r\n\]+" if $tracelevel then { ! strace $tracelevel } if { [skip_cplus_tests] } { continue } --- 19,31 ---- # bug-gdb@prep.ai.mit.edu # This file was written by Fred Fish. (fnf@cygnus.com) + # And rewritten by Michael Chastain . set ws "\[\r\n\t \]+" set nl "\[\r\n\]+" if $tracelevel then { ! strace $tracelevel } if { [skip_cplus_tests] } { continue } *************** set testfile "misc" *** 33,591 **** set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} - # Create and source the file that provides information about the compiler - # used to compile the test case. - - if [get_compiler_info ${binfile} "c++"] { - return -1 - } - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } - # # Test ptype of class objects. # proc test_ptype_class_objects {} { global gdb_prompt global ws global nl ! # Note that struct members are public by default, so we don't print ! # "public:" for the public members of structs. ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! ! send_gdb "ptype struct default_public_struct\n" ! gdb_expect { ! -re "type = struct default_public_struct \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { pass "ptype struct default_public_struct" } ! -re "type = class default_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct default_public_struct" } - -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" } - timeout { fail "ptype struct default_public_struct (timeout)" ; return } } ! # Note that struct members are public by default, so we don't print ! # "public:" for the public members of structs. ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! ! send_gdb "ptype struct explicit_public_struct\n" ! gdb_expect { ! -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct explicit_public_struct" } ! -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct explicit_public_struct" } - -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" } - timeout { fail "ptype struct explicit_public_struct (timeout)" ; return } } ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! send_gdb "ptype struct protected_struct\n" ! gdb_expect { ! -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { pass "ptype struct protected_struct" } ! -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct protected_struct" } - -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" } - timeout { fail "ptype struct protected_struct (timeout)" ; return } } ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! send_gdb "ptype struct private_struct\n" ! gdb_expect { ! -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { pass "ptype struct private_struct" } ! -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct private_struct" } - -re ".*$gdb_prompt $" { fail "ptype struct private_struct" } - timeout { fail "ptype struct private_struct (timeout)" ; return } } ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! send_gdb "ptype struct mixed_protection_struct\n" ! gdb_expect { ! -re "type = struct mixed_protection_struct \{${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" { pass "ptype struct mixed_protection_struct" } ! -re "type = struct mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { ! pass "ptype struct mixed_protection_struct (extra public)" ! } ! -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { pass "ptype struct mixed_protection_struct" } - -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" } - timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return } } ! # Accept it if gdb just fails to distinguish between ! # class and struct, and everything else is OK. ! send_gdb "ptype class public_class\n" ! gdb_expect { ! -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype class public_class" } ! -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { pass "ptype class public_class" } - -re ".*$gdb_prompt $" { fail "ptype class public_class" } - timeout { fail "ptype class public_class (timeout)" ; return } } ! send_gdb "ptype class protected_class\n" ! gdb_expect { ! -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype class protected_class" } ! -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! fail "ptype class protected_class" } - -re ".*$gdb_prompt $" { fail "ptype class protected_class" } - timeout { fail "ptype class protected_class (timeout)" ; return } } ! # Accept it if gdb just emits a superflous "private:" ! # attribute, since classes default to private and for consistency with ! # structs (where we don't print the "public:" attribute) we don't print ! # the "private:" attribute. ! send_gdb "ptype class default_private_class\n" ! gdb_expect { ! -re "type = class default_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype class default_private_class" } ! -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype class default_private_class" } - -re ".*$gdb_prompt $" { fail "ptype class default_private_class" } - timeout { fail "ptype class default_private_class (timeout)" ; return } } ! send_gdb "ptype class explicit_private_class\n" ! gdb_expect { ! -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { pass "ptype class explicit_private_class" } ! -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { ! pass "ptype class explicit_private_class" ! } ! -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { ! fail "ptype class explicit_private_class" } - -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" } - timeout { fail "ptype class explicit_private_class (timeout)" ; return } } ! send_gdb "ptype class mixed_protection_class\n" ! gdb_expect { ! -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" { pass "ptype class mixed_protection_class" } ! -re "type = struct mixed_protection_class \{${ws}int a;${ws}int b;${ws}int c;${ws}int d;${ws}int e;${ws}int f;${ws}int g;${ws}int h;${ws}int i;$nl.*\}$nl$gdb_prompt $" { ! fail "ptype class mixed_protection_class" } - -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" } - timeout { fail "ptype class mixed_protection_class (timeout)" ; return } } ! # This class does not use any C++-specific features, so it's fine for ! # it to print as "struct". ! send_gdb "ptype class A\n" ! gdb_expect { ! -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\((A const|const A) ?&\\);)|(${ws}A\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { pass "ptype class A" } ! -re ".*$gdb_prompt $" { ! fail "ptype class A" ! } ! timeout { ! fail "ptype class A (timeout)" ! return } } ! send_gdb "ptype class B\n" ! gdb_expect { ! -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class B" } ! -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(B const ?&\\);)|(${ws}B\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class B (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class B" ! } ! timeout { ! fail "ptype class B (timeout)" ! return } } ! send_gdb "ptype class C\n" ! gdb_expect { ! -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class C" } ! -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(C const ?&\\);)|(${ws}C\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class C (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class C" ! } ! timeout { ! fail "ptype class C (timeout)" ! return } } ! send_gdb "ptype class D\n" ! gdb_expect { ! -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class D" } ! -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(D const ?&\\);)|(${ws}D\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class D (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class D" ! } ! timeout { ! fail "ptype class D (timeout)" ! return } } ! send_gdb "ptype class E\n" ! gdb_expect { ! -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class E" } ! -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\((E const|const E) ?&\\);)|(${ws}E\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { pass "ptype class E" } - -re ".*$gdb_prompt $" { - fail "ptype class E" - } - timeout { - fail "ptype class E (timeout)" - return - } } ! # With g++ 2.x and stabs debug info, we misinterpret static methods ! # whose name matches their argument mangling. ! send_gdb "ptype class Static\n" ! gdb_expect { ! -re "type = (class|struct) Static \{(${ws}public:|)${ws}Static & operator=\\(Static const ?&\\);${ws}Static\\((Static const|const Static) ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Static" } ! -re "type = (class|struct) Static \{(${ws}public:|)${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Static" } ! -re ".*$gdb_prompt $" { ! fail "ptype class Static" ! } ! timeout { ! fail "ptype class Static (timeout)" ! return } } ! send_gdb "ptype class vA\n" ! gdb_expect { ! -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}\}$nl$gdb_prompt $" { pass "ptype class vA" } ! -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const ?&\\);${ws}vA\\((vA const|const vA) ?&\\);${ws}vA\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class vA" } - -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;((${ws}vA & operator=\\(vA const ?&\\);)|(${ws}vA\\(vA const ?&\\);)|(${ws}vA\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" { - pass "ptype class vA (obsolescent gcc or gdb)" - } - -re ".*$gdb_prompt $" { - fail "ptype class vA" - } - timeout { - fail "ptype class vA (timeout)" - return - } } ! # Accept the form with embedded GNU style mangled virtual table constructs ! # for now, but with a FIXME. At some future point, gdb should use a ! # portable representation for the virtual table constructs. ! ! # The format of a g++ virtual base pointer. ! set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" ! ! send_gdb "ptype class vB\n" ! gdb_expect { ! -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\((vB const|const vB) ?&\\);${ws}vB\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class vB" } ! -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vB (FIXME: non-portable virtual table constructs)" ! } ! -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" { ! pass "ptype class vB" ! } ! -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;((${ws}vB & operator=\\(vB const ?&\\);)|(${ws}vB\\(int, vB const ?&\\);)|(${ws}vB\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vB (FIXME) (obsolescent gcc or gdb)" } ! -re ".*$gdb_prompt $" { ! fail "ptype class vB" } ! timeout { ! fail "ptype class vB (timeout)" ! return } } ! # Accept the form with embedded GNU style mangled virtual table constructs ! # for now, but with a FIXME. At some future point, gdb should use a ! # portable representation for the virtual table constructs. ! send_gdb "ptype class vC\n" ! gdb_expect { ! -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\((vC const|const vC) ?&\\);${ws}vC\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class vC" } ! -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vC (FIXME: non-portable virtual table constructs)" ! } ! -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" { ! pass "ptype class vC" ! } ! -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;((${ws}vC & operator=\\(vC const ?&\\);)|(${ws}vC\\(int, vC const ?&\\);)|(${ws}vC\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vC (FIXME) (obsolescent gcc or gdb)" } ! -re ".*$gdb_prompt $" { ! fail "ptype class vC" } ! timeout { ! fail "ptype class vC (timeout)" ! return } } ! # Accept the form with embedded GNU style mangled virtual table constructs ! # for now, but with a FIXME. At some future point, gdb should use a ! # portable representation for the virtual table constructs. ! send_gdb "ptype class vD\n" ! gdb_expect { ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\((vD const|const vD) ?&\\);${ws}vD\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class vD" } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vD (FIXME: non-portable virtual table constructs)" ! } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" { ! pass "ptype class vD" ! } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*_vb.vC;${ws}vB \\*_vb.vB;${ws}public:${ws}int vd;${ws}int vx;((${ws}vD & operator=\\(vD const ?&\\);)|(${ws}vD\\(int, vD const ?&\\);)|(${ws}vD\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vD (FIXME) (obsolescent gcc or gdb)" } ! -re ".*$gdb_prompt $" { ! fail "ptype class vD" } ! timeout { ! fail "ptype class vD (timeout)" ! return } } ! # Accept the form with embedded GNU style mangled virtual table constructs ! # for now, but with a FIXME. At some future point, gdb should use a ! # portable representation for the virtual table constructs. ! send_gdb "ptype class vE\n" ! gdb_expect { ! -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\((vE const|const vE) ?&\\);${ws}vE\\((void|)\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class vE" } ! -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vE (FIXME: non-portable virtual table constructs)" ! } ! -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" { ! pass "ptype class vE" ! } ! -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;((${ws}vE & operator=\\(vE const ?&\\);)|(${ws}vE\\(int, vE const ?&\\);)|(${ws}vE\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "ptype class vE (FIXME) (obsolescent gcc or gdb)" } ! -re ".*$gdb_prompt $" { ! fail "ptype class vE" } ! timeout { ! fail "ptype class vE (timeout)" ! return } } ! send_gdb "ptype class Base1\n" ! gdb_expect { ! -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const ?&\\);${ws}Base1\\(((Base1 const)|(const Base1)) ?&\\);${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Base1" } ! -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Base1" } ! -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const ?&\\);)|(${ws}Base1\\(Base1 const ?&\\);)|(${ws}Base1\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class Base1 (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class Base1" ! } ! timeout { ! fail "ptype class Base1 (timeout)" ! return } } ! send_gdb "ptype class Foo\n" ! gdb_expect { ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;\r\n${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { ! pass "ptype class Foo" ! } ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo & operator=\\(Foo const ?&\\);${ws}Foo\\((Foo const|const Foo) ?&\\);${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Foo" } ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;((${ws}Foo & operator=\\(Foo const ?&\\);)|(${ws}Foo\\(Foo const ?&\\);)|(${ws}Foo\\(int, int\\);)|(${ws}int operator!\\((void|)\\);)|(${ws}int operator int\\((void|)\\);)|(${ws}int times\\(int\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class Foo (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class Foo" } ! timeout { ! fail "ptype class Foo (timeout)" ! return } } ! send_gdb "ptype class Bar\n" ! gdb_expect { ! -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const ?&\\);${ws}Bar\\((Bar const|const Bar) ?&\\);${ws}Bar\\(int, int, int\\);${ws}\}$nl$gdb_prompt $" { pass "ptype class Bar" } ! -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;((${ws}Bar & operator=\\(Bar const ?&\\);)|(${ws}Bar\\(Bar const ?&\\);)|(${ws}Bar\\(int, int, int\\);))*${ws}\}$nl$gdb_prompt $" { ! pass "ptype class Bar (obsolescent gcc or gdb)" ! } ! -re ".*$gdb_prompt $" { ! fail "ptype class Bar" } ! timeout { ! fail "ptype class Bar (timeout)" ! return } } } - # # Test simple access to class members. ! # proc test_non_inherited_member_access {} { global gdb_prompt # Print non-inherited members of g_A. - gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" - gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" # Print non-inherited members of g_B. - gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" - gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" # Print non-inherited members of g_C. - gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" - gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" # Print non-inherited members of g_D. - gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" - gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" # Print non-inherited members of g_E. - gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" - gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" } ! # ! # Try access to non-members that are members of another class. ! # Should give errors. ! # proc test_wrong_class_members {} { global gdb_prompt gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" - gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" - gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" - gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" - gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" - gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" } ! # ! # Try access to non-members that are not members of any class. ! # Should give errors. ! # proc test_nonexistent_members {} { global gdb_prompt gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" - gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" - gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" - gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" } - # # Call a method that expects a base class parameter with base, inherited, # and unrelated class arguments. - # proc test_method_param_class {} { gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" --- 34,590 ---- set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } # Test ptype of class objects. # + # This code accepts the output of gcc v2 and v3, dwarf-2 and stabs+. + # It could use some expansion with other compilers such as hp-ux ac++. + # + # There are lots of variations in the output: + # + # . gcc -stabs+ emits debug info for implicit member functions: + # operator=, copy ctor, ctor. gcc -gdwarf-2 does not. + # + # . gcc with abi version 1 puts the implicit member functions + # at the beginning of the member function list; with abi version 2, + # the implicit member functions are at the end of the member function + # list. This appears as an output difference with -gstabs+. + # gcc 3.3.X defaults to abi version 1, and gcc 3.4 will default + # to abi version 2. + # + # . gcc v2 shows data members for virtual base pointers. + # gcc v3 does not. + # + # . gdb always prints "class" for both "class" and "struct". + # In the future, I should accept "struct" in case gdb improves. proc test_ptype_class_objects {} { global gdb_prompt global ws global nl ! # Simple type. ! ! gdb_test_multiple "ptype struct default_public_struct" "ptype struct default_public_struct" { ! -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype struct default_public_struct" } ! -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}default_public_struct ?& ?operator ?=\\(default_public_struct const ?&\\);${ws}default_public_struct\\(default_public_struct const ?&\\);${ws}default_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype struct default_public_struct" } } ! # Same test, slightly different type. ! ! gdb_test_multiple "ptype struct explicit_public_struct" "ptype struct explicit_public_struct" { ! -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype struct explicit_public_struct" } ! -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}explicit_public_struct ?& ?operator ?=\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype struct explicit_public_struct" } } ! # Same test, slightly different type. ! gdb_test_multiple "ptype struct protected_struct" "ptype struct protected_struct" { ! -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype struct protected_struct" } ! -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_struct ?& ?operator ?=\\(protected_struct const ?&\\);${ws}protected_struct\\(protected_struct const ?&\\);${ws}protected_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype struct protected_struct" } } ! # Same test, slightly different type. ! gdb_test_multiple "ptype struct private_struct" "ptype struct private_struct" { ! -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype struct private_struct" } ! -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;${ws}public:${ws}private_struct ?& ?operator ?=\\(private_struct const ?&\\);${ws}private_struct\\(private_struct const ?&\\);${ws}private_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype struct private_struct" } } ! # Similar test, bigger type. ! gdb_test_multiple "ptype struct mixed_protection_struct" "ptype struct mixed_protection_struct" { ! -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype struct mixed_protection_struct" } ! -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_struct ?& ?operator ?=\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype struct mixed_protection_struct" } } ! # All that again with "class" instead of "struct". ! # gdb does not care about the difference anyways. ! gdb_test_multiple "ptype class public_class" "ptype class public_class" { ! -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class public_class" } ! -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;${ws}public_class ?& ?operator ?=\\(public_class const ?&\\);${ws}public_class\\(public_class const ?&\\);${ws}public_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype class public_class" } } ! # Same test, slightly different type. ! ! gdb_test_multiple "ptype class protected_class" "ptype class protected_class" { ! -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class protected_class" } ! -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_class ?& ?operator ?=\\(protected_class const ?&\\);${ws}protected_class\\(protected_class const ?&\\);${ws}protected_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class protected_class" } } ! # Same test, slightly different type. ! # The 'private' is optional but gdb always prints it. ! gdb_test_multiple "ptype class default_private_class" "ptype class default_private_class" { ! -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class default_private_class" } ! -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}default_private_class ?& ?operator ?=\\(default_private_class const ?&\\);${ws}default_private_class\\(default_private_class const ?&\\);${ws}default_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype class default_private_class" } } ! # Same test, slightly different type. ! ! gdb_test_multiple "ptype class explicit_private_class" "ptype class explicit_private_class" { ! -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class explicit_private_class" } ! -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}explicit_private_class ?& ?operator ?=\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class explicit_private_class" } } ! # Similar test, bigger type. ! ! gdb_test_multiple "ptype class mixed_protection_class" "ptype struct mixed_protection_class" { ! -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class mixed_protection_class" } ! -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_class ?& ?operator ?=\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class mixed_protection_class" } } ! # Here are some classes with inheritance. ! ! # Base class. ! ! gdb_test_multiple "ptype class A" "ptype class A" { ! -re "type = class A \{${ws}public:${ws}int a;${ws}int x;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class A" } ! -re "type = class A \{${ws}public:${ws}int a;${ws}int x;${ws}A ?& ?operator ?=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class A" } } ! # Derived class. ! ! gdb_test_multiple "ptype class B" "ptype class B" { ! -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class B" } ! -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B ?& ?operator ?=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class B" } } ! # Derived class. ! ! gdb_test_multiple "ptype class C" "ptype class C" { ! -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class C" } ! -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C ?& ?operator ?=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class C" } } ! # Derived class, multiple inheritance. ! ! gdb_test_multiple "ptype class D" "ptype class D" { ! -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class D" } ! -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D ?& ?operator ?=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class D" } } ! # Derived class. ! ! gdb_test_multiple "ptype class E" "ptype class E" { ! -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class E" } ! -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E ?& ?operator ?=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype class E" } } ! # This is a break from inheritance tests. ! # ! # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with ! # static methods whose name is the same as their argument mangling. ! ! gdb_test_multiple "ptype class Static" "ptype class Static" { ! -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class Static" } ! -re "type = class Static \{${ws}public:${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ pass "ptype class Static" } ! -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class Static" } } ! # Here are some virtual inheritance tests. ! ! gdb_test_multiple "ptype class vA" "ptype class vA" { ! -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class vA" } ! -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;${ws}vA ?& ?operator ?=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ pass "ptype class vA" } } ! # Accept the virtual base pointer if gdb wants to print it. ! # Those cases will go away when gcc 2 dies. ! # With gcc 3, gdb does not print the virtual base pointer. ! ! gdb_test_multiple "ptype class vB" "ptype class vB" { ! -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 pass "ptype class vB" } ! -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! pass "ptype class vB" } ! -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(int, ?vB const ?&\\);${ws}vB\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # See the hidden "in-charge" ctor parameter! ! pass "ptype class vB" } ! -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(vB const ?&\\);${ws}vB\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class vB" } } ! # Another class with a virtual base. ! gdb_test_multiple "ptype class vC" "ptype class vC" { ! -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 pass "ptype class vC" } ! -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! pass "ptype class vC" } ! -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(int, ?vC const ?&\\);${ws}vC\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # See the hidden "in-charge" ctor parameter! ! pass "ptype class vC" } ! -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(vC const ?&\\);${ws}vC\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class vC" } } ! # The classic diamond inheritance. ! gdb_test_multiple "ptype class vD" "ptype class vD" { ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.2vC;${ws}vB ?\\* ?_vb.2vB;${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 pass "ptype class vD" } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! pass "ptype class vD" } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.vC;${ws}vB ?\\* ?_vb.vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(int, ?vD const ?&\\);${ws}vD\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # See the hidden "in-charge" ctor parameter! ! pass "ptype class vD" } ! -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(vD const ?&\\);${ws}vD\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class vD" } } ! # One more case of virtual derivation. ! gdb_test_multiple "ptype class vE" "ptype class vE" { ! -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.2vD;${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 pass "ptype class vE" } ! -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! pass "ptype class vE" } ! -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(int, ?vE const ?&\\);${ws}vE\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # See the hidden "in-charge" ctor parameter! ! pass "ptype class vE" } ! -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(vE const ?&\\);${ws}vE\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class vE" } } ! # Another inheritance series. ! ! gdb_test_multiple "ptype class Base1" "ptype class Base1" { ! -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class Base1" } ! -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ pass "ptype class Base1" } ! -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);$nl\}$nl$gdb_prompt $" { ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class Base1" } } ! # The second base class. ! ! gdb_test_multiple "ptype class Foo" "ptype class Foo" { ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class Foo" } ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # ! # gcc 2.95.3 -gstabs+ does not match this because gdb ! # prints "int operator int(void)", which is wrong because ! # of the return type. That is a gdb bug or a gcc bug. ! pass "ptype class Foo" } ! -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);$nl\}$nl$gdb_prompt $" { ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class Foo" } } ! # A multiple inheritance derived class. ! ! gdb_test_multiple "ptype class Bar" "ptype class Bar" { ! -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 pass "ptype class Bar" } ! -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! pass "ptype class Bar" } ! -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);$nl\}$nl$gdb_prompt $" { ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype class Bar" } } } # Test simple access to class members. ! # TODO: these test names are gross! ! # Just let the test name default. proc test_non_inherited_member_access {} { global gdb_prompt # Print non-inherited members of g_A. gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect" gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect" # Print non-inherited members of g_B. gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect" gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect" # Print non-inherited members of g_C. gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect" gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect" # Print non-inherited members of g_D. gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect" gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect" # Print non-inherited members of g_E. gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect" gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect" } ! # Test access to members of other classes. ! # gdb should refuse to print them. ! # (I feel old -- I remember when this was legal in C -- chastain). ! # TODO: Again, change the silly test names. proc test_wrong_class_members {} { global gdb_prompt gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error" gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error" gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error" gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error" gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error" gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error" } ! # Test access to names that are not members of any class. ! # TODO: test names again. proc test_nonexistent_members {} { global gdb_prompt gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error" gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error" gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error" gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error" } # Call a method that expects a base class parameter with base, inherited, # and unrelated class arguments. proc test_method_param_class {} { gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a" *************** proc test_method_param_class {} { *** 606,667 **** gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" } - # # Examine a class with an enum field. - # proc test_enums {} { global gdb_prompt ! global hp_aCC_compiler # print the object - send_gdb "print obj_with_enum\n" - gdb_expect { - -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } - -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } - timeout { fail "(timeout) print obj_with_enum (1)" } - } ! send_gdb "next\n" ! gdb_expect { ! -re "$gdb_prompt $" { pass "next" } ! timeout { fail "(timeout) next" } ! } # print the object again - send_gdb "print obj_with_enum\n" - gdb_expect { - -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } - -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } - timeout { fail "(timeout) print obj_with_enum (2)" } - } ! # print out the enum member ! send_gdb "print obj_with_enum.priv_enum\n" ! gdb_expect { ! -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } ! -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } ! timeout { fail "(timeout) print obj_with_enum.priv_enum" } ! } # ptype on the enum member ! # The third success case is a little dubious, but it's not clear what ! # ought to be required of a ptype on a private enum... -sts 19990324 ! send_gdb "ptype obj_with_enum.priv_enum\n" ! gdb_expect { ! -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } ! -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } ! -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } ! -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } ! timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } } # ptype on the object ! send_gdb "ptype obj_with_enum\n" ! gdb_expect { ! -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" } ! -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)PrivEnum priv_enum;\r\n\[ \t\]*int x;.*\\}\r\n$gdb_prompt $" ! { # NOTE: carlton/2003-02-28: One could certainly argue that # this output is acceptable: PrivEnum is a member of # ClassWithEnum, so there's no need to explicitly qualify --- 605,673 ---- gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" } # Examine a class with an enum field. proc test_enums {} { global gdb_prompt ! global nl ! global ws # print the object ! gdb_test "print obj_with_enum" \ ! "\\$\[0-9\]+ = \{priv_enum = red, x = 0\}" \ ! "print obj_with_enum (1)" ! ! # advance one line ! ! gdb_test "next" "" ! ! # TODO: with gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2, ! # gdb is out of scope here and the tests after this FAIL. ! # This needs investigation. -- chastain 2003-12-30 # print the object again ! gdb_test "print obj_with_enum" \ ! "\\$\[0-9\]+ = \{priv_enum = green, x = 0\}" \ ! "print obj_with_enum (2)" ! ! # print the enum member ! ! gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = green" # ptype on the enum member ! ! gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" { ! -re "type = enum ClassWithEnum::PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { ! pass "ptype obj_with_enum.priv_enum" ! } ! -re "type = enum PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! pass "ptype obj_with_enum.priv_enum" ! } ! -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { ! # This case case is a little dubious, but it's not clear what ! # ought to be required of a ptype on a private enum... ! # -sts 19990324 ! # ! # It bugs me that this happens with gcc 3. ! # -- chastain 2003-12-30 ! # ! # gcc 2.95.3 -gstabs+ ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype obj_with_enum.priv_enum" ! } } # ptype on the object ! gdb_test_multiple "ptype obj_with_enum" "ptype obj_with_enum" { ! -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" { ! pass "ptype obj_with_enum" ! } ! -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" { # NOTE: carlton/2003-02-28: One could certainly argue that # this output is acceptable: PrivEnum is a member of # ClassWithEnum, so there's no need to explicitly qualify *************** proc test_enums {} { *** 670,819 **** # of ClassWithEnum, so we do that output for a bad reason # instead of a good reason. Under stabs, we probably # can't get this right; under DWARF-2, we can. kfail "gdb/57" "ptype obj_with_enum" } ! -re "$gdb_prompt $" { fail "ptype obj_with_enum" } ! timeout { fail "(timeout) ptype obj_with_enum" } } ! # We'll do this test twice, because of a parser bug: see ! # PR gdb/826. ! ! send_gdb "print (ClassWithEnum::PrivEnum) 42\n" ! gdb_expect { ! -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } ! -re "A parse error in expression, near `42'.\r\n$gdb_prompt $" { ! # bison 1.35 kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" } - -re "A syntax error in expression, near `42'.\r\n$gdb_prompt $" { - # bison 1.875 - kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" - } - -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } - timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } } ! send_gdb "print ('ClassWithEnum::PrivEnum') 42\n" ! gdb_expect { ! -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print ('ClassWithEnum::PrivEnum') 42" } ! -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.\r\n$gdb_prompt $" ! { kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" } ! -re "$gdb_prompt $" { fail "print ('ClassWithEnum::PrivEnum') 42" } ! timeout { fail "(timeout) print ('ClassWithEnum::PrivEnum') 42" } } } - # # Pointers to class members - # proc test_pointers_to_class_members {} { global gdb_prompt - global decimal - global nl - - gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" - - gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" - - gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" - - send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" - gdb_expect { - -re ".* = true$nl$gdb_prompt $" { - pass "print (int)&Bar::y == 2*sizeof(int)" - } - -re "There is no field named y.*$gdb_prompt $" { - setup_xfail "*-*-*" - fail "print (int)&Bar::y == 2*sizeof(int)" - } - -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } - timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } - } - - send_gdb "next 2\n" - setup_xfail "*-*-*" - gdb_expect { - -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {} - -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } - } - clear_xfail "*-*-*" ! gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)" } - # # Test static members. - # proc test_static_members {} { global gdb_prompt global hex - global nl ! send_gdb "print Foo::st\n" ! gdb_expect { ! -re ".* = 100$nl$gdb_prompt $" { ! pass "print Foo::st" ! } ! -re "There is no field named st.*$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "print Foo::st" ! } ! -re ".*$gdb_prompt $" { fail "print Foo::st" } ! timeout { fail "print Foo::st (timeout)" ; return } ! } ! ! send_gdb "set foo.st = 200\n" ! gdb_expect { ! -re ".*$gdb_prompt $" {} ! } ! ! send_gdb "print bar.st\n" ! gdb_expect { ! -re ".* = 200$nl$gdb_prompt $" { ! pass "print bar.st" ! } ! -re "There is no member( or method|) named st.*$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "print bar.st" ! } ! -re ".*$gdb_prompt $" { fail "print bar.st" } ! timeout { fail "print bar.st (timeout)" ; return } ! } ! ! send_gdb "print &foo.st\n" ! gdb_expect { ! -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { ! pass "print &foo.st" ! } ! -re "There is no member( or method|) named st.*$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "print &foo.st" ! } ! -re ".*$gdb_prompt $" { fail "print &foo.st" } ! timeout { fail "print &foo.st (timeout)" ; return } ! } ! ! set got_bar_st 0 ! send_gdb "print &Bar::st\n" ! gdb_expect { ! -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { ! pass "print &Bar::st" ! set got_bar_st 1 ! } ! -re "There is no field named st.*$gdb_prompt $" { ! setup_xfail "*-*-*" ! fail "print &Bar::st" ! } ! -re ".*$gdb_prompt $" { fail "print &Bar::st" } ! timeout { fail "print &Bar::st (timeout)" ; return } ! } ! ! if $got_bar_st then { ! gdb_test "print *\$" ".* = 200" "print *\$" ! } gdb_test "set print static-members off" "" gdb_test "print csi" \ --- 676,765 ---- # of ClassWithEnum, so we do that output for a bad reason # instead of a good reason. Under stabs, we probably # can't get this right; under DWARF-2, we can. + # + # gcc 2.95.3 -gdwarf-2 + # gcc 3.3.2 -gdwarf-2 + kfail "gdb/57" "ptype obj_with_enum" + } + -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ kfail "gdb/57" "ptype obj_with_enum" } ! -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" { ! # I think this is a PASS, but only carlton knows for sure. ! # -- chastain 2003-12-30 ! # ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "ptype obj_with_enum" ! } } ! # I'll do this test two different ways, because of a parser bug. ! # See PR gdb/826. ! ! gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" { ! -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" { ! pass "print (ClassWithEnum::PrivEnum) 42" ! } ! -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" { ! # "parse error" is bison 1.35. ! # "syntax error" is bison 1.875. kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" } } ! gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" { ! -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" { ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "print ('ClassWithEnum::PrivEnum') 42" ! } ! -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! # gcc 2.95.3 -gstabs+ ! kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" ! } } } # Pointers to class members proc test_pointers_to_class_members {} { global gdb_prompt ! gdb_test "print Bar::z" "\\$\[0-9\]+ = \\(int ?\\( ?Bar::& ?\\) ?\\) ?Bar::z" ! gdb_test "print &Foo::x" "\\$\[0-9\]+ = \\(int ?\\( ?Foo::\\* ?\\) ?\\) ?&Foo::x" ! gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0" ! gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true" ! ! # TODO: why does this line even exist? And whatever it is, ! # it is out of sync with misc.cc! ! # gdb_test "next 2" "\[0-9\]+.*inheritance3 \\(\\);" ! ! # TODO: This is strange, because pmi has not even been declared yet. ! # Plus it is dumb to test for something false, because it will ! # usually PASS if gdb has memory corruption. It's been this way ! # since gdb 4.10, 1993. What gives? # -- chastain 2003-12-30 ! gdb_test "print (int)pmi == sizeof(int)" "\\$\[0-9\]+ = false" } # Test static members. proc test_static_members {} { global gdb_prompt global hex ! gdb_test "print Foo::st" "\\$\[0-9\]+ = 100" ! gdb_test "set foo.st = 200" "" ! gdb_test "print bar.st" "\\$\[0-9\]+ = 200" ! gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" ! gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" ! gdb_test "print *\$" "\\$\[0-9\]+ = 200" gdb_test "set print static-members off" "" gdb_test "print csi" \ *************** proc do_tests {} { *** 840,845 **** --- 786,792 ---- global srcdir global binfile global gdb_prompt + global nl set prms_id 0 set bug_id 0 *************** proc do_tests {} { *** 851,924 **** gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile ! send_gdb "set language c++\n" ! gdb_expect -re "$gdb_prompt $" ! send_gdb "set width 0\n" ! gdb_expect -re "$gdb_prompt $" ! runto_main ! test_ptype_class_objects ! ! if [ runto 'inheritance2' ] then { ! test_non_inherited_member_access ! test_wrong_class_members ! test_nonexistent_members ! test_method_param_class } gdb_breakpoint enums2 ! if [ gdb_continue "enums2(\\(\\)|)" ]==0 then { ! gdb_test "finish" "" "" ! test_enums ! } ! ! if [istarget "mips-idt-*"] then { ! # Restart because IDT/SIM runs out of file descriptors. ! gdb_exit ! gdb_start ! gdb_reinitialize_dir $srcdir/$subdir ! gdb_load $binfile ! } ! ! if [ runto_main ] then { ! test_pointers_to_class_members ! test_static_members ! } ! ! if [istarget "mips-idt-*"] then { ! # Restart because IDT/SIM runs out of file descriptors. ! gdb_exit ! gdb_start ! gdb_reinitialize_dir $srcdir/$subdir ! gdb_load $binfile ! } ! ! if [ runto marker_reg1 ] then { ! ! gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" ! ! send_gdb "print v.method ()\n" ! gdb_expect { ! -re "= 82.*$gdb_prompt $" { ! pass "calling method for small class" ! } ! -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" { ! setup_xfail "*-*-*" 2972 ! fail "calling method for small class" ! } ! -re ".*$gdb_prompt $" { fail "calling method for small class" } ! timeout { fail "calling method for small class (timeout)" } ! eof { fail "calling method for small class (eof)" } } } } do_tests - - send_gdb "maint demangle inheritance1__Fv\n" - gdb_expect { - -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } - -re ".*$gdb_prompt $" { fail "demangle" } - timeout { fail "(timeout) demangle" } - } --- 798,864 ---- gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile ! gdb_test "set language c++" "" "" ! gdb_test "set width 0" "" "" ! if ![runto_main ] then { ! perror "couldn't run to breakpoint" ! return } + test_pointers_to_class_members + test_static_members + + gdb_breakpoint inheritance2 + gdb_test "continue" ".*Breakpoint .* inheritance2.*" "" + + test_ptype_class_objects + test_non_inherited_member_access + test_wrong_class_members + test_nonexistent_members + test_method_param_class + gdb_breakpoint enums2 ! gdb_test "continue" ".*Breakpoint .* enums2.*" "" ! gdb_test "finish" "" "" ! test_enums ! ! # Now some random tests that were just thrown in here. ! ! gdb_breakpoint marker_reg1 ! gdb_test "continue" ".*Breakpoint .* marker_reg1.*" "" ! gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" ! ! # This class is so small that an instance of it can fit in a register. ! # When gdb tries to call a method, it gets embarrassed about taking ! # the address of a register. Actually I think this should be a PASS, ! # not an XFAIL: gdb prints an informative message and declines to do ! # something impossible. ! # ! # The only way this test can PASS is if the compiler fails to allocate ! # very small classes to registers, in which case it's just the same ! # as a normal method call. ! # ! # -- chastain 2003-12-30 ! gdb_test_multiple "print v.method ()" "calling method for small class" { ! -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" { ! # gcc 3.3.2 -gdwarf-2 ! # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 ! # gcc 3.3.2 -gstabs+ ! # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ ! pass "calling method for small class" ! } ! -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" { ! # gcc 2.95.3 -gdwarf-2 ! # gcc 2.95.3 -gstabs+ ! setup_xfail "*-*-*" 2972 ! fail "calling method for small class" } } + # TODO: demangle.exp already has several tests exactly like this. + # How about just removing this? -- chastain 2003-12-30 + gdb_test "maint demangle inheritance1__Fv" "inheritance1\\(void\\)" "demangle" } do_tests