Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2020-2022 Free Software Foundation, Inc. |
25c11aca TV |
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 | # Test that a concrete var importing an abstract var using | |
17 | # DW_AT_abstract_origin inherits the DW_AT_const_value attribute. | |
18 | ||
19 | load_lib dwarf.exp | |
20 | ||
21 | # This test can only be run on targets which support DWARF-2 and use gas. | |
22 | if {![dwarf2_support]} { | |
23 | return 0 | |
24 | }; | |
25 | ||
26 | standard_testfile main.c .S | |
27 | ||
28 | set executable ${testfile} | |
29 | set asm_file [standard_output_file ${srcfile2}] | |
30 | ||
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 | |
35 | } | |
36 | ||
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] | |
42 | ||
25c11aca TV |
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} | |
52 | } | |
53 | ||
54 | aaa_label: DW_TAG_variable { | |
55 | {name aaa} | |
56 | {type :$int_label} | |
57 | {const_value 1 DW_FORM_sdata} | |
58 | } | |
59 | ||
60 | main_label: subprogram { | |
61 | {name main} | |
62 | {type :$int_label} | |
63 | {external 1 flag} | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | cu {} { | |
69 | compile_unit { | |
70 | {language @DW_LANG_C} | |
71 | {name "<artificial>"} | |
72 | } { | |
73 | DW_TAG_variable { | |
74 | {abstract_origin %$aaa_label} | |
75 | } | |
76 | subprogram { | |
77 | {abstract_origin %$main_label} | |
90c3ec2d | 78 | {MACRO_AT_range {main}} |
25c11aca TV |
79 | } |
80 | } | |
81 | } | |
82 | } | |
83 | ||
84 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
85 | [list $srcfile $asm_file] {nodebug}] } { | |
86 | return -1 | |
87 | } | |
88 | ||
89 | gdb_test "p aaa" "= 1" |