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