1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2017 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 if { [skip_btrace_tests] } {
19 unsupported "target does not support record-btrace"
24 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
25 untested "failed to prepare"
29 # We need to enable non-stop mode for the remote case.
30 save_vars { GDBFLAGS } {
31 append GDBFLAGS " -ex \"set non-stop on\""
32 clean_restart $testfile
36 untested "failed to run to main"
40 set bp_1 [gdb_get_line_number "bp.1" $srcfile]
43 gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
44 gdb_test "cont&" "Continuing\."
46 # All threads are running. Let's start recording.
47 gdb_test_no_output "record btrace"
49 proc check_tracing_enabled { thread } {
52 with_test_prefix "thread $thread" {
53 gdb_test "thread $thread" "(running).*" "is running"
55 # We can't read the trace while the thread is running.
56 gdb_test "info record" "Selected thread is running\." \
57 "info record while running"
59 # Try various commands that try to read trace.
60 gdb_test "record instruction-history" "Selected thread is running\."
61 gdb_test "record function-call-history" "Selected thread is running\."
63 # Including reverse-stepping commands.
64 gdb_test "reverse-continue" "\[Ss\]elected thread is running\."
65 gdb_test "reverse-step" "\[Ss\]elected thread is running\."
66 gdb_test "reverse-next" "\[Ss\]elected thread is running\."
67 gdb_test "reverse-finish" "\[Ss\]elected thread is running\."
69 # Stop the thread before reading the trace.
70 gdb_test_multiple "interrupt" "interrupt" {
71 -re "interrupt\r\n$gdb_prompt " {
75 # Wait until the thread actually stopped.
76 gdb_test_multiple "" "stopped" {
77 -re "Thread $thread.*stopped\." {
81 # We will consume the thread's current location as part of the
82 # "info record" output.
83 gdb_test "info record" [multi_line \
84 "Active record target: record-btrace" \
85 "Recording format: .*" \
86 "Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" \
89 # Continue the thread again.
90 gdb_test "cont&" "Continuing\."
94 # Check that recording was started on each thread.
95 foreach thread {1 2 3 4} {
96 check_tracing_enabled $thread
99 # Stop recording while all threads are running.
100 gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"