Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.dwarf2 / imported-unit-abstract-const-value.exp
blobe0b0baf36c4ccb9da2d209bf7f069db63a5e8b52
1 # Copyright 2020-2022 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.
19 load_lib dwarf.exp
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 if {![dwarf2_support]} {
23 return 0
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}] {
34 return -1
37 # Create the DWARF.
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 cu {} {
44 cu_label: partial_unit {
45 {language @DW_LANG_C}
46 {name "imported_unit.c"}
47 } {
48 int_label: base_type {
49 {byte_size $int_size sdata}
50 {encoding @DW_ATE_signed}
51 {name int}
54 aaa_label: DW_TAG_variable {
55 {name aaa}
56 {type :$int_label}
57 {const_value 1 DW_FORM_sdata}
60 main_label: subprogram {
61 {name main}
62 {type :$int_label}
63 {external 1 flag}
68 cu {} {
69 compile_unit {
70 {language @DW_LANG_C}
71 {name "<artificial>"}
72 } {
73 DW_TAG_variable {
74 {abstract_origin %$aaa_label}
76 subprogram {
77 {abstract_origin %$main_label}
78 {MACRO_AT_range {main}}
84 if { [prepare_for_testing "failed to prepare" ${testfile} \
85 [list $srcfile $asm_file] {nodebug}] } {
86 return -1
89 gdb_test "p aaa" "= 1"