From 98ccdffc2f1e49b3bc4eef682d6806001595af92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 16 May 2023 16:53:07 -0400 Subject: [PATCH 1/2] ENH: Add Visual Studio specific debug helpers to ITKCommon project Starting in Visual Studio 2022 version 17.6, copying these files to VS installation directory will no longer be required. Natvis has been supported for longer, including all currently supported Visual Studio versions. --- Modules/Core/Common/src/CMakeLists.txt | 40 ++++++++++++++++++++++++ Utilities/Debugger/ITK.natstepfilter | 9 ++++++ Utilities/Debugger/ITK.natvis | 3 +- Utilities/Debugger/default.natstepfilter | 31 ------------------ 4 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 Utilities/Debugger/ITK.natstepfilter delete mode 100644 Utilities/Debugger/default.natstepfilter diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index d7da6aa50ba..d99c8ed0e1b 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -278,3 +278,43 @@ if(ITK_USE_TBB) # Define TBB_USE_CAPTURED_EXCEPTION=0 to request rethrow of the exact exception. target_compile_definitions(ITKCommon PUBLIC TBB_USE_CAPTURED_EXCEPTION=0) endif() + +if(MSVC) + set(ITK_NATVIS_FILE "${ITK_SOURCE_DIR}/Utilities/Debugger/ITK.natvis") + if(CMAKE_GENERATOR MATCHES "Ninja") + # Ninja/Makefiles Generator support (embeds directly inside the executable's PDB) + target_link_options( + ITKCommon + INTERFACE + "$" + "$/${ITK_INSTALL_DATA_DIR}/Debugger/ITK.natvis>" + ) + # Force Ninja to re-link if the .natvis file changes + set_property( + TARGET + ITKCommon + APPEND + PROPERTY + LINK_DEPENDS + "${ITK_NATVIS_FILE}" + ) + else() + # Visual Studio Generator support (shows up in the Solution Explorer) + target_sources( + ITKCommon + INTERFACE + "$" + "$" + "$" + "$" + ) + endif() + + install( + FILES + "${ITK_NATVIS_FILE}" + "${ITK_SOURCE_DIR}/Utilities/Debugger/ITK.natstepfilter" + DESTINATION ${ITK_INSTALL_DATA_DIR}/Debugger + COMPONENT Development + ) +endif() diff --git a/Utilities/Debugger/ITK.natstepfilter b/Utilities/Debugger/ITK.natstepfilter new file mode 100644 index 00000000000..f1a6b471c53 --- /dev/null +++ b/Utilities/Debugger/ITK.natstepfilter @@ -0,0 +1,9 @@ + + + + itk::SmartPointer.*NoStepInto + itk::Object::RegisterNoStepInto + vtkSmartPointer.*NoStepInto + + + diff --git a/Utilities/Debugger/ITK.natvis b/Utilities/Debugger/ITK.natvis index 0aa7df0a612..d7e46e84593 100644 --- a/Utilities/Debugger/ITK.natvis +++ b/Utilities/Debugger/ITK.natvis @@ -1,6 +1,5 @@ - - + diff --git a/Utilities/Debugger/default.natstepfilter b/Utilities/Debugger/default.natstepfilter deleted file mode 100644 index 6433b9291da..00000000000 --- a/Utilities/Debugger/default.natstepfilter +++ /dev/null @@ -1,31 +0,0 @@ - - - - __abi_winrt_.*NoStepInto - __security_check_cookieNoStepInto - _chkstkNoStepInto - __chkstkNoStepInto - _Invoke@12NoStepInto - _ObjectStublessClient.*NoStepInto - _RTC_Check(Esp|StackVars)NoStepInto - ATL::CComBSTR::operator&NoStepInto - ATL::CComPtrBase.*::operator->NoStepInto - ATL::CComPtrBase.*::operator&NoStepInto - ATL::CHeapPtrBase.*::operator->NoStepInto - ATL::CHeapPtrBase.*::operator&NoStepInto - IID_PPV_ARGS_Helper<.*NoStepInto - Microsoft::WRL::ComPtr<.*>::operator->NoStepInto - Microsoft::WRL::ComPtr<.*>::operator&NoStepInto - Microsoft::WRL::Details::ComPtrRef.*NoStepInto - operator newNoStepInto - Platform::EventSource::Invoke.*NoStepInto - std::_Variant_base<.*>::_StorageNoStepInto - std::_Variant_raw_get<.*NoStepInto - std::forward<.*NoStepInto - std::move<.*NoStepInto - - itk::SmartPointer.*NoStepInto - vtkSmartPointer.*NoStepInto - std::.+NoStepInto - itk::Object::RegisterNoStepInto - From 0d69216843c549ec7b1629908422cdba6cdd1ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 28 Jul 2026 15:20:53 -0400 Subject: [PATCH 2/2] ENH: Expand Visual Studio debug visualizer specifications * Generalize FixedArray for template types other than float/double * Add customized member names for Point Add new visualizers for: * Vector * CovariantVector * ContinuousIndex * RGBPixel * RGBAPixel * VariableLengthVector * Matrix --- Utilities/Debugger/ITK.natvis | 155 ++++++++++++++++++++++++++++++++-- 1 file changed, 146 insertions(+), 9 deletions(-) diff --git a/Utilities/Debugger/ITK.natvis b/Utilities/Debugger/ITK.natvis index d7e46e84593..4be732b26a7 100644 --- a/Utilities/Debugger/ITK.natvis +++ b/Utilities/Debugger/ITK.natvis @@ -86,23 +86,20 @@ - - + [{m_InternalArray[0],g}] m_InternalArray[0] - - + [{m_InternalArray[0],g}, {m_InternalArray[1],g}] m_InternalArray[0] m_InternalArray[1] - - + [{m_InternalArray[0],g}, {m_InternalArray[1],g}, {m_InternalArray[2],g}] m_InternalArray[0] @@ -110,17 +107,157 @@ m_InternalArray[2] - - + {m_InternalArray} - $T1 + $T2 + m_InternalArray + + + + + + + Point[{m_InternalArray[0],g}] + + m_InternalArray[0] + + + + Point[{m_InternalArray[0],g}, {m_InternalArray[1],g}] + + m_InternalArray[0] + m_InternalArray[1] + + + + Point[{m_InternalArray[0],g}, {m_InternalArray[1],g}, {m_InternalArray[2],g}] + + m_InternalArray[0] + m_InternalArray[1] + m_InternalArray[2] + + + + Point{m_InternalArray} + + + $T2 + m_InternalArray + + + + + + Vector{m_InternalArray} + + + $T2 + m_InternalArray + + + + + + CovariantVector{m_InternalArray} + + + $T2 m_InternalArray + + ContinuousIndex[{m_InternalArray[0]}] + + m_InternalArray[0] + + + + ContinuousIndex[{m_InternalArray[0]}, {m_InternalArray[1]}] + + m_InternalArray[0] + m_InternalArray[1] + + + + ContinuousIndex[{m_InternalArray[0]}, {m_InternalArray[1]}, {m_InternalArray[2]}] + + m_InternalArray[0] + m_InternalArray[1] + m_InternalArray[2] + + + + ContinuousIndex{m_InternalArray} + + + $T2 + m_InternalArray + + + + + + RGB({m_InternalArray[0]}, {m_InternalArray[1]}, {m_InternalArray[2]}) + + m_InternalArray[0] + m_InternalArray[1] + m_InternalArray[2] + + + + + RGBA({m_InternalArray[0]}, {m_InternalArray[1]}, {m_InternalArray[2]}, {m_InternalArray[3]}) + + m_InternalArray[0] + m_InternalArray[1] + m_InternalArray[2] + m_InternalArray[3] + + + + + empty + {m_Data,[m_NumElements]} + + m_NumElements + m_LetArrayManageMemory + + m_NumElements + m_Data + + + + + + empty + {data,[num_elmts]} + + num_elmts + + num_elmts + data + + + + + + Matrix {$T2}x{$T3} + + + Forward + 2 + $T2 + $T3 + m_Matrix.data_[0] + + + + ({m_Index}->[{m_Index.m_InternalArray[0] + long long(m_Size.m_InternalArray[0])}])