This is an archive of the discontinued LLVM Phabricator instance.

[ObjectYAML][ELF] Add support for emitting the .debug_line section.

Authored by Higuoxing on Jun 9 2020, 2:22 AM.



This patch enables yaml2elf emit the .debug_line section.

Test cases for emitting the dwarf64 .debug_line section and opcodes will be added later.

Known issues:

  • We should replace InitialLength with Format and Length
  • Currently implementation of the .debug_line section only fully supports DWARFv2, some header fields in DWARFv4 and DWARFv5 is missing, e.g., header_length in DWARFv4, address_size and segment_selector_size in DWARFv5.
  • Some opcodes relies on the .debug_info section, we should warn user about it.

These issues will be addressed in a follow-up patch.

Diff Detail

Event Timeline

Higuoxing created this revision.Jun 9 2020, 2:22 AM
jhenderson added inline comments.Jun 9 2020, 2:57 AM

As a suggestion, how about you make these somewhat less default values. For example:

MinInstLength:  1
DefaultIsStmt:  2
LineBase:       3
LineRange:      4
OpcodeBase:     5
StandardOpcodeLengths: [ 0, 1, 2, 3, 4 ]

You could probably even do that for the other fields too.

Higuoxing updated this revision to Diff 269482.Jun 9 2020, 3:46 AM

Use some non-default values in the header.

Higuoxing marked an inline comment as done.Jun 9 2020, 3:47 AM
jhenderson accepted this revision.Jun 9 2020, 4:26 AM

Thanks, LGTM, but best wait for @grimar to check too.

This revision is now accepted and ready to land.Jun 9 2020, 4:26 AM
grimar added inline comments.Jun 9 2020, 4:43 AM

Is it a reason not to do the same as done like in b) ?


FileCheck %s -DSIZE=10 -DADDRALIGN=0 --check-prefixes=SHDR,SIZE

I am not sure how much it is useful to check it, but anyways it looks probably it could be a generic test?
I.e. it could check that no .debug_* sections are emitted when there is an empty "DWARF" entry.

Perhaps it should be in a different test case file then.

Higuoxing updated this revision to Diff 269505.Jun 9 2020, 5:29 AM
Higuoxing marked 3 inline comments as done.

Address comments.

Thanks for reviewing!


Thanks, Can we do it in a follow-up patch? There are several testcases like this.

grimar added inline comments.Jun 9 2020, 6:17 AM


grimar accepted this revision.Jun 9 2020, 6:17 AM


This revision was automatically updated to reflect the committed changes.