Commit | Line | Data |
---|---|---|
02506ff1 MS |
1 | # Copyright 2009 |
2 | # Free Software Foundation, Inc. | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # This file is part of the GDB testsuite. It tests precord debugging | |
18 | # with shared libraries and a logfile. | |
19 | ||
20 | # This test suitable only for process record-replay | |
21 | if ![target_info exists gdb,use_precord] { | |
22 | return | |
23 | } | |
24 | ||
25 | set testfile "solib-reverse" | |
26 | set srcfile ${testfile}.c | |
27 | set libfile "shr2" | |
28 | set libsrc ${libfile}.c | |
29 | set library ${objdir}/${subdir}/${libfile}.sl | |
30 | set binfile ${objdir}/${subdir}/${testfile} | |
31 | ||
32 | if [get_compiler_info ${binfile}] { | |
33 | return -1 | |
34 | } | |
35 | ||
36 | if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } { | |
37 | untested "Could not compile shared library." | |
38 | return -1 | |
39 | } | |
40 | ||
41 | set exec_opts [list debug shlib=${library}] | |
42 | ||
43 | if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { | |
44 | untested "Could not compile $binfile." | |
45 | return -1 | |
46 | } | |
47 | ||
48 | # Start with a fresh gdb. | |
49 | ||
50 | gdb_exit | |
51 | gdb_start | |
52 | gdb_reinitialize_dir $srcdir/$subdir | |
53 | gdb_load ${binfile} | |
54 | ||
55 | ||
56 | runto main | |
57 | ||
58 | if [target_info exists gdb,use_precord] { | |
59 | # Activate process record/replay | |
60 | gdb_test "record" "" "Turn on process record" | |
61 | # FIXME: command ought to acknowledge, so we can test if it succeeded. | |
62 | } | |
63 | ||
64 | set end_of_main [gdb_get_line_number "end of main" ] | |
65 | gdb_test "break $end_of_main" \ | |
66 | "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \ | |
67 | "BP at end of main" | |
68 | ||
69 | gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" | |
70 | ||
71 | gdb_test "record save solib.precsave" \ | |
72 | "Saved core file solib.precsave with execution log\." \ | |
73 | "save process recfile" | |
74 | ||
75 | gdb_test "kill" "" "Kill process, prepare to debug log file" \ | |
76 | "Kill the program being debugged\\? \\(y or n\\) " "y" | |
77 | ||
78 | gdb_test "record restore solib.precsave" \ | |
79 | "Program terminated with signal .*" \ | |
80 | "reload core file" | |
81 | ||
82 | # | |
83 | # Test reverse-step over undebuggable solib functions. | |
84 | # | |
85 | ||
86 | # Run forward past some solib function calls. | |
87 | ||
88 | set end_part_one [gdb_get_line_number " end part one" "$srcfile"] | |
89 | set end_part_two [gdb_get_line_number " end part two" "$srcfile"] | |
90 | gdb_test "until $end_part_one" " end part one.*" "run until end part one" | |
91 | ||
92 | gdb_test "reverse-step" " sleep three .*" "reverse-step third sleep" | |
93 | gdb_test "reverse-step" " sleep two .*" "reverse-step second sleep" | |
94 | gdb_test "reverse-step" " sleep one .*" \ | |
95 | "reverse-step first sleep, dynsym resolve" | |
96 | ||
97 | gdb_test "reverse-step" " printf three .*" "reverse-step third printf" | |
98 | gdb_test "reverse-step" " printf two .*" "reverse-step second printf" | |
99 | gdb_test "reverse-step" " printf one .*" \ | |
100 | "reverse-step first printf, dynsym resolve" | |
101 | gdb_test "reverse-step" " generic statement.*" "reverse-step generic" | |
102 | ||
103 | ||
104 | # | |
105 | # Test reverse-next over undebuggable solib functions. | |
106 | # | |
107 | ||
108 | # Run forward again... | |
109 | ||
110 | gdb_test "until $end_part_one" " end part one.*" "forward to end part one" | |
111 | ||
112 | gdb_test "reverse-next" " sleep three .*" "reverse-next third sleep" | |
113 | gdb_test "reverse-next" " sleep two .*" "reverse-next second sleep" | |
114 | gdb_test "reverse-next" " sleep one .*" \ | |
115 | "reverse-next first sleep, dynsym resolve" | |
116 | ||
117 | gdb_test "reverse-next" " printf three .*" "reverse-next third printf" | |
118 | gdb_test "reverse-next" " printf two .*" "reverse-next second printf" | |
119 | gdb_test "reverse-next" " printf one .*" \ | |
120 | "reverse-next first printf, dynsym resolve" | |
121 | gdb_test "reverse-next" " generic statement.*" "reverse-next generic" | |
122 | ||
123 | ||
124 | # | |
125 | # Test reverse-step into debuggable solib function | |
126 | # | |
127 | ||
128 | gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function one" | |
129 | gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" | |
130 | gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" | |
131 | ||
132 | gdb_test "reverse-step" "${libsrc}.*" "reverse-step into solib function two" | |
133 | gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" | |
134 | gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" | |
135 | ||
136 | # | |
137 | # Test reverse-next over debuggable solib function | |
138 | # | |
139 | ||
140 | gdb_test "until $end_part_two" " end part two.*" "run until end part two" | |
141 | ||
142 | gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one" | |
143 | gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two" |