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