[Lldb-commits] [PATCH] D101237: [lldb] Fix [[no_unique_address]] and libstdc++ 11's std::unique_ptr

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 30 05:23:44 PDT 2021


teemperor added a comment.

> (and it could tell clang exactly how large the structure is too - from the DWARF)

We are actually doing that to my knowledge and return the `DW_AT_byte_size` value for the record type. The relevant API that LLDB implements to get layout/size info back to Clang is:

  bool layoutRecordType(
      const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
      llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
          &BaseOffsets,
      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
          &VirtualBaseOffsets) override;

I think the `sizeof` part actually works* in this regard as we just return whatever we got from DWARF. I get the correct results for the example above (both with and without this patch). There might be some weirder corner cases that could go wrong but I think the main concern are more complicated situations like in the crash that is fixed here.

FWIW, I took a look at the DWARF standard and I think that is actually something we should already emit in the form of a `DW_AT_byte_size 0` attribute at the field? Quote:

  If the size of a data member is not the same as the size of the type given for the data member, the data member has either a DW_AT_byte_size or a DW_AT_bit_size attribute whose integer constant value (see Section 2.19) is the amount of storage needed to hold the value of the data member.

I am not a DWARF laywer so maybe I understand that part wrong.

(*I actually found a bug that miscalculated empty structs while testing, but that's unrelated. Patch incoming).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101237



More information about the lldb-commits mailing list