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 precord debugging
|
17 |
|
|
# with shared libraries and a logfile.
|
18 |
|
|
|
19 |
|
|
# This test suitable only for process record-replay
|
20 |
|
|
if ![target_info exists gdb,use_precord] {
|
21 |
|
|
return
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
set testfile "solib-reverse"
|
25 |
|
|
set srcfile ${testfile}.c
|
26 |
|
|
set libfile "shr2"
|
27 |
|
|
set libsrc ${libfile}.c
|
28 |
|
|
set library ${objdir}/${subdir}/${libfile}.sl
|
29 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
30 |
|
|
|
31 |
|
|
if [get_compiler_info ${binfile}] {
|
32 |
|
|
return -1
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } {
|
36 |
|
|
untested "Could not compile shared library."
|
37 |
|
|
return -1
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
set exec_opts [list debug shlib=${library}]
|
41 |
|
|
|
42 |
|
|
if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
|
43 |
|
|
untested "Could not compile $binfile."
|
44 |
|
|
return -1
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
# Start with a fresh gdb.
|
48 |
|
|
|
49 |
|
|
gdb_exit
|
50 |
|
|
gdb_start
|
51 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
52 |
|
|
gdb_load ${binfile}
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
runto main
|
56 |
|
|
|
57 |
|
|
if [target_info exists gdb,use_precord] {
|
58 |
|
|
# Activate process record/replay
|
59 |
|
|
gdb_test "record" "" "Turn on process record"
|
60 |
|
|
# FIXME: command ought to acknowledge, so we can test if it succeeded.
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
set end_of_main [gdb_get_line_number "end of main" ]
|
64 |
|
|
gdb_test "break $end_of_main" \
|
65 |
|
|
"Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
|
66 |
|
|
"BP at end of main"
|
67 |
|
|
|
68 |
|
|
gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
|
69 |
|
|
|
70 |
|
|
gdb_test "record save solib.precsave" \
|
71 |
|
|
"Saved core file solib.precsave with execution log\." \
|
72 |
|
|
"save process recfile"
|
73 |
|
|
|
74 |
|
|
gdb_test "kill" "" "Kill process, prepare to debug log file" \
|
75 |
|
|
"Kill the program being debugged\\? \\(y or n\\) " "y"
|
76 |
|
|
|
77 |
|
|
gdb_test "record restore solib.precsave" \
|
78 |
|
|
"Program terminated with signal .*" \
|
79 |
|
|
"reload core file"
|
80 |
|
|
|
81 |
|
|
#
|
82 |
|
|
# Test reverse-step over undebuggable solib functions.
|
83 |
|
|
#
|
84 |
|
|
|
85 |
|
|
# Run forward past some solib function calls.
|
86 |
|
|
|
87 |
|
|
set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
|
88 |
|
|
set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
|
89 |
|
|
gdb_test "until $end_part_one" " end part one.*" "run until end part one"
|
90 |
|
|
|
91 |
|
|
gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
|
92 |
|
|
gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep"
|
93 |
|
|
gdb_test "reverse-step" " sleep one .*" \
|
94 |
|
|
"reverse-step first sleep, dynsym resolve"
|
95 |
|
|
|
96 |
|
|
gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
|
97 |
|
|
gdb_test "reverse-step" " printf two .*" "reverse-step second printf"
|
98 |
|
|
gdb_test "reverse-step" " printf one .*" \
|
99 |
|
|
"reverse-step first printf, dynsym resolve"
|
100 |
|
|
gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
#
|
104 |
|
|
# Test reverse-next over undebuggable solib functions.
|
105 |
|
|
#
|
106 |
|
|
|
107 |
|
|
# Run forward again...
|
108 |
|
|
|
109 |
|
|
gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
|
110 |
|
|
|
111 |
|
|
gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
|
112 |
|
|
gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep"
|
113 |
|
|
gdb_test "reverse-next" " sleep one .*" \
|
114 |
|
|
"reverse-next first sleep, dynsym resolve"
|
115 |
|
|
|
116 |
|
|
gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
|
117 |
|
|
gdb_test "reverse-next" " printf two .*" "reverse-next second printf"
|
118 |
|
|
gdb_test "reverse-next" " printf one .*" \
|
119 |
|
|
"reverse-next first printf, dynsym resolve"
|
120 |
|
|
gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
#
|
124 |
|
|
# Test reverse-step into debuggable solib function
|
125 |
|
|
#
|
126 |
|
|
|
127 |
|
|
gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
|
128 |
|
|
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
|
129 |
|
|
gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
|
130 |
|
|
|
131 |
|
|
gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
|
132 |
|
|
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
|
133 |
|
|
gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
|
134 |
|
|
|
135 |
|
|
#
|
136 |
|
|
# Test reverse-next over debuggable solib function
|
137 |
|
|
#
|
138 |
|
|
|
139 |
|
|
gdb_test "until $end_part_two" " end part two.*" "run until end part two"
|
140 |
|
|
|
141 |
|
|
gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
|
142 |
|
|
gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two"
|