]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/clear_non_user_bp.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / clear_non_user_bp.exp
1 # Copyright 2022-2023 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 # Regression test for PR gdb/7161. Test that GDB cannot delete non-user
17 # breakpoints with clear command.
18
19 # get_first_maint_bp_num
20 #
21 # Purpose:
22 # Get the first number of all internal breakpoints when using command
23 # "maint info breakpoints".
24 #
25 # Parameter:
26 # None.
27 #
28 # Return:
29 # Internal breakpoint number, which is negative.
30 #
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)
35 }
36 }
37 return ""
38 }
39
40 standard_testfile .c
41
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"
46 return -1
47 }
48
49 # Start with a fresh gdb.
50 clean_restart ${binfile}
51
52 if {![runto_main]} {
53 return 0
54 }
55
56 set bp_num [get_first_maint_bp_num]
57 set bp_addr [gdb_get_bp_addr $bp_num]
58
59 gdb_test "maint info break $bp_num" \
60 "$bp_num.*$bp_addr.*" \
61 "maint info breakpoint \$bp_num"
62
63 gdb_test "clear *$bp_addr" \
64 "No breakpoint at \\*$bp_addr." \
65 "clear internal breakpoint"
66
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"
71