1 # Copyright
2009-2019 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.
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.
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
/>.
15 # Contributed by Paul Pluzhnikov
<ppluzhnikov@google.com
>
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
).
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.
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.
31 if { [skip_shlib_tests
] } {
35 # This test is currently not supported
for stub targets
, because it uses the
36 # start command
(through gdb_start_cmd
). In theory
, it could be changed to
37 # use something
else (kill
+ gdb_run_cmd with a manual breakpoint at main
).
38 # However
, when we try that with the native
-gdbserver board
, we see that the
39 # test fails and gdb outputs this upon connection
:
41 # warning
: Unable to display
"a_global": No symbol "a_global" in current context.
42 # warning
: Unable to display
"b_global": No symbol "b_global" in current context.
43 # warning
: Unable to display
"c_global": No symbol "c_global" in current context.
45 # This is because the initial stop is done before the shared libraries are
48 if { [use_gdb_stub
] } {
53 set libname
"solib-display-lib"
54 set srcfile_lib $
{srcdir
}/$
{subdir
}/$
{libname
}.c
55 set binfile_lib
[standard_output_file $
{libname
}.so
]
58 set testfile
"solib-display-main"
59 set srcfile $
{srcdir
}/$
{subdir
}/$
{testfile
}.c
60 set executable $
{testfile
}
61 set binfile
[standard_output_file $
{executable
}]
62 set bin_flags
[list debug shlib
=$
{binfile_lib
}]
64 if [get_compiler_info
] {
68 # SEP must be last
for the possible `unsupported
' error path.
69 foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
71 set sep_lib_flags $lib_flags
72 if {$libsepdebug != "NO"} {
73 lappend sep_lib_flags {debug}
75 if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != ""
76 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
77 untested "failed to compile"
81 if {$libsepdebug == "SEP"} {
82 if {[gdb_gnu_strip_debug $binfile_lib] != 0} {
83 unsupported "could not split debug of $binfile_lib."
90 clean_restart $executable
92 if ![runto_main] then {
93 fail "can't run to main
"
97 gdb_test
"display (int) a_global" "1: \\(int\\) a_global = 41"
98 gdb_test
"display (int) b_global" "2: \\(int\\) b_global = 42"
99 gdb_test
"display (int) c_global" "3: \\(int\\) c_global = 43"
101 if { [gdb_start_cmd
] < 0 } {
102 fail
"can't run to main (2)"
106 gdb_test
"" [multi_line \
107 "1: \\(int\\) a_global = 41" \
108 "2: \\(int\\) b_global = 42" \
109 "3: \\(int\\) c_global = 43" \
112 # Now rebuild the library without b_global
113 if { [gdb_compile_shlib $
{srcfile_lib
} $
{binfile_lib
} \
114 "$sep_lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
115 fail
"can't rebuild $binfile_lib"
118 if {$libsepdebug
== "SEP"} {
119 set test
"split solib second time"
120 if {[gdb_gnu_strip_debug $binfile_lib
] != 0} {
128 if { [gdb_start_cmd
] < 0 } {
129 fail
"can't run to main (3)"
134 gdb_test
"" [multi_line \
135 "1: \\(int\\) a_global = 41" \
136 "warning: .*b_global.*" \
137 "3: \\(int\\) c_global = 43" \
140 # Now verify that displays which are not in the shared library
141 # are not cleared permaturely.
143 gdb_test
"break [gdb_get_line_number "break here" ${testfile}.c]" \
144 ".*Breakpoint.* at .*"
147 gdb_test
"display main_global" "4: main_global = 44"
148 gdb_test
"display a_local" "5: a_local = 45"
149 gdb_test
"display a_static" "6: a_static = 46"
151 if { [gdb_start_cmd
] < 0 } {
152 fail
"can't run to main (4)"
156 gdb_test
"" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
157 gdb_test
"break [gdb_get_line_number "break here" ${testfile}.c]" \
158 ".*Breakpoint.* at .*"
159 gdb_test
"continue" [multi_line \
160 "4: main_global = 44" \