Use gdb_test_sequence in gdb.base/save-bp.exp.
[platform/upstream/binutils.git] / gdb / testsuite / gdb.base / save-bp.exp
1 # Copyright (C) 2011-2014 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 standard_testfile .c
17
18 if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
19     return -1
20 }
21
22 if ![runto_main] {
23     untested ${testfile}.exp
24     return -1
25 }
26 # Delete all breakpoints so that the "runto_main" breakpoint above
27 # does not interfere with our testing.
28 delete_breakpoints
29
30 # Insert a bunch of breakpoints... The goal is to create breakpoints
31 # that we are going to try to save in a file and then reload.  So
32 # try to create a good variety of them.
33 gdb_breakpoint "break_me"
34
35 set loc_bp2 [gdb_get_line_number "BREAK HERE"]
36 gdb_breakpoint ${srcfile}:${loc_bp2}
37
38 set loc_bp3 [gdb_get_line_number "thread-specific"]
39 gdb_breakpoint "${srcfile}:${loc_bp3} thread 1"
40
41 set loc_bp4 [gdb_get_line_number "condition"]
42 gdb_breakpoint "${srcfile}:${loc_bp4} if i == 1"
43
44 set loc_bp5 [gdb_get_line_number "with commands"]
45 gdb_breakpoint ${srcfile}:${loc_bp5}
46 gdb_test "commands\nsilent\nend" "End with.*" "add breakpoint commands"
47
48 gdb_test "dprintf ${srcfile}:${loc_bp5},\"At foo entry\\n\"" "Dprintf .*"
49
50 # Now, save the breakpoints into a file...
51 if {[is_remote host]} {
52     set bps bps
53 } else {
54     set bps [standard_output_file bps]
55 }
56 remote_file host delete "$bps"
57 gdb_test "save breakpoint $bps" "" "save breakpoint bps"
58
59 # Now start a new debugger session...
60 clean_restart $testfile
61 if ![runto_main] {
62     fail "cannot restart program"
63     return -1
64 }
65 # Delete all breakpoints so that the "runto_main" breakpoint above
66 # does not interfere with our testing.
67 delete_breakpoints
68
69 # ... and restore the breakpoints.
70 gdb_test "source $bps" "" "source bps"
71
72 # Now, verify that all breakpoints have been created correctly...
73 set bp_row_start "\[0-9\]+ +breakpoint +keep +y +0x\[0-9a-f\]+ +in"
74 set dprintf_row_start "\[0-9\]+ +dprintf +keep +y +0x\[0-9a-f\]+ +in"
75 gdb_test_sequence "info break" "info break" [list                               \
76   "\[\r\n\]+Num +Type +Disp +Enb +Address +What"                                \
77   "\[\r\n\]+$bp_row_start break_me at \[^\r\n\]*$srcfile:\[0-9\]+"              \
78   "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp2"                  \
79   "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp3 +thread 1"        \
80   "\[\r\n\]+\[ \t]+stop only in thread 1"                                       \
81   "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp4"                  \
82   "\[\r\n\]+\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?"           \
83   "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp5"                  \
84   "\[\r\n\]+\[ \t\]+silent"                                                     \
85   "\[\r\n\]+$dprintf_row_start main at \[^\r\n\]*$srcfile:$loc_bp5"             \
86   "\[\r\n\]+\[ \t\]+printf"                                                     \
87 ]