1 # Copyright 2023-2024 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 # This test is for creating thread-specific breakpoint using the MI,
17 # and checking the results from GDB.
19 load_lib mi-support.exp
22 if {[mi_clean_restart]} {
28 if [build_executable ${testfile}.exp ${binfile} ${srcfile}] {
33 return [mi_make_breakpoint_loc -thread "1" -number "$::decimal\\.$num"]
36 foreach_mi_ui_mode mode {
38 if {$mode == "separate"} {
39 set start_ops "separate-mi-tty"
44 if {[mi_clean_restart $binfile $start_ops]} {
48 # Ensure we get an error when placing a b/p for thread 1 at a point
49 # where thread 1 doesn't exist.
50 mi_gdb_test "-break-insert -p 1 bar" \
51 "\\^error,msg=\"Unknown thread 1\\.\""
53 # If we have a separate CLI UI then run the 'info breakpoints'
54 # command. There was a time when the previous breakpoint request
55 # would succeed, and then 'info breakpoint' on the CLI would
56 # trigger an assertion.
57 if {$mode eq "separate"} {
58 with_spawn_id $gdb_main_spawn_id {
59 gdb_test "info breakpoints" "No breakpoints or watchpoints\\." \
60 "check CLI 'info breakpoints' when there are no breakpoints"
64 if {[mi_runto_main] == -1} {
68 # Ensure we get an error when placing a b/p for a thread that doesn't
69 # exist (when other threads do exist).
70 mi_gdb_test "-break-insert -p 999 bar" \
71 "\\^error,msg=\"Unknown thread 999\\.\""
73 mi_create_breakpoint "-p 1 bar" "thread-specific b/p on bar" \
80 mi_create_breakpoint_multi "-p 1 foo" "thread-specific b/p on foo" \
82 -locations "\\\[$loc1,$loc2,$loc3\\\]"
84 # Check that 'info breakpoints' on the CLI succeeds.
85 if {$mode eq "separate"} {
86 with_spawn_id $gdb_main_spawn_id {
87 gdb_test "info breakpoints" ".*" \
88 "check CLI 'info breakpoints' when there are some breakpoints"