Share the "multi_line" helper among all testcases
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / stepi.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2013-2015 Free Software Foundation, Inc.
4 #
5 # Contributed by Intel Corp. <markus.t.metzger@intel.com>
6 #
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.
11 #
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.
16 #
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/>.
19
20 # check for btrace support
21 if { [skip_btrace_tests] } { return -1 }
22
23 # This test is stepping on instruction level. To guarantee that we always
24 # get the same execution trace, we use an assembly source file.
25 #
26 # We use different assembly sources based on the target architecture.
27 #
28 # Luckily, they are similar enough that a single test script can handle
29 # both.
30 if {[istarget "x86_64-*-*"]} {
31 standard_testfile x86_64-record_goto.S
32 } elseif {[istarget "i?86-*-*"]} {
33 standard_testfile i686-record_goto.S
34 } else {
35 return -1
36 }
37
38 # start inferior
39 if [prepare_for_testing stepi.exp $testfile $srcfile] {
40 return -1
41 }
42
43 global gdb_prompt
44
45 if ![runto_main] {
46 return -1
47 }
48
49 proc check_replay_at { insn } {
50 gdb_test "info record" [multi_line \
51 "Active record target: record-btrace" \
52 ".*" \
53 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \
54 "Replay in progress\. At instruction $insn\." \
55 ]
56 }
57
58 # trace the call to the test function
59 gdb_test_no_output "record btrace"
60 gdb_test "next"
61
62 # we start with stepping to make sure that the trace is fetched automatically
63 gdb_test "reverse-stepi" ".*fun4\.5.*"
64 gdb_test "reverse-stepi" ".*fun4\.5.*"
65
66 # let's check where we are in the trace
67 with_test_prefix "reverse-stepi to 39" { check_replay_at 39 }
68
69 # let's step forward and check again
70 gdb_test "stepi" ".*fun4\.5.*"
71 with_test_prefix "stepi to 40" { check_replay_at 40 }
72
73 # with the next step, we stop replaying
74 gdb_test "stepi" ".*main\.3.*"
75 gdb_test "info record" [multi_line \
76 "Active record target: record-btrace" \
77 ".*" \
78 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
79 ] "stepi to live"
80
81 # let's try nexti
82 gdb_test "reverse-nexti" ".*main\.2.*"
83 with_test_prefix "reverse-nexti - 1" { check_replay_at 1 }
84
85 # we can't reverse-nexti any further
86 gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
87 with_test_prefix "reverse-nexti - 1" { check_replay_at 1 }
88
89 # but we can step back again
90 gdb_test "nexti" ".*main\.3.*" "next, 1.5"
91 gdb_test "info record" [multi_line \
92 "Active record target: record-btrace" \
93 ".*" \
94 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
95 ] "nexti back"
96
97 # let's step from a goto position somewhere in the middle
98 gdb_test "record goto 22" ".*fun3\.2.*"
99 with_test_prefix "goto 22" { check_replay_at 22 }
100
101 gdb_test "stepi" ".*fun1\.1.*"
102 with_test_prefix "stepi to 23" { check_replay_at 23 }
103
104 gdb_test "reverse-stepi" ".*fun3\.2.*"
105 with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
106
107 gdb_test "nexti" ".*fun3\.3.*"
108 with_test_prefix "nexti to 27" { check_replay_at 27 }
109
110 gdb_test "reverse-nexti" ".*fun3\.2.*"
111 with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
112
113 # let's try to step off the left end
114 gdb_test "record goto begin" ".*main\.2.*"
115 with_test_prefix "goto begin" { check_replay_at 1 }
116
117 gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
118 gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
119 with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
120
121 gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
122 gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*"
123 with_test_prefix "reverse-nexti at begin" { check_replay_at 1 }
124
125 # we can step forward, though
126 gdb_test "stepi" ".*fun4\.1.*"
127 with_test_prefix "stepi to 2" { check_replay_at 2 }
128
129 # let's try to step off the left end again
130 gdb_test "reverse-stepi" ".*main\.2.*"
131 gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
132 gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
133 with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
This page took 0.033652 seconds and 5 git commands to generate.