gdb/dwarf: Ensure the target type of ranges is not void
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 7 May 2019 23:01:14 +0000 (00:01 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 12 Jul 2019 11:09:53 +0000 (12:09 +0100)
commitb86352cfc17fb7f07d5da9efcfd59f8b2bd08eee
treedc4d45d16d17b894c3864560ceae7afeec01cfce
parent603490bf53fe1885ef45f9d0fb783b32f8ef6049
gdb/dwarf: Ensure the target type of ranges is not void

If a DW_TAG_subrange_type DWARF entry has no DW_AT_type then a default
type based on the size of an address on the current target is assumed.
We store this type as the target type for GDB's range types.

Currently GDB can create ranges for which the target type is VOID,
this is incorrect but seems to cause no problems. I believe the reason
this doesn't cause any issues is because the languages (for example
Ada) that actually make use of a ranges target type also have
compilers that generate DWARF that includes a DW_AT_type attribute.

However, gfortran does not include a DW_AT_type, its DWARF instead
relies on the default target type.  This isn't currently a problem for
GDB as gfortran doesn't make use of the target type when printing
subranges, but it shouldn't hurt to fix this issue now.

I've added an assert into create_range_type that will catch this issue
if it comes up again.

This was tested on an x86-64/GNU-Linux machine with both the Ada and
gfortran compilers available with both '--target_board=unix' and
'--target_board=unix/-m32'.  There are no user visible changes after
this commit.

gdb/ChangeLog:

* dwarf2read.c (read_subrange_index_type): New function.
(read_subrange_type): Move code into new function and call it.
* gdbtypes.c (create_range_type): Add some asserts.
gdb/ChangeLog
gdb/dwarf2read.c
gdb/gdbtypes.c
This page took 0.025273 seconds and 4 git commands to generate.