f5f3a911ec
* gdb.cp/ambiguous.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/annota2.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/annota3.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/anon-ns.exp: Use standard_testfile. * gdb.cp/anon-struct.exp: Use standard_testfile. * gdb.cp/anon-union.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/arg-reference.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/bool.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/breakpoint.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/bs15503.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/call-c.exp: Use standard_testfile, clean_restart, standard_output_file. * gdb.cp/casts.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/class2.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/classes.exp: Use standard_testfile, prepare_for_testing. (test_static_members): Update. * gdb.cp/cmpd-minsyms.exp: Use standard_testfile. * gdb.cp/converts.exp: Use standard_testfile. * gdb.cp/cp-relocate.exp: Use standard_testfile. * gdb.cp/cpcompletion.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/cpexprs.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/cplabel.exp: Use standard_testfile. * gdb.cp/cplusfuncs.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/ctti.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/derivation.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/destrprint.exp: Use standard_testfile. * gdb.cp/dispcxx.exp: Use standard_testfile. * gdb.cp/exception.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/expand-psymtabs-cxx.exp: Use standard_testfile. * gdb.cp/extern-c.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/formatted-ref.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/fpointer.exp: Use standard_testfile. * gdb.cp/gdb1355.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/gdb2384.exp: Use standard_testfile, clean_restart, standard_output_file. * gdb.cp/gdb2495.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/hang.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/infcall-dlopen.exp: Use standard_testfile, standard_output_file. * gdb.cp/inherit.exp: Use standard_testfile, prepare_for_testing. (do_tests): Update. * gdb.cp/koenig.exp: Use standard_testfile. * gdb.cp/local.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/m-data.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/m-static.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/mb-ctor.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/mb-inline.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/mb-templates.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/member-ptr.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/meth-typedefs.exp: Use standard_testfile. * gdb.cp/method.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/method2.exp: Use standard_testfile. * gdb.cp/minsym-fallback.exp: Use standard_testfile, standard_output_file. * gdb.cp/misc.exp: Use standard_testfile, prepare_for_testing. (do_tests): Update. * gdb.cp/namespace-enum.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/namespace-nested-import.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/namespace.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/nextoverthrow.exp: Use standard_testfile. * gdb.cp/no-dmgl-verbose.exp: Use standard_testfile. * gdb.cp/nsdecl.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/nsimport.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/nsnested.exp: Use standard_testfile. * gdb.cp/nsnoimports.exp: Use standard_testfile. * gdb.cp/nsrecurs.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/nsstress.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/nsusing.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/operator.exp: Use standard_testfile. * gdb.cp/oranking.exp: Use standard_testfile. * gdb.cp/overload-const.exp: Use standard_testfile. * gdb.cp/overload.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/ovldbreak.exp: Use standard_testfile. * gdb.cp/ovsrch.exp: Use standard_testfile. * gdb.cp/paren-type.exp: Use standard_testfile. * gdb.cp/pass-by-ref.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/pr-1023.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/pr-1210.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/pr-574.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/pr10687.exp: Use standard_testfile, clean_restart. * gdb.cp/pr10728.exp: Use standard_testfile, standard_output_file. * gdb.cp/pr12028.exp: Use standard_testfile. * gdb.cp/pr9067.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/pr9167.exp: Use standard_testfile. * gdb.cp/pr9631.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/printmethod.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/psmang.exp: Use standard_testfile, clean_restart. * gdb.cp/psymtab-parameter.exp: Use standard_testfile. * gdb.cp/ptype-cv-cp.exp: Use standard_testfile. * gdb.cp/re-set-overloaded.exp: Use standard_testfile, standard_output_file. * gdb.cp/readnow-language.exp: Use standard_testfile. * gdb.cp/ref-params.exp: Use standard_testfile, build_executable. (gdb_start_again): Use clean_restart. * gdb.cp/ref-types.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/rtti.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/shadow.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/smartp.exp: Use standard_testfile. * gdb.cp/static-method.exp: Use standard_testfile. * gdb.cp/static-print-quit.exp: Use standard_testfile. * gdb.cp/temargs.exp: Use standard_testfile. * gdb.cp/templates.exp: Use standard_testfile, prepare_for_testing. (do_tests): Update. * gdb.cp/try_catch.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/typedef-operator.exp: Use standard_testfile. * gdb.cp/userdef.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/virtbase.exp: Use standard_testfile, prepare_for_testing. * gdb.cp/virtfunc.exp: Use standard_testfile, prepare_for_testing. (do_tests): Update. * gdb.cp/virtfunc2.exp: Use standard_testfile, prepare_for_testing.
294 lines
8.1 KiB
Text
294 lines
8.1 KiB
Text
# Copyright 1992, 1994-1999, 2001-2004, 2006-2012 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 { [skip_cplus_tests] } { continue }
|
|
|
|
load_lib "cp-support.exp"
|
|
|
|
standard_testfile .cc
|
|
|
|
if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
|
|
return -1
|
|
}
|
|
|
|
proc test_ptype_of_classes {} {
|
|
|
|
# class VA
|
|
|
|
cp_test_ptype_class \
|
|
"ptype VA" "" "class" "VA" \
|
|
{
|
|
{ field public "int va;" }
|
|
}
|
|
|
|
# class VB
|
|
|
|
cp_test_ptype_class \
|
|
"ptype VB" "" "class" "VB" \
|
|
{
|
|
{ field public "int vb;" }
|
|
{ method public "int fvb();" }
|
|
{ method public "virtual int vvb();" }
|
|
}
|
|
|
|
# class V
|
|
|
|
cp_test_ptype_class \
|
|
"ptype V" "" "class" "V" \
|
|
{
|
|
{ base "public VA" }
|
|
{ base "public VB" }
|
|
{ field public "int w;" }
|
|
{ method public "int f();" }
|
|
{ method public "virtual int vv();" }
|
|
}
|
|
|
|
# class A
|
|
|
|
cp_test_ptype_class \
|
|
"ptype A" "" "class" "A" \
|
|
{
|
|
{ base "public virtual V" }
|
|
{ vbase "V" }
|
|
{ field private "int a;" }
|
|
{ method public "virtual int f();" }
|
|
}
|
|
|
|
# class B
|
|
|
|
cp_test_ptype_class \
|
|
"ptype B" "" "class" "B" \
|
|
{
|
|
{ base "public A" }
|
|
{ field private "int b;" }
|
|
{ method public "virtual int f();" }
|
|
}
|
|
|
|
# class C
|
|
|
|
cp_test_ptype_class \
|
|
"ptype C" "" "class" "C" \
|
|
{
|
|
{ base "public virtual V" }
|
|
{ vbase "V" }
|
|
{ field public "int c;" }
|
|
}
|
|
|
|
# class AD
|
|
|
|
cp_test_ptype_class \
|
|
"ptype AD" "" "class" "AD" \
|
|
{
|
|
{ method public "virtual int vg();" }
|
|
}
|
|
|
|
# class D
|
|
|
|
cp_test_ptype_class \
|
|
"ptype D" "" "class" "D" \
|
|
{
|
|
{ base "public AD" }
|
|
{ base "public virtual V" }
|
|
{ vbase "V" }
|
|
{ method public "static void s();" }
|
|
{ method public "virtual int vg();" }
|
|
{ method public "virtual int vd();" }
|
|
{ method public "int fd();" }
|
|
{ field public "int d;" }
|
|
}
|
|
|
|
# class E
|
|
|
|
cp_test_ptype_class \
|
|
"ptype E" "" "class" "E" \
|
|
{
|
|
{ base "public B" }
|
|
{ base "public virtual V" }
|
|
{ base "public D" }
|
|
{ base "public C" }
|
|
{ vbase "V" }
|
|
{ method public "virtual int f();" }
|
|
{ method public "virtual int vg();" }
|
|
{ method public "virtual int vv();" }
|
|
{ field public "int e;" }
|
|
}
|
|
|
|
# An instance of D
|
|
|
|
cp_test_ptype_class "ptype dd" "" "class" "D" ibid
|
|
|
|
# An instance of D *
|
|
|
|
cp_test_ptype_class "ptype ppd" "" "class" "D" ibid "*"
|
|
|
|
# An instance of AD *
|
|
# TODO: this should be named pADd, not pAd.
|
|
|
|
cp_test_ptype_class "ptype pAd" "" "class" "AD" ibid "*"
|
|
|
|
# Instances of these classes.
|
|
|
|
cp_test_ptype_class "ptype a" "" "class" "A" ibid
|
|
cp_test_ptype_class "ptype b" "" "class" "B" ibid
|
|
cp_test_ptype_class "ptype c" "" "class" "C" ibid
|
|
cp_test_ptype_class "ptype d" "" "class" "D" ibid
|
|
cp_test_ptype_class "ptype e" "" "class" "E" ibid
|
|
cp_test_ptype_class "ptype v" "" "class" "V" ibid
|
|
cp_test_ptype_class "ptype vb" "" "class" "VB" ibid
|
|
|
|
# Instances of pointers to these classes.
|
|
|
|
cp_test_ptype_class "ptype pAa" "" "class" "A" ibid "*"
|
|
cp_test_ptype_class "ptype pAe" "" "class" "A" ibid "*"
|
|
cp_test_ptype_class "ptype pBe" "" "class" "B" ibid "*"
|
|
cp_test_ptype_class "ptype pDd" "" "class" "D" ibid "*"
|
|
cp_test_ptype_class "ptype pDe" "" "class" "D" ibid "*"
|
|
cp_test_ptype_class "ptype pVa" "" "class" "V" ibid "*"
|
|
cp_test_ptype_class "ptype pVv" "" "class" "V" ibid "*"
|
|
cp_test_ptype_class "ptype pVe" "" "class" "V" ibid "*"
|
|
cp_test_ptype_class "ptype pVd" "" "class" "V" ibid "*"
|
|
cp_test_ptype_class "ptype pADe" "" "class" "AD" ibid "*"
|
|
cp_test_ptype_class "ptype pEe" "" "class" "E" ibid "*"
|
|
cp_test_ptype_class "ptype pVB" "" "class" "VB" ibid "*"
|
|
|
|
}
|
|
|
|
# Call virtual functions.
|
|
|
|
proc test_virtual_calls {} {
|
|
global gdb_prompt
|
|
global nl
|
|
|
|
if [target_info exists gdb,cannot_call_functions] {
|
|
setup_xfail "*-*-*" 2416
|
|
fail "This target can not call functions"
|
|
return 0
|
|
}
|
|
|
|
gdb_test "print pAe->f()" "\\$\[0-9\]+ = 20"
|
|
gdb_test "print pAa->f()" "\\$\[0-9\]+ = 1"
|
|
gdb_test "print pDe->vg()" "\\$\[0-9\]+ = 202"
|
|
gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202"
|
|
gdb_test "print pDd->vg()" "\\$\[0-9\]+ = 101"
|
|
gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411"
|
|
gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407"
|
|
gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411"
|
|
gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411"
|
|
gdb_test "print pEe->vd()" "\\$\[0-9\]+ = 282"
|
|
gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311"
|
|
|
|
# more recent results:
|
|
# wrong value "202"
|
|
# gcc 2.95.3 -gdwarf-2
|
|
# gcc 2.95.3 -gstabs+
|
|
# attempt to take addres of value not located in memory
|
|
# gcc 3.3.2 -gdwarf-2
|
|
# gcc 3.3.2 -gstabs+
|
|
#
|
|
# -- chastain 2003-12-31
|
|
|
|
gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" {
|
|
-re "\\$\[0-9]+ = 102$nl$gdb_prompt $" {
|
|
pass "print pEe->D::vg()"
|
|
}
|
|
-re "\\$\[0-9]+ = 202$nl$gdb_prompt $" {
|
|
# To get this result, we have called pEe->*(&D::vg) ().
|
|
# That's how GDB interprets this, but it's wrong; in fact
|
|
# the explicit D:: means to bypass virtual function lookup,
|
|
# and call D::vg as if it were non-virtual. We still have
|
|
# to e.g. adjust "this", though.
|
|
kfail "gdb/1064" "print pEe->D::vg()"
|
|
}
|
|
-re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" {
|
|
kfail "gdb/1064" "print pEe->D::vg()"
|
|
}
|
|
}
|
|
}
|
|
|
|
# A helper proc that creates a regular expression matching a
|
|
# particular vtable. NAME is the type name. Each element of ARGS is
|
|
# the name of a function in the vtable.
|
|
|
|
proc make_one_vtable_result {name args} {
|
|
global hex
|
|
|
|
set nls "\[\r\n\]+"
|
|
|
|
set result "vtable for '${name}' @ $hex .subobject @ $hex.:$nls"
|
|
set count 0
|
|
foreach func $args {
|
|
append result ".${count}.: $hex <$func..>${nls}"
|
|
incr count
|
|
}
|
|
|
|
return $result
|
|
}
|
|
|
|
# Test "info vtbl".
|
|
|
|
proc test_info_vtbl {} {
|
|
global hex
|
|
|
|
set nls "\[\r\n\]+"
|
|
|
|
set vt_A [make_one_vtable_result A A::f]
|
|
set vt_B [make_one_vtable_result B B::f]
|
|
set vt_V [make_one_vtable_result V VB::vvb V::vv]
|
|
set vt_V2 [make_one_vtable_result V VB::vvb "virtual thunk to E::vv"]
|
|
set vt_D [make_one_vtable_result D D::vg D::vd]
|
|
set vt_D2 [make_one_vtable_result D "non-virtual thunk to E::vg" D::vd]
|
|
set vt_E [make_one_vtable_result E E::f E::vg E::vv]
|
|
|
|
gdb_test "info vtbl a" "${vt_A}${vt_V}"
|
|
gdb_test "info vtbl b" "${vt_B}${vt_V}"
|
|
gdb_test "info vtbl c" "${vt_V}"
|
|
gdb_test "info vtbl d" "${vt_D}${vt_V}"
|
|
gdb_test "info vtbl e" "${vt_E}${vt_D2}${vt_V2}"
|
|
gdb_test "info vtbl pEe" "${vt_E}${vt_D2}${vt_V2}"
|
|
|
|
gdb_test "info vtbl" "Argument required.*"
|
|
gdb_test "info vtbl va" \
|
|
"This object does not have a virtual function table.*"
|
|
gdb_test "info vtbl all_count" \
|
|
"This object does not have a virtual function table.*"
|
|
}
|
|
|
|
proc do_tests {} {
|
|
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
|
|
}
|
|
test_ptype_of_classes
|
|
test_info_vtbl
|
|
|
|
gdb_breakpoint test_calls
|
|
gdb_test "continue" ".*Breakpoint .* test_calls.*" ""
|
|
test_virtual_calls
|
|
|
|
gdb_test "next" ".*pAa->f.*" "next to pAa->f call"
|
|
gdb_test "next" ".*pDe->vg.*" "next to pDe->vg call"
|
|
gdb_test "step" ".*E::vg.*" "step through thunk into E::vg"
|
|
}
|
|
|
|
do_tests
|