1 # Copyright 2009, 2010 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 reverse debugging
17 # with shared libraries.
19 if ![target_info exists gdb,can_reverse] {
23 set testfile "solib-reverse"
24 set srcfile ${testfile}.c
26 set libsrc ${libfile}.c
27 set library ${objdir}/${subdir}/${libfile}.sl
28 set binfile ${objdir}/${subdir}/${testfile}
30 if [get_compiler_info ${binfile}] {
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 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
42 untested "Could not compile $binfile."
46 # Start with a fresh gdb.
50 gdb_reinitialize_dir $srcdir/$subdir
56 if [target_info exists gdb,use_precord] {
57 # Activate process record/replay
58 gdb_test "record" "" "Turn on process record"
59 # FIXME: command ought to acknowledge, so we can test if it succeeded.
63 # Test reverse-step over undebuggable solib functions.
66 # Run forward past some solib function calls.
68 set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
69 set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
70 gdb_test "until $end_part_one" " end part one.*" "run until end part one"
72 gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
73 gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep"
74 gdb_test "reverse-step" " sleep one .*" \
75 "reverse-step first sleep, dynsym resolve"
77 gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
78 gdb_test "reverse-step" " printf two .*" "reverse-step second printf"
79 gdb_test "reverse-step" " printf one .*" \
80 "reverse-step first printf, dynsym resolve"
81 gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
85 # Test reverse-next over undebuggable solib functions.
88 # Run forward again...
90 gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
92 gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
93 gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep"
94 gdb_test "reverse-next" " sleep one .*" \
95 "reverse-next first sleep, dynsym resolve"
97 gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
98 gdb_test "reverse-next" " printf two .*" "reverse-next second printf"
99 gdb_test "reverse-next" " printf one .*" \
100 "reverse-next first printf, dynsym resolve"
101 gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
105 # Test reverse-step into debuggable solib function
108 gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
109 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
110 gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
112 gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
113 gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
114 gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
117 # Test reverse-next over debuggable solib function
120 gdb_test "until $end_part_two" " end part two.*" "run until end part two"
122 gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
123 gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two"