Commit | Line | Data |
---|---|---|
52834460 MM |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
618f726f | 3 | # Copyright 2013-2016 Free Software Foundation, Inc. |
52834460 MM |
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 | ||
66849923 MM |
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. | |
e0461dbb MM |
30 | if [info exists COMPILE] { |
31 | # make check RUNTESTFLAGS="gdb.btrace/stepi.exp COMPILE=1" | |
32 | standard_testfile record_goto.c | |
33 | lappend opts debug | |
34 | } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} { | |
35 | if {[is_amd64_regs_target]} { | |
36 | standard_testfile x86_64-record_goto.S | |
37 | } else { | |
38 | standard_testfile i686-record_goto.S | |
39 | } | |
66849923 | 40 | } else { |
e0461dbb MM |
41 | verbose "Skipping ${testfile}." |
42 | return -1 | |
66849923 MM |
43 | } |
44 | ||
52834460 | 45 | # start inferior |
52834460 MM |
46 | if [prepare_for_testing stepi.exp $testfile $srcfile] { |
47 | return -1 | |
48 | } | |
49 | ||
50 | global gdb_prompt | |
51 | ||
52 | if ![runto_main] { | |
53 | return -1 | |
54 | } | |
55 | ||
56 | proc check_replay_at { insn } { | |
3c724c8c | 57 | gdb_test "info record" [multi_line \ |
52834460 | 58 | "Active record target: record-btrace" \ |
66849923 | 59 | ".*" \ |
31fd9caa | 60 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \ |
52834460 | 61 | "Replay in progress\. At instruction $insn\." \ |
3c724c8c | 62 | ] |
52834460 MM |
63 | } |
64 | ||
65 | # trace the call to the test function | |
66 | gdb_test_no_output "record btrace" | |
67 | gdb_test "next" | |
68 | ||
69 | # we start with stepping to make sure that the trace is fetched automatically | |
70 | gdb_test "reverse-stepi" ".*fun4\.5.*" | |
71 | gdb_test "reverse-stepi" ".*fun4\.5.*" | |
72 | ||
73 | # let's check where we are in the trace | |
74 | with_test_prefix "reverse-stepi to 39" { check_replay_at 39 } | |
75 | ||
76 | # let's step forward and check again | |
77 | gdb_test "stepi" ".*fun4\.5.*" | |
78 | with_test_prefix "stepi to 40" { check_replay_at 40 } | |
79 | ||
80 | # with the next step, we stop replaying | |
81 | gdb_test "stepi" ".*main\.3.*" | |
3c724c8c | 82 | gdb_test "info record" [multi_line \ |
52834460 | 83 | "Active record target: record-btrace" \ |
66849923 | 84 | ".*" \ |
31fd9caa | 85 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ |
3c724c8c | 86 | ] "stepi to live" |
52834460 | 87 | |
66849923 MM |
88 | # let's try nexti |
89 | gdb_test "reverse-nexti" ".*main\.2.*" | |
90 | with_test_prefix "reverse-nexti - 1" { check_replay_at 1 } | |
91 | ||
92 | # we can't reverse-nexti any further | |
93 | gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*" | |
94 | with_test_prefix "reverse-nexti - 1" { check_replay_at 1 } | |
95 | ||
96 | # but we can step back again | |
97 | gdb_test "nexti" ".*main\.3.*" "next, 1.5" | |
3c724c8c | 98 | gdb_test "info record" [multi_line \ |
66849923 MM |
99 | "Active record target: record-btrace" \ |
100 | ".*" \ | |
101 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ | |
3c724c8c | 102 | ] "nexti back" |
66849923 | 103 | |
52834460 MM |
104 | # let's step from a goto position somewhere in the middle |
105 | gdb_test "record goto 22" ".*fun3\.2.*" | |
106 | with_test_prefix "goto 22" { check_replay_at 22 } | |
107 | ||
108 | gdb_test "stepi" ".*fun1\.1.*" | |
109 | with_test_prefix "stepi to 23" { check_replay_at 23 } | |
110 | ||
52834460 | 111 | gdb_test "reverse-stepi" ".*fun3\.2.*" |
66849923 MM |
112 | with_test_prefix "reverse-stepi to 22" { check_replay_at 22 } |
113 | ||
114 | gdb_test "nexti" ".*fun3\.3.*" | |
115 | with_test_prefix "nexti to 27" { check_replay_at 27 } | |
116 | ||
117 | gdb_test "reverse-nexti" ".*fun3\.2.*" | |
118 | with_test_prefix "reverse-nexti to 22" { check_replay_at 22 } | |
52834460 MM |
119 | |
120 | # let's try to step off the left end | |
121 | gdb_test "record goto begin" ".*main\.2.*" | |
122 | with_test_prefix "goto begin" { check_replay_at 1 } | |
123 | ||
124 | gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*" | |
125 | gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*" | |
126 | with_test_prefix "reverse-stepi at begin" { check_replay_at 1 } | |
127 | ||
66849923 MM |
128 | gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*" |
129 | gdb_test "reverse-nexti" "No more reverse-execution history\.\r\n.*main\.2.*" | |
130 | with_test_prefix "reverse-nexti at begin" { check_replay_at 1 } | |
131 | ||
52834460 MM |
132 | # we can step forward, though |
133 | gdb_test "stepi" ".*fun4\.1.*" | |
134 | with_test_prefix "stepi to 2" { check_replay_at 2 } | |
135 | ||
136 | # let's try to step off the left end again | |
137 | gdb_test "reverse-stepi" ".*main\.2.*" | |
138 | gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*" | |
139 | gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*" | |
140 | with_test_prefix "reverse-stepi at begin" { check_replay_at 1 } |