gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / gdb2384.exp
CommitLineData
4c38e0a4 1# Copyright 2007, 2009, 2010 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.
21
22if $tracelevel then {
23 strace $tracelevel
24}
25
26if { [skip_cplus_tests] } { continue }
27if { [skip_shlib_tests] } { continue }
28
29set prms_id 2384
30set bug_id 0
31
32set testfile "gdb2384"
33set srcfile ${testfile}.cc
34set binfile $objdir/$subdir/$testfile
35
36set libfile "gdb2384-base"
37set libsrcfile ${libfile}.cc
38set sofile $objdir/$subdir/${libfile}.so
39
40# Create and source the file that provides information about the compiler
41# used to compile the test case.
42if [get_compiler_info ${binfile} "c++"] {
43 return -1
44}
45
46if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != ""
47 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} {
48 untested gdb2384.exp
49 return -1
50}
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56gdb_load_shlibs ${sofile}
57
4fc5b208
PP
58
59if ![runto_main] then {
60 perror "couldn't run to breakpoint"
61 return -1
81fe8080
DE
62}
63
4fc5b208
PP
64gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
65gdb_continue_to_breakpoint "set breakpoint here"
66
67gdb_test "print d1.meth ()" \
81fe8080 68 ".*42.*" \
4fc5b208 69 "print d1.meth ()"
81fe8080
DE
70
71# Now try again. gdb's without the fix will hopefully segv here
72
4fc5b208
PP
73runto_main
74gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
75gdb_continue_to_breakpoint "set breakpoint here"
76gdb_test "print d1.meth ()" \
81fe8080
DE
77 ".*42.*" \
78 "gdb2384"
4fc5b208
PP
79
80# second case
81
82runto_main
83gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"]
84gdb_continue_to_breakpoint "set breakpoint here (second)"
85gdb_test "print d2.meth ()" \
86 ".*24.*" \
87 "print d2.meth()"
88
89runto_main
90gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"]
91gdb_continue_to_breakpoint "set breakpoint here (second)"
92gdb_test "print d2.meth ()" \
93 ".*24.*" \
94 "gdb2384 (second)"
95
This page took 0.21829 seconds and 4 git commands to generate.