This is an archive of the discontinued LLVM Phabricator instance.

[DWARFv5] Emit .debug_line_str (in a non-DWO file)
ClosedPublic

Authored by probinson on Jan 30 2018, 1:48 PM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

probinson created this revision.Jan 30 2018, 1:48 PM
aprantl accepted this revision.Jan 30 2018, 1:57 PM

Looks reasonable.

llvm/lib/MC/MCDwarf.cpp
321 ↗(On Diff #132043)

Sounds like a std::vector<uint_8t> or something would also be sufficient (but I'm not sure if that's any more efficient).

This revision is now accepted and ready to land.Jan 30 2018, 1:57 PM
probinson added inline comments.Jan 30 2018, 2:15 PM
llvm/lib/MC/MCDwarf.cpp
321 ↗(On Diff #132043)

This sequence is cargo-culting StringTableBuilder::write(raw_ostream&). I don't think a std::vector would be any more efficient, and EmitBinaryData wants a StringRef anyway which I'd have to construct manually.

dblaikie added inline comments.Jan 30 2018, 2:27 PM
llvm/lib/MC/MCDwarf.cpp
78 ↗(On Diff #132043)

Any op bool should be marked explicit - otherwise there's all manner of implicit conversions that can get weird.

482 ↗(On Diff #132043)

I'm not quite sure - is there a reason that emitV5FileDirTables handle the whole MCDwarfLineStr functionality internally without having to pass in an MCDwarfLineStr object? (emitV5FileDirTables could create the MCDwarfLineStr locally, potentially & emit it immediately?)?

llvm/test/MC/ELF/debug-md5.s
20–25 ↗(On Diff #132043)

Any way to test that the line table is actually using the indexes into the debug_line_str section?

probinson added inline comments.Jan 30 2018, 4:43 PM
llvm/lib/MC/MCDwarf.cpp
78 ↗(On Diff #132043)

Got it.
Would you rather have it be a normal predicate method? I went with operator bool mainly for compactness.

482 ↗(On Diff #132043)

When there are multiple CUs (e.g. LTO) we want the MCDwarfLineStr instance to span emitting all of them. Otherwise we can get multiple instances of the same path in the same .debug_line_str section, in a single .o file.
I could have put MCDwarfLineStr in the MCContext, but this way we have better data hiding.
Also we need a parameter of some kind anyway, to distinguish the DWO and non-DWO cases.

llvm/test/MC/ELF/debug-md5.s
20–25 ↗(On Diff #132043)

Maybe, when printing the directory/file names we could print the section+index when they're indirect. I'll look into that.

probinson added inline comments.Jan 31 2018, 11:42 AM
llvm/test/MC/ELF/debug-md5.s
20–25 ↗(On Diff #132043)

So, this would be a missing feature in llvm-dwarfdump, which doesn't provide a way to dump the section/index pointed to by an indirect reference in the line table (like it does in .debug_info). In fact by the time we're dumping the line table header, the relevant information is long gone.
That should be its own patch. Follow-up, or put this on hold to wait for it?

dblaikie added inline comments.Jan 31 2018, 2:31 PM
llvm/lib/MC/MCDwarf.cpp
78 ↗(On Diff #132043)

Nah - op bool is OK, if it's expliict - and it'll still be usable implicitly in bool contexts like "if (x)".

Though, alternatively, I wonder if it'd be better to not give this object the extra state - and pass through a null pointer instead of a 'false' MCDwarfLineStr object? It looks like it's only constructed in one place & so the check for DWARF version could go there rather than inside this class & the other caller could pass null?

482 ↗(On Diff #132043)

Ah, right, the line table's one of the things that's not shared between CUs (unlike the abbrev table and string pool, etc - and the line string pool).

llvm/test/MC/ELF/debug-md5.s
20–25 ↗(On Diff #132043)

(replied to this on-list too, but: Whichever order you like)

probinson updated this revision to Diff 132930.Feb 5 2018, 7:18 PM

Address review comments:
Pass the MCDwarfLineStr around by pointer, eliminating the operator-bool;
use new dwarfdump feature in the test to show the section for the string references;
put more responsibility on the (only) user of the class.

That last bit is not really my preference, but as this new class is basically an implementation detail within MCDwarf.cpp I think it should be okay.

dblaikie accepted this revision.Feb 5 2018, 7:21 PM
dblaikie added inline comments.
llvm/lib/MC/MCDwarf.cpp
245–246 ↗(On Diff #132930)

Maybe using an Optional<MCDwarfLineStr> (you've got the bool and the MCDwarfLineStr there already, this would just wrap it up together & avoid the construction of an MCDwarfLineStr when it's not used)

This revision was automatically updated to reflect the committed changes.