1 # Copyright 2022-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/>.
16 # Regression test for PR gdb/7161. Test that GDB cannot delete non-user
17 # breakpoints with clear command.
19 # get_first_maint_bp_num
22 # Get the first number of all internal breakpoints when using command
23 # "maint info breakpoints".
29 # Internal breakpoint number, which is negative.
31 proc get_first_maint_bp_num { } {
32 gdb_test_multiple "maint info break" "find first internal bp num" {
33 -re -wrap "(-\[0-9\]).*" {
34 return $expect_out(1,string)
42 # This testcase just needs a "Hello world" source file, reuse
43 # gdb.base/main.c instead of adding a new one.
44 if { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}" executable {debug}] != "" } {
45 untested "failed to compile"
49 # Start with a fresh gdb.
50 clean_restart ${binfile}
56 set bp_num [get_first_maint_bp_num]
57 set bp_addr [gdb_get_bp_addr $bp_num]
59 gdb_test "maint info break $bp_num" \
60 "$bp_num.*$bp_addr.*" \
61 "maint info breakpoint \$bp_num"
63 gdb_test "clear *$bp_addr" \
64 "No breakpoint at \\*$bp_addr." \
65 "clear internal breakpoint"
67 # Check again, make sure that GDB really didn't delete the internal breakpoint.
68 gdb_test "maint info break $bp_num" \
69 "$bp_num.*$bp_addr.*" \
70 "maint info breakpoint \$bp_num after clear"