1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2024 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Test complaints about .debug_macro section.
22 require dwarf2_support
25 standard_testfile main.c .S
27 lassign [function_range main $srcdir/$subdir/$srcfile] \
30 set asm_file [standard_output_file $srcfile2]
32 set line [gdb_get_line_number "return 0;"]
34 Dwarf::assemble $asm_file {
35 declare_labels L cu_macro1
39 {DW_AT_name $::srcfile}
40 {DW_AT_macros $cu_macro1 DW_FORM_sec_offset}
41 {DW_AT_stmt_list $L DW_FORM_sec_offset}
43 declare_labels int_type
45 int_type: DW_TAG_base_type {
46 {DW_AT_byte_size 4 DW_FORM_sdata}
47 {DW_AT_encoding @DW_ATE_signed}
51 {MACRO_AT_func {main}}
58 file_name $::srcfile 1
60 DW_LNE_set_address $::main_start
63 DW_LNE_set_address "$::main_start + $::main_len"
68 # Define the .debug_macro section.
71 "debug-line-offset-label" $L
73 define 0 "M1_01_BUILTIN_OK 1"
74 define 1 "M1_02_BUILTIN_BADLINE 1"
79 define 0 "M1_04_BADLINE 1"
82 define 1 "M1_05_BADFILE 1"
86 define 1 "M1_07_MALFORMED"
87 define 1 "M1_08_OK() 1"
88 define 1 "M1_09_OK(ARG) (ARG)"
89 define 1 "M1_10_OK(ARG1,ARG2) (ARG1+ARG2)"
91 define 1 "M1_11_MALFORMED(ARG"
92 define 1 "M1_12_MALFORMED(ARG,"
93 define 1 "M1_13_MALFORMED(ARG,)"
94 define 1 "M1_14_MALFORMED()1"
101 if { [build_executable "failed to prepare" $testfile \
102 [list $srcfile $asm_file] {nodebug}] } {
109 "debug info gives command-line macro definition with non-zero line 1: M1_02_BUILTIN_BADLINE 1"
112 "debug info gives in-file macro definition with zero line 0: M1_04_BADLINE 1"
115 [string_to_regexp "bad file number in macro information (1234)"]
119 "macro debug info contains a malformed macro definition:" \
124 "macro debug info contains a malformed macro definition:" \
125 [string_to_regexp "`M1_11_MALFORMED(ARG'"]]
129 "macro debug info contains a malformed macro definition:" \
130 [string_to_regexp "`M1_12_MALFORMED(ARG,'"]]
134 "macro debug info contains a malformed macro definition:" \
135 [string_to_regexp "`M1_13_MALFORMED(ARG,)'"]]
139 "macro debug info contains a malformed macro definition:" \
140 [string_to_regexp "`M1_14_MALFORMED()1'"]]
143 "During symbol reading"
147 "$prefix: $re_complaint1" \
148 "$prefix: $re_complaint2" \
149 "$prefix: $re_complaint3" \
150 "$prefix: $re_complaint4" \
151 "$prefix: $re_complaint5" \
152 "$prefix: $re_complaint6" \
153 "$prefix: $re_complaint7" \
154 "$prefix: $re_complaint8" \
155 [string cat [string_to_regexp {$}] "$decimal = \[^\r\n\]+"]]
159 gdb_test "p main" ^$re "complaints"
164 "Defined at $srcfile:0" \
165 "-DM1_01_BUILTIN_OK=1" \
166 "Defined at $srcfile:1" \
167 "#define M1_02_BUILTIN_BADLINE 1" \
168 "Defined at $srcfile:1" \
169 "#define M1_03_OK 1" \
170 "Defined at $srcfile:0" \
171 "-DM1_04_BADLINE=1" \
172 "Defined at <bad macro file number 1234>:1" \
173 " included at $srcfile:1" \
174 "#define M1_05_BADFILE 1" \
175 "Defined at $srcfile:1" \
176 "#define M1_06_OK " \
177 "Defined at $srcfile:1" \
178 "#define M1_07_MALFORMED " \
179 "Defined at $srcfile:1" \
180 [string_to_regexp "#define M1_08_OK() 1"] \
181 "Defined at $srcfile:1" \
182 [string_to_regexp "#define M1_09_OK(ARG) (ARG)"] \
183 "Defined at $srcfile:1" \
184 [string_to_regexp "#define M1_10_OK(ARG1, ARG2) (ARG1+ARG2)"] \
185 "Defined at $srcfile:1" \
186 [string_to_regexp "#define M1_13_MALFORMED(ARG) "]]
190 "Defined at $srcfile:-1" \
191 "#define __FILE__ \"$srcfile\"" \
192 "Defined at $srcfile:-1" \
193 "#define __LINE__ $line"]
195 gdb_test "info macros $line" \