1 # Copyright 2009-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests precord debugging
17 # with shared libraries and a logfile.
19 # This test suitable only for process record-replay
20 if ![supports_process_record] {
24 standard_testfile solib-reverse.c
25 set precsave [standard_output_file solib.precsave]
27 set libsrc ${libfile}.c
28 set library [standard_output_file ${libfile}.sl]
30 if [get_compiler_info] {
34 if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
35 untested "Could not compile shared library."
39 set exec_opts [list debug shlib=${library}]
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
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."
52 # Start with a fresh gdb.
57 # Clear it to never find any separate system debug infos.
58 gdb_test_no_output "set debug-file-directory"
60 gdb_reinitialize_dir $srcdir/$subdir
66 if [supports_process_record] {
67 # Activate process record/replay
68 gdb_test_no_output "record" "Turn on process record"
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\." \
76 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
78 gdb_test "record save $precsave" \
79 "Saved core file $precsave with execution log\." \
80 "save process recfile"
82 gdb_test "kill" "" "Kill process, prepare to debug log file" \
83 "Kill the program being debugged\\? \\(y or n\\) " "y"
85 gdb_test "record restore $precsave" \
86 "Program terminated with signal .*" \
90 # Test reverse-step over undebuggable solib functions.
93 # Run forward past some solib function calls.
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"
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"
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"
112 # Test reverse-next over undebuggable solib functions.
115 # Run forward again...
117 gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
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"
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"
132 # Test reverse-step into debuggable solib function
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"
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"
144 # Test reverse-next over debuggable solib function
147 gdb_test "until $end_part_two" " end part two.*" "run until end part two"
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"