1 # Copyright 2020 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test that a concrete var importing an abstract var using
17 # DW_AT_abstract_origin inherits the DW_AT_const_value attribute.
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 if {![dwarf2_support]} {
26 standard_testfile main.c .S
28 set executable ${testfile}
29 set asm_file [standard_output_file ${srcfile2}]
31 # We need to know the size of integer type in order
32 # to write some of the debugging info we'd like to generate.
33 if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
38 Dwarf::assemble $asm_file {
39 declare_labels cu_label main_label int_label
40 declare_labels aaa_label
41 set int_size [get_sizeof "int" 4]
43 global srcdir subdir srcfile
47 set main_range [function_range main ${srcdir}/${subdir}/${srcfile}]
48 set main_start [lindex $main_range 0]
49 set main_length [lindex $main_range 1]
52 cu_label: partial_unit {
54 {name "imported_unit.c"}
56 int_label: base_type {
57 {byte_size $int_size sdata}
58 {encoding @DW_ATE_signed}
62 aaa_label: DW_TAG_variable {
65 {const_value 1 DW_FORM_sdata}
68 main_label: subprogram {
82 {abstract_origin %$aaa_label}
85 {abstract_origin %$main_label}
86 {low_pc $main_start addr}
87 {high_pc "$main_start + $main_length" addr}
93 if { [prepare_for_testing "failed to prepare" ${testfile} \
94 [list $srcfile $asm_file] {nodebug}] } {
98 gdb_test "p aaa" "= 1"