]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/clang-debug-names.exp
[gdb/testsuite] Add gdb.dwarf2/clang-debug-names.c
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / clang-debug-names.exp
1 # Copyright 2020 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 load_lib dwarf.exp
17
18 # This test can only be run on targets which support DWARF-2 and use gas.
19 if {![dwarf2_support]} {
20 return 0
21 }
22
23 standard_testfile clang-debug-names.c clang-debug-names-debug.S
24
25 # Set up the DWARF for the test.
26
27 set main_str_label [Dwarf::_compute_label info_string3]
28 set int_str_label [Dwarf::_compute_label info_string4]
29 set main_die_label [Dwarf::_compute_label main_die_label]
30 set int_die_label [Dwarf::_compute_label int_die_label]
31
32 set debug_str \
33 [list \
34 "$main_str_label:" \
35 " .asciz \"main\"" \
36 "$int_str_label:" \
37 " .asciz \"int\""]
38
39 set debug_names \
40 [list \
41 " .4byte .Ldebug_names_end - .Ldebug_names_start" \
42 ".Ldebug_names_start:" \
43 " .short 5 # Header: version" \
44 " .short 0 # Header: padding" \
45 " .long 1 # Header: compilation unit count" \
46 " .long 0 # Header: local type unit count" \
47 " .long 0 # Header: foreign type unit count" \
48 " .long 2 # Header: bucket count" \
49 " .long 2 # Header: name count" \
50 " .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \
51 " # Header: abbreviation table size" \
52 " .long 8 # Header: augmentation string size" \
53 " .ascii \"LLVM0700\" # Header: augmentation string" \
54 " .long .Lcu1_begin # Compilation unit 0" \
55 " .long 1 # Bucket 0" \
56 " .long 0 # Bucket 1" \
57 " .long 193495088 # Hash in Bucket 0" \
58 " .long 2090499946 # Hash in Bucket 0" \
59 " .long $int_str_label # String in Bucket 0: int" \
60 " .long $main_str_label # String in Bucket 0: main" \
61 " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \
62 " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \
63 ".Lnames_abbrev_start0:" \
64 " .byte 46 # Abbrev code" \
65 " .byte 46 # DW_TAG_subprogram" \
66 " .byte 3 # DW_IDX_die_offset" \
67 " .byte 19 # DW_FORM_ref4" \
68 " .byte 0 # End of abbrev" \
69 " .byte 0 # End of abbrev" \
70 " .byte 36 # Abbrev code" \
71 " .byte 36 # DW_TAG_base_type" \
72 " .byte 3 # DW_IDX_die_offset" \
73 " .byte 19 # DW_FORM_ref4" \
74 " .byte 0 # End of abbrev" \
75 " .byte 0 # End of abbrev" \
76 " .byte 0 # End of abbrev list" \
77 ".Lnames_abbrev_end0:" \
78 ".Lnames_entries0:" \
79 ".Lnames1:" \
80 " .byte 36 # Abbreviation code" \
81 " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \
82 " .long 0 # End of list: int" \
83 ".Lnames0:" \
84 " .byte 46 # Abbreviation code" \
85 " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \
86 " .long 0 # End of list: main" \
87 " .p2align 2" \
88 ".Ldebug_names_end:"]
89
90 set asm_file [standard_output_file $srcfile2]
91 Dwarf::assemble $asm_file {
92 global srcdir subdir srcfile
93
94 lassign [function_range main ${srcdir}/${subdir}/${srcfile}] \
95 main_start main_length
96
97 cu {} {
98 DW_TAG_compile_unit {
99 {DW_AT_language @DW_LANG_C}
100 {DW_AT_name clang-debug-names.c}
101 {DW_AT_comp_dir /tmp}
102
103 } {
104 global int_die_label
105 global main_die_label
106
107 define_label $int_die_label
108 base_type {
109 {name "int"}
110 {encoding @DW_ATE_signed}
111 {byte_size 4 DW_FORM_sdata}
112 }
113
114 define_label $main_die_label
115 subprogram {
116 {name main}
117 {type :$int_die_label}
118 {low_pc $main_start addr}
119 {high_pc "$main_start + $main_length" addr}
120 }
121 }
122 }
123
124 _defer_output .debug_str {
125 global debug_str
126 _emit [join $debug_str "\n"]
127 }
128
129 _defer_output .debug_names {
130 global debug_names
131 _emit [join $debug_names "\n"]
132 }
133 }
134
135 if { [prepare_for_testing "failed to prepare" ${testfile} \
136 [list $srcfile $asm_file] {nodebug}] } {
137 return -1
138 }
139
140 set cmd "ptype main"
141 set pass_re \
142 [multi_line \
143 $cmd \
144 "type = int \\(\\)"]
145 set kfail_re \
146 [multi_line \
147 $cmd \
148 "type = <unknown return type> \\(\\)"]
149 gdb_test_multiple $cmd "" {
150 -re -wrap $pass_re {
151 pass $gdb_test_name
152 }
153 -re -wrap $kfail_re {
154 kfail symtab/25952 $gdb_test_name
155 }
156 }