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