From 58816906b49629bed948dbfce7a2d87deba800a1 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 15 Jun 2019 19:50:43 -0400 Subject: [PATCH] add natvis file --- CMakeLists.txt | 19 ++++++------ examples/allmaps.cc | 59 ++++++++++++++++++++++++++++++++++++ phmap.natvis | 74 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 137 insertions(+), 15 deletions(-) create mode 100644 examples/allmaps.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index bde0f9f..05089de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,20 +114,21 @@ endif() if (PHMAP_BUILD_EXAMPLES) if(NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=12 -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused") endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) - add_executable(ex_basic examples/basic.cc) - add_executable(ex_bench examples/bench.cc) - add_executable(ex_emplace examples/emplace.cc) - add_executable(ex_hash_std examples/hash_std.cc) - add_executable(ex_hash_value examples/hash_value.cc) - add_executable(ex_two_files examples/f1.cc examples/f2.cc) - add_executable(ex_insert_bench examples/insert_bench.cc) - add_executable(ex_knucleotide examples/knucleotide.cc) + add_executable(ex_allmaps examples/allmaps.cc phmap.natvis) + add_executable(ex_basic examples/basic.cc phmap.natvis) + add_executable(ex_bench examples/bench.cc phmap.natvis) + add_executable(ex_emplace examples/emplace.cc phmap.natvis) + add_executable(ex_hash_std examples/hash_std.cc phmap.natvis) + add_executable(ex_hash_value examples/hash_value.cc phmap.natvis) + add_executable(ex_two_files examples/f1.cc examples/f2.cc phmap.natvis) + add_executable(ex_insert_bench examples/insert_bench.cc phmap.natvis) + add_executable(ex_knucleotide examples/knucleotide.cc phmap.natvis) target_link_libraries(ex_knucleotide Threads::Threads) target_link_libraries(ex_bench Threads::Threads) endif() diff --git a/examples/allmaps.cc b/examples/allmaps.cc new file mode 100644 index 0000000..83e4a33 --- /dev/null +++ b/examples/allmaps.cc @@ -0,0 +1,59 @@ +// Silly program just to test the natvis file for Visual Studio +// ------------------------------------------------------------ +#include +#include "parallel_hashmap/phmap.h" + +template +void test_set(F &f) +{ + Set s; + Set::iterator it; + for (int i=0; i<100; ++i) + s.insert(f(i)); + + it = s.begin(); + ++it; + + it = s.end(); + it = s.begin(); + while(it != s.end()) + ++it; + it = s.begin(); +} + +int main(int argc, char ** argv) +{ + using namespace std; + + auto make_int = [](int i) { return i; }; + auto make_string = [](int i) { return std::to_string(i); }; + + auto make_2int = [](int i) { return std::make_pair(i, i); }; + auto make_2string = [](int i) { return std::make_pair(std::to_string(i), std::to_string(i)); }; + + test_set>(make_int); + test_set>(make_string); + + test_set>(make_int); + test_set>(make_string); + + test_set>(make_2int); + test_set>(make_2string); + + test_set>(make_2int); + test_set>(make_2string); + + test_set>(make_int); + test_set>(make_string); + + test_set>(make_int); + test_set>(make_string); + + test_set>(make_2int); + test_set>(make_2string); + + test_set>(make_2int); + test_set>(make_2string); + + +} diff --git a/phmap.natvis b/phmap.natvis index 793f351..46b927f 100644 --- a/phmap.natvis +++ b/phmap.natvis @@ -1,11 +1,9 @@ - + - - {{size = {size_}}} @@ -26,21 +24,52 @@ + + + + + {{size = {size_}}} + + + + + + + + size_ + + + + **slot,na + + ++slot + ++ctrl + + + + {value} + unset end() {*slot_,na} + + + unset + end() + {**slot_,na} + + + - - {{size = ?}} @@ -70,7 +99,40 @@ - + + + + + {{size = ?}} + + + + + + + + + maxidx = 2 << maxidx + + + ctrl = sets_._Elems[idx].set_.ctrl_ + slot = sets_._Elems[idx].set_.slots_ + ctrl_end = sets_._Elems[idx].set_.ctrl_ + sets_._Elems[idx].set_.capacity_ + slot_end = sets_._Elems[idx].set_.slots_ + sets_._Elems[idx].set_.capacity_ + + + + *slot,na + + ++slot + ++ctrl + + ++idx + + + + + {it_,na}