reconnect.exp revision 1.1.1.1.4.1 1 1.1 christos # This testcase is part of GDB, the GNU debugger.
2 1.1 christos #
3 1.1.1.1.4.1 christos # Copyright 2016-2017 Free Software Foundation, Inc.
4 1.1 christos #
5 1.1 christos # Contributed by Intel Corp. <tim.wiederhake (at) intel.com>
6 1.1 christos #
7 1.1 christos # This program is free software; you can redistribute it and/or modify
8 1.1 christos # it under the terms of the GNU General Public License as published by
9 1.1 christos # the Free Software Foundation; either version 3 of the License, or
10 1.1 christos # (at your option) any later version.
11 1.1 christos #
12 1.1 christos # This program is distributed in the hope that it will be useful,
13 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos # GNU General Public License for more details.
16 1.1 christos #
17 1.1 christos # You should have received a copy of the GNU General Public License
18 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 1.1 christos
20 1.1 christos load_lib gdbserver-support.exp
21 1.1 christos
22 1.1.1.1.4.1 christos if { [skip_btrace_tests] } {
23 1.1.1.1.4.1 christos unsupported "target does not support record-btrace"
24 1.1.1.1.4.1 christos return -1
25 1.1.1.1.4.1 christos }
26 1.1.1.1.4.1 christos if { [skip_gdbserver_tests] } {
27 1.1.1.1.4.1 christos unsupported "target does not support gdbserver"
28 1.1.1.1.4.1 christos return -1
29 1.1.1.1.4.1 christos }
30 1.1 christos
31 1.1 christos standard_testfile
32 1.1.1.1.4.1 christos if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
33 1.1 christos return -1
34 1.1 christos }
35 1.1 christos
36 1.1 christos # Make sure we're disconnected and no recording is active, in case
37 1.1 christos # we're testing with an extended-remote board, therefore already
38 1.1 christos # connected.
39 1.1 christos with_test_prefix "preparation" {
40 1.1 christos gdb_test "record stop" ".*"
41 1.1 christos gdb_test "disconnect" ".*"
42 1.1 christos }
43 1.1 christos
44 1.1 christos # Start fresh gdbserver.
45 1.1 christos set gdbserver_reconnect_p 1
46 1.1 christos set res [gdbserver_start "" $binfile]
47 1.1 christos set gdbserver_protocol [lindex $res 0]
48 1.1 christos set gdbserver_gdbport [lindex $res 1]
49 1.1 christos gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
50 1.1 christos
51 1.1 christos # Create a record, check, reconnect
52 1.1 christos with_test_prefix "first" {
53 1.1 christos gdb_test_no_output "record btrace" "record btrace enable"
54 1.1 christos gdb_test "stepi 19" "0x.* in .* from target.*"
55 1.1 christos
56 1.1 christos gdb_test "info record" [multi_line \
57 1.1 christos "Active record target: .*" \
58 1.1 christos "Recorded 19 instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
59 1.1 christos ]
60 1.1 christos
61 1.1 christos gdb_test "disconnect" "Ending remote debugging."
62 1.1 christos gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
63 1.1 christos }
64 1.1 christos
65 1.1 christos # Test if we can access the recorded data from first connect.
66 1.1 christos # Note: BTS loses the first function call entry with its associated
67 1.1 christos # instructions for technical reasons. This is why we test for
68 1.1 christos # "a number between 10 and 19", so we catch at least the case where
69 1.1 christos # there are 0 instructions in the record.
70 1.1 christos with_test_prefix "second" {
71 1.1 christos gdb_test "info record" [multi_line \
72 1.1 christos "Active record target: .*" \
73 1.1 christos "Recorded 1. instructions in .+ functions \\(. gaps\\) for thread 1 \\(Thread .*\\)."
74 1.1 christos ]
75 1.1 christos
76 1.1 christos gdb_test "record stop" "Process record is stopped and all execution logs are deleted."
77 1.1 christos
78 1.1 christos gdb_test "disconnect" "Ending remote debugging."
79 1.1 christos gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
80 1.1 christos }
81 1.1 christos
82 1.1 christos # Test that recording is now off.
83 1.1 christos with_test_prefix "third" {
84 1.1 christos gdb_test "info record" "No record target is currently active."
85 1.1 christos }
86