[PATCH] D81470: [DebugInfo] Report errors for truncated debug line standard opcode

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 10:25:38 PDT 2020


JDevlieghere added inline comments.


================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:940
         {
-          uint64_t AddrOffset = State.advanceAddr(
-              TableData.getULEB128(OffsetPtr), Opcode, OpcodeOffset);
-          if (Verbose)
-            *OS << " (" << AddrOffset << ")";
+          uint64_t Operand = TableData.getULEB128(Cursor);
+          if (Cursor) {
----------------
A helper function might simplify this code a little bit:

```
template <typename T>
Optional<T> parseULEB128(DWARFDataExtractor &TableData,
                         DataExtractor::Cursor &Cursor) {
  T Value = TableData.getULEB128(Cursor);
  if (Cursor)
    return Value;
  return {};
}
```

```
        if (auto Operand = parseULEB128<uint64_t>(TableData, Cursor)) {
          uint64_t AddrOffset =
              State.advanceAddr(*Operand, Opcode, OpcodeOffset);
          if (Verbose)
            *OS << " (" << AddrOffset << ")";
        }
```

I was considering making the helper more generic so it could do both ULEB and SLEB but I don't think that's worth the extra complexity. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81470





More information about the llvm-commits mailing list