* hppa.h (pa_opcodes): Use "cX" completer instead of "cx" in fstqx
[external/binutils.git] / gdb / testsuite / gdb.cp / virtfunc.exp
index 4b1472e..4621a74 100644 (file)
@@ -1,40 +1,32 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
-# 2006, 2007 Free Software Foundation, Inc.
+# 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 2 of the License, or
+# 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, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# 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
-}
-
 if { [skip_cplus_tests] } { continue }
 
 load_lib "cp-support.exp"
 
-set testfile "virtfunc"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
-     untested virtfunc.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 proc test_ptype_of_classes {} {
@@ -231,25 +223,64 @@ proc test_virtual_calls {} {
     }
 }
 
-proc do_tests {} {
-    global prms_id
-    global bug_id
-    global srcdir subdir binfile
-    global gdb_prompt
+# 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 prms_id 0
-    set bug_id 0
+    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
+}
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
+# 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.*"
+}
 
-    gdb_test "set language c++" "" ""
-    gdb_test "set width 0" "" ""
+proc do_tests {} {
+    gdb_test_no_output "set language c++" ""
+    gdb_test_no_output "set width 0" ""
 
-    runto_main
+    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.*" ""