[PATCH 1/4] gas/Dwarf: improve debug info generation from .irp and alike blocks

Jan Beulich jbeulich@suse.com
Tue Mar 22 14:56:30 GMT 2022


On 22.03.2022 15:18, Nick Clifton wrote:
>> As to .file being required for .line to have any effect (see as_where()
>> for why this is) - that's not documented anywhere afaics, and hence I
>> wonder whether this isn't another bug.
> 
> Is that right ?  Looking at the code, it seems to me that either
> physical_file_name or logical_file_name would have to be set any time a
> .line directive is encountered.  Is there a sceanario where this does
> not happen ?

Well, yes, from my testing removing the .file from the new testcase
renders the .line there meaningless (as far as debug info generation
goes). For as_where() to return logical_input_{file,line},
logical_input_file needs to be non-NULL; as long as it falls back to
as_where_physical(), the checking that file/line have actually
changed would prevent new information to be recorded. But of course if
the problem described below was fixed, I think the problem here would
vanish as a side effect (except that actual line numbers recorded may
then still be sub-optimal).

>> dwarf2_gen_line_info() bailing when finding the line number unchanged is
>> a problem elsewhere as well, I think: Shouldn't it also take into
>> consideration whether now_{,sub}seg have changed? After all
>> .debug_aranges and .debug_rnglists are populated from the collected info
>> as well, and with them incomplete analysis or debugging tools won't have
>> a complete view of the sections a source file contributes to. The issue
>> with it not doing so can actually be seen when removing one of the .nop
>> in the new testcase ...
> 
> Agreed - this should be examined and fixed.

Any thoughts regarding the mentioned checking of now_seg / now_subseg
there, to deal with this?

>> Further I wonder about line numbers for directives which actually
>> generate code: .nop is documented to have debug info generated, whereas
>> .nops is explicitly documented to not have this effect (for whatever
>> reason). Other directives have nothing stated, and most don't generate
>> debug info - not even ones specifically there to generate instructions,
>> like e.g. Arm's .inst (but unlike RISC-V's .insn).
> 
> The target specific instruction directives definitely should generate DWARF
> info, so if they don't it is a bug.

Okay, so at least Arm would seem to need fixing. I'll see if I can get
to this.

Do you have an idea why .nops is explicitly documented to not generate
debug info? And can you provide any insight on why e.g. .byte wouldn't
want to have line number info generated when used in an executable
section?

> Anyway, patch, and testcase, approved - please apply.

Thanks (including the other approvals).

Jan



More information about the Binutils mailing list