]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - 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
CommitLineData
8acc9f48 1# Copyright 2009-2013 Free Software Foundation, Inc.
02506ff1
MS
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
d3895d7d 20if ![supports_process_record] {
02506ff1
MS
21 return
22}
44883546
YQ
23if {[skip_shlib_tests]} {
24 return
25}
02506ff1 26
7686c074 27standard_testfile solib-reverse.c
55baab26 28set precsave [standard_output_file solib.precsave]
02506ff1
MS
29set libfile "shr2"
30set libsrc ${libfile}.c
7686c074 31set library [standard_output_file ${libfile}.sl]
02506ff1 32
4c93b1db 33if [get_compiler_info] {
02506ff1
MS
34 return -1
35}
36
37if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
38 untested "Could not compile shared library."
39 return -1
40}
41
42set exec_opts [list debug shlib=${library}]
43
51898c15
JK
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
48if { [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] != "" } {
02506ff1
MS
51 untested "Could not compile $binfile."
52 return -1
53}
54
55# Start with a fresh gdb.
56
57gdb_exit
58gdb_start
596ba138
JK
59
60# Clear it to never find any separate system debug infos.
61gdb_test_no_output "set debug-file-directory"
62
02506ff1
MS
63gdb_reinitialize_dir $srcdir/$subdir
64gdb_load ${binfile}
44883546 65gdb_load_shlibs $library
02506ff1
MS
66
67runto main
68
d3895d7d 69if [supports_process_record] {
02506ff1 70 # Activate process record/replay
bcd2dc50 71 gdb_test_no_output "record" "Turn on process record"
02506ff1
MS
72}
73
74set end_of_main [gdb_get_line_number "end of main" ]
75gdb_test "break $end_of_main" \
76 "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
77 "BP at end of main"
78
79gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
80
55baab26
TT
81gdb_test "record save $precsave" \
82 "Saved core file $precsave with execution log\." \
02506ff1
MS
83 "save process recfile"
84
85gdb_test "kill" "" "Kill process, prepare to debug log file" \
86 "Kill the program being debugged\\? \\(y or n\\) " "y"
87
55baab26 88gdb_test "record restore $precsave" \
02506ff1
MS
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
98set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
99set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
100gdb_test "until $end_part_one" " end part one.*" "run until end part one"
101
102gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
103gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep"
104gdb_test "reverse-step" " sleep one .*" \
105 "reverse-step first sleep, dynsym resolve"
106
107gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
108gdb_test "reverse-step" " printf two .*" "reverse-step second printf"
109gdb_test "reverse-step" " printf one .*" \
110 "reverse-step first printf, dynsym resolve"
111gdb_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
120gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
121
122gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
123gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep"
124gdb_test "reverse-next" " sleep one .*" \
125 "reverse-next first sleep, dynsym resolve"
126
127gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
128gdb_test "reverse-next" " printf two .*" "reverse-next second printf"
129gdb_test "reverse-next" " printf one .*" \
130 "reverse-next first printf, dynsym resolve"
131gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
132
133
134#
135# Test reverse-step into debuggable solib function
136#
137
138gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
139gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
140gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
141
142gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
143gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
144gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
145
146#
147# Test reverse-next over debuggable solib function
148#
149
150gdb_test "until $end_part_two" " end part two.*" "run until end part two"
151
152gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
153gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two"