summaryrefslogtreecommitdiffstats
path: root/tests/run-readelf-variant.sh
blob: dcc0d5e162991e5a8f78dc82fc2c5cbcef4cbc86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /bin/sh
# Copyright (C) 2017 Red Hat, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# elfutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. $srcdir/test-subr.sh

# Tests exprloc for an Ada record variants byte_size.

# = pck.ads
#
# with System;
#
# package Pck is
#
#    type One_To_Five is range 1 .. 5;
#
#    type Rec (Discr : One_To_Five) is
#    record
#       case Discr is
#          when 1 => Field1 : Integer;
#          when 4 => null;
#          when 3 => Field3 : Boolean;
#          when 5 => null;
#          when others => null;
#       end case;
#    end record;
#
#    procedure Do_Nothing (A : System.Address);
#
# end Pck;

# = pck.adb
#
# package body Pck is
#
#    procedure Do_Nothing (A : System.Address) is
#    begin
#       null;
#    end Do_Nothing;
#
# end Pck;

# = foo.adb
#
# with Pck; use Pck;
#
# procedure Foo is
#
#    R : Rec (1);
#
# begin
#    Do_Nothing (R'Address);
# end Foo;

# gnatmake -g -fgnat-encodings=minimal foo.adb -cargs

testfiles testfile-ada-variant

tempfiles testfile.temp testfile2.temp

testrun ${abs_top_builddir}/src/readelf --debug-dump=info \
        testfile-ada-variant > testfile.temp

grep -A6 byte_size testfile.temp | grep -A6 exprloc > testfile2.temp

diff -u testfile2.temp - <<EOF
             byte_size            (exprloc) 
              [ 0] push_object_address
              [ 1] deref_size 1
              [ 3] call4 [    95]
              [ 8] plus_uconst 7
              [10] const1s -4
              [12] and
EOF

exit 0