1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2022-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 # Clang has this bug where it puts the macros defined on the command-line
19 # after the main file portion (see PR 29034 and
20 # https://github.com/llvm/llvm-project/issues/54506 )
21 # Test that GDB is still able to print macros in clang versions that
26 require dwarf2_support
28 standard_testfile .c .S
30 lassign [function_range main $srcdir/$subdir/$srcfile] \
33 set asm_file [standard_output_file $srcfile2]
35 Dwarf::assemble $asm_file {
36 declare_labels L cu_macros
40 {DW_AT_producer "clang version 15.0.0"}
41 {DW_AT_language @DW_LANG_C11}
42 {DW_AT_name $::srcfile}
43 {DW_AT_macros $cu_macros DW_FORM_sec_offset}
44 {DW_AT_stmt_list $L DW_FORM_sec_offset}
46 declare_labels int_type
48 int_type: DW_TAG_base_type {
49 {DW_AT_byte_size 4 DW_FORM_sdata}
50 {DW_AT_encoding @DW_ATE_signed}
54 {MACRO_AT_func {main}}
60 file_name $::srcfile 1
62 DW_LNE_set_address $::main_start
65 DW_LNE_set_address "$::main_start + $::main_len"
70 # Define the .debug_macro section.
73 "debug-line-offset-label" $L
76 # A macro defined at line 1 of the main file.
84 if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $asm_file] {nodebug}]} {
92 gdb_test "print TWO" "= 2" "print simple macro"
93 gdb_test "print ONE" "= 1" "print defined from CLI"