BitField.natvis 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Copyright 2015 Scott Mansell
  4. All rights reserved.
  5. SPDX-License-Identifier: BSD-3-Clause
  6. -->
  7. <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  8. <!--
  9. This is a re-implementation of the abstract bitfield class' algrothm (in BitField.h)
  10. for Visual Studio to use for pretty-printing during debugging.
  11. -->
  12. <Type Name="BitField&lt;*,*,*,*&gt;">
  13. <DisplayString><![CDATA[{($T3)((storage >> $T1) & ((1 << $T2) - 1))}]]></DisplayString>
  14. <Expand>
  15. <Item Name="Offset">$T1</Item>
  16. <Item Name="Size">$T2</Item>
  17. </Expand>
  18. </Type>
  19. <!-- Similar re-implementation for BitFieldArray -->
  20. <Type Name="BitFieldArray&lt;*,*,*,*,*&gt;">
  21. <Expand>
  22. <IndexListItems>
  23. <Size>$T3</Size>
  24. <ValueNode><![CDATA[($T4)((storage >> ($T1 + $T2*$i)) & ((1 << $T2) - 1))]]></ValueNode>
  25. </IndexListItems>
  26. <!-- Put these after the index list, so that the index list is the main thing in the unexpanded preview -->
  27. <Item Name="Offset">$T1</Item>
  28. <Item Name="Size">$T2</Item>
  29. <Item Name="Count">$T3</Item>
  30. </Expand>
  31. </Type>
  32. <!--Specialised versions for signed types-->
  33. <Type Name="BitField&lt;*,*,signed char,*&gt;">
  34. <!-- It seems like we can't use s8/s16/s32/s64, nor can we use std::int8_t or the like; we have to use these names -->
  35. <AlternativeType Name="BitField&lt;*,*,short,*&gt;" />
  36. <AlternativeType Name="BitField&lt;*,*,int,*&gt;" />
  37. <AlternativeType Name="BitField&lt;*,*,long long,*&gt;" />
  38. <!-- This is what I have do to get a sign extension in this crappy natvis "language"
  39. Basically, we check the top bit, if it's one, we add the remaining
  40. bits to the smallest (most negative) number. -->
  41. <DisplayString Condition="(storage &amp; (1 &lt;&lt; ($T1 + $T2 - 1))) != 0">
  42. <![CDATA[{($T3)((-1 * (1 << ($T2-1))) + ((storage >> $T1) & ((1 << ($T2-1)) - 1)))}]]>
  43. </DisplayString>
  44. <DisplayString><![CDATA[{($T3)((storage >> $T1) & ((1 << ($T2-1)) - 1))}]]></DisplayString>
  45. <Expand>
  46. <Item Name="Offset">$T1</Item>
  47. <Item Name="Size">$T2</Item>
  48. </Expand>
  49. </Type>
  50. <Type Name="BitFieldArray&lt;*,*,*,signed char,*&gt;">
  51. <AlternativeType Name="BitFieldArray&lt;*,*,*,short,*&gt;" />
  52. <AlternativeType Name="BitFieldArray&lt;*,*,*,int,*&gt;" />
  53. <AlternativeType Name="BitFieldArray&lt;*,*,*,long,*&gt;" />
  54. <Expand>
  55. <IndexListItems>
  56. <Size>$T3</Size>
  57. <ValueNode Condition="(storage &amp; (1 &lt;&lt; ($T1 + $T2 * $i + $T2 - 1))) != 0">
  58. <![CDATA[($T4)((-1 * (1 << ($T2-1))) + ((storage >> ($T1 + $T2*$i)) & ((1 << ($T2-1)) - 1)))]]>
  59. </ValueNode>
  60. <ValueNode><![CDATA[($T4)((storage >> ($T1 + $T2*$i)) & ((1 << ($T2-1)) - 1))]]></ValueNode>
  61. </IndexListItems>
  62. <Item Name="Offset">$T1</Item>
  63. <Item Name="Size">$T2</Item>
  64. <Item Name="Count">$T3</Item>
  65. </Expand>
  66. </Type>
  67. </AutoVisualizer>