1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2022 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 if {![dwarf2_support]} {
29 if {![test_compiler_info gcc-*-*]} {
30 untested "dwarf assembler needs GCC"
33 standard_testfile .c .S
35 lassign [function_range main $srcdir/$subdir/$srcfile] \
38 set asm_file [standard_output_file $srcfile2]
40 Dwarf::assemble $asm_file {
41 declare_labels L cu_macros
45 {DW_AT_producer "clang version 15.0.0"}
46 {DW_AT_language @DW_LANG_C11}
47 {DW_AT_name $::srcfile}
48 {DW_AT_macros $cu_macros DW_FORM_sec_offset}
49 {DW_AT_stmt_list $L DW_FORM_sec_offset}
51 declare_labels int_type
53 int_type: DW_TAG_base_type {
54 {DW_AT_byte_size 4 DW_FORM_sdata}
55 {DW_AT_encoding @DW_ATE_signed}
59 {MACRO_AT_func {main}}
65 file_name $::srcfile 1
67 DW_LNE_set_address $::main_start
70 DW_LNE_set_address "$::main_start + $::main_len"
75 # Define the .debug_macro section.
78 "debug-line-offset-label" $L
81 # A macro defined at line 1 of the main file.
89 if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $asm_file] {nodebug}]} {
97 gdb_test "print TWO" "= 2" "print simple macro"
98 gdb_test "print ONE" "= 1" "print defined from CLI"