Skip to content

Commit

Permalink
Create natvis definition for offset_ptr, and implement the Unordered …
Browse files Browse the repository at this point in the history
…customization point intrinsic functions
  • Loading branch information
k3DW committed Jul 16, 2024
1 parent f75fd25 commit 4278066
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ target_link_libraries(boost_interprocess
Boost::winapi
)

if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")

file(GLOB_RECURSE boost_interprocess_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_interprocess_IDEFILES} PREFIX "Header Files")
list(APPEND boost_interprocess_IDEFILES extra/boost_interprocess.natvis)
target_sources(boost_interprocess PRIVATE ${boost_interprocess_IDEFILES})

endif()

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(boost_interprocess INTERFACE rt)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down
27 changes: 27 additions & 0 deletions extra/boost_interprocess.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Braden Ganetsky.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-->

<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

<Type Name="boost::interprocess::offset_ptr&lt;*&gt;" Inheritable="false">
<!-- This is a simplified and inlined version of `offset_ptr::get()` -->
<Intrinsic Name="get" Expression="(internal.m_offset == 1) ? (pointer)nullptr : (pointer)((unsigned char*)this + internal.m_offset)" />
<Intrinsic Name="boost_to_address" ReturnType="pointer" Expression="get()" />

<!-- This is a simplified and inlined version of `offset_ptr::operator+=()` -->
<Intrinsic Name="boost_next" ReturnType="pointer" Expression="reinterpret_cast&lt;pointer&gt;( reinterpret_cast&lt;unsigned char*&gt;(ptr) + static_cast&lt;offset_type&gt;(offset * (difference_type)sizeof(element_type)) )">
<Parameter Name="ptr" Type="pointer" />
<Parameter Name="offset" Type="difference_type" />
</Intrinsic>

<DisplayString>{get()}</DisplayString>
<Expand>
<ExpandedItem>get()</ExpandedItem>
</Expand>
</Type>

</AutoVisualizer>

0 comments on commit 4278066

Please sign in to comment.