1 # Copyright 2023-2024 Free Software Foundation, Inc. 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 that the DWARF reader works with a a DW_AT_specification that 17 # refers to a later DIE. 18 19 require !readnow 20 21 load_lib dwarf.exp 22 23 # This test can only be run on targets which support DWARF-2 and use gas. 24 require dwarf2_support 25 26 standard_testfile main.c -debug.S 27 28 # Set up the DWARF for the test. 29 set asm_file [standard_output_file $srcfile2] 30 Dwarf::assemble $asm_file { 31 global srcfile 32 33 cu {} { 34 DW_TAG_compile_unit { 35 {DW_AT_language @DW_LANG_C_plus_plus} 36 {DW_AT_name $srcfile} 37 {DW_AT_comp_dir /tmp} 38 39 } { 40 declare_labels spec myint 41 42 # The new indexer has special code to compute the full 43 # name of an object that uses a specification that appears 44 # later in the DWARF. 45 DW_TAG_variable { 46 {DW_AT_specification :$spec} 47 {DW_AT_location { 48 DW_OP_const1u 23 49 DW_OP_stack_value 50 } SPECIAL_expr} 51 } 52 53 myint: DW_TAG_base_type { 54 {DW_AT_byte_size 4 DW_FORM_sdata} 55 {DW_AT_encoding @DW_ATE_signed} 56 {DW_AT_name myint} 57 } 58 59 DW_TAG_namespace { 60 {DW_AT_name ns} 61 } { 62 spec: DW_TAG_variable { 63 {DW_AT_name v} 64 {DW_AT_type :$myint} 65 {DW_AT_declaration 1 DW_FORM_flag_present} 66 } 67 } 68 } 69 } 70 } 71 72 if {[prepare_for_testing "failed to prepare" ${testfile} \ 73 [list $srcfile $asm_file] {nodebug}]} { 74 return -1 75 } 76 77 require {string equal [have_index $binfile] ""} 78 79 set re_ws "\[ \t\]" 80 81 gdb_test_lines "maint print objfiles" \ 82 "v has a parent" \ 83 [multi_line \ 84 "" \ 85 "$re_ws+qualified:$re_ws+ns::v" \ 86 ".*"] 87