1#! /bin/sh
2# Copyright (C) 2019 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20# = rng.ads =
21# package Rng is
22#
23#    type Rec (I : Integer) is record
24#       case I is
25#  when Positive =>
26#     case I is
27#        when 1..15 | 17 | 23 =>
28#   null;
29#        when others =>
30#   J : Integer;
31#     end case;
32#  when -52..-1 =>
33#     Q: Integer;
34#  when -64 =>
35#     R: Boolean;
36#  when others =>
37#     null;
38#       end case;
39#    end record;
40#
41#    R : Rec (1);
42#
43# end Rng;
44
45# = urng.ads =
46#
47# package Urng is
48#
49#    type Unsigned is mod 65536;
50#    type Rec (U : Unsigned) is record
51#       case U is
52#  when 17 | 23 | 32768..65535 =>
53#     null;
54#  when 256 =>
55#     B: Boolean;
56#  when others =>
57#     I : Integer;
58#       end case;
59#    end record;
60#
61#    R : Rec (1);
62#
63# end Urng;
64
65# gcc -c -g -fgnat-encodings=minimal -gstrict-dwarf rng.ads
66# eu-strip -g -f rng.debug rng.o
67# gcc -c -g -fgnat-encodings=minimal -gstrict-dwarf urng.ads
68# eu-strip -g -f urng.debug urng.o
69
70testfiles testfile-rng.debug testfile-urng.debug
71
72testrun_compare ${abs_top_builddir}/src/readelf -U --debug-dump=info testfile-rng.debug testfile-urng.debug <<EOF
73
74testfile-rng.debug:
75
76
77DWARF section [ 5] '.debug_info' at offset 0x40:
78 [Offset]
79 Compilation unit at offset 0:
80 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
81 [     b]  compile_unit         abbrev: 1
82           producer             (strp) "GNU Ada 9.1.1 20190503 (Red Hat 9.1.1-1) -g -fgnat-encodings=minimal -gstrict-dwarf -mtune=generic -march=x86-64"
83           language             (data1) Ada95 (13)
84           name                 (strp) "rng.ads"
85           comp_dir             (strp) "/home/mark"
86           low_pc               (addr) 000000000000000000
87           high_pc              (data8) 2016 (0x00000000000007e0)
88           stmt_list            (sec_offset) 0
89 [    2d]    structure_type       abbrev: 2
90             name                 (strp) "rng__rec"
91             byte_size            (exprloc) 
92              [ 0] push_object_address
93              [ 1] deref_size 4
94              [ 3] call4 [    c6]
95              [ 8] plus_uconst 7
96              [10] const1s -4
97              [12] and
98             decl_file            (data1) rng.ads (1)
99             decl_line            (data1) 3
100             decl_column          (data1) 9
101             sibling              (ref4) [    ab]
102 [    47]      member               abbrev: 3
103               name                 (string) "i"
104               decl_file            (data1) rng.ads (1)
105               decl_line            (data1) 3
106               decl_column          (data1) 14
107               type                 (ref4) [    fe]
108               data_member_location (data1) 0
109 [    52]      variant_part         abbrev: 4
110               discr                (ref4) [    47]
111 [    57]        variant              abbrev: 5
112                 discr_list           (block1) range 1..2147483647
113                 sibling              (ref4) [    81]
114 [    64]          variant_part         abbrev: 4
115                   discr                (ref4) [    47]
116 [    69]            variant              abbrev: 6
117                     discr_list           (block1) range 1..15, label 17, label 23
118 [    72]            variant              abbrev: 7
119 [    73]              member               abbrev: 3
120                       name                 (string) "j"
121                       decl_file            (data1) rng.ads (1)
122                       decl_line            (data1) 10
123                       decl_column          (data1) 19
124                       type                 (ref4) [    fe]
125                       data_member_location (data1) 4
126 [    81]        variant              abbrev: 5
127                 discr_list           (block1) range -52..-1
128                 sibling              (ref4) [    96]
129 [    8a]          member               abbrev: 3
130                   name                 (string) "q"
131                   decl_file            (data1) rng.ads (1)
132                   decl_line            (data1) 13
133                   decl_column          (data1) 13
134                   type                 (ref4) [    fe]
135                   data_member_location (data1) 4
136 [    96]        variant              abbrev: 8
137                 discr_value          (sdata) -64
138                 sibling              (ref4) [    a8]
139 [    9c]          member               abbrev: 3
140                   name                 (string) "r"
141                   decl_file            (data1) rng.ads (1)
142                   decl_line            (data1) 15
143                   decl_column          (data1) 13
144                   type                 (ref4) [   105]
145                   data_member_location (data1) 4
146 [    a8]        variant              abbrev: 9
147 [    ab]    dwarf_procedure      abbrev: 10
148             location             (exprloc) 
149              [ 0] dup
150              [ 1] lit0
151              [ 2] gt
152              [ 3] over
153              [ 4] lit15
154              [ 5] le
155              [ 6] and
156              [ 7] over
157              [ 8] lit17
158              [ 9] eq
159              [10] or
160              [11] over
161              [12] lit23
162              [13] eq
163              [14] or
164              [15] bra 22
165              [18] lit4
166              [19] skip 23
167              [22] lit0
168              [23] swap
169              [24] drop
170 [    c6]    dwarf_procedure      abbrev: 10
171             location             (exprloc) 
172              [ 0] dup
173              [ 1] lit0
174              [ 2] gt
175              [ 3] bra 36
176              [ 6] dup
177              [ 7] const1s -52
178              [ 9] lt
179              [10] over
180              [11] lit0
181              [12] ge
182              [13] or
183              [14] bra 21
184              [17] lit4
185              [18] skip 33
186              [21] dup
187              [22] const1s -64
188              [24] eq
189              [25] bra 32
190              [28] lit0
191              [29] skip 33
192              [32] lit4
193              [33] skip 52
194              [36] dup
195              [37] call4 [    ab]
196              [42] plus_uconst 3
197              [44] const1s -4
198              [46] and
199              [47] plus_uconst 3
200              [49] const1s -4
201              [51] and
202              [52] swap
203              [53] drop
204 [    fe]    base_type            abbrev: 11
205             byte_size            (data1) 4
206             encoding             (data1) signed (5)
207             name                 (strp) "integer"
208             artificial           (flag_present) yes
209 [   105]    base_type            abbrev: 12
210             byte_size            (data1) 1
211             encoding             (data1) boolean (2)
212             name                 (strp) "boolean"
213 [   10c]    variable             abbrev: 13
214             name                 (strp) "rng__r"
215             decl_file            (data1) rng.ads (1)
216             decl_line            (data1) 21
217             decl_column          (data1) 4
218             type                 (ref4) [    2d]
219             external             (flag_present) yes
220             location             (exprloc) 
221              [ 0] addr 0x7e4
222 [   122]    subprogram           abbrev: 14
223             external             (flag_present) yes
224             name                 (strp) "rng___elabs"
225             artificial           (flag_present) yes
226             low_pc               (addr) 0x0000000000000734
227             high_pc              (data8) 22 (0x000000000000074a)
228             frame_base           (exprloc) 
229              [ 0] call_frame_cfa
230
231testfile-urng.debug:
232
233
234DWARF section [ 5] '.debug_info' at offset 0x40:
235 [Offset]
236 Compilation unit at offset 0:
237 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4
238 [     b]  compile_unit         abbrev: 1
239           producer             (strp) "GNU Ada 9.1.1 20190503 (Red Hat 9.1.1-1) -g -fgnat-encodings=minimal -gstrict-dwarf -mtune=generic -march=x86-64"
240           language             (data1) Ada95 (13)
241           name                 (strp) "urng.ads"
242           comp_dir             (strp) "/home/mark"
243           low_pc               (addr) 000000000000000000
244           high_pc              (data8) 977 (0x00000000000003d1)
245           stmt_list            (sec_offset) 0
246 [    2d]    base_type            abbrev: 2
247             byte_size            (data1) 2
248             encoding             (data1) unsigned (7)
249             name                 (strp) "urng__unsigned"
250 [    34]    structure_type       abbrev: 3
251             name                 (strp) "urng__rec"
252             byte_size            (exprloc) 
253              [ 0] push_object_address
254              [ 1] deref_size 2
255              [ 3] call4 [    8d]
256              [ 8] plus_uconst 7
257              [10] const1s -4
258              [12] and
259             decl_file            (data1) urng.ads (1)
260             decl_line            (data1) 4
261             decl_column          (data1) 9
262             sibling              (ref4) [    8d]
263 [    4e]      member               abbrev: 4
264               name                 (string) "u"
265               decl_file            (data1) urng.ads (1)
266               decl_line            (data1) 4
267               decl_column          (data1) 14
268               type                 (ref4) [    2d]
269               data_member_location (data1) 0
270 [    59]      variant_part         abbrev: 5
271               discr                (ref4) [    4e]
272 [    5e]        variant              abbrev: 6
273                 discr_list           (block1) label 17, label 23, range 32768..65535
274 [    6b]        variant              abbrev: 7
275                 discr_value          (udata) 256
276                 sibling              (ref4) [    7e]
277 [    72]          member               abbrev: 4
278                   name                 (string) "b"
279                   decl_file            (data1) urng.ads (1)
280                   decl_line            (data1) 9
281                   decl_column          (data1) 13
282                   type                 (ref4) [    a4]
283                   data_member_location (data1) 4
284 [    7e]        variant              abbrev: 8
285 [    7f]          member               abbrev: 4
286                   name                 (string) "i"
287                   decl_file            (data1) urng.ads (1)
288                   decl_line            (data1) 11
289                   decl_column          (data1) 13
290                   type                 (ref4) [    ab]
291                   data_member_location (data1) 4
292 [    8d]    dwarf_procedure      abbrev: 9
293             location             (exprloc) 
294              [ 0] dup
295              [ 1] lit17
296              [ 2] ne
297              [ 3] over
298              [ 4] lit23
299              [ 5] ne
300              [ 6] and
301              [ 7] over
302              [ 8] lit0
303              [ 9] ge
304              [10] and
305              [11] bra 18
306              [14] lit0
307              [15] skip 19
308              [18] lit4
309              [19] swap
310              [20] drop
311 [    a4]    base_type            abbrev: 2
312             byte_size            (data1) 1
313             encoding             (data1) boolean (2)
314             name                 (strp) "boolean"
315 [    ab]    base_type            abbrev: 10
316             byte_size            (data1) 4
317             encoding             (data1) signed (5)
318             name                 (strp) "integer"
319             artificial           (flag_present) yes
320 [    b2]    variable             abbrev: 11
321             name                 (strp) "urng__r"
322             decl_file            (data1) urng.ads (1)
323             decl_line            (data1) 15
324             decl_column          (data1) 4
325             type                 (ref4) [    34]
326             external             (flag_present) yes
327             location             (exprloc) 
328              [ 0] addr 0x3d8
329 [    c8]    subprogram           abbrev: 12
330             external             (flag_present) yes
331             name                 (strp) "urng___elabs"
332             artificial           (flag_present) yes
333             low_pc               (addr) 0x0000000000000386
334             high_pc              (data8) 22 (0x000000000000039c)
335             frame_base           (exprloc) 
336              [ 0] call_frame_cfa
337EOF
338