Don't print wNumVirtuals wNumVtableSlots if they're 0 (#4760)
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Fri, 2 Aug 2024 17:49:38 +0000 (13:49 -0400)
committerGitHub <noreply@github.com>
Fri, 2 Aug 2024 17:49:38 +0000 (10:49 -0700)
Since .NET 9 the runtime will always set these MethodTableData fields to
0

src/SOS/Strike/strike.cpp

index 282182b23ad4b75d5df40a13e9533ea8a9852856..70e2a1dbdaf3d7feed127c0625ebef8965bbafd5 100644 (file)
@@ -1096,8 +1096,14 @@ DECLARE_API(DumpClass)
     {
         DMLOut("Canonical MethodTable: %s\n", DMLClass(mtdata.Class));
     }
-    ExtOut("Vtable Slots:    %x\n", mtdata.wNumVirtuals);
-    ExtOut("Total Method Slots:  %x\n", mtdata.wNumVtableSlots);
+    if (mtdata.wNumVirtuals != 0)
+    {
+        ExtOut("Vtable Slots:    %x\n", mtdata.wNumVirtuals);
+    }
+    if (mtdata.wNumVtableSlots != 0)
+    {
+        ExtOut("Total Method Slots:  %x\n", mtdata.wNumVtableSlots);
+    }
     ExtOut("Class Attributes:    %x  ", mtdata.dwAttrClass);
 
     if (IsTdInterface(mtdata.dwAttrClass))
@@ -1252,7 +1258,7 @@ DECLARE_API(DumpMT)
     table.WriteRow("ComponentSize:", PrefixHex(vMethTable.ComponentSize));
     table.WriteRow("DynamicStatics:", vMethTable.bIsDynamic ? "true" : "false");
     table.WriteRow("ContainsPointers:", vMethTable.bContainsPointers ? "true" : "false");
-    table.WriteRow("Slots in VTable:", Decimal(vMethTable.wNumMethods));
+    table.WriteRow("Number of Methods:", Decimal(vMethTable.wNumMethods));
 
     table.SetColWidth(0, 29);
     table.WriteRow("Number of IFaces in IFaceMap:", Decimal(vMethTable.wNumInterfaces));