📄 classes.exp
字号:
# Copyright (C) 1992, 1994, 1995, 1997, 1999 Free Software Foundation, Inc.# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.# # This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# # You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Please email any bugs, comments, and/or additions to this file to:# 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 }set testfile "misc"set srcfile ${testfile}.ccset 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 as an expected failure 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 $" { setup_xfail "*-*-*" fail "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 as an expected failure 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 $" { setup_xfail "*-*-*" fail "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 as an expected failure if gdb just fails to distinguish between # class and struct, and everything else is OK. setup_xfail_format "DWARF 1" 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 (FIXME)" } -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { setup_xfail "*-*-*" fail "ptype struct protected_struct (FIXME)" } -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" } timeout { fail "ptype struct protected_struct (timeout)" ; return } } # Accept it as an expected failure if gdb just fails to distinguish between # class and struct, and everything else is OK. setup_xfail_format "DWARF 1" 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 (FIXME)" } -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { setup_xfail "*-*-*" fail "ptype struct private_struct (FIXME)" } -re ".*$gdb_prompt $" { fail "ptype struct private_struct" } timeout { fail "ptype struct private_struct (timeout)" ; return } } # Accept it as an expected failure if gdb just fails to distinguish between # class and struct, and everything else is OK. setup_xfail_format "DWARF 1" 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 (FIXME)" } -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 $" { setup_xfail "*-*-*" fail "ptype struct mixed_protection_struct (FIXME)" } -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" } timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return } } # Accept it as an expected failure 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 (FIXME)" } -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" { setup_xfail "*-*-*" fail "ptype class public_class (FIXME)" } -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 $" { setup_xfail "*-*-*" fail "ptype class protected_class" } -re ".*$gdb_prompt $" { fail "ptype class protected_class" } timeout { fail "ptype class protected_class (timeout)" ; return } } # Accept it as an expected failure 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. setup_xfail_format "DWARF 1" 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 (FIXME)" } -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { setup_xfail "*-*-*" fail "ptype class default_private_class (FIXME)" } -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 (OK for HP aCC)" } -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" { setup_xfail "*-*-*" 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 $" { setup_xfail "*-*-*" 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 &\\);)|(${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 } } setup_xfail_format "DWARF 1" 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 &\\);${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 } } setup_xfail_format "DWARF 1" 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 &\\);${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 } } setup_xfail_format "DWARF 1" 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 &\\);${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 } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -