OSDN Git Service

Add natvis visualizers for endian types.
authorZachary Turner <zturner@google.com>
Thu, 21 Apr 2016 20:58:41 +0000 (20:58 +0000)
committerZachary Turner <zturner@google.com>
Thu, 21 Apr 2016 20:58:41 +0000 (20:58 +0000)
This allows ulittle* and ubig* types to be visualized properly
in VS.

Differential Revision: http://reviews.llvm.org/D19339
Reviewed By: Aaron Ballman

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267050 91177308-0d34-0410-b5e6-96231b3b80d8

utils/LLVMVisualizers/llvm.natvis

index 0ab921c..9b00483 100644 (file)
@@ -168,4 +168,45 @@ For later versions of Visual Studio, no setup is required.
       <Item Name="[underlying]" Condition="hasVal">*(($T1 *)(unsigned char *)storage.buffer)</Item>\r
     </Expand>\r
   </Type>\r
+\r
+  <!-- Since we're in MSVC, we can assume that the system is little endian.  Therefore\r
+       the little and native cases just require a cast.  Handle this easy case first. Use\r
+       a wildcard for the second template argument (the endianness), but we will use a\r
+       specific value of 0 later on for the big endian to give it priority for being a\r
+       better match.  -->\r
+  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,*,1&gt;">\r
+    <DisplayString>{{little endian value = {*(($T1*)(unsigned char *)Value.buffer)} }}</DisplayString>\r
+    <Expand>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>\r
+    </Expand>\r
+  </Type>\r
+  \r
+  <!-- Now handle the hard case of big endian.  We need to do the swizzling here, but\r
+       we need to specialize it based on the size of the value type. -->\r
+  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,0,1&gt;">\r
+    <DisplayString Condition="sizeof($T1)==1">{{ big endian value = {*(unsigned char *)Value.buffer} }}</DisplayString>\r
+    <DisplayString Condition="sizeof($T1)==2">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 8) \r
+                                                                    | ($T1)(*((unsigned char *)Value.buffer+1))} }}</DisplayString>\r
+    <DisplayString Condition="sizeof($T1)==4">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 24) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 16) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 8) \r
+                                                                    |  ($T1)(*((unsigned char *)Value.buffer+3))} }}</DisplayString>\r
+    <DisplayString Condition="sizeof($T1)==8">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 56) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 48) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 40) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+3)) &lt;&lt; 32) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+4)) &lt;&lt; 24) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+5)) &lt;&lt; 16) \r
+                                                                    | (($T1)(*((unsigned char *)Value.buffer+6)) &lt;&lt; 8) \r
+                                                                    |  ($T1)(*((unsigned char *)Value.buffer+7))} }}</DisplayString>\r
+    <Expand>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>\r
+      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>\r
+    </Expand>\r
+  </Type>\r
 </AutoVisualizer>\r