This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Set discriminator to 0 for DW_LNS_copy
ClosedPublic

Authored by MaskRay on Apr 6 2019, 9:24 AM.

Details

Summary

Make DW_LNS_copy set the discriminator register to 0, to conform to
DWARF 4 & 5: "Then it sets the discriminator register to 0, and sets the
basic_block, prologue_end and epilogue_begin registers to false."

Because all of DW_LNE_end_sequence, DN_LNS_copy, and special opcodes reset
discriminator to 0, we can move discriminator=0 to appendRowToMatrix.

Also, make DW_LNS_copy print before appending the row, as it is similar
to a address+=0,line+=0 special opcode, which prints before appending
the row.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Apr 6 2019, 9:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2019, 9:24 AM

+Dehao who I believe did the discriminator work in the first place.

ormris removed a subscriber: ormris.Apr 8 2019, 8:57 AM

Should there also be an LLVM test - given that LLVM does emit DW_LNS_copy by the looks of it, and if it's been being incorrectly interpreted/dumped, then that seems to imply there's some missing LLVM test coverage for that case, maybe?

Should there also be an LLVM test - given that LLVM does emit DW_LNS_copy by the looks of it, and if it's been being incorrectly interpreted/dumped, then that seems to imply there's some missing LLVM test coverage for that case, maybe?

Do you mean a test of lib/MC/MCDwarf.cpp? As I understand it, lib/DebugInfo/DWARF is mostly the reader part and MC the writer part. With my casual reading, MCDwarf.cpp seems to do the correct thing by doing Discriminator = 0;. I haven't looked into that part yet but I can investigate that and add a test if needed in a separate change.

dblaikie accepted this revision.Apr 10 2019, 2:23 PM

Should there also be an LLVM test - given that LLVM does emit DW_LNS_copy by the looks of it, and if it's been being incorrectly interpreted/dumped, then that seems to imply there's some missing LLVM test coverage for that case, maybe?

Do you mean a test of lib/MC/MCDwarf.cpp? As I understand it, lib/DebugInfo/DWARF is mostly the reader part and MC the writer part. With my casual reading, MCDwarf.cpp seems to do the correct thing by doing Discriminator = 0;. I haven't looked into that part yet but I can investigate that and add a test if needed in a separate change.

Right (& yes, lib/DebugInfo is for reading, lib/MC is for writing) - it seems likely lib/MC is doing the right thing, but it might be missing some test coverage (given the bug in the dumper, it should've been visible in some test case).

But this patch looks generally good.

This revision is now accepted and ready to land.Apr 10 2019, 2:23 PM
MaskRay updated this revision to Diff 194628.Apr 10 2019, 6:57 PM

Rebase and fix DW_LNCT_directory_index in the test (2 -> 0)

This revision was automatically updated to reflect the committed changes.