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

Added Natvis for some internal datalibrary types #179

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,17 @@ if (DATA_LIBRARY_BENCHMARK)
target_link_libraries(dlbench PRIVATE data_library)
include_directories(src include build/local)
endif()

if ((CMAKE_VERSION GREATER 3.7.9) OR (CMAKE_VERSION EQUAL 3.7.9))
if (MSVC_IDE)
option(VS_ADD_NATIVE_VISUALIZERS "Configure project to use Visual Studio native visualizers" TRUE)
else()
set(VS_ADD_NATIVE_VISUALIZERS FALSE CACHE INTERNAL "Native visualizers are Visual Studio extension" FORCE)
endif()
# add natvis file to the library so it will automatically be loaded into Visual Studio
if(VS_ADD_NATIVE_VISUALIZERS)
target_sources(GSL INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/src/datalibrary.natvis
)
endif()
endif()
245 changes: 245 additions & 0 deletions src/datalibrary.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
<?xml version="1.0" encoding="utf-8"?>

<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="dl_substr">
<DisplayString Encoding="Utf8">{str,[len]s8}</DisplayString>
<StringView>str,[len]s8</StringView>
</Type>
<Type Name="dl_type_desc">
<DisplayString Condition="name >= (*ctx)->typedata_strings_size">Change g_DlDebuggingContext in watch window</DisplayString>
<DisplayString Condition="member_count &gt; 3">struct {(*ctx)->typedata_strings + name,s8b} {{{member_count,u} members}}</DisplayString>
<DisplayString Condition="member_count &gt; 2">struct {(*ctx)->typedata_strings + name,s8b} {{{*((*ctx)->member_descs + member_start)}; {*((*ctx)->member_descs + member_start + 1)}; {*((*ctx)->member_descs + member_start + 2)};}}</DisplayString>
<DisplayString Condition="member_count &gt; 1">struct {(*ctx)->typedata_strings + name,s8b} {{{*((*ctx)->member_descs + member_start)}; {*((*ctx)->member_descs + member_start + 1)};}}</DisplayString>
<DisplayString>struct {(*ctx)->typedata_strings + name,s8b} {{{*((*ctx)->member_descs + member_start)};]</DisplayString>
<Expand>
<Item Name="[name]" ExcludeView="simple">(*ctx)->typedata_strings + name,s8</Item>
<Item Name="[typeid]">(*ctx)->type_ids[this - (*ctx)->type_descs],X</Item>
<Item Name="[comment]" Condition="comment!=0xFFFFFFFF" ExcludeView="simple">(*ctx)->typedata_strings + comment,s8</Item>
<Synthetic Name="[members]">
<DisplayString Condition="member_count &gt; 3">Count: {member_count,u}, {{{*((*ctx)->member_descs + member_start)}; {*((*ctx)->member_descs + member_start + 1)}; {*((*ctx)->member_descs + member_start + 2)}; ...}}</DisplayString>
<DisplayString Condition="member_count &gt; 2">Count: {member_count,u}, {{{*((*ctx)->member_descs + member_start)}; {*((*ctx)->member_descs + member_start + 1)}; {*((*ctx)->member_descs + member_start + 2)};}}</DisplayString>
<DisplayString Condition="member_count &gt; 1">Count: {member_count,u}, {{{*((*ctx)->member_descs + member_start)}; {*((*ctx)->member_descs + member_start + 1)};}}</DisplayString>
<DisplayString>Count: {member_count,u}, {{{*((*ctx)->member_descs + member_start)};]</DisplayString>
<Expand>
<ArrayItems>
<Size>member_count</Size>
<ValuePointer>(*ctx)->member_descs + member_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Item Name="[flags]" ExcludeView="simple">flags</Item>
<Item Name="[size]" ExcludeView="simple">size[DL_PTR_SIZE_HOST]</Item>
<Item Name="[alignment]" ExcludeView="simple">alignment[DL_PTR_SIZE_HOST]</Item>
<Synthetic Name="[metadata]" Condition="metadata_count!=0">
<DisplayString>Count: {metadata_count,u}</DisplayString>
<Expand>
<ArrayItems>
<Size>metadata_count</Size>
<ValuePointer>(*ctx)->metadatas + metadata_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="dl_member_desc">
<DisplayString Condition="name >= (*ctx)->typedata_strings_size">Change g_DlDebuggingContext in watch window</DisplayString>
<DisplayString Condition="type == 0x0000">int8 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0100">int16 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0200">int32 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0300">int64 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0400">uint8 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0500">uint16 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0600">uint32 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0700">uint64 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0800">float {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0900">double {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0A00">enum:int8 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0B00">enum:int16 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0C00">enum:int32 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0D00">enum:int64 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0E00">enum:uint8 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0F00">enum:uint16 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1000">enum:uint32 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1100">enum:uint64 {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1200">const char* {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1300">ptr {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1400">struct {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1500">anypointer {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1600">anyarray {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0001">dl_array&lt;int8&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0101">dl_array&lt;int16&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0201">dl_array&lt;int32&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0301">dl_array&lt;int64&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0401">dl_array&lt;uint8&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0501">dl_array&lt;uint16&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0601">dl_array&lt;uint32&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0701">dl_array&lt;uint64&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0801">dl_array&lt;float&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0901">dl_array&lt;double&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0A01">dl_array&lt;enum:int8&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0B01">dl_array&lt;enum:int16&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0C01">dl_array&lt;enum:int32&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0D01">dl_array&lt;enum:int64&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0E01">dl_array&lt;enum:uint8&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x0F01">dl_array&lt;enum:uint16&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1001">dl_array&lt;enum:uint32&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1101">dl_array&lt;enum:uint64&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1201">dl_array&lt;const char*&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1301">dl_array&lt;ptr&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1401">dl_array&lt;struct&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1501">dl_array&lt;anypointer&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="type == 0x1601">dl_array&lt;anyarray&gt; {(*ctx)->typedata_strings + name,s8b}</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0002">int8 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0102">int16 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0202">int32 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0302">int64 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0402">uint8 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0502">uint16 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0602">uint32 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0702">uint64 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0802">float {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0902">double {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0A02">enum:int8 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0B02">enum:int16 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0C02">enum:int32 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0D02">enum:int64 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0E02">enum:uint8 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0F02">enum:uint16 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1002">enum:uint32 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1102">enum:uint64 {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1202">const char* {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1302">ptr {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1402">struct {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1502">anypointer {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x1602">anyarray {(*ctx)->typedata_strings + name,s8b}[{type&gt;&gt;16,u}]</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0403">uint8 {(*ctx)->typedata_strings + name,s8b}:{(type&gt;&gt;16)&amp;0xFF,u}</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0503">uint16 {(*ctx)->typedata_strings + name,s8b}:{(type&gt;&gt;16)&amp;0xFF,u}</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0603">uint32 {(*ctx)->typedata_strings + name,s8b}:{(type&gt;&gt;16)&amp;0xFF,u}</DisplayString>
<DisplayString Condition="(type &amp; 0xFFFF) == 0x0703">uint64 {(*ctx)->typedata_strings + name,s8b}:{(type&gt;&gt;16)&amp;0xFF,u}</DisplayString>
<DisplayString>{(*ctx)->typedata_strings + name,s8b}, {(dl_type_atom_t)(type &amp; 0xFF)}</DisplayString>
<Expand>
<Item Name="[name]">(*ctx)->typedata_strings + name,s8</Item>
<Item Name="[comment]" Condition="comment!=0xFFFFFFFF" ExcludeView="simple">(*ctx)->typedata_strings + comment,s8</Item>
<Item Name="[atom]">(dl_type_atom_t)(type &amp; 0xFF)</Item>
<Item Name="[storage]">(dl_type_storage_t)((type &gt;&gt; 8) &amp; 0xFF)</Item>
<Item Name="[flags]" ExcludeView="simple">flags</Item>
<Item Name="[typeid]" Condition="type_id!=0">type_id,X</Item>
<Item Name="[offset]" ExcludeView="simple">offset[DL_PTR_SIZE_HOST]</Item>
<Item Name="[bitoffset]" Condition="(type&amp;0xFF)==3" ExcludeView="simple">(type&gt;&gt;24)&amp;0xFF,u</Item>
<Item Name="[bitcount]" Condition="(type&amp;0xFF)==3" ExcludeView="simple">(type&gt;&gt;16)&amp;0xFF,u</Item>
<Item Name="[size]" ExcludeView="simple">size[DL_PTR_SIZE_HOST]</Item>
<Item Name="[alignment]" ExcludeView="simple">alignment[DL_PTR_SIZE_HOST]</Item>
<Synthetic Name="[default values]" Condition="default_value_offset!=0xFFFFFFFF">
<Expand>
<ArrayItems>
<Size>default_value_size</Size>
<ValuePointer>(*ctx)->default_data + default_value_offset</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[metadata]" Condition="metadata_count!=0">
<DisplayString>Count: {metadata_count,u}</DisplayString>
<Expand>
<ArrayItems>
<Size>metadata_count</Size>
<ValuePointer>(*ctx)->metadatas + metadata_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="dl_enum_desc">
<DisplayString Condition="name >= (*ctx)->typedata_strings_size">Change g_DlDebuggingContext in watch window</DisplayString>
<DisplayString>{(*ctx)->typedata_strings + name,s8}</DisplayString>
<Expand>
<Item Name="[name]" ExcludeView="simple">(*ctx)->typedata_strings + name,s8</Item>
<Item Name="[comment]" Condition="comment!=0xFFFFFFFF" ExcludeView="simple">(*ctx)->typedata_strings + comment,s8</Item>
<Item Name="[storage]" ExcludeView="simple">storage</Item>
<Item Name="[flags]" ExcludeView="simple">flags</Item>
<Synthetic Name="[values]" Condition="value_count!=0">
<DisplayString>Count: {value_count,u}, [{*((*ctx)->enum_value_descs + value_start)}...]</DisplayString>
<Expand>
<ArrayItems>
<Size>value_count</Size>
<ValuePointer>(*ctx)->enum_value_descs + value_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[aliases]" Condition="alias_count!=0">
<DisplayString>Count: {alias_count,u}, [{*((*ctx)->enum_alias_descs + alias_start)}...]</DisplayString>
<Expand>
<ArrayItems>
<Size>alias_count</Size>
<ValuePointer>(*ctx)->enum_alias_descs + alias_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[metadata]" Condition="metadata_count!=0">
<DisplayString>Count: {metadata_count,u}</DisplayString>
<Expand>
<ArrayItems>
<Size>metadata_count</Size>
<ValuePointer>(*ctx)->metadatas + metadata_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="dl_enum_value_desc">
<DisplayString Condition="main_alias >= (*ctx)->enum_alias_count">Change g_DlDebuggingContext in watch window</DisplayString>
<DisplayString>{(*ctx)->enum_alias_descs + main_alias,na}</DisplayString>
<Expand>
<Item Name="[name]" ExcludeView="simple">(*ctx)->enum_alias_descs + main_alias,na</Item>
<Item Name="[value]" ExcludeView="simple">value</Item>
<Item Name="[comment]" Condition="comment!=0xFFFFFFFF" ExcludeView="simple">(*ctx)->typedata_strings + comment,s8</Item>
<Synthetic Name="[metadata]" Condition="metadata_count!=0">
<DisplayString>Count: {metadata_count,u}</DisplayString>
<Expand>
<ArrayItems>
<Size>metadata_count</Size>
<ValuePointer>(*ctx)->metadatas + metadata_start</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="dl_enum_alias_desc">
<DisplayString Condition="name >= (*ctx)->typedata_strings_size">Change g_DlDebuggingContext in watch window</DisplayString>
<DisplayString>{(*ctx)->typedata_strings + name,s8}</DisplayString>
<Expand>
<Item Name="[name]" ExcludeView="simple">(*ctx)->typedata_strings + name,s8</Item>
<Item Name="[value_index]" ExcludeView="simple">value_index</Item>
</Expand>
</Type>
<Type Name="dl_context">
<Expand>
<Synthetic Name="[types]">
<DisplayString>Size:{type_count}, Capacity:{type_capacity}</DisplayString>
<Expand>
<ArrayItems>
<Size>type_count</Size>
<ValuePointer>type_descs</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
<Synthetic Name="[enums]">
<DisplayString>Size:{enum_count}, Capacity:{enum_capacity}</DisplayString>
<Expand>
<ArrayItems>
<Size>enum_count</Size>
<ValuePointer>enum_descs</ValuePointer>
</ArrayItems>
</Expand>
</Synthetic>
</Expand>
</Type>
<Type Name="dl_array&lt;*&gt;">
<DisplayString>Size = {count}</DisplayString>
<Expand>
<ArrayItems>
<Size>count</Size>
<ValuePointer>data</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
14 changes: 14 additions & 0 deletions src/dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

#include <algorithm>

#ifdef DL_DEBUGGING_ENABLED
// This is just for natvis, not to be used elsewhere
dl_ctx_t g_DlDebuggingContext = nullptr;
const dl_ctx_t* dl_type_desc::ctx = &g_DlDebuggingContext;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am no fan of all of these globals but I can see that it can't really be done in natvis without at least one global :(

I would like the define to be DL_NATVIS_ENABLED as this relates to natvis and not some general debugging.
It should also be enough with one g_DlActiveNatvisCtx so that we don't pollute all structs with this CTX.

The comment above might need a bit of expansion as well on the fact that this context will be used when inspecting values via natvis.

One thing that could be worth considering is to add a DL_NATVIS_SCOPE(ctx) that can be put in the top-level functions, that with a tls might automate the setup of the global? Not sure how much "muck" that would add to the codebase however?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't access "global scope variables", only "type scoped globals" from natvis. In other words I need all the globals except g_DlDebuggingContext. I added g_DlDebuggingContext just so I can change a single pointer in the debugger when I want to inspect a different context, instead of manually having to change all five places.

I will improve the documentation about this and rename them to your liking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About making the natvis context TLS (or FLS) aware, this seems very exotic to me. If a developer uses different contexts per thread or fiber then I think they should make that adaptation in their own local version of the library. This is an open source library where such adaptations are easy to do, and thus I would prefer to only provide basic and common use cases.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting globals to work as this doc says that it should work https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022. But I also trust you on this one, just not a fan of polluting the structs with all these statics :(

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thought on the scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a scope which can declare the global as extern and then assign it? Or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the statics neither. I guess it could be solved by adding a dll based natvis or something similar. But that is far past my ambitions in this case.

const dl_ctx_t* dl_member_desc::ctx = &g_DlDebuggingContext;
const dl_ctx_t* dl_enum_value_desc::ctx = &g_DlDebuggingContext;
const dl_ctx_t* dl_enum_desc::ctx = &g_DlDebuggingContext;
const dl_ctx_t* dl_enum_alias_desc::ctx = &g_DlDebuggingContext;
#endif

dl_error_t dl_context_create( dl_ctx_t* dl_ctx, dl_create_params_t* create_params )
{
dl_allocator alloc;
Expand All @@ -25,6 +35,10 @@ dl_error_t dl_context_create( dl_ctx_t* dl_ctx, dl_create_params_t* create_param

*dl_ctx = ctx;

#ifdef DL_DEBUGGING_ENABLED
g_DlDebuggingContext = ctx;
#endif

return DL_ERROR_OK;
}

Expand Down
Loading