[Lldb-commits] [PATCH] D53506: [ClangASTContext] Extract VTable pointers from C++ objects

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 22 09:56:18 PDT 2018


zturner added a comment.

In https://reviews.llvm.org/D53506#1270919, @aleksandr.urakov wrote:

> In https://reviews.llvm.org/D53506#1270893, @zturner wrote:
>
> > What's missing that you're unable to restore the VBase offset properly?
>
>
> If I understand correctly, in the PDB there is only info about offset to VTablePtr and index in VTable, so there is enough info to retrieve VBase offset fairly, and we do it in that way. But there's no info in PDB about offset to VBase directly from object. This info is used when the "fair" doesn't work (e.g. at line 6640). This patch just makes the "fair" way to work in more cases.


My understanding of record layout with virtual bases is still sketchy (it's very confusing), and it's even worse with DIA because the API is so general and poorly documented, so let's go to the low-level CodeView records.

  typedef struct lfVBClass {
      unsigned short  leaf;           // LF_VBCLASS (virtual base) | LV_IVBCLASS (indirect virtual base)
      CV_fldattr_t    attr;           // attribute
      CV_typ_t        index;          // type index of direct virtual base class
      CV_typ_t        vbptr;          // type index of virtual base pointer
      unsigned char   vbpoff[CV_ZEROLEN];       // virtual base pointer offset from address point
                                      // followed by virtual base offset from vbtable
  } lfVBClass;

This is what we have access to reading directly from the raw pdb file, which is sometimes more information than what we have access to using DIA.  Of course, we also have to interpret whether this actually means what we think it means by inspecting the bytes of a C++ object in a debugger and comparing the layout to what the debug info tells us.

So, the point is, just because we don't have access to the info via DIA doesn't mean we won't have access to the info once the native pdb plugin is complete.  Just something to think about.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53506





More information about the lldb-commits mailing list