1 # Copyright
(C
) 2011-2023 Free Software Foundation
, Inc.
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.
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.
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
/>.
18 if { [prepare_for_testing
"failed to prepare" ${testfile} $srcfile] } {
25 #
Delete all breakpoints so that the
"runto_main" breakpoint above
26 # does not interfere with our testing.
29 # Insert a bunch of breakpoints... The goal is to create breakpoints
30 # that we are going to try to save in a file and
then reload. So
31 # try to create a good variety of them.
32 gdb_breakpoint
"break_me"
34 set loc_bp2
[gdb_get_line_number
"BREAK HERE"]
35 gdb_breakpoint $
{srcfile
}:$
{loc_bp2
}
37 set loc_bp3
[gdb_get_line_number
"thread-specific"]
38 gdb_breakpoint
"${srcfile}:${loc_bp3} thread 1"
40 set loc_bp4
[gdb_get_line_number
"condition"]
41 gdb_breakpoint
"${srcfile}:${loc_bp4} if i == 1"
43 set loc_bp5
[gdb_get_line_number
"with commands"]
44 gdb_breakpoint $
{srcfile
}:$
{loc_bp5
}
45 gdb_test
"commands\nsilent\nend" "End with.*" "add breakpoint commands"
47 gdb_test
"dprintf ${srcfile}:${loc_bp5},\"At foo entry\\n\"" "Dprintf .*"
49 set loc_bp8
[gdb_get_line_number
"Return line"]
50 gdb_breakpoint
"${srcfile}:${loc_bp8}"
51 gdb_test_no_output
{disable $bpnum
}
53 # Now
, save the breakpoints into a file...
54 if {[is_remote host
]} {
57 set bps
[standard_output_file bps
]
59 remote_file host
delete "$bps"
60 gdb_test
"save breakpoint $bps" "" "save breakpoint bps"
62 # Now start a new debugger session...
63 clean_restart $testfile
67 #
Delete all breakpoints so that the
"runto_main" breakpoint above
68 # does not interfere with our testing.
71 # ... and restore the breakpoints.
72 gdb_test
"source $bps" "" "source bps"
74 # Now
, verify that all breakpoints have been created correctly...
75 set bp_row_start
"\[0-9\]+ +breakpoint +keep +y +0x\[0-9a-f\]+ +in"
76 set disabled_row_start
"\[0-9\]+ +breakpoint +keep +n +0x\[0-9a-f\]+ +in"
77 set dprintf_row_start
"\[0-9\]+ +dprintf +keep +y +0x\[0-9a-f\]+ +in"
78 gdb_test_sequence
"info break" "info break" [list \
79 "\[\r\n\]+Num +Type +Disp +Enb +Address +What" \
80 "\[\r\n\]+$bp_row_start break_me at \[^\r\n\]*$srcfile:\[0-9\]+" \
81 "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp2" \
82 "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp3" \
83 "\[\r\n\]+\[ \t]+stop only in thread 1" \
84 "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp4" \
85 "\[\r\n\]+\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?" \
86 "\[\r\n\]+$bp_row_start main at \[^\r\n\]*$srcfile:$loc_bp5" \
87 "\[\r\n\]+\[ \t\]+silent" \
88 "\[\r\n\]+$dprintf_row_start main at \[^\r\n\]*$srcfile:$loc_bp5" \
89 "\[\r\n\]+\[ \t\]+printf" \
90 "\[\r\n\]+$disabled_row_start main at \[^\r\n\]*$srcfile:$loc_bp8" \
93 # Copy the saved breakpoints file to the local machine
(if necessary
),
94 # and
then check its contents.
95 if {[is_remote host
]} {
96 set bps
[remote_upload host bps
[standard_output_file bps
]]
99 set lines
[split
[read $fh
] "\n"]
102 with_test_prefix
"in bps file" {
103 gdb_assert
{[lsearch
-regexp $lines
"break ${srcfile}:${loc_bp2}$"] != -1} \
104 "check for general breakpoint"
105 gdb_assert
{[lsearch
-regexp $lines
"break ${srcfile}:${loc_bp3} thread 1\\.1"] != -1} \
106 "check for thread-specific breakpoint"