1 |
330 |
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_no_output "record" "Turn on process record"
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
set end_of_main [gdb_get_line_number "end of main" ]
|
63 |
|
|
gdb_test "break $end_of_main" \
|
64 |
|
|
"Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
|
65 |
|
|
"BP at end of main"
|
66 |
|
|
|
67 |
|
|
gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
|
68 |
|
|
|
69 |
|
|
gdb_test "record save solib.precsave" \
|
70 |
|
|
"Saved core file solib.precsave with execution log\." \
|
71 |
|
|
"save process recfile"
|
72 |
|
|
|
73 |
|
|
gdb_test "kill" "" "Kill process, prepare to debug log file" \
|
74 |
|
|
"Kill the program being debugged\\? \\(y or n\\) " "y"
|
75 |
|
|
|
76 |
|
|
gdb_test "record restore solib.precsave" \
|
77 |
|
|
"Program terminated with signal .*" \
|
78 |
|
|
"reload core file"
|
79 |
|
|
|
80 |
|
|
#
|
81 |
|
|
# Test reverse-step over undebuggable solib functions.
|
82 |
|
|
#
|
83 |
|
|
|
84 |
|
|
# Run forward past some solib function calls.
|
85 |
|
|
|
86 |
|
|
set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
|
87 |
|
|
set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
|
88 |
|
|
gdb_test "until $end_part_one" " end part one.*" "run until end part one"
|
89 |
|
|
|
90 |
|
|
gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep"
|
91 |
|
|
gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep"
|
92 |
|
|
gdb_test "reverse-step" " sleep one .*" \
|
93 |
|
|
"reverse-step first sleep, dynsym resolve"
|
94 |
|
|
|
95 |
|
|
gdb_test "reverse-step" " printf three .*" "reverse-step third printf"
|
96 |
|
|
gdb_test "reverse-step" " printf two .*" "reverse-step second printf"
|
97 |
|
|
gdb_test "reverse-step" " printf one .*" \
|
98 |
|
|
"reverse-step first printf, dynsym resolve"
|
99 |
|
|
gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
#
|
103 |
|
|
# Test reverse-next over undebuggable solib functions.
|
104 |
|
|
#
|
105 |
|
|
|
106 |
|
|
# Run forward again...
|
107 |
|
|
|
108 |
|
|
gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
|
109 |
|
|
|
110 |
|
|
gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep"
|
111 |
|
|
gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep"
|
112 |
|
|
gdb_test "reverse-next" " sleep one .*" \
|
113 |
|
|
"reverse-next first sleep, dynsym resolve"
|
114 |
|
|
|
115 |
|
|
gdb_test "reverse-next" " printf three .*" "reverse-next third printf"
|
116 |
|
|
gdb_test "reverse-next" " printf two .*" "reverse-next second printf"
|
117 |
|
|
gdb_test "reverse-next" " printf one .*" \
|
118 |
|
|
"reverse-next first printf, dynsym resolve"
|
119 |
|
|
gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
#
|
123 |
|
|
# Test reverse-step into debuggable solib function
|
124 |
|
|
#
|
125 |
|
|
|
126 |
|
|
gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one"
|
127 |
|
|
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
|
128 |
|
|
gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
|
129 |
|
|
|
130 |
|
|
gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two"
|
131 |
|
|
gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
|
132 |
|
|
gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
|
133 |
|
|
|
134 |
|
|
#
|
135 |
|
|
# Test reverse-next over debuggable solib function
|
136 |
|
|
#
|
137 |
|
|
|
138 |
|
|
gdb_test "until $end_part_two" " end part two.*" "run until end part two"
|
139 |
|
|
|
140 |
|
|
gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
|
141 |
|
|
gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two"
|