1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2013-2015 Free Software Foundation, Inc.
5 # Contributed by Intel Corp. <markus.t.metzger@intel.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # check for btrace support
21 if { [skip_btrace_tests] } { return -1 }
25 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
28 clean_restart $testfile
35 set bp_1 [gdb_get_line_number "bp.1" $srcfile]
36 set bp_2 [gdb_get_line_number "bp.2" $srcfile]
37 set bp_3 [gdb_get_line_number "bp.3" $srcfile]
39 proc gdb_cont_to_line { line } {
41 gdb_continue_to_breakpoint "cont to $line" ".*$line\r\n.*"
45 # trace the code between the two breakpoints
47 gdb_cont_to_line $srcfile:$bp_1
48 # make sure GDB knows about the new thread
49 gdb_test "info threads" ".*"
50 gdb_test_no_output "record btrace"
51 gdb_cont_to_line $srcfile:$bp_2
53 # navigate in the trace history for both threads
54 with_test_prefix "navigate" {
55 gdb_test "thread 1" ".*"
56 with_test_prefix "thread 1" {
57 gdb_test "record goto begin" ".*"
58 gdb_test "info record" ".*Replay in progress\. At instruction 1\."
60 gdb_test "thread 2" ".*"
61 with_test_prefix "thread 2" {
62 gdb_test "record goto begin" ".*"
63 gdb_test "info record" ".*Replay in progress\. At instruction 1\."
68 with_test_prefix "step" {
69 gdb_test "thread 1" ".*"
70 with_test_prefix "thread 1" {
71 gdb_test "info record" ".*Replay in progress\. At instruction 1\."
73 gdb_test "info record" ".*Replay in progress\. At instruction 2\."
75 gdb_test "thread 2" ".*"
76 with_test_prefix "thread 2" {
77 gdb_test "info record" ".*Replay in progress\. At instruction 1\."
79 gdb_test "info record" ".*Replay in progress\. At instruction 2\."
83 # run to the end of the history for both threads
84 with_test_prefix "cont" {
85 gdb_test "thread 1" ".*"
86 with_test_prefix "thread 1" {
87 gdb_test "info record" ".*Replay in progress\. At instruction 2\."
88 gdb_test "continue" "No more reverse-execution history.*"
90 gdb_test "thread 2" ".*"
91 with_test_prefix "thread 2" {
92 gdb_test "info record" ".*Replay in progress\. At instruction 2\."
93 gdb_test "continue" "No more reverse-execution history.*"
97 # reverse-step both threads
98 with_test_prefix "reverse-step" {
99 gdb_test "thread 1" ".*"
100 with_test_prefix "thread 1" {
101 gdb_test "reverse-stepi" ".*"
102 gdb_test "info record" ".*Replay in progress\..*"
104 gdb_test "thread 2" ".*"
105 with_test_prefix "thread 2" {
106 gdb_test "reverse-stepi" ".*"
107 gdb_test "info record" ".*Replay in progress\..*"
111 # both threads are still replaying
112 with_test_prefix "check" {
113 gdb_test "thread 1" ".*"
114 with_test_prefix "thread 1" {
115 gdb_test "info record" ".*Replay in progress\..*"
117 gdb_test "thread 2" ".*"
118 with_test_prefix "thread 2" {
119 gdb_test "info record" ".*Replay in progress\..*"
123 # navigate back into the history for thread 1 and continue thread 2
124 with_test_prefix "cont" {
125 gdb_test "thread 1" ".*"
126 with_test_prefix "thread 1" {
127 gdb_test "record goto begin" ".*"
128 gdb_test "info record" ".*Replay in progress\. At instruction 1\."
130 gdb_test "thread 2" ".*"
131 with_test_prefix "thread 2" {
132 gdb_test "record goto end" ".*"
133 gdb_cont_to_line $srcfile:$bp_3