Improve gdb_remote_download, remove gdb_download
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-display.exp
1 # Copyright 2009-2016 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
31 if { [skip_shlib_tests] || [is_remote target] } {
32 return 0
33 }
34
35 # Library file.
36 set libname "solib-display-lib"
37 set srcfile_lib ${srcdir}/${subdir}/${libname}.c
38 set binfile_lib [standard_output_file ${libname}.so]
39 set lib_flags {}
40 # Binary file.
41 set testfile "solib-display-main"
42 set srcfile ${srcdir}/${subdir}/${testfile}.c
43 set executable ${testfile}
44 set binfile [standard_output_file ${executable}]
45 set bin_flags [list debug shlib=${binfile_lib}]
46
47 if [get_compiler_info] {
48 return -1
49 }
50
51 # SEP must be last for the possible `unsupported' error path.
52 foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
53
54 set sep_lib_flags $lib_flags
55 if {$libsepdebug != "NO"} {
56 lappend sep_lib_flags {debug}
57 }
58 if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != ""
59 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
60 untested "Could not compile $binfile_lib or $binfile."
61 return -1
62 }
63
64 if {$libsepdebug == "SEP"} {
65 if {[gdb_gnu_strip_debug $binfile_lib] != 0} {
66 unsupported "Could not split debug of $binfile_lib."
67 return
68 } else {
69 pass "split solib"
70 }
71 }
72
73 clean_restart $executable
74
75 if ![runto_main] then {
76 fail "Can't run to main"
77 return 0
78 }
79
80 gdb_test "display a_global" "1: a_global = 41"
81 gdb_test "display b_global" "2: b_global = 42"
82 gdb_test "display c_global" "3: c_global = 43"
83
84 if { [gdb_start_cmd] < 0 } {
85 fail "Can't run to main (2)"
86 continue
87 }
88
89 gdb_test "" [multi_line \
90 "1: a_global = 41" \
91 "2: b_global = 42" \
92 "3: c_global = 43" \
93 ] "after rerun"
94
95 # Now rebuild the library without b_global
96 if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} \
97 "$sep_lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
98 fail "Can't rebuild $binfile_lib"
99 }
100
101 if {$libsepdebug == "SEP"} {
102 set test "split solib second time"
103 if {[gdb_gnu_strip_debug $binfile_lib] != 0} {
104 fail $test
105 continue
106 } else {
107 pass $test
108 }
109 }
110
111 if { [gdb_start_cmd] < 0 } {
112 fail "Can't run to main (3)"
113 continue
114 }
115
116
117 gdb_test "" [multi_line \
118 "1: a_global = 41" \
119 "warning: .*b_global.*" \
120 "3: c_global = 43" \
121 ] "after rerun (2)"
122
123 # Now verify that displays which are not in the shared library
124 # are not cleared permaturely.
125
126 gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
127 ".*Breakpoint.* at .*"
128
129 gdb_test "continue"
130 gdb_test "display main_global" "4: main_global = 44"
131 gdb_test "display a_local" "5: a_local = 45"
132 gdb_test "display a_static" "6: a_static = 46"
133
134 if { [gdb_start_cmd] < 0 } {
135 fail "Can't run to main (4)"
136 continue
137 }
138
139 gdb_test "" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
140 gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
141 ".*Breakpoint.* at .*"
142 gdb_test "continue" [multi_line \
143 "4: main_global = 44" \
144 "5: a_local = 45" \
145 "6: a_static = 46" \
146 ]
147 }}
This page took 0.03275 seconds and 4 git commands to generate.