binutils-gdb/gdb/testsuite/gdb.cp/classes.exp

640 lines
18 KiB
Plaintext
Raw Normal View History

2007-01-09 18:59:20 +01:00
# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2011-01-01 16:34:07 +01:00
# 2004, 2006, 2007, 2008, 2009, 2010, 2011 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 3 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, see <http://www.gnu.org/licenses/>.
# This file was written by Fred Fish. (fnf@cygnus.com)
# And rewritten by Michael Chastain <mec.gnu@mindspring.com>.
set nl "\[\r\n\]+"
if $tracelevel then {
strace $tracelevel
}
1999-09-09 02:02:17 +02:00
if { [skip_cplus_tests] } { continue }
load_lib "cp-support.exp"
set testfile "classes"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
* gdb.arch/altivec-abi.exp: Replace gdb_suppress_entire_file with untested followed by return combination. * gdb.arch/altivec-regs.exp: Likewise. * gdb.arch/e500-abi.exp: Likewise. * gdb.arch/e500-regs.exp: Likewise. * gdb.arch/gdb1291.exp: Likewise. * gdb.arch/gdb1431.exp: Likewise. * gdb.arch/gdb1558.exp: Likewise. * gdb.arch/i386-prologue.exp: Likewise. * gdb.arch/i386-unwind.exp: Likewise. * gdb.asm/asm-source.exp: Likewise. * gdb.base/a2-run.exp: Likewise. * gdb.base/advance.exp: Likewise. * gdb.base/all-bin.exp: Likewise. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/args.exp: Likewise. * gdb.base/arithmet.exp: Likewise. * gdb.base/assign.exp: Likewise. * gdb.base/async.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bang.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/bitfields.exp: Likewise. * gdb.base/bitfields2.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-sc.exp: Likewise. * gdb.base/call-strs.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/checkpoint.exp: Likewise. * gdb.base/chng-syms.exp: Likewise. * gdb.base/code-expr.exp: Likewise. * gdb.base/commands.exp: Likewise. * gdb.base/completion.exp: Likewise. * gdb.base/cond-expr.exp: Likewise. * gdb.base/condbreak.exp: Likewise. * gdb.base/consecutive.exp: Likewise. * gdb.base/constvars.exp: Likewise. * gdb.base/corefile.exp: Likewise. * gdb.base/cvexpr.exp: Likewise. * gdb.base/dbx.exp: Likewise. * gdb.base/define.exp: Likewise. * gdb.base/detach.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/dump.exp: Likewise. * gdb.base/ena-dis-br.exp: Likewise. * gdb.base/ending-run.exp: Likewise. * gdb.base/environ.exp: Likewise. * gdb.base/eval-skip.exp: Likewise. * gdb.base/exprs.exp: Likewise. * gdb.base/fileio.exp: Likewise. * gdb.base/finish.exp: Likewise. * gdb.base/float.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/freebpcmd.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/gcore.exp: Likewise. * gdb.base/gdb1090.exp: Likewise. * gdb.base/gdb1250.exp: Likewise. * gdb.base/huge.exp: Likewise. * gdb.base/info-proc.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/jump.exp: Likewise. * gdb.base/langs.exp: Likewise. * gdb.base/lineinc.exp: Likewise. * gdb.base/list.exp: Likewise. * gdb.base/logical.exp: Likewise. * gdb.base/long_long.exp: Likewise. * gdb.base/macscp.exp: Likewise. * gdb.base/maint.exp: Likewise. * gdb.base/mips_pro.exp: Likewise. * gdb.base/miscexprs.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/opaque.exp: Likewise. * gdb.base/overlays.exp: Likewise. * gdb.base/pc-fp.exp: Likewise. * gdb.base/pointers.exp: Likewise. * gdb.base/printcmds.exp: Likewise. * gdb.base/psymtab.exp: Likewise. * gdb.base/ptype.exp: Likewise. * gdb.base/recurse.exp: Likewise. * gdb.base/relational.exp: Likewise. * gdb.base/relocate.exp: Likewise. * gdb.base/remote.exp: Likewise. * gdb.base/reread.exp: Likewise. * gdb.base/restore.exp: Likewise. * gdb.base/return.exp: Likewise. * gdb.base/return2.exp: Likewise. * gdb.base/scope.exp: Likewise. * gdb.base/sect-cmd.exp: Likewise. * gdb.base/sep.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/setshow.exp: Likewise. * gdb.base/setvar.exp: Likewise. * gdb.base/sigall.exp: Likewise. * gdb.base/sigbpt.exp: Likewise. * gdb.base/signals.exp: Likewise. * gdb.base/signull.exp: Likewise. * gdb.base/sizeof.exp: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/step-line.exp: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.base/structs.exp: Likewise. * gdb.base/structs2.exp: Likewise. * gdb.base/term.exp: Likewise. * gdb.base/twice.exp: Likewise. * gdb.base/until.exp: Likewise. * gdb.base/varargs.exp: Likewise. * gdb.base/volatile.exp: Likewise. * gdb.base/watchpoint.exp: Likewise. * gdb.base/whatis-exp.exp: Likewise. * gdb.base/whatis.exp: Likewise. * gdb.cp/ambiguous.exp: Likewise. * gdb.cp/annota2.exp: Likewise. * gdb.cp/annota3.exp: Likewise. * gdb.cp/bool.exp: Likewise. * gdb.cp/breakpoint.exp: Likewise. * gdb.cp/casts.exp: Likewise. * gdb.cp/class2.exp: Likewise. * gdb.cp/classes.exp: Likewise. * gdb.cp/cplusfuncs.exp: Likewise. * gdb.cp/ctti.exp: Likewise. * gdb.cp/derivation.exp: Likewise. * gdb.cp/exception.exp: Likewise. * gdb.cp/gdb1355.exp: Likewise. * gdb.cp/hang.exp: Likewise. * gdb.cp/inherit.exp: Likewise. * gdb.cp/local.exp: Likewise. * gdb.cp/m-data.exp: Likewise. * gdb.cp/m-static.exp: Likewise. * gdb.cp/member-ptr.exp: Likewise. * gdb.cp/method.exp: Likewise. * gdb.cp/misc.exp: Likewise. * gdb.cp/namespace.exp: Likewise. * gdb.cp/overload.exp: Likewise. * gdb.cp/ovldbreak.exp: Likewise. * gdb.cp/pr-1023.exp: Likewise. * gdb.cp/pr-1210.exp: Likewise. * gdb.cp/pr-574.exp: Likewise. * gdb.cp/printmethod.exp: Likewise. * gdb.cp/psmang.exp: Likewise. * gdb.cp/ref-params.exp: Likewise. * gdb.cp/ref-types.exp: Likewise. * gdb.cp/rtti.exp: Likewise. * gdb.cp/templates.exp: Likewise. * gdb.cp/try_catch.exp: Likewise. * gdb.cp/userdef.exp: Likewise. * gdb.cp/virtfunc.exp: Likewise. * gdb.disasm/am33.exp: Likewise. * gdb.disasm/h8300s.exp: Likewise. * gdb.disasm/mn10300.exp: Likewise. * gdb.disasm/sh3.exp: Likewise. * gdb.disasm/t01_mov.exp: Likewise. * gdb.disasm/t02_mova.exp: Likewise. * gdb.disasm/t03_add.exp: Likewise. * gdb.disasm/t04_sub.exp: Likewise. * gdb.disasm/t05_cmp.exp: Likewise. * gdb.disasm/t06_ari2.exp: Likewise. * gdb.disasm/t07_ari3.exp: Likewise. * gdb.disasm/t08_or.exp: Likewise. * gdb.disasm/t09_xor.exp: Likewise. * gdb.disasm/t10_and.exp: Likewise. * gdb.disasm/t11_logs.exp: Likewise. * gdb.disasm/t12_bit.exp: Likewise. * gdb.disasm/t13_otr.exp: Likewise. * gdb.hp/gdb.aCC/optimize.exp: Likewise. * gdb.hp/gdb.aCC/watch-cmd.exp: Likewise. * gdb.hp/gdb.base-hp/callfwmall.exp: Likewise. * gdb.hp/gdb.base-hp/dollar.exp: Likewise. * gdb.hp/gdb.base-hp/hwwatchbus.exp: Likewise. * gdb.hp/gdb.base-hp/pxdb.exp: Likewise. * gdb.hp/gdb.base-hp/reg-pa64.exp: Likewise. * gdb.hp/gdb.base-hp/reg.exp: Likewise. * gdb.hp/gdb.base-hp/sized-enum.exp: Likewise. * gdb.hp/gdb.compat/xdb1.exp: Likewise. * gdb.hp/gdb.compat/xdb3.exp: Likewise. * gdb.hp/gdb.objdbg/objdbg01.exp: Likewise. * gdb.hp/gdb.objdbg/objdbg02.exp: Likewise. * gdb.hp/gdb.objdbg/objdbg03.exp: Likewise. * gdb.hp/gdb.objdbg/objdbg04.exp: Likewise. * gdb.mi/gdb701.exp: Likewise. * gdb.mi/gdb792.exp: Likewise. * gdb.mi/mi-basics.exp: Likewise. * gdb.mi/mi-break.exp: Likewise. * gdb.mi/mi-cli.exp: Likewise. * gdb.mi/mi-console.exp: Likewise. * gdb.mi/mi-disassemble.exp: Likewise. * gdb.mi/mi-eval.exp: Likewise. * gdb.mi/mi-file.exp: Likewise. * gdb.mi/mi-read-memory.exp: Likewise. * gdb.mi/mi-regs.exp: Likewise. * gdb.mi/mi-return.exp: Likewise. * gdb.mi/mi-simplerun.exp: Likewise. * gdb.mi/mi-stack.exp: Likewise. * gdb.mi/mi-stepi.exp: Likewise. * gdb.mi/mi-syn-frame.exp: Likewise. * gdb.mi/mi-until.exp: Likewise. * gdb.mi/mi-var-block.exp: Likewise. * gdb.mi/mi-var-child.exp: Likewise. * gdb.mi/mi-var-cmd.exp: Likewise. * gdb.mi/mi-var-display.exp: Likewise. * gdb.mi/mi-watch.exp: Likewise. * gdb.mi/mi2-basics.exp: Likewise. * gdb.mi/mi2-break.exp: Likewise. * gdb.mi/mi2-cli.exp: Likewise. * gdb.mi/mi2-console.exp: Likewise. * gdb.mi/mi2-disassemble.exp: Likewise. * gdb.mi/mi2-eval.exp: Likewise. * gdb.mi/mi2-file.exp: Likewise. * gdb.mi/mi2-read-memory.exp: Likewise. * gdb.mi/mi2-regs.exp: Likewise. * gdb.mi/mi2-return.exp: Likewise. * gdb.mi/mi2-simplerun.exp: Likewise. * gdb.mi/mi2-stack.exp: Likewise. * gdb.mi/mi2-stepi.exp: Likewise. * gdb.mi/mi2-syn-frame.exp: Likewise. * gdb.mi/mi2-until.exp: Likewise. * gdb.mi/mi2-var-block.exp: Likewise. * gdb.mi/mi2-var-child.exp: Likewise. * gdb.mi/mi2-var-cmd.exp: Likewise. * gdb.mi/mi2-var-display.exp: Likewise. * gdb.mi/mi2-watch.exp: Likewise. * gdb.stabs/exclfwd.exp: Likewise. * gdb.stabs/weird.exp: Likewise. * gdb.threads/gcore-thread.exp: Likewise. * gdb.trace/actions.exp: Likewise. * gdb.trace/backtrace.exp: Likewise. * gdb.trace/circ.exp: Likewise. * gdb.trace/collection.exp: Likewise. * gdb.trace/deltrace.exp: Likewise. * gdb.trace/infotrace.exp: Likewise. * gdb.trace/limits.exp: Likewise. * gdb.trace/packetlen.exp: Likewise. * gdb.trace/passc-dyn.exp: Likewise. * gdb.trace/passcount.exp: Likewise. * gdb.trace/report.exp: Likewise. * gdb.trace/save-trace.exp: Likewise. * gdb.trace/tfind.exp: Likewise. * gdb.trace/tracecmd.exp: Likewise. * gdb.trace/while-dyn.exp: Likewise. * gdb.trace/while-stepping.exp: Likewise.
2006-08-10 07:27:22 +02:00
untested classes.exp
return -1
}
# Test ptype of class objects.
proc test_ptype_class_objects {} {
# Simple type.
cp_test_ptype_class \
"ptype struct default_public_struct" "" "struct" "default_public_struct" \
{
{ field public "int a;" }
{ field public "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype struct explicit_public_struct" "" "struct" "explicit_public_struct" \
{
{ field public "int a;" }
{ field public "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype struct protected_struct" "" "struct" "protected_struct" \
{
{ field protected "int a;" }
{ field protected "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype struct private_struct" "" "struct" "private_struct" \
{
{ field private "int a;" }
{ field private "int b;" }
}
# A bigger type.
cp_test_ptype_class \
"ptype struct mixed_protection_struct" "" "struct" "mixed_protection_struct" \
{
{ field public "int a;" }
{ field public "int b;" }
{ field private "int c;" }
{ field private "int d;" }
{ field protected "int e;" }
{ field protected "int f;" }
{ field public "int g;" }
{ field private "int h;" }
{ field protected "int i;" }
}
# All that again with "class" instead of "struct".
# gdb does not care about the difference anyways.
cp_test_ptype_class \
"ptype class public_class" "" "class" "public_class" \
{
{ field public "int a;" }
{ field public "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype class protected_class" "" "class" "protected_class" \
{
{ field protected "int a;" }
{ field protected "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype class default_private_class" "" "class" "default_private_class" \
{
{ field private "int a;" }
{ field private "int b;" }
}
# Another simple type.
cp_test_ptype_class \
"ptype class explicit_private_class" "" "class" "explicit_private_class" \
{
{ field private "int a;" }
{ field private "int b;" }
}
# A bigger type.
cp_test_ptype_class \
"ptype class mixed_protection_class" "" "class" "mixed_protection_class" \
{
{ field public "int a;" }
{ field public "int b;" }
{ field private "int c;" }
{ field private "int d;" }
{ field protected "int e;" }
{ field protected "int f;" }
{ field public "int g;" }
{ field private "int h;" }
{ field protected "int i;" }
}
# Here are some classes with inheritance.
# Base class.
cp_test_ptype_class \
"ptype class A" "" "class" "A" \
{
{ field public "int a;" }
{ field public "int x;" }
}
# Derived class.
cp_test_ptype_class \
"ptype class B" "" "class" "B" \
{
{ base "public A" }
{ field public "int b;" }
{ field public "int x;" }
}
# Derived class.
cp_test_ptype_class \
"ptype class C" "" "class" "C" \
{
{ base "public A" }
{ field public "int c;" }
{ field public "int x;" }
}
# Derived class, multiple inheritance.
cp_test_ptype_class \
"ptype class D" "" "class" "D" \
{
{ base "public B" }
{ base "public C" }
{ field public "int d;" }
{ field public "int x;" }
}
# Derived class.
cp_test_ptype_class \
"ptype class E" "" "class" "E" \
{
{ base "public D" }
{ field public "int e;" }
{ field public "int x;" }
}
# 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.
cp_test_ptype_class \
"ptype class Static" "" "class" "Static" \
{
{ method public "static void ii(int, int);" }
}
# Here are some virtual inheritance tests.
# A virtual base class.
cp_test_ptype_class \
"ptype class vA" "" "class" "vA" \
{
{ field public "int va;" }
{ field public "int vx;" }
}
# A derived class with a virtual base.
cp_test_ptype_class \
"ptype class vB" "" "class" "vB" \
{
{ base "public virtual vA" }
{ vbase "vA" }
{ field public "int vb;" }
{ field public "int vx;" }
}
# Another derived class with a virtual base.
cp_test_ptype_class \
"ptype class vC" "" "class" "vC" \
{
{ base "public virtual vA" }
{ vbase "vA" }
{ field public "int vc;" }
{ field public "int vx;" }
}
# A classic diamond class.
cp_test_ptype_class \
"ptype class vD" "" "class" "vD" \
{
{ base "public virtual vB" }
{ base "public virtual vC" }
{ vbase "vC" }
{ vbase "vB" }
{ field public "int vd;" }
{ field public "int vx;" }
}
# A class derived from a diamond class.
cp_test_ptype_class \
"ptype class vE" "" "class" "vE" \
{
{ base "public virtual vD" }
{ vbase "vD" }
{ field public "int ve;" }
{ field public "int vx;" }
}
# Another inheritance series.
# A base class.
cp_test_ptype_class \
"ptype class Base1" "" "class" "Base1" \
{
{ field public "int x;" }
{ method public "Base1(int);" }
}
# Another base class.
cp_test_ptype_class \
"ptype class Foo" "" "class" "Foo" \
{
{ field public "int x;" }
{ field public "int y;" }
{ field public "static int st;" }
{ method public "Foo(int, int);" }
{ method public "int operator!();" }
{ method public "operator int();" }
{ method public "int times(int);" }
} \
"" \
{
{
"operator int();"
"int operator int();"
{ setup_kfail "gdb/1497" "*-*-*" }
}
{
"operator int();"
"int operator int(void);"
{ setup_kfail "gdb/1497" "*-*-*" }
}
}
# A multiple inheritance derived class.
cp_test_ptype_class \
"ptype class Bar" "" "class" "Bar" \
{
{ base "public Base1" }
{ base "public Foo" }
{ field public "int z;" }
{ method public "Bar(int, int, int);" }
}
}
# Test simple access to class members.
proc test_non_inherited_member_access {} {
# Print non-inherited members of g_A.
gdb_test "print g_A.a" ".* = 1"
gdb_test "print g_A.x" ".* = 2"
# Print non-inherited members of g_B.
gdb_test "print g_B.b" ".* = 5"
gdb_test "print g_B.x" ".* = 6"
# Print non-inherited members of g_C.
gdb_test "print g_C.c" ".* = 9"
gdb_test "print g_C.x" ".* = 10"
# Print non-inherited members of g_D.
gdb_test "print g_D.d" ".* = 19"
gdb_test "print g_D.x" ".* = 20"
# Print non-inherited members of g_E.
gdb_test "print g_E.e" ".* = 31"
gdb_test "print g_E.x" ".* = 32"
}
# 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).
proc test_wrong_class_members {} {
gdb_test "print g_A.b" "There is no member( or method|) named b."
gdb_test "print g_B.c" "There is no member( or method|) named c."
gdb_test "print g_B.d" "There is no member( or method|) named d."
gdb_test "print g_C.b" "There is no member( or method|) named b."
gdb_test "print g_C.d" "There is no member( or method|) named d."
gdb_test "print g_D.e" "There is no member( or method|) named e."
}
# Test access to names that are not members of any class.
proc test_nonexistent_members {} {
gdb_test "print g_A.y" "There is no member( or method|) named y."
gdb_test "print g_B.z" "There is no member( or method|) named z."
gdb_test "print g_C.q" "There is no member( or method|) named q."
gdb_test "print g_D.p" "There is no member( or method|) named p."
}
# 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"
gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2"
gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3"
gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4"
gdb_test "call class_param.Aref_a (g_A)" ".* = 1"
gdb_test "call class_param.Aref_x (g_A)" ".* = 2"
gdb_test "call class_param.Aref_a (g_B)" ".* = 3"
gdb_test "call class_param.Aref_x (g_B)" ".* = 4"
gdb_test "call class_param.Aval_a (g_A)" ".* = 1"
gdb_test "call class_param.Aval_x (g_A)" ".* = 2"
gdb_test "call class_param.Aval_a (g_B)" ".* = 3"
gdb_test "call class_param.Aval_x (g_B)" ".* = 4"
gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param"
gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class &param"
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
# print the object
# We match the enum values with and without qualifiers. As of
# 2008-08-21 we can output the qualifiers for DWARF-2.
gdb_test "print obj_with_enum" \
"\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \
"print obj_with_enum (1)"
# advance one line
2010-06-08 Michael Snyder <msnyder@vmware.com> * gdb.ada/assign_1.exp: Use ".*" instead of "" as wildcard regexp. * gdb.ada/boolean_expr.exp: * gdb.ada/frame_args.exp: Ditto. * gdb.ada/lang_switch.exp: Ditto. * gdb.ada/ptype_arith_binop.exp: Ditto. * gdb.ada/ref_param.exp: Ditto. * gdb.ada/type_coercion.exp:Ditto. * gdb.asm/asm-source.exp: Ditto. * gdb.base/attach.exp: Ditto. * gdb.base/bitfields2.exp: Ditto. * gdb.base/call-signal-resume.exp: Ditto. * gdb.base/callfuncs.exp: Ditto. * gdb.base/commands.exp: Ditto. * gdb.base/dbx.exp: Ditto. * gdb.base/default.exp: Ditto. * gdb.base/dump.exp: Ditto. * gdb.base/exprs.exp: Ditto. * gdb.base/freebpcmd.exp: Ditto. * gdb.base/interrupt.exp: Ditto. * gdb.base/list.exp: Ditto. * gdb.base/long_long.exp: Ditto. * gdb.base/maint.exp: Ditto. * gdb.base/ptype.exp: Ditto. * gdb.base/return.exp: Ditto. * gdb.base/setshow.exp: Ditto. * gdb.base/sigbpt.exp: Ditto. * gdb.base/sigrepeat.exp: Ditto. * gdb.cp/classes.exp: Ditto. * gdb.dwarf2/dw2-restore.exp: Ditto. * gdb.gdb/selftest.exp: Ditto. * gdb.multi/base.exp: Ditto. * gdb.multi/bkpt-multi-exec.exp: Ditto. * gdb.python/py-block.exp: Ditto. * gdb.python/py-prettyprint.exp: Ditto. * gdb.python/py-template.exp: Ditto. * gdb.server/ext-attach.exp: Ditto. * gdb.server/ext-run.exp: Ditto. * gdb.server/server-mon.exp: Ditto. * gdb.threads/fork-thread-pending.exp: Ditto. * gdb.threads/hand-call-in-threads.exp: Ditto. * gdb.threads/interrupted-hand-call.exp: Ditto. * gdb.threads/linux-dp.exp: Ditto. * gdb.threads/manythreads.exp: Ditto. * gdb.threads/print-threads.exp: Ditto. * gdb.threads/pthreads.exp: Ditto. * gdb.threads/schedlock.exp: Ditto. * gdb.threads/thread-unwindonsignal.exp: Ditto. * gdb.threads/threadapply.exp: Ditto.
2010-06-10 21:48:20 +02:00
gdb_test "next" ".*"
# print the object again
gdb_test "print obj_with_enum" \
"\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
"print obj_with_enum (2)"
# print the enum member
gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?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 \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" {
pass "ptype obj_with_enum.priv_enum"
}
-re "type = enum PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?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
# NOTE: carlton/2003-02-28: One could certainly argue that plain
# "PrivEnum"
# is acceptable: PrivEnum is a member of ClassWithEnum, so
# there's no need to explicitly qualify its name with
# "ClassWithEnum::". The truth, though, is that GDB is simply
# forgetting that PrivEnum is a member 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.
cp_test_ptype_class \
"ptype obj_with_enum" "" "class" "ClassWithEnum" \
{
{ field public "ClassWithEnum::PrivEnum priv_enum;" }
{ field public "int x;" }
} \
"" \
{
{
"ClassWithEnum::PrivEnum priv_enum;"
"PrivEnum priv_enum;"
{ setup_kfail "gdb/57" "*-*-*" }
}
}
# I'll do this test two different ways, because of a parser bug.
# See PR gdb/1588.
gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
-re "\\$\[0-9\]+ = (ClassWithEnum::)?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/1588" "print (ClassWithEnum::PrivEnum) 42"
}
}
gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
-re "\\$\[0-9\]+ = (ClassWithEnum::)?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 {} {
* NEWS: Mention pointer to member improvements. * Makefile.in (gnu-v3-abi.o): Delete special rule. (eval.o, gnu-v3-abi.o, ia64-tdep.o): Update. * ada-valprint.c (ada_print_scalar): Update for new type codes. * c-typeprint.c (c_print_type): Update for new type codes. (c_type_print_varspec_prefix, c_type_print_varspec_suffix) (c_type_print_base): Likewise. (c_type_print_args): Rewrite. * c-valprint.c (c_val_print): Update for new type codes. Remove support for references to members. Treat methods like functions. * cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New. * cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes. (struct cp_abi_ops): Add corresponding members. * cp-valprint.c (cp_print_class_method): Delete. (cp_find_class_member): New function. (cp_print_class_member): Use it. Simplify support for bogus member pointers. * dwarf2read.c (quirk_gcc_member_function_pointer): Use lookup_methodptr_type. (read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type. * eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for OP_SCOPE. Update call to value_aggregate_elt. Rewrite member pointer support. (evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle references returned by user defined operators. * f-typeprint.c (f_print_type, f_type_print_varspec_prefix) (f_type_print_varspec_suffix): Remove support for member pointers. * gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type and adjusted. (smash_to_memberptr_type): Likewise, from smash_to_member_type. (lookup_methodptr_type): New. (rank_one_type): Adjust for TYPE_CODE_MEMBERPTR. (recursive_dump_type): Update for new types. * gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR. (lookup_memberptr_type, lookup_methodptr_type) (smash_to_memberptr_type): New prototypes. (smash_to_method_type): Formatting fix. (lookup_member_type, smash_to_member_type): Delete prototypes. * gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New. Do not rely on debug information for the vptr or the method's enclosing type. Handle function descriptors for IA64. (gnuv3_virtual_fn_field): Rewrite using the new functions. (gnuv3_find_method_in, gnuv3_print_method_ptr) (gnuv3_method_ptr_size, gnuv3_make_method_ptr) (gnuv3_method_ptr_to_value): New. (init_gnuv3_ops): Set new members of gnu_v3_abi_ops. * hpread.c (hpread_type_lookup): Update for new types. * infcall.c (value_arg_coerce): Likewise. * m2-typeprint.c (m2_print_type): Remove explicit support for member pointers. * m2-valprint.c (m2_val_print): Likewise. * p-typeprint.c (pascal_type_print_varspec_prefix) (pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_class_method, pascal_object_print_class_member): Delete. * p-lang.h (pascal_object_print_class_method) (pascal_object_print_class_member): Delete prototypes. * stabsread.c (read_type): Update for new types. * typeprint.c (print_type_scalar): Likewise. * valops.c (value_struct_elt_for_reference, value_namespace_elt) (value_maybe_namespace_elt, value_aggregate_elt): Add want_address argument. Construct a pointer to member if the address of a function or data member is requested. (value_cast_pointers): Don't modify the input value. (value_cast): Adjust pointer to member handling for new types. Allow null pointer to member constants. Don't modify the input value. (value_ind): Remove pointer to member check. Handle function descriptors for function pointers. (value_struct_elt, value_find_oload_method_list, check_field): Remove pointer to member checks. * value.c (unpack_long): Allow pointers to data members. (value_from_longest): Allow member pointers. * value.h (value_aggregate_elt): Add want_address. * varobj.c (c_variable_editable): Remove check for members. * gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors in virtual tables. (ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors. * c-lang.h (cp_print_class_method): Delete prototype. * arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta. * mips-tdep.c (mips_gdbarch_init): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * gdb.cp/classes.exp (test_pointers_to_class_members): Update expected output. Test the types of members and member pointers. * gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for gdb/2092. * gdb.cp/member-ptr.exp: Search for a comment instead of a statement. Enable for GCC. Update expected output for some tests and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class layout. * gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x) (Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond) (Diamond::vget_base): New. (main): Add new tests. * gdb.cp/printmethod.exp: Update expected output for member functions. * gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for print pEe->D::vg().
2007-01-03 19:05:45 +01:00
gdb_test "print Bar::z" "Cannot reference non-static field \"z\""
gdb_test "print &Foo::x" "\\$\[0-9\]+ = &Foo::x"
gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
* NEWS: Mention pointer to member improvements. * Makefile.in (gnu-v3-abi.o): Delete special rule. (eval.o, gnu-v3-abi.o, ia64-tdep.o): Update. * ada-valprint.c (ada_print_scalar): Update for new type codes. * c-typeprint.c (c_print_type): Update for new type codes. (c_type_print_varspec_prefix, c_type_print_varspec_suffix) (c_type_print_base): Likewise. (c_type_print_args): Rewrite. * c-valprint.c (c_val_print): Update for new type codes. Remove support for references to members. Treat methods like functions. * cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New. * cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes. (struct cp_abi_ops): Add corresponding members. * cp-valprint.c (cp_print_class_method): Delete. (cp_find_class_member): New function. (cp_print_class_member): Use it. Simplify support for bogus member pointers. * dwarf2read.c (quirk_gcc_member_function_pointer): Use lookup_methodptr_type. (read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type. * eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for OP_SCOPE. Update call to value_aggregate_elt. Rewrite member pointer support. (evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle references returned by user defined operators. * f-typeprint.c (f_print_type, f_type_print_varspec_prefix) (f_type_print_varspec_suffix): Remove support for member pointers. * gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type and adjusted. (smash_to_memberptr_type): Likewise, from smash_to_member_type. (lookup_methodptr_type): New. (rank_one_type): Adjust for TYPE_CODE_MEMBERPTR. (recursive_dump_type): Update for new types. * gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR. (lookup_memberptr_type, lookup_methodptr_type) (smash_to_memberptr_type): New prototypes. (smash_to_method_type): Formatting fix. (lookup_member_type, smash_to_member_type): Delete prototypes. * gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New. Do not rely on debug information for the vptr or the method's enclosing type. Handle function descriptors for IA64. (gnuv3_virtual_fn_field): Rewrite using the new functions. (gnuv3_find_method_in, gnuv3_print_method_ptr) (gnuv3_method_ptr_size, gnuv3_make_method_ptr) (gnuv3_method_ptr_to_value): New. (init_gnuv3_ops): Set new members of gnu_v3_abi_ops. * hpread.c (hpread_type_lookup): Update for new types. * infcall.c (value_arg_coerce): Likewise. * m2-typeprint.c (m2_print_type): Remove explicit support for member pointers. * m2-valprint.c (m2_val_print): Likewise. * p-typeprint.c (pascal_type_print_varspec_prefix) (pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_class_method, pascal_object_print_class_member): Delete. * p-lang.h (pascal_object_print_class_method) (pascal_object_print_class_member): Delete prototypes. * stabsread.c (read_type): Update for new types. * typeprint.c (print_type_scalar): Likewise. * valops.c (value_struct_elt_for_reference, value_namespace_elt) (value_maybe_namespace_elt, value_aggregate_elt): Add want_address argument. Construct a pointer to member if the address of a function or data member is requested. (value_cast_pointers): Don't modify the input value. (value_cast): Adjust pointer to member handling for new types. Allow null pointer to member constants. Don't modify the input value. (value_ind): Remove pointer to member check. Handle function descriptors for function pointers. (value_struct_elt, value_find_oload_method_list, check_field): Remove pointer to member checks. * value.c (unpack_long): Allow pointers to data members. (value_from_longest): Allow member pointers. * value.h (value_aggregate_elt): Add want_address. * varobj.c (c_variable_editable): Remove check for members. * gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors in virtual tables. (ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors. * c-lang.h (cp_print_class_method): Delete prototype. * arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta. * mips-tdep.c (mips_gdbarch_init): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * gdb.cp/classes.exp (test_pointers_to_class_members): Update expected output. Test the types of members and member pointers. * gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for gdb/2092. * gdb.cp/member-ptr.exp: Search for a comment instead of a statement. Enable for GCC. Update expected output for some tests and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class layout. * gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x) (Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond) (Diamond::vget_base): New. (main): Add new tests. * gdb.cp/printmethod.exp: Update expected output for member functions. * gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for print pEe->D::vg().
2007-01-03 19:05:45 +01:00
gdb_test "ptype Bar::z" "type = int"
gdb_test "ptype &Bar::z" "type = int Bar::\\*"
# TODO: this is a bogus test. It's looking at a variable that
# has not even been declared yet, so it's accessing random junk
# on the stack and comparing that it's NOT equal to a specific
# value. It's been like this since gdb 4.10 in 1993!
# -- chastain 2004-01-01
gdb_test "print (int)pmi == sizeof(int)" ".* = false"
}
# Test static members.
proc test_static_members {} {
global hex
gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
gdb_test_no_output "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_no_output "set print static-members off"
gdb_test "print csi" \
"{x = 10, y = 20}" \
"print csi without static members"
gdb_test "print cnsi" \
"{x = 30, y = 40}" \
"print cnsi without static members"
gdb_test_no_output "set print static-members on"
gdb_test "print csi" \
"{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \
"print csi with static members"
gdb_test "print cnsi" \
"{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \
"print cnsi with static members"
}
proc do_tests {} {
global subdir
global objdir
global srcdir
global binfile
global gdb_prompt
global nl
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile
gdb_test_no_output "set language c++" ""
gdb_test_no_output "set width 0" ""
if ![runto_main ] then {
perror "couldn't run to breakpoint"
return
}
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.*" "continue to enums2(\\(\\)|)"
# Leave enums2. Make sure we reach the next line, in case there
# are any more instructions to finish the function call.
gdb_test_multiple "finish" "" {
-re "enums2 \\(\\);.*$gdb_prompt $" {
gdb_test "next" ".*" ""
}
-re "$gdb_prompt $" { }
}
test_enums
gdb_test "finish" ".*" ""
test_pointers_to_class_members
test_static_members
# 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.
#
# TODO: I think that message should be a PASS, not an XFAIL.
# gdb prints an informative message and declines to do something
# impossible.
#
# The method call actually succeeds if the compiler allocates very
# small classes in memory instead of registers. So this test does
# not tell us anything interesting if the call succeeds.
#
# -- chastain 2003-12-31
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"
}
}
gdb_test "print base1::Base1" "<.*Base1.*>" "print ctor of typedef class"
gdb_test "print base1::~Base1" "<.*~Base1(\\(\\))?>" \
"print dtor of typedef class"
gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*"
}
do_tests