1 |
227 |
jeremybenn |
# Copyright 2009, 2010 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 .
|
14 |
|
|
#
|
15 |
|
|
# Contributed by Paul Pluzhnikov
|
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 ${objdir}/${subdir}/${libname}.so
|
39 |
|
|
set lib_flags [list debug]
|
40 |
|
|
# Binary file.
|
41 |
|
|
set testfile "solib-display-main"
|
42 |
|
|
set srcfile ${srcdir}/${subdir}/${testfile}.c
|
43 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
44 |
|
|
set bin_flags [list debug shlib=${binfile_lib}]
|
45 |
|
|
|
46 |
|
|
if [get_compiler_info ${binfile}] {
|
47 |
|
|
return -1
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
if { [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 |
|
|
|
56 |
|
|
gdb_exit
|
57 |
|
|
gdb_start
|
58 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
59 |
|
|
gdb_load ${binfile}
|
60 |
|
|
|
61 |
|
|
if ![runto_main] then {
|
62 |
|
|
fail "Can't run to main"
|
63 |
|
|
return 0
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
gdb_test "display a_global" "1: a_global = 41"
|
67 |
|
|
gdb_test "display b_global" "2: b_global = 42"
|
68 |
|
|
gdb_test "display c_global" "3: c_global = 43"
|
69 |
|
|
|
70 |
|
|
if { [gdb_start_cmd] < 0 } {
|
71 |
|
|
fail "Can't run to main (2)"
|
72 |
|
|
return 0
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
gdb_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
|
78 |
|
|
if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} \
|
79 |
|
|
"$lib_flags additional_flags=-DNO_B_GLOBAL"] != ""} {
|
80 |
|
|
fail "Can't rebuild $binfile_lib"
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
if { [gdb_start_cmd] < 0 } {
|
84 |
|
|
fail "Can't run to main (3)"
|
85 |
|
|
return 0
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
gdb_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 |
|
|
|
93 |
|
|
gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
|
94 |
|
|
".*Breakpoint.* at .*"
|
95 |
|
|
|
96 |
|
|
gdb_test "continue"
|
97 |
|
|
gdb_test "display main_global" "4: main_global = 44"
|
98 |
|
|
gdb_test "display a_local" "5: a_local = 45"
|
99 |
|
|
gdb_test "display a_static" "6: a_static = 46"
|
100 |
|
|
|
101 |
|
|
if { [gdb_start_cmd] < 0 } {
|
102 |
|
|
fail "Can't run to main (4)"
|
103 |
|
|
return 0
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
gdb_test "" "6: a_static = 46\\r\\n4: main_global = 44\\r\\n.*"
|
107 |
|
|
gdb_test "break [gdb_get_line_number "break here" ${testfile}.c]" \
|
108 |
|
|
".*Breakpoint.* at .*"
|
109 |
|
|
gdb_test "continue" "6: a_static = 46\\r\\n5: a_local = 45\\r\\n4: main_global = 44\\r\\n.*"
|
110 |
|
|
|
111 |
|
|
gdb_exit
|
112 |
|
|
|
113 |
|
|
return 0
|
114 |
|
|
|
115 |
|
|
|