zequanwu added a comment. >> 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. > > Yes, so should we take the offsets from the debug info and provide them to > clang (so that it does not have to recompute the offsets) ?
Oh, it's already there <https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp#L259>. This patch just add the missing bit_size. >>> 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. > > Imagine a class like `struct B : A { virtual void foo(); int b; };` and two > classes like `struct A1 { virtual void bar(); }; struct A2 { void *a; };`. > Both A1 and A2 have the same size (`sizeof(void *)`), but that doesn't mean > the layout of B will be the same if we substitute it for the base > <https://godbolt.org/z/rT98cxq53>. If A = A1, then B will reuse the vtable > pointer of the base, and `offsetof(B, b)` will be 8. That can't happen with > A2, so the compiler will create a new vtable pointer and `b` offset will be > 16 (2*sizeof(void)) (at least that's how it works in the itanium ABI, but I'm > sure you could create something similar with the MSVC ABI as well). If you > don't have the definition of A, then you just can't know which of these two > cases you are in. That's why I think that getting the member locations from > the debug info is important. Yeah, in this case, pdb has the info: offsetof(B<A1>, b) == 8 and offsetof(B<A2>, b) == 16. And they are added into `LayoutInfo::field_offsets`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134656/new/ https://reviews.llvm.org/D134656 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits