Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions debugger/visualizers/unordered_dense.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

<!--unordered_dense::set-->
<Type Name="ankerl::unordered_dense::v4_5_0::detail::table&lt;*, void, *,*,*,*,*,0&gt;">
<DisplayString>{{ size={m_values.size()} }}</DisplayString>
<Expand>
<CustomListItems Optional="true">
<Variable Name="idx" InitialValue="0" />
<Loop>
<Break Condition="idx == m_values.size()"/>
<Item>m_values[idx]</Item>
<Exec>++idx</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>

<!--unordered_dense::segmented_set-->
<Type Name="ankerl::unordered_dense::v4_5_0::detail::table&lt;*, void, *,*,*,*,*,1&gt;">
<DisplayString>{{ size={m_values.m_size}, blocks={m_values.m_blocks.size()}}}</DisplayString>
<Expand>
<CustomListItems Optional="true">
<Variable Name="idx1" InitialValue="0" />
<Variable Name="idx2" InitialValue="0" />
<Variable Name="num_vals" InitialValue="0" />
<Variable Name="alt_bound" InitialValue="0" />
<Loop>
<Break Condition="idx1 == m_values.m_blocks.size()"/>
<Exec>alt_bound = m_values.m_size - idx1*m_values.num_elements_in_block</Exec>
<Exec>num_vals = m_values.num_elements_in_block &gt; alt_bound ? alt_bound : m_values.num_elements_in_block</Exec>

<Loop Condition="idx2 &lt; num_vals">
<Item Name="[{idx1*m_values.num_elements_in_block + idx2}] ({idx1}x{idx2})">m_values.m_blocks[0][idx2]</Item>
<Exec>++idx2</Exec>
</Loop>
<Exec>++idx1</Exec>
<Exec>idx2=0</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>


<!--unordered_dense::map-->
<Type Name="ankerl::unordered_dense::v4_5_0::detail::table&lt;*,*,*,*,*,*,*,0&gt;">
<DisplayString>{{ size={m_values.size()} }}</DisplayString>
<Expand>
<CustomListItems Optional="true">
<Variable Name="idx" InitialValue="0" />
<Loop>
<Break Condition="idx == m_values.size()"/>
<Item Name="[{idx}] {m_values[idx].first}">m_values[idx].second</Item>
<Exec>++idx</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>

<!--unordered_dense::segmented_map-->
<Type Name="ankerl::unordered_dense::v4_5_0::detail::table&lt;*,*,*,*,*,*,*,1&gt;">
<DisplayString>{{ size={m_values.m_size}, blocks={m_values.m_blocks.size()}}}</DisplayString>
<Expand>
<CustomListItems Optional="true">
<Variable Name="idx1" InitialValue="0" />
<Variable Name="idx2" InitialValue="0" />
<Variable Name="num_vals" InitialValue="0" />
<Variable Name="alt_bound" InitialValue="0" />
<Loop>
<Break Condition="idx1 == m_values.m_blocks.size()"/>
<Exec>alt_bound = m_values.m_size - idx1*m_values.num_elements_in_block</Exec>
<Exec>num_vals = m_values.num_elements_in_block &gt; alt_bound ? alt_bound : m_values.num_elements_in_block</Exec>

<Loop Condition="idx2 &lt; num_vals">
<Item Name="[{idx1*m_values.num_elements_in_block + idx2}] ({idx1}x{idx2}) {m_values.m_blocks[idx1][idx2].first}">m_values.m_blocks[0][idx2].second</Item>
<Exec>++idx2</Exec>
</Loop>
<Exec>++idx1</Exec>
<Exec>idx2=0</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>

<Type Name="ankerl::unordered_dense::v4_5_0::segmented_vector&lt;*&gt;">
<DisplayString>{{ size={m_size} }}</DisplayString>
<Expand>
<Item Name="m_blocks">m_blocks</Item>
<!--Item Name="num_bits">num_bits</Item-->
<Item Name="num_elements_in_block">num_elements_in_block</Item>
</Expand>
</Type>

</AutoVisualizer>
55 changes: 55 additions & 0 deletions test/natvis/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// natvis_test.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <string>

import ankerl.unordered_dense;

auto& map_1() {
const static std::unordered_map<std::string, double> m{
{"Hello,", 1.23},
{"world!", 4.56},
};
return m;
}

auto pattern_map(int num_elem) {
std::unordered_map<std::string, double> m{};
for (int i = 1; i <= num_elem; ++i) {
const auto key = std::string("key_") + std::to_string(i);
double value = i * 1.23;
m.emplace(key, value);
}
return m;
}

int main()
{
std::unordered_map<std::string, double> map_classic = pattern_map(130);
ankerl::unordered_dense::map<decltype(map_classic)::key_type, decltype(map_classic)::mapped_type> map_dense{};
ankerl::unordered_dense::segmented_map<decltype(map_classic)::key_type, decltype(map_classic)::mapped_type> map_sgm{};

std::unordered_set<decltype(map_classic)::key_type> set_classic{};
ankerl::unordered_dense::set<decltype(map_classic)::key_type> set_dense{};
ankerl::unordered_dense::segmented_set<decltype(map_classic)::key_type> set_sgm{};


for (const auto [key, value] : map_classic) {
set_classic.insert(key);

map_dense[key] = value;
map_sgm[key] = value;

set_dense.insert(key);
set_sgm.insert(key);
}

// Put a breakpoint here to see debug info.
for (auto const& [key, val] : map_classic) {
std::cout << key << " => " << val << std::endl;
}
}

31 changes: 31 additions & 0 deletions test/natvis/natvis_demo.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35806.99
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "natvis_demo", "natvis_demo.vcxproj", "{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Debug|x64.ActiveCfg = Debug|x64
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Debug|x64.Build.0 = Debug|x64
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Debug|x86.ActiveCfg = Debug|Win32
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Debug|x86.Build.0 = Debug|Win32
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Release|x64.ActiveCfg = Release|x64
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Release|x64.Build.0 = Release|x64
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Release|x86.ActiveCfg = Release|Win32
{0FC2E957-E173-46A4-BF05-C0F3A03EA1BD}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B926FE15-ACE7-450F-A24C-C0A1CD6BB2C2}
EndGlobalSection
EndGlobal
150 changes: 150 additions & 0 deletions test/natvis/natvis_demo.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{0fc2e957-e173-46a4-bf05-c0f3a03ea1bd}</ProjectGuid>
<RootNamespace>natvisdemo</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>natvis_demo</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>..\..\include;..\..\src;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\ankerl.unordered_dense.cpp">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCppModule</CompileAs>
</ClCompile>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ankerl\unordered_dense.h" />
</ItemGroup>
<ItemGroup>
<Natvis Include="..\..\debugger\visualizers\unordered_dense.natvis" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
33 changes: 33 additions & 0 deletions test/natvis/natvis_demo.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ankerl.unordered_dense.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ankerl\unordered_dense.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="..\..\debugger\visualizers\unordered_dense.natvis" />
</ItemGroup>
</Project>
Loading