[llvm] 26fee39 - Fixed NATVIS debug visualizers for LLVM

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 06:29:13 PDT 2023


Author: Aaron Ballman
Date: 2023-05-11T09:28:57-04:00
New Revision: 26fee39c2525111265825fe13f7f2aaa60095f87

URL: https://github.com/llvm/llvm-project/commit/26fee39c2525111265825fe13f7f2aaa60095f87
DIFF: https://github.com/llvm/llvm-project/commit/26fee39c2525111265825fe13f7f2aaa60095f87.diff

LOG: Fixed NATVIS debug visualizers for LLVM

This fixes the visualizers for:
PointerIntPair
PointerUnion
PointerIntPair<PointerUnion<*>, *>
StringMapEntry

and adds a visualizer for:
PunnedPointer

Added: 
    

Modified: 
    llvm/utils/LLVMVisualizers/llvm.natvis

Removed: 
    


################################################################################
diff  --git a/llvm/utils/LLVMVisualizers/llvm.natvis b/llvm/utils/LLVMVisualizers/llvm.natvis
index 2a34702709019..0fc50f79466a4 100644
--- a/llvm/utils/LLVMVisualizers/llvm.natvis
+++ b/llvm/utils/LLVMVisualizers/llvm.natvis
@@ -68,48 +68,54 @@ For later versions of Visual Studio, no setup is required.
     </Expand>
   </Type>
 
-  <!-- PointerIntPair. In addition to the regular view, it is possible to view just the pointer or just the int
-    The same code is duplicated from the regular viewer to improve the performance of the common case -->
+  <Type Name="llvm::PunnedPointer">
+    <DisplayString>{($T1)*(intptr_t *)Data}</DisplayString>
+  </Type>
+
+  <!-- PointerIntPair. In addition to the regular view, it is possible to view
+       just the pointer or just the int. The same code is duplicated from the
+       regular viewer to improve the performance of the common case. Note, we
+       need to specify PointerIntPair<PointerUnion<*>, *> 
diff erently because
+       we need to "look through" the PointerUnion to display it. Otherwise, we
+       get errors about ambiguous conversion from uintptr_t to PointerUnion.-->
+  <Type Name="llvm::PointerIntPair<llvm::PointerUnion<*>, *>">
+    <!-- $T1 is the parameter pack of PointerUnion, $T3 is IntBits,
+         $T4 is IntType, $T5 is PtrTraits, and $T6 is Info. -->
+    <DisplayString IncludeView="ptr">{($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask)}</DisplayString>
+    <DisplayString IncludeView="int">{($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask)}</DisplayString>
+    <DisplayString>{$T6::IntMask}: {($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask)} [{($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask)}]</DisplayString>
+    <Expand>
+      <Item Name="[ptr]">($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask)</Item>
+      <Item Name="[int]">($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask)</Item>
+    </Expand>
+  </Type>
+
   <Type Name="llvm::PointerIntPair<*>">
-    <DisplayString IncludeView="ptr">{($T1)(Value & $T5::PointerBitMask)}</DisplayString>
-    <DisplayString IncludeView="int">{($T3)((Value >> $T5::IntShift) & $T5::IntMask)}</DisplayString>
-    <DisplayString>{$T5::IntMask}: {($T1)(Value & $T5::PointerBitMask)} [{($T3)((Value >> $T5::IntShift) & $T5::IntMask)}]</DisplayString>
+    <DisplayString IncludeView="ptr">{($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask)}</DisplayString>
+    <DisplayString IncludeView="int">{($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask)}</DisplayString>
+    <DisplayString>{$T5::IntMask}: {($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask)} [{($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask)}]</DisplayString>
     <Expand>
-      <Item Name="[ptr]">($T1)(Value & $T5::PointerBitMask)</Item>
-      <Item Name="[int]">($T3)((Value >> $T5::IntShift) & $T5::IntMask)</Item>
+      <Item Name="[ptr]">($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask)</Item>
+      <Item Name="[int]">($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask)</Item>
     </Expand>
   </Type>
   <!-- PointerUnion types -->
   <Type Name="llvm::pointer_union_detail::PointerUnionMembers<*>">
-    <DisplayString Optional="true" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">
-      {($T4)(Val.Value & $T2::InfoTy::PointerBitMask)}
+    <DisplayString Optional="true" Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">
+      {($T4)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)}
     </DisplayString>
-    <DisplayString Optional="true" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">
-      {($T5)(Val.Value & $T2::InfoTy::PointerBitMask)}
+    <DisplayString Optional="true" Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">
+      {($T5)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)}
     </DisplayString>
-    <DisplayString Optional="true" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 2">
-      {($T6)(Val.Value & $T2::InfoTy::PointerBitMask)}
-    </DisplayString>
-    <DisplayString Optional="true" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 3">
-      {($T7)(Val.Value & $T2::InfoTy::PointerBitMask)}
-    </DisplayString>
-    <DisplayString>Unexpected index in PointerUnion: {(Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask}</DisplayString>
+    <DisplayString>Unexpected index in PointerUnion: {(*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask}</DisplayString>
     <Expand>
-      <Item Name="[Holds]" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">"$T4",s8b</Item>
-      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">
-        ($T4)(Val.Value & $T2::InfoTy::PointerBitMask)
-      </Item>
-      <Item Name="[Holds]" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">"$T5",s8b</Item>
-      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">
-        ($T5)(Val.Value & $T2::InfoTy::PointerBitMask)
-      </Item>
-      <Item Name="[Holds]" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 2">"$T6",s8b</Item>
-      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 2">
-        ($T6)(Val.Value & $T2::InfoTy::PointerBitMask)
+      <Item Name="[Holds]" Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">"$T4",s8b</Item>
+      <Item Name="[Ptr]" Optional="true"  Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 0">
+        ($T4)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)
       </Item>
-      <Item Name="[Holds]" Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 3">"$T6",s8b</Item>
-      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 3">
-        ($T7)(Val.Value & $T2::InfoTy::PointerBitMask)
+      <Item Name="[Holds]" Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">"$T5",s8b</Item>
+      <Item Name="[Ptr]" Optional="true"  Condition="((*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask) == 1">
+        ($T5)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)
       </Item>
     </Expand>
   </Type>
@@ -175,11 +181,11 @@ For later versions of Visual Studio, no setup is required.
   </Type>
 
   <Type Name="llvm::StringMapEntry<*>">
-    <DisplayString Condition="StrLen == 0">empty</DisplayString>
-    <DisplayString Condition="StrLen != 0">({this+1,s8}, {second})</DisplayString>
+    <DisplayString Condition="keyLength == 0">empty</DisplayString>
+    <DisplayString Condition="keyLength != 0">({this+1,s8}, {second})</DisplayString>
     <Expand>
       <Item Name="[key]">this+1,s</Item>
-      <Item Name="[value]" Condition="StrLen != 0">second</Item>
+      <Item Name="[value]" Condition="keyLength != 0">second</Item>
     </Expand>
   </Type>
 


        


More information about the llvm-commits mailing list