]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2023-2024 Free Software Foundation, Inc. |
68ca7890 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 'bt' through a function without debuginfo. | |
17 | ||
95e592d9 TV |
18 | require allow_dap_tests |
19 | ||
68ca7890 TT |
20 | load_lib dap-support.exp |
21 | ||
22 | standard_testfile bt-main.c bt-inner.c | |
23 | ||
24 | if {[build_executable_from_specs $testfile.exp $testfile {} \ | |
25 | $srcfile debug \ | |
26 | $srcfile2 {}] == -1} { | |
27 | return | |
28 | } | |
29 | ||
30 | if {[dap_launch $testfile] == ""} { | |
31 | return | |
32 | } | |
33 | ||
34 | set obj [dap_check_request_and_response "set breakpoint on inner" \ | |
35 | setFunctionBreakpoints \ | |
36 | {o breakpoints [a [o name [s function_breakpoint_here]]]}] | |
37 | set fn_bpno [dap_get_breakpoint_number $obj] | |
38 | ||
39 | dap_check_request_and_response "start inferior" configurationDone | |
40 | dap_wait_for_event_and_check "inferior started" thread "body reason" started | |
41 | ||
42 | lassign [dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ | |
43 | "body reason" breakpoint \ | |
44 | "body hitBreakpointIds" $fn_bpno] unused objs | |
45 | ||
46 | # The bug was that this request would fail. | |
30baee68 TT |
47 | set obj [dap_check_request_and_response "backtrace" \ |
48 | stackTrace {o threadId [i 1]}] | |
49 | set frames [dict get [lindex $obj 0] body stackFrames] | |
50 | ||
51 | gdb_assert {[llength $frames] == 3} "three frames" | |
52 | ||
53 | gdb_assert {[dict get [lindex $frames 1] name] == "no_debug_info"} \ | |
54 | "name of no-debug frame" | |
68ca7890 | 55 | |
155f5df5 GA |
56 | # Breakpoint can be set without source file information |
57 | set obj [dap_check_request_and_response "set breakpoint on no_debug_info" \ | |
58 | setFunctionBreakpoints \ | |
59 | {o breakpoints [a [o name [s no_debug_info]]]}] | |
60 | set breakpoints [dict get [lindex $obj 0] body breakpoints] | |
57c69939 TT |
61 | gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} \ |
62 | "breakpoint has instructionReference" | |
63 | ||
64 | # instructionReference is specified as a string, but it's form is not | |
65 | # otherwise given in the spec. gdb always emits it as hex. A bug | |
66 | # slipped in that caused this to be incorrect, so we test both parts | |
67 | # here; to test whether a string was given, we have to reach into the | |
68 | # TON form. | |
69 | set list_form [namespace eval ton::2list $last_ton] | |
70 | set ref [namespace eval ton::2list { | |
71 | get $list_form body breakpoints 0 instructionReference | |
72 | }] | |
73 | gdb_assert {[regexp "^$hex\$" $ref]} \ | |
74 | "instructionReference is a hex string" | |
155f5df5 | 75 | |
68ca7890 | 76 | dap_shutdown |