Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2021-2022 Free Software Foundation, Inc. |
ebde6f2d TV |
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 | # Check whether stepping out of a function works, in case: | |
17 | # - the first insn after the call has an is-stmt=no entry | |
18 | # - the next insn has an is-stmt=yes entry, for the same line number | |
19 | # | |
20 | # This sort of thing can occur in optimized code, f.i. here a slightly more | |
21 | # elaborate case with another is-stmt=no entry (the one with line number 12) | |
22 | # inbetween: | |
23 | # INDEX LINE ADDRESS IS-STMT | |
24 | # 12 13 0x00000000004003ed | |
25 | # 13 12 0x00000000004003f2 | |
26 | # 14 13 0x00000000004003f4 Y | |
27 | ||
28 | load_lib dwarf.exp | |
29 | ||
30 | # This test can only be run on targets which support DWARF-2 and use gas. | |
31 | if {![dwarf2_support]} { | |
32 | verbose "Skipping $gdb_test_file_name." | |
33 | return 0 | |
34 | } | |
35 | ||
36 | # The .c files use __attribute__. | |
37 | if [get_compiler_info] { | |
38 | return -1 | |
39 | } | |
40 | if !$gcc_compiled { | |
41 | verbose "Skipping $gdb_test_file_name." | |
42 | return 0 | |
43 | } | |
44 | ||
45 | standard_testfile .c -dw.S | |
46 | ||
47 | set asm_file [standard_output_file $srcfile2] | |
48 | Dwarf::assemble $asm_file { | |
49 | declare_labels Llines | |
50 | global srcdir subdir srcfile | |
51 | ||
52 | lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \ | |
53 | main_start main_len | |
54 | set main_end "$main_start + $main_len" | |
55 | ||
56 | lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \ | |
57 | bar_start bar_len | |
58 | set bar_end "$bar_start + $bar_len" | |
59 | ||
60 | cu {} { | |
61 | compile_unit { | |
62 | {language @DW_LANG_C} | |
63 | {name $srcfile} | |
64 | {stmt_list $Llines DW_FORM_sec_offset} | |
65 | } { | |
66 | subprogram { | |
67 | {external 1 flag} | |
68 | {MACRO_AT_func {main}} | |
69 | } | |
70 | subprogram { | |
71 | {external 1 flag} | |
72 | {MACRO_AT_func {bar}} | |
73 | } | |
74 | } | |
75 | } | |
76 | ||
77 | lines {version 2} Llines { | |
78 | include_dir "${srcdir}/${subdir}" | |
79 | file_name "$srcfile" 1 | |
80 | ||
81 | program { | |
82 | {DW_LNE_set_address bar_label} | |
83 | {line 26} | |
84 | {DW_LNS_copy} | |
85 | ||
86 | {DW_LNE_set_address $bar_end} | |
87 | {DW_LNE_end_sequence} | |
88 | ||
89 | {DW_LNE_set_address main_label} | |
90 | {line 32} | |
91 | {DW_LNS_copy} | |
92 | ||
93 | {DW_LNE_set_address main_label_2} | |
94 | {line 36} | |
95 | {DW_LNS_negate_stmt} | |
96 | {DW_LNS_copy} | |
97 | {DW_LNS_negate_stmt} | |
98 | ||
99 | {DW_LNE_set_address main_label_3} | |
100 | {line 36} | |
101 | {DW_LNS_copy} | |
102 | ||
103 | {DW_LNE_set_address $main_end} | |
104 | {DW_LNE_end_sequence} | |
105 | } | |
106 | } | |
107 | } | |
108 | ||
109 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
110 | [list $srcfile $asm_file] {nodebug}] } { | |
111 | return -1 | |
112 | } | |
113 | ||
114 | if ![runto_main] { | |
115 | return -1 | |
116 | } | |
117 | ||
118 | # Step into bar. | |
119 | gdb_breakpoint "bar" | |
120 | gdb_continue_to_breakpoint "bar" | |
121 | ||
122 | # Step out of bar. | |
123 | gdb_test "step" [multi_line \ | |
124 | "main \\(\\) at \[^\r\n\]*$srcfile:36" \ | |
125 | "36\t\[^\r\n\]*"] | |
126 |