08d682e4f7010f8c27bf0c3b37b037e1235ff8aa
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / enable-running.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2017-2021 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 untested "failed to run to main"
37 return -1
38 }
39
40 set bp_1 [gdb_get_line_number "bp.1" $srcfile]
41
42 gdb_breakpoint $bp_1
43 gdb_continue_to_breakpoint "cont to $bp_1" ".*$bp_1\r\n.*"
44 gdb_test "cont&" "Continuing\."
45
46 # All threads are running. Let's start recording.
47 gdb_test_no_output "record btrace"
48
49 proc check_tracing_enabled { thread } {
50 global gdb_prompt
51
52 with_test_prefix "thread $thread" {
53 gdb_test "thread $thread" "(running).*" "is running"
54
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"
58
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\."
62
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\."
68
69 # Stop the thread before reading the trace.
70 gdb_test_multiple "interrupt" "interrupt" {
71 -re "interrupt\r\n$gdb_prompt " {
72 pass "interrupt"
73 }
74 }
75 # Wait until the thread actually stopped.
76 gdb_test_multiple "" "stopped" {
77 -re "Thread $thread.*stopped\." {
78 pass "stopped"
79 }
80 }
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\]*" \
87 ]
88
89 # Continue the thread again.
90 gdb_test "cont&" "Continuing\."
91 }
92 }
93
94 # Check that recording was started on each thread.
95 foreach thread {1 2 3 4} {
96 check_tracing_enabled $thread
97 }
98
99 # Stop recording while all threads are running.
100 gdb_test "record stop" "Process record is stopped \[^\\\r\\\n\]*"
This page took 0.044263 seconds and 3 git commands to generate.