btrace: Resume recording after disconnect.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / reconnect.exp
CommitLineData
c0272db5
TW
1# This testcase is part of GDB, the GNU debugger.
2#
3# Copyright 2016 Free Software Foundation, Inc.
4#
5# Contributed by Intel Corp. <tim.wiederhake@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
20load_lib gdbserver-support.exp
21
22if { [skip_btrace_tests] } { return -1 }
23if { [skip_gdbserver_tests] } { return -1 }
24
25standard_testfile
26if [prepare_for_testing $testfile.exp $testfile $srcfile] {
27 return -1
28}
29
30# Make sure we're disconnected and no recording is active, in case
31# we're testing with an extended-remote board, therefore already
32# connected.
33with_test_prefix "preparation" {
34 gdb_test "record stop" ".*"
35 gdb_test "disconnect" ".*"
36}
37
38# Start fresh gdbserver.
39set gdbserver_reconnect_p 1
40set res [gdbserver_start "" $binfile]
41set gdbserver_protocol [lindex $res 0]
42set gdbserver_gdbport [lindex $res 1]
43gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
44
45# Create a record, check, reconnect
46with_test_prefix "first" {
47 gdb_test_no_output "record btrace" "record btrace enable"
48 gdb_test "stepi 19" "0x.* in .* from target.*"
49
50 gdb_test "info record" [multi_line \
51 "Active record target: .*" \
52 "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
53 ]
54
55 gdb_test "disconnect" "Ending remote debugging."
56 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
57}
58
59# Test if we can access the recorded data from first connect.
60# Note: BTS loses the first function call entry with its associated
61# instructions for technical reasons. This is why we test for
62# "a number between 10 and 19", so we catch at least the case where
63# there are 0 instructions in the record.
64with_test_prefix "second" {
65 gdb_test "info record" [multi_line \
66 "Active record target: .*" \
67 "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
68 ]
69
70 gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
71
72 gdb_test "disconnect" "Ending remote debugging."
73 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
74}
75
76# Test that recording is now off.
77with_test_prefix "third" {
78 gdb_test "info record" "No record target is currently active."
79}
This page took 0.024763 seconds and 4 git commands to generate.