# Regression test for PR gdb/7161. Test that GDB cannot delete non-user
# breakpoints with clear command.
-proc get_maint_info_bp { var } {
- global expect_out
- global gdb_prompt
-
- gdb_test_multiple "maint info break $var" "find address of internal bp $var" {
- -re ".*(0x\[0-9a-f\]+).*$gdb_prompt $" {
+# get_maint_bp_addr num
+#
+# Purpose:
+# Get address of the specified internal breakpoint when using command
+# "maint info breakpoints $num".
+#
+# Parameter:
+# The parameter "num" indicates the number of the internal breakpoint
+# to get. Note that this parameter must be a negative number.
+# E.g., -1 means that we're gonna get the first internal breakpoint.
+#
+# Return:
+# Internal breakpoint address.
+#
+proc get_maint_bp_addr { num } {
+ gdb_test_multiple "maint info break $num" "find address of internal bp $num" {
+ -re -wrap ".*(0x\[0-9a-f\]+).*" {
return $expect_out(1,string)
}
- timeout {
- perror "couldn't find address of $var"
- return ""
+ }
+ return ""
+}
+
+# get_first_maint_bp_num
+#
+# Purpose:
+# Get the first number of all internal breakpoints when using command
+# "maint info breakpoints".
+#
+# Parameter:
+# None.
+#
+# Return:
+# Internal breakpoint number, which is negative.
+#
+proc get_first_maint_bp_num { } {
+ gdb_test_multiple "maint info break" "find first internal bp num" {
+ -re -wrap "(-\[0-9\]).*" {
+ return $expect_out(1,string)
}
}
return ""
return 0
}
-gdb_test "break main.c:21" \
- ".*Breakpoint.* at .*" \
- "set breakpoint"
+set bp_num [get_first_maint_bp_num]
+set bp_addr [get_maint_bp_addr $bp_num]
-set bp_addr [get_maint_info_bp "-1"]
-
-gdb_test "maint info break -1" \
- "-1.*shlib events.*keep y.*$bp_addr.*" \
- "maint info breakpoint -1 error"
+gdb_test "maint info break $bp_num" \
+ "$bp_num.*$bp_addr.*" \
+ "maint info breakpoint \$bp_num"
gdb_test "clear *$bp_addr" \
"No breakpoint at \\*$bp_addr." \
- "clear internal breakpoint error"
+ "clear internal breakpoint"
+
+# Check again, make sure that GDB really didn't delete the internal breakpoint.
+gdb_test "maint info break $bp_num" \
+ "$bp_num.*$bp_addr.*" \
+ "maint info breakpoint \$bp_num after clear"