Re: Source info in discontiguous hand asm files

Daniel Jacobowitz
2006-05-04T12:45:47Z

On Thu, May 04, 2006 at 02:06:08AM -0700, Ross Morley wrote:
> Yes, it is correct, though not as extensive as it could be.
> In the case where there are multiple ranges of text in a compilation
> unit, DA_AT_{low,high}_pc is omitted from the CU per DWARF spec.
> Where there is only one range of text, those are present and correct.
> The assembler doesn't add function-specific info.
> There is info in the aranges table to associate the ranges with the
> compilation unit, so a scan of that table could provide it.

The section .debug_info contains:

Compilation Unit @ offset 0x0:
Length: 52
Version: 2
Abbrev Offset: 0
Pointer Size: 8
<0>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_name : text.S
DW_AT_comp_dir : /home/drow/text
DW_AT_producer : GNU AS 2.16.91
DW_AT_language : 32769 (MIPS assembler)

From the DWARF standard:

Compilation unit entries may have the following attributes:

1. Either a DW_AT_low_pc and DW_AT_high_pc pair of attributes or a
DW_AT_ranges attribute whose values encode the contiguous or
non-contiguous address ranges, respectively, of the machine
instructions generated for the compilation unit (see Section 2.16).

A DW_AT_low_pc attribute may also be specified in combination with
DW_AT_ranges to specify the default base address for use in location
lists (see Section 2.5.4) and range lists (see Section 2.16.3).

Now, there's a "may" there, so the compilation unit clearly isn't
required to have either. But GDB definitely expects a compilation unit
to have one or the other. It does not implement .debug_aranges
support.

So, your options are to use .debug_aranges to look up textlow/texthigh
for compilation units that don't have a PC range, or to modify gas to
emit DW_AT_ranges. The latter is likely to be easier.

--
Daniel Jacobowitz
CodeSourcery