[Dwarf-Discuss] Using DW_TAG_imported_declaration with Fortran's DW_TAG_namelist

Cary Coutant ccoutant at gmail.com
Mon Nov 18 21:34:15 PST 2013


(Putting this discussion back on the original thread…)

>>> ---[ sketch of DWARF for file 2 ]---
>>>
>>> DW_TAG_subprogram 'read_nml'
>>>   DW_TAG_imported_declaration '/nml'
>>>     DW_AT_import DW_FORM_ref_addr [ somehow a reference to $1 ]
>>
>> Well, that's probably the problem: The "somehow". If the files are generated independently, the "reference to $1" is not available. At least that's how I understand it. (My DWARF knowledge is rather weak.)
>
> At least on ELF and PECOFF platforms it's perfectly possible: you just insert a reference to a global symbol declared in the DWARF section of another object file. Our compiler doesn't use this particular tag, but at least for e.g. DW_TAG_typedef it works fine with gdb.

Yes, but the compiler has to anticipate the need for the reference by
generating a global symbol when compiling the other file. This is why
DW_FORM_ref_addr isn't used much outside of contexts where the entire
program is visible (e.g., dwz).

Another problem with using DW_FORM_ref_addr is that it's not
compatible with split dwarf (aka "Fission"), because the .dwo files
are stripped of both ELF symbols and relocations.

I think it'd probably be simpler to just emit an empty
DW_TAG_namelist, maybe with the DW_AT_declaration flag set. Let the
debugger find the definition of the namelist via the DW_AT_name.

-cary



More information about the Dwarf-Discuss mailing list