@@ -1231,19 +1231,25 @@ private void findDirectBaseVxtPtrs(VxtManager vxtManager) {
12311231 // Note that if the parent has already had its layout done, it will not have
12321232 // used the vxtManager that we are passing in here; it will have used whatever
12331233 // was passed to the layout method for that class
1234- for (VxtPtrInfo parentInfo : cppBaseType .getPropagatedSelfBaseVfts ()) {
1235- VxtPtrInfo newInfo =
1236- createSelfOwnedDirectVxtPtrInfo (parentInfo , baseId , baseOffset );
1237- updateVft (vxtManager , baseId , newInfo , parentInfo );
1238- storeVxtInfo (propagatedSelfBaseVfts , finalVftPtrInfoByOffset , vftTableIdByOffset ,
1239- vftOffsetByTableId , newInfo );
1234+ if (cppBaseType .getPropagatedSelfBaseVfts () != null ) {
1235+ for (VxtPtrInfo parentInfo : cppBaseType .getPropagatedSelfBaseVfts ()) {
1236+ VxtPtrInfo newInfo =
1237+ createSelfOwnedDirectVxtPtrInfo (parentInfo , baseId , baseOffset );
1238+ updateVft (vxtManager , baseId , newInfo , parentInfo );
1239+ storeVxtInfo (propagatedSelfBaseVfts , finalVftPtrInfoByOffset ,
1240+ vftTableIdByOffset ,
1241+ vftOffsetByTableId , newInfo );
1242+ }
12401243 }
1241- for (VxtPtrInfo parentInfo : cppBaseType .getPropagatedSelfBaseVbts ()) {
1242- VxtPtrInfo newInfo =
1243- createSelfOwnedDirectVxtPtrInfo (parentInfo , baseId , baseOffset );
1244- updateVbt (vxtManager , baseId , newInfo , parentInfo );
1245- storeVxtInfo (propagatedSelfBaseVbts , finalVbtPtrInfoByOffset , vbtTableIdByOffset ,
1246- vbtOffsetByTableId , newInfo );
1244+ if (cppBaseType .getPropagatedSelfBaseVbts () != null ) {
1245+ for (VxtPtrInfo parentInfo : cppBaseType .getPropagatedSelfBaseVbts ()) {
1246+ VxtPtrInfo newInfo =
1247+ createSelfOwnedDirectVxtPtrInfo (parentInfo , baseId , baseOffset );
1248+ updateVbt (vxtManager , baseId , newInfo , parentInfo );
1249+ storeVxtInfo (propagatedSelfBaseVbts , finalVbtPtrInfoByOffset ,
1250+ vbtTableIdByOffset ,
1251+ vbtOffsetByTableId , newInfo );
1252+ }
12471253 }
12481254 }
12491255 }
@@ -1253,8 +1259,9 @@ private void findDirectBaseVxtPtrs(VxtManager vxtManager) {
12531259 * virtual bases. Gathers results from the accumulation of all "direct" virtual base classes;
12541260 * we are not relying on the "indirect" virtual base class information from the PDB. This
12551261 * is done this way so that we can collect parentage information for the pointers.
1262+ * @throws PdbException upon issue finding base offset
12561263 */
1257- private void findVirtualBaseVxtPtrs (MsftVxtManager vxtManager ) {
1264+ private void findVirtualBaseVxtPtrs (MsftVxtManager vxtManager ) throws PdbException {
12581265 // Walk direct bases to find vxts of virtual bases. TODO: also notate all rolled up
12591266 // virtuals for each direct base.
12601267 for (DirectLayoutBaseClass base : directLayoutBaseClasses ) {
@@ -1396,10 +1403,16 @@ private VxtPtrInfo createVirtualOwnedSelfVxtPtrInfo(VxtPtrInfo baseInfo, ClassID
13961403 * Converts VxtPtrInfo from virtual-based-owned direct or indirect virtual base for this class
13971404 * @param baseInfo the vxt info from the base
13981405 * @return the new VxtPtrInfo for this class
1406+ * @throws PdbException upon issue getting base offset
13991407 */
1400- private VxtPtrInfo createVirtualOwnedVirtualVxtPtrInfo (VxtPtrInfo baseInfo ) {
1408+ private VxtPtrInfo createVirtualOwnedVirtualVxtPtrInfo (VxtPtrInfo baseInfo )
1409+ throws PdbException {
14011410 Long accumOffset = baseInfo .accumOffset ();
1402- Long finalOffset = accumOffset + baseOffsetById .get (baseInfo .baseId ());
1411+ Long baseOffset = baseOffsetById .get (baseInfo .baseId ());
1412+ if (baseOffset == null ) {
1413+ throw new PdbException ("Cannot find base offset" );
1414+ }
1415+ Long finalOffset = accumOffset + baseOffset ;
14031416 return new VxtPtrInfo (finalOffset , accumOffset , baseInfo .baseId (),
14041417 updateParentage (baseInfo ));
14051418 }
@@ -1440,20 +1453,10 @@ private void findOrAllocateMainVftPtr(MsftVxtManager vxtManager) {
14401453 myVftPtrOffset = vftPtrTypeByOffset .firstKey ();
14411454 VxtPtrInfo info =
14421455 new VxtPtrInfo (myVftPtrOffset , myVftPtrOffset , myId , List .of (myId ));
1443- VirtualFunctionTable myVft =
1444- vxtManager .findVft (myId , List .of (myId ));
1445- if (myVft != null ) {
1446- myVft .setPtrOffsetInClass (info .finalOffset ());
1447- propagatedSelfBaseVfts .add (info );
1448- finalVftByOffset .put (info .finalOffset (), myVft );
1449- }
1450- else {
1451- PlaceholderVirtualFunctionTable t = new PlaceholderVirtualFunctionTable (
1452- myId , List .of (myId ));
1453- t .setPtrOffsetInClass (info .finalOffset ());
1454- propagatedSelfBaseVfts .add (info );
1455- finalVftByOffset .put (info .finalOffset (), t );
1456- }
1456+ VirtualFunctionTable myVft = vxtManager .findVft (myId , info .parentage ());
1457+ myVft .setPtrOffsetInClass (info .finalOffset ());
1458+ propagatedSelfBaseVfts .add (info );
1459+ finalVftByOffset .put (info .finalOffset (), myVft );
14571460 finalVftPtrInfoByOffset .put (info .accumOffset (), info );
14581461 OwnerParentage op = new OwnerParentage (info .baseId (), info .parentage ());
14591462 vftTableIdByOffset .put (info .accumOffset (), op );
@@ -1473,8 +1476,8 @@ private void findOrAllocateMainVftPtr(MsftVxtManager vxtManager) {
14731476 * structure
14741477 */
14751478 private void findOrAllocateMainVbtPtr (MsftVxtManager vxtManager ) {
1476- if (propagatedSelfBaseVbts .isEmpty ()) {
1477- if (!virtualLayoutBaseClasses .isEmpty ()) {
1479+ if (propagatedSelfBaseVbts .isEmpty ()) { // a pointer might be available in a direct base
1480+ if (!virtualLayoutBaseClasses .isEmpty ()) { // there is a need for a main vbtptr
14781481 TreeSet <Long > vbtOffsets = new TreeSet <>();
14791482 for (VirtualLayoutBaseClass base : virtualLayoutBaseClasses ) {
14801483 vbtOffsets .add ((long ) base .getBasePointerOffset ());
@@ -1487,12 +1490,10 @@ private void findOrAllocateMainVbtPtr(MsftVxtManager vxtManager) {
14871490 Msg .warn (this , "Mismatch vbt location for " + myId );
14881491 }
14891492 VxtPtrInfo info = new VxtPtrInfo (vbtPtrOffset , vbtPtrOffset , myId , List .of (myId ));
1490- VirtualBaseTable myVbt = vxtManager .findVbt (myId , List .of (myId ));
1491- if (myVbt != null ) {
1492- myVbt .setPtrOffsetInClass (info .finalOffset ());
1493- propagatedSelfBaseVbts .add (info );
1494- finalVbtByOffset .put (info .finalOffset (), myVbt );
1495- }
1493+ VirtualBaseTable myVbt = vxtManager .findVbt (myId , info .parentage ());
1494+ myVbt .setPtrOffsetInClass (info .finalOffset ());
1495+ propagatedSelfBaseVbts .add (info );
1496+ finalVbtByOffset .put (info .finalOffset (), myVbt );
14961497 finalVbtPtrInfoByOffset .put (info .accumOffset (), info );
14971498 OwnerParentage op = new OwnerParentage (info .baseId (), info .parentage ());
14981499 vbtTableIdByOffset .put (info .accumOffset (), op );
@@ -1699,7 +1700,7 @@ private VirtualBaseTable updateVbt(VxtManager vxtManager, ClassID baseId, VxtPtr
16991700 private VirtualFunctionTable getMainVft (MsftVxtManager vxtManager ) throws PdbException {
17001701 if (!finalVftPtrInfoByOffset .isEmpty ()) {
17011702 VxtPtrInfo firstVftPtrInfo = finalVftPtrInfoByOffset .firstEntry ().getValue ();
1702- VirtualFunctionTable vft = vxtManager .findVft (myId , firstVftPtrInfo .parentage ());
1703+ VirtualFunctionTable vft = vxtManager .findPrimaryVft (myId , firstVftPtrInfo .parentage ());
17031704 return vft ;
17041705 // Following is for consideration for testing without a program:
17051706// if (vft instanceof ProgramVirtualFunctionTable pvft) {
@@ -1723,7 +1724,7 @@ private VirtualFunctionTable getMainVft(MsftVxtManager vxtManager) throws PdbExc
17231724 private VirtualBaseTable getMainVbt (MsftVxtManager vxtManager ) throws PdbException {
17241725 if (!finalVbtPtrInfoByOffset .isEmpty ()) {
17251726 VxtPtrInfo firstVbtPtrInfo = finalVbtPtrInfoByOffset .firstEntry ().getValue ();
1726- VirtualBaseTable vbt = vxtManager .findVbt (myId , firstVbtPtrInfo .parentage ());
1727+ VirtualBaseTable vbt = vxtManager .findPrimaryVbt (myId , firstVbtPtrInfo .parentage ());
17271728 if (vbt instanceof ProgramVirtualBaseTable pvbt ) {
17281729 return pvbt ;
17291730 }
@@ -1747,8 +1748,10 @@ else if (vbt instanceof PlaceholderVirtualBaseTable plvbt) {
17471748 return plvbt ;
17481749 }
17491750 else {
1750- throw new PdbException (
1751- "VBT type not expected: " + vbt .getClass ().getSimpleName ());
1751+ if (vbt != null ) {
1752+ throw new PdbException (
1753+ "VBT type not expected: " + vbt .getClass ().getSimpleName ());
1754+ }
17521755 }
17531756 }
17541757 return null ;
0 commit comments