]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/solib-precsave.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / solib-precsave.exp
1 # Copyright 2009-2013 Free Software Foundation, Inc.
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 # This file is part of the GDB testsuite. It tests precord debugging
17 # with shared libraries and a logfile.
18
19 # This test suitable only for process record-replay
20 if ![supports_process_record] {
21 return
22 }
23 if {[skip_shlib_tests]} {
24 return
25 }
26
27 standard_testfile solib-reverse.c
28 set precsave [standard_output_file solib.precsave]
29 set libfile "shr2"
30 set libsrc ${libfile}.c
31 set library [standard_output_file ${libfile}.sl]
32
33 if [get_compiler_info] {
34 return -1
35 }
36
37 if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
38 untested "Could not compile shared library."
39 return -1
40 }
41
42 set exec_opts [list debug shlib=${library}]
43
44 # Attempt to prevent -Wl,-z,relro which may happen by default with some
45 # toolchain configurations. Due to PR corefiles/11804 GDB will then produce
46 # invalid core file.
47
48 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
49 [concat $exec_opts additional_flags=-Wl,-z,norelro]] != ""
50 && [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
51 untested "Could not compile $binfile."
52 return -1
53 }
54
55 # Start with a fresh gdb.
56
57 gdb_exit
58 gdb_start
59
60 # Clear it to never find any separate system debug infos.
61 gdb_test_no_output "set debug-file-directory"
62
63 gdb_reinitialize_dir $srcdir/$subdir
64 gdb_load ${binfile}
65 gdb_load_shlibs $library
66
67 runto main
68
69 if [supports_process_record] {
70 # Activate process record/replay
71 gdb_test_no_output "record" "Turn on process record"
72 }
73
74 set end_of_main [gdb_get_line_number "end of main" ]
75 gdb_test "break $end_of_main" \
76 "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
77 "BP at end of main"
78
79 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
80
81 gdb_test "record save $precsave" \
82 "Saved core file $precsave with execution log\." \
83 "save process recfile"
84
85 gdb_test "kill" "" "Kill process, prepare to debug log file" \
86 "Kill the program being debugged\\? \\(y or n\\) " "y"
87
88 gdb_test "record restore $precsave" \
89 "Program terminated with signal .*" \
90 "reload core file"
91
92 #
93 # Test reverse-step over undebuggable solib functions.
94 #
95
96 # Run forward past some solib function calls.
97
98 set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
99 set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
100 gdb_test "until $end_part_one" " end part one.*" "run until end part one"
101
102 gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
103 gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep"
104 gdb_test "reverse-step" " sleep one .*" \
105 "reverse-step first sleep, dynsym resolve"
106
107 gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
108 gdb_test "reverse-step" " printf two .*" "reverse-step second printf"
109 gdb_test "reverse-step" " printf one .*" \
110 "reverse-step first printf, dynsym resolve"
111 gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
112
113
114 #
115 # Test reverse-next over undebuggable solib functions.
116 #
117
118 # Run forward again...
119
120 gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
121
122 gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
123 gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep"
124 gdb_test "reverse-next" " sleep one .*" \
125 "reverse-next first sleep, dynsym resolve"
126
127 gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
128 gdb_test "reverse-next" " printf two .*" "reverse-next second printf"
129 gdb_test "reverse-next" " printf one .*" \
130 "reverse-next first printf, dynsym resolve"
131 gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
132
133
134 #
135 # Test reverse-step into debuggable solib function
136 #
137
138 gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
139 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
140 gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
141
142 gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
143 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
144 gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
145
146 #
147 # Test reverse-next over debuggable solib function
148 #
149
150 gdb_test "until $end_part_two" " end part two.*" "run until end part two"
151
152 gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
153 gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two"