blob: dcc0d5e162991e5a8f78dc82fc2c5cbcef4cbc86 [file] [log] [blame]
Brian Silverman86497922018-02-10 19:28:39 -05001#! /bin/sh
2# Copyright (C) 2017 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# Tests exprloc for an Ada record variants byte_size.
21
22# = pck.ads
23#
24# with System;
25#
26# package Pck is
27#
28# type One_To_Five is range 1 .. 5;
29#
30# type Rec (Discr : One_To_Five) is
31# record
32# case Discr is
33# when 1 => Field1 : Integer;
34# when 4 => null;
35# when 3 => Field3 : Boolean;
36# when 5 => null;
37# when others => null;
38# end case;
39# end record;
40#
41# procedure Do_Nothing (A : System.Address);
42#
43# end Pck;
44
45# = pck.adb
46#
47# package body Pck is
48#
49# procedure Do_Nothing (A : System.Address) is
50# begin
51# null;
52# end Do_Nothing;
53#
54# end Pck;
55
56# = foo.adb
57#
58# with Pck; use Pck;
59#
60# procedure Foo is
61#
62# R : Rec (1);
63#
64# begin
65# Do_Nothing (R'Address);
66# end Foo;
67
68# gnatmake -g -fgnat-encodings=minimal foo.adb -cargs
69
70testfiles testfile-ada-variant
71
72tempfiles testfile.temp testfile2.temp
73
74testrun ${abs_top_builddir}/src/readelf --debug-dump=info \
75 testfile-ada-variant > testfile.temp
76
77grep -A6 byte_size testfile.temp | grep -A6 exprloc > testfile2.temp
78
79diff -u testfile2.temp - <<EOF
80 byte_size (exprloc)
81 [ 0] push_object_address
82 [ 1] deref_size 1
83 [ 3] call4 [ 95]
84 [ 8] plus_uconst 7
85 [10] const1s -4
86 [12] and
87EOF
88
89exit 0