Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-indexed map view for MSVC debugger #40

Merged
merged 11 commits into from
Sep 21, 2018
50 changes: 42 additions & 8 deletions tsl_hopscotch_map.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,42 @@
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- Written in VC 2017 15.7 but is expected to be compatible with VC 2015 -->

<Type Name="tsl::detail_hopscotch_hash::hopscotch_bucket&lt;*&gt;">
<DisplayString Condition="(m_neighborhood_infos &amp; 1) == 0">empty</DisplayString>
<DisplayString Condition="(m_neighborhood_infos &amp; 1) != 0">{*reinterpret_cast&lt;$T1*&gt;(&amp;m_value)}</DisplayString>
<!-- Visualization that shows the index in the name column and the key-value pair in the value column -->
<Type Name="tsl::hopscotch_map&lt;*&gt;" Priority="Medium">
<AlternativeType Name="tsl::bhopscotch_map&lt;*&gt;"/>
<AlternativeType Name="tsl::bhopscotch_set&lt;*&gt;"/>
<AlternativeType Name="tsl::hopscotch_set&lt;*&gt;"/>
<DisplayString>{{ size={m_ht.m_nb_elements} }}</DisplayString>
<Expand>
<ExpandedItem Condition="(m_neighborhood_infos &amp; 1) != 0">*reinterpret_cast&lt;$T1*&gt;(&amp;m_value)</ExpandedItem>
<Item Name="[bucket_count]" IncludeView="detailed">m_ht.m_buckets._Mypair._Myval2._Mylast - m_ht.m_buckets._Mypair._Myval2._Myfirst</Item>
<Item Name="[load_factor]" Condition="m_ht.m_buckets._Mypair._Myval2._Myfirst != m_ht.m_buckets._Mypair._Myval2._Mylast" IncludeView="detailed">
((float)m_ht.m_nb_elements) / ((float)(m_ht.m_buckets._Mypair._Myval2._Mylast - m_ht.m_buckets._Mypair._Myval2._Myfirst))
</Item>
<Item Name="[load_factor]" Condition="m_ht.m_buckets._Mypair._Myval2._Myfirst == m_ht.m_buckets._Mypair._Myval2._Mylast" IncludeView="detailed">
0
</Item>
<Item Name="[max_load_factor]" IncludeView="detailed">m_ht.m_max_load_factor</Item>
<CustomListItems>
<Variable Name="bucket" InitialValue="m_ht.m_first_or_empty_bucket"/>
<Loop>
<!-- Bucket is either pointing to a static empty bucket (then m_nb_elements == 0) or to a value in m_ht.m_buckets.
Break early if m_nb_elements == 0 to avoid using the static empty bucket. -->
<Break Condition="m_ht.m_nb_elements == 0 || bucket == m_ht.m_buckets._Mypair._Myval2._Mylast"/>
<Item Condition="(bucket-&gt;m_neighborhood_infos &amp; 1) != 0">*bucket</Item>
<Exec>++bucket</Exec>
</Loop>
</CustomListItems>
<Synthetic Name="overflown elements">
<Expand>
<ExpandedItem>m_ht.m_overflow_elements</ExpandedItem>
</Expand>
</Synthetic>
</Expand>
</Type>

<Type Name="tsl::hopscotch_map&lt;*&gt;">
<!-- Visualization that shows the key in the name column and the key-value pair in the value column -->
<Type Name="tsl::hopscotch_map&lt;*&gt;" ExcludeView="ShowElementsByIndex" Priority="MediumHigh">
<AlternativeType Name="tsl::bhopscotch_map&lt;*&gt;"/>
<AlternativeType Name="tsl::bhopscotch_set&lt;*&gt;"/>
<AlternativeType Name="tsl::hopscotch_set&lt;*&gt;"/>
<DisplayString>{{ size={m_ht.m_nb_elements} }}</DisplayString>
<Expand>
<Item Name="[bucket_count]" IncludeView="detailed">m_ht.m_buckets._Mypair._Myval2._Mylast - m_ht.m_buckets._Mypair._Myval2._Myfirst</Item>
Expand All @@ -30,7 +54,9 @@
<!-- Bucket is either pointing to a static empty bucket (then m_nb_elements == 0) or to a value in m_ht.m_buckets.
Break early if m_nb_elements == 0 to avoid using the static empty bucket. -->
<Break Condition="m_ht.m_nb_elements == 0 || bucket == m_ht.m_buckets._Mypair._Myval2._Mylast"/>
<Item Condition="(bucket-&gt;m_neighborhood_infos &amp; 1) != 0">bucket,na</Item>
<Item Name="[{reinterpret_cast&lt;std::pair&lt;$T1,$T2&gt;*&gt;(&amp;bucket->m_value)->first}]" Condition="(bucket-&gt;m_neighborhood_infos &amp; 1) != 0">
*bucket
</Item>
<Exec>++bucket</Exec>
</Loop>
</CustomListItems>
Expand All @@ -50,4 +76,12 @@
<ExpandedItem Condition="m_buckets_iterator._Ptr == m_buckets_end_iterator._Ptr">m_overflow_iterator</ExpandedItem>
</Expand>
</Type>

<Type Name="tsl::detail_hopscotch_hash::hopscotch_bucket&lt;*&gt;">
<DisplayString Condition="(m_neighborhood_infos &amp; 1) == 0">empty</DisplayString>
<DisplayString Condition="(m_neighborhood_infos &amp; 1) != 0">{*reinterpret_cast&lt;$T1*&gt;(&amp;m_value)}</DisplayString>
<Expand>
<ExpandedItem Condition="(m_neighborhood_infos &amp; 1) != 0">*reinterpret_cast&lt;$T1*&gt;(&amp;m_value)</ExpandedItem>
</Expand>
</Type>
</AutoVisualizer>