[Bug tools/24550] eu-readelf does not know about DW_AT_GNU_{bias,numerator,denumerator}

2019-05-15 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=24550

--- Comment #2 from Tom Tromey  ---
(In reply to Mark Wielaard from comment #1)

> Could you help me with creating gnat examples that compile and show their
> usage?

For bias, the above works.

> If I try to compile your example I get two warnings:
> 
> tt.adb:4:04: warning: size clause forces biased representation for "Small"
> tt.adb:8:03: warning: size clause forces biased representation for
> "Repeat_Count_T"
> 
> Are those expected?

Yes, though I don't know the rationale.

The numerator and denominator attributes are used for fixed-point types.
There is a test for this in g...@github.com:pmderodat/dwarf-ada-testsuite.git

murgatroyd. readelf -wi tests/fixedpoint/foo.o |grep DW_AT_GNU_[dn]
<229>   DW_AT_GNU_numerator: 1
<22a>   DW_AT_GNU_denominator: 30
<237>   DW_AT_GNU_numerator: 0
<238>   DW_AT_GNU_denominator: 0


> Also the subranges come out as:
[...]
> There are three things that surprised me about this.
> First that the byte_size is 1, are these types really using a full byte and
> not 2 or 6 bits?

I'm not totally sure what is going on here.  Maybe the type needs to be
used in a packed record to see it actually shrink?  I will see if I can write
a test for this.

> And second that the bias is on the subrange_type and not the base_type. Is
> that intended?

Yes, the bias only applies to subrange types, not the base type.

> Finally, why is the last type signed?

I think that's the default.  You have to request an unsigned based type
explicitly, like:

   type Byte is mod 256;
   type Repeat_Count_T is new Byte range 1 .. 2 ** 6;

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug tools/24550] eu-readelf does not know about DW_AT_GNU_{bias,numerator,denumerator}

2019-05-15 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=24550

--- Comment #3 from Tom Tromey  ---
> > There are three things that surprised me about this.
> > First that the byte_size is 1, are these types really using a full byte and
> > not 2 or 6 bits?
> 
> I'm not totally sure what is going on here.  Maybe the type needs to be
> used in a packed record to see it actually shrink?  I will see if I can write
> a test for this.

Thanks for noticing this.  I think the DWARF is incorrect here in a few
ways -- I am going to update the internal bug about it to get it fixed.

Meanwhile here is the updated test case I am using

--  Copyright 2019 Free Software Foundation, Inc.
--
--  This program 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.
--
--  This program 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 .

procedure Bias is
   type Small is range -7 .. -4;
   for Small'Size use 2;
   Y : Small := -5;
   Y1 : Small := -7;

   type Byte is mod 256;
   type Repeat_Count_T is new Byte range 1 .. 2 ** 6;
   for Repeat_Count_T'Size use 6;
   X : Repeat_Count_T := 64;
   X1 : Repeat_Count_T := 1;

   type Char_Range is range 65 .. 68;
   for Char_Range'Size use 2;
   Cval : Char_Range := 65;

   type SomePackedRecord is record
  R: Small;
  S: Small;
   end record;
   pragma Pack (SomePackedRecord);
   SPR : SomePackedRecord := (R => -4, S => -5);

   type Packed_Array is array (1 .. 3) of Small;
   pragma pack (Packed_Array);
   A : Packed_Array := (-7, -5, -4);

begin
   null;
end Bias;

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug tools/24550] eu-readelf does not know about DW_AT_GNU_{bias,numerator,denumerator}

2019-05-15 Thread tromey at sourceware dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=24550

--- Comment #4 from Tom Tromey  ---
BTW some of the oddities encountered might be good for dwarflint...

-- 
You are receiving this mail because:
You are on the CC list for the bug.