[PATCH] D75043: [DWARFDebugLine] Avoid dumping prologue members we did not parse

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 05:03:02 PST 2020


labath created this revision.
labath added reviewers: jhenderson, ikudrin, dblaikie.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This patch if motivated by D74560 <https://reviews.llvm.org/D74560>, specifically the subthread about what
to print upon encountering reserved initial length values.

If the debug_line prologue has an unsupported version, we skip parsing
the rest of the data. If we encounter an reserved initial length field,
we don't even parse the version. However, we still print out all members
(with value 0) in the dump function.

This patch introduces early exits in the Prologue::dump function so that
we print only the fields that were parsed successfully. In case of an
unsupported version, we skip printing all subsequent prologue fields --
because we don't even know if this version has those field. In case of a
reserved unit length, we don't print anything -- if the very first field
of the prologue is invalid, it's hard to say if we even have a prologue
to begin with.

Note that the user will still be able to see the invalid/reserved
initial length value in the error message. I've modified (reordered)
debug_line_invalid.test to show that the error message comes straight
after the debug_line offset. I've also added some flush() calls to the
dumping code to ensure this is the case in all situations (without that,
the warnings could get out of sync if the output was not a terminal -- I
guess this is why std::iostreams have the tie() function).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75043

Files:
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75043.246184.patch
Type: text/x-patch
Size: 16325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200224/05b9c4ef/attachment.bin>


More information about the llvm-commits mailing list