1 # Copyright (C) 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 # Check that the MI interpreter correctly emits breakpoint-modified
17 # notifications when a breakpoint's thread or inferior is set from
20 load_lib mi-support.exp
25 require allow_python_tests
27 if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
31 set remote_python_file [gdb_remote_download host \
32 ${srcdir}/${subdir}/${testfile}.py]
34 mi_clean_restart $binfile
37 # Delete all breakpoints.
40 # Create a breakpoint. At this point the breakpoint is global, but
41 # this will be adjusted from Python code.
42 mi_create_breakpoint "foo" "break in foo" -disp keep -func foo
43 set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID" \
44 "get number for thread-specific breakpoint"]
46 # Some patterns used in the expected output below.
47 set thr_group_re [string_to_regexp {thread-groups=["i1"]}]
48 set times_re [string_to_regexp {times="0"}]
50 # Source the Python script, the script changes the thread then
51 # inferior field of the first breakpoint, we expect to see the
52 # breakpoint modified four times.
53 mi_gdb_test "source $remote_python_file" \
55 "&\"source \[^\r\n\]+\"" \
56 "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,thread=\"1\",$times_re,\[^\r\n\]+}" \
57 "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,$times_re,\[^\r\n\]+}" \
58 "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,inferior=\"1\",$times_re,\[^\r\n\]+}" \
59 "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,$times_re,\[^\r\n\]+}" \
61 "source python script"