[Lldb-commits] [PATCH] D134656: [LLDB][NativePDB] Add class/union layout bit size.

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 27 11:23:20 PDT 2022


zequanwu added a comment.

In D134656#3818234 <https://reviews.llvm.org/D134656#3818234>, @labath wrote:

> That said, I am kinda surprised that this is the whole thing. I would have expected to see more here. In dwarf we specify the offsets of individual class members. Does PDB encode that information?

Yes. It has offsets to non-inherited individual class members. For members from parent classes, pdb only has information saying that its direct parents class are at some offsets for this class. For class without vtable, it's easy to calculate inherited member offsets by adding parent class offsets with their member offsets. For class with vtable, it's more complicated to calculate the offsets.

> If not, how does it handle the case when the definition of some class is missing? If that class is a member of some other class, the offsets of all subsequent members in the bigger class will be wrong? That will probably be true even if we are always able to obtain the size of the smaller class, because of things like vtable pointers.

I don't quite understand this. vtable pointers are ignored in this visitor https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp#L136-L139.



================
Comment at: lldb/test/Shell/SymbolFile/NativePDB/packed_class_layout.cpp:24
+
+union __attribute__((packed, aligned(1))) U {
+  char c[2];
----------------
labath wrote:
> I suspect these attributes do not materially change the layout of the union when it stands on its own. It might be more interesting to take this under-aligned union, place it into a (regular) struct, and then check whether we can print it correctly.
Yeah, it doesn't change layout of the union. Moved to a struct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134656



More information about the lldb-commits mailing list