1 |
227 |
jeremybenn |
# Copyright 2009, 2010 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 .
|
15 |
|
|
|
16 |
|
|
# This file is part of the GDB testsuite. It tests reverse debugging
|
17 |
|
|
# with shared libraries.
|
18 |
|
|
|
19 |
|
|
if ![target_info exists gdb,can_reverse] {
|
20 |
|
|
return
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
set testfile "solib-reverse"
|
24 |
|
|
set srcfile ${testfile}.c
|
25 |
|
|
set libfile "shr2"
|
26 |
|
|
set libsrc ${libfile}.c
|
27 |
|
|
set library ${objdir}/${subdir}/${libfile}.sl
|
28 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
29 |
|
|
|
30 |
|
|
if [get_compiler_info ${binfile}] {
|
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 |
|
|
if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
|
42 |
|
|
untested "Could not compile $binfile."
|
43 |
|
|
return -1
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
# Start with a fresh gdb.
|
47 |
|
|
|
48 |
|
|
gdb_exit
|
49 |
|
|
gdb_start
|
50 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
51 |
|
|
gdb_load ${binfile}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
runto main
|
55 |
|
|
|
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.
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
#
|
63 |
|
|
# Test reverse-step over undebuggable solib functions.
|
64 |
|
|
#
|
65 |
|
|
|
66 |
|
|
# Run forward past some solib function calls.
|
67 |
|
|
|
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"
|
71 |
|
|
|
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"
|
76 |
|
|
|
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"
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
#
|
85 |
|
|
# Test reverse-next over undebuggable solib functions.
|
86 |
|
|
#
|
87 |
|
|
|
88 |
|
|
# Run forward again...
|
89 |
|
|
|
90 |
|
|
gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
|
91 |
|
|
|
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"
|
96 |
|
|
|
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"
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
#
|
105 |
|
|
# Test reverse-step into debuggable solib function
|
106 |
|
|
#
|
107 |
|
|
|
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"
|
111 |
|
|
|
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"
|
115 |
|
|
|
116 |
|
|
#
|
117 |
|
|
# Test reverse-next over debuggable solib function
|
118 |
|
|
#
|
119 |
|
|
|
120 |
|
|
gdb_test "until $end_part_two" " end part two.*" "run until end part two"
|
121 |
|
|
|
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"
|