]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.btrace/enable-running.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.btrace / enable-running.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2017-2023 Free Software Foundation, Inc.
4 #
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.
9 #
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.
14 #
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/>.
17
18 if { [skip_btrace_tests] } {
19 unsupported "target does not support record-btrace"
20 return -1
21 }
22
23 standard_testfile
24 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } {
25 untested "failed to prepare"
26 return -1
27 }
28
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
33 }
34
35 if ![runto_main] {
36 return -1
37 }
38
39 set bp_1 [gdb_get_line_number "bp.1" $srcfile]
40
41 gdb_breakpoint $bp_1
42 gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
43 gdb_test "cont&" "Continuing\."
44
45 # All threads are running. Let's start recording.
46 gdb_test_no_output "record btrace"
47
48 proc check_tracing_enabled { thread } {
49 global gdb_prompt
50
51 with_test_prefix "thread $thread" {
52 gdb_test "thread $thread" "(running).*" "is running"
53
54 # We can't read the trace while the thread is running.
55 gdb_test "info record" "Selected thread is running\." \
56 "info record while running"
57
58 # Try various commands that try to read trace.
59 gdb_test "record instruction-history" "Selected thread is running\."
60 gdb_test "record function-call-history" "Selected thread is running\."
61
62 # Including reverse-stepping commands.
63 gdb_test "reverse-continue" "\[Ss\]elected thread is running\."
64 gdb_test "reverse-step" "\[Ss\]elected thread is running\."
65 gdb_test "reverse-next" "\[Ss\]elected thread is running\."
66 gdb_test "reverse-finish" "\[Ss\]elected thread is running\."
67
68 # Stop the thread before reading the trace.
69 gdb_test_multiple "interrupt" "interrupt" {
70 -re "interrupt\r\n$gdb_prompt " {
71 pass "interrupt"
72 }
73 }
74 # Wait until the thread actually stopped.
75 gdb_test_multiple "" "stopped" {
76 -re "Thread $thread.*stopped\." {
77 pass "stopped"
78 }
79 }
80 # We will consume the thread's current location as part of the
81 # "info record" output.
82 gdb_test "info record" [multi_line \
83 "Active record target: record-btrace" \
84 "Recording format: .*" \
85 "Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" \
86 ]
87
88 # Continue the thread again.
89 gdb_test "cont&" "Continuing\."
90 }
91 }
92
93 # Check that recording was started on each thread.
94 foreach thread {1 2 3 4} {
95 check_tracing_enabled $thread
96 }
97
98 # Stop recording while all threads are running.
99 gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"