run copyright.sh for 2011.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / gdb2384.exp
CommitLineData
7b6bb8da 1# Copyright 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
81fe8080
DE
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# When gdb resolves type information for class "derived" from objfile
17# gdb2384, it use to fill in the TYPE_VPTR_BASETYPE field with class "base"
18# from objfile gdb2384-base.so. When the program is rerun the type
19# information for base-in-so-base.so is discarded leaving
20# TYPE_VPTR_BASETYPE dangling.
02e7ea18
JB
21#
22# PR c++/9489.
81fe8080
DE
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28if { [skip_cplus_tests] } { continue }
29if { [skip_shlib_tests] } { continue }
30
81fe8080
DE
31set testfile "gdb2384"
32set srcfile ${testfile}.cc
33set binfile $objdir/$subdir/$testfile
34
35set libfile "gdb2384-base"
36set libsrcfile ${libfile}.cc
37set sofile $objdir/$subdir/${libfile}.so
38
39# Create and source the file that provides information about the compiler
40# used to compile the test case.
41if [get_compiler_info ${binfile} "c++"] {
42 return -1
43}
44
45if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != ""
46 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} {
47 untested gdb2384.exp
48 return -1
49}
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load ${binfile}
55gdb_load_shlibs ${sofile}
56
4fc5b208
PP
57
58if ![runto_main] then {
59 perror "couldn't run to breakpoint"
60 return -1
81fe8080
DE
61}
62
4fc5b208
PP
63gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
64gdb_continue_to_breakpoint "set breakpoint here"
65
66gdb_test "print d1.meth ()" \
81fe8080 67 ".*42.*" \
4fc5b208 68 "print d1.meth ()"
81fe8080
DE
69
70# Now try again. gdb's without the fix will hopefully segv here
71
4fc5b208
PP
72runto_main
73gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
74gdb_continue_to_breakpoint "set breakpoint here"
75gdb_test "print d1.meth ()" \
81fe8080
DE
76 ".*42.*" \
77 "gdb2384"
4fc5b208
PP
78
79# second case
80
81runto_main
82gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"]
83gdb_continue_to_breakpoint "set breakpoint here (second)"
84gdb_test "print d2.meth ()" \
85 ".*24.*" \
86 "print d2.meth()"
87
88runto_main
89gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"]
90gdb_continue_to_breakpoint "set breakpoint here (second)"
91gdb_test "print d2.meth ()" \
92 ".*24.*" \
93 "gdb2384 (second)"
94
This page took 0.330679 seconds and 4 git commands to generate.