2012-05-11 Hui Zhu <hui_zhu@mentor.com>
[external/binutils.git] / gdb / testsuite / gdb.trace / disconnected-tracing.exp
1 #   Copyright 2012 Free Software Foundation, Inc.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 # Test of disconnected-tracing.
17
18 load_lib "trace-support.exp";
19
20 set testfile "disconnected-tracing"
21 set executable $testfile
22 set srcfile ${testfile}.c
23 set binfile $objdir/$subdir/$testfile
24 set expfile $testfile.exp
25 set gdbserver_reconnect_p 1
26
27 if { [info proc gdb_reconnect] == "" } {
28     unsupported "target does not support reconnect"
29     return -1
30 }
31
32 if [prepare_for_testing $expfile $executable $srcfile \
33         {debug nowarnings}] {
34     untested "failed to prepare for trace tests"
35     return -1
36 }
37
38 if ![runto_main] {
39     fail "can't run to main to check for trace support"
40     return -1
41 }
42
43 if ![gdb_target_supports_trace] {
44     unsupported "target does not support trace"
45     return -1;
46 }
47
48 delete_breakpoints
49 gdb_test_no_output "set confirm off"
50 gdb_test_no_output "set disconnected-tracing on"
51 gdb_test "trace main" ".*"
52 gdb_test_no_output "tstart"
53
54 gdb_test "info tracepoints" ".*in main at.*" "first info tracepoints"
55
56 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
57 if { [gdb_reconnect] == 0 } {
58     pass "first reconnect after unload"
59 } else {
60     fail "first reconnect after unload"
61     return 0
62 }
63 gdb_test "info tracepoints" ".*in main at.*" "second info tracepoints"
64
65 delete_breakpoints
66 gdb_test "info tracepoints" ".*No tracepoints..*" "third info tracepoints"
67
68 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
69 if { [gdb_reconnect] == 0 } {
70     pass "second reconnect after unload"
71 } else {
72     fail "second reconnect after unload"
73     return 0
74 }
75 gdb_test "info tracepoints" ".*in main at.*" "fourth info tracepoints"
76