PR gdb/8704
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-display.exp
CommitLineData
a3247a22
PP
1# Copyright 2009 Free Software Foundation, Inc.
2# This program is free software; you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation; either version 3 of the License, or
5# (at your option) any later version.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14#
15# Contributed by Paul Pluzhnikov <ppluzhnikov@google.com>
16#
17
18# This test case verifies that if a display is active on a variable
19# which belongs in a shared library, and that shared library is
20# reloaded (e.g. due to re-execution of the program), GDB will continue
21# to display it (gdb-6.8 crashed under this scenario).
22
23# Also test that a display of variable which is currently present in
24# a shared library, but disappears before re-run, doesn't cause GDB
25# difficulties, and that it continues to display other variables.
26
27# Finally, test that displays which refer to main executable
28# (and thus aren't affected by shared library unloading) are not
29# disabled prematurely.
30
d24948ac 31if { [skip_shlib_tests] || [is_remote target] } {
a3247a22
PP
32 return 0
33}
34
35# Library file.
36set libname "solib-display-lib"
37set srcfile_lib ${srcdir}/${subdir}/${libname}.c
38set binfile_lib ${objdir}/${subdir}/${libname}.so
39set lib_flags [list debug]
40# Binary file.
41set testfile "solib-display-main"
42set srcfile ${srcdir}/${subdir}/${testfile}.c
43set binfile ${objdir}/${subdir}/${testfile}
44set bin_flags [list debug shlib=${binfile_lib}]
45
46if [get_compiler_info ${binfile}] {
47 return -1
48}
49
50if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
51 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
52 untested "Could not compile $binfile_lib or $binfile."
53 return -1
54}
55
56gdb_exit
57gdb_start
58gdb_reinitialize_dir $srcdir/$subdir
59gdb_load ${binfile}
60
61if ![runto_main] then {
62 fail "Can't run to main"
63 return 0
64}
65
66gdb_test "display a_global" "1: a_global = 41"
67gdb_test "display b_global" "2: b_global = 42"
68gdb_test "display c_global" "3: c_global = 43"
69
70if { [gdb_start_cmd] < 0 } {
71 fail "Can't run to main (2)"
72 return 0
73}
74
75gdb_test "" "3: c_global = 43\\r\\n2: b_global = 42\\r\\n1: a_global = 41" "after rerun"
76
77# Now rebuild the library without b_global
78if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} \
79 "$lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
80 fail "Can't rebuild $binfile_lib"
81}
82
83if { [gdb_start_cmd] < 0 } {
84 fail "Can't run to main (3)"
85 return 0
86}
87
88gdb_test "" "3: c_global = 43\\r\\nwarning: .*b_global.*\\r\\n1: a_global = 41" "after rerun"
89
90# Now verify that displays which are not in the shared library
91# are not cleared permaturely.
92
93gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
94 ".*Breakpoint.* at .*"
95
96gdb_test "continue"
97gdb_test "display main_global" "4: main_global = 44"
98gdb_test "display a_local" "5: a_local = 45"
99gdb_test "display a_static" "6: a_static = 46"
100
101if { [gdb_start_cmd] < 0 } {
102 fail "Can't run to main (4)"
103 return 0
104}
105
106gdb_test "" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
107gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
108 ".*Breakpoint.* at .*"
109gdb_test "continue" "6: a_static = 46\\r\\n5: a_local = 45\\r\\n4: main_global = 44\\r\\n.*"
110
111gdb_exit
112
113return 0
114
115
This page took 0.134978 seconds and 4 git commands to generate.