]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dap/modules.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dap / modules.exp
CommitLineData
1d506c26 1# Copyright 2023-2024 Free Software Foundation, Inc.
8a35f6b3
TT
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# Test DAP modules functionality.
17
18require allow_shlib_tests allow_dap_tests
19
20load_lib dap-support.exp
21
22standard_testfile
23
24set libname $testfile-solib
25set srcfile_lib $srcdir/$subdir/$libname.c
26set binfile_lib [standard_output_file $libname.so]
27
28if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
29 untested "failed to compile shared library"
30 return
31}
32
33set binfile_lib_target [gdb_download_shlib $binfile_lib]
34set define -DSHLIB_NAME=\"$binfile_lib_target\"
35
36if {[build_executable ${testfile}.exp $testfile $srcfile \
37 [list additional_flags=$define debug shlib_load]] == -1} {
38 return
39}
40
41if {[dap_launch $testfile] == ""} {
42 return
43}
44
100dbc6d 45set obj [dap_check_request_and_response "set breakpoint on stop function" \
8a35f6b3
TT
46 setFunctionBreakpoints \
47 {o breakpoints [a [o name [s stop]]]}]
48set fn_bpno [dap_get_breakpoint_number $obj]
49
50dap_check_request_and_response "start inferior" configurationDone
51
52dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
53 "body reason" breakpoint \
54 "body hitBreakpointIds" $fn_bpno
55
100dbc6d 56dap_check_request_and_response "continue to second stop" continue \
8a35f6b3
TT
57 {o threadId [i 1]}
58
59
60lassign [dap_wait_for_event_and_check "module event" module \
61 "body reason" new] module_event ignore
62
63gdb_assert {[string match *$libname* [dict get $module_event body module id]]} \
64 "module.id"
65gdb_assert {[string match *$libname* [dict get $module_event body module name]]} \
66 "module.name"
67gdb_assert {[string match *$libname* [dict get $module_event body module path]]} \
68 "module.path"
69
70dap_wait_for_event_and_check "second stop at function breakpoint" stopped \
71 "body reason" breakpoint \
72 "body hitBreakpointIds" $fn_bpno
73
74set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
75 {o threadId [i 1]}] \
76 0]
77set frame_id [dict get [lindex [dict get $bt body stackFrames] 1] moduleId]
78
79gdb_assert {[string match *$libname* $frame_id]} "module.id in stack trace"
80
100dbc6d
TT
81
82dap_check_request_and_response "continue to third stop" continue \
83 {o threadId [i 1]}
84
85dap_wait_for_event_and_check "module removed event" module \
86 "body reason" removed
87
88dap_wait_for_event_and_check "third stop at function breakpoint" stopped \
89 "body reason" breakpoint \
90 "body hitBreakpointIds" $fn_bpno
91
8a35f6b3 92dap_shutdown