[PATCH] D81570: [DebugInfo] Don't print extended opcode operands if invalid

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 22 07:30:23 PDT 2020


jhenderson marked an inline comment as done.
jhenderson added a comment.

In D81570#2106512 <https://reviews.llvm.org/D81570#2106512>, @ikudrin wrote:

> Oh, and there are still no tests with unknown opcodes and truncated operands.


Oops, missed that bit of your earlier comment. Thanks.



================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:937-946
+        while (ByteCursor && ByteCursor.tell() < End) {
+          uint8_t Byte = TableData.getU8(ByteCursor);
+          if (ByteCursor) {
+            if (ByteCursor.tell() == OperandOffset + 1)
+              *OS << " (<parsing error>";
+            *OS << format(" %2.2" PRIx8, Byte);
+          }
----------------
ikudrin wrote:
> I suppose that this might be simplified a bit using a `do-while` loop. Something like this:
> ```
> uint8_t Byte = TableData.getU8(ByteCursor);
> if (ByteCursor) {
>   *OS << " (<parsing error>";
>   do {
>     *OS << format(" %2.2" PRIx8, Byte);
>     Byte = TableData.getU8(ByteCursor);
>   } while (ByteCursor);
>   *OS << ")";
> }
> ```
> WDYT?
I think that makes sense. I previously didn't do that, since it didn't seem to interact well with the `ByteCursor.tell() < End`, but looking at it again, I realise that bit is irrelevant, since we can just keep parsing until the end, and then ignore the error like we're already doing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81570/new/

https://reviews.llvm.org/D81570





More information about the llvm-commits mailing list