Natvis adjustments to make debugging bearable (#13237)

### Description

- Fix Abseil::InlinedVector inlined storage visualization
- Fix typo in protobuf natvis.
- Add basic gsl.natvis


### Motivation and Context
Debugging is hard.
This commit is contained in:
Dmitri Smirnov 2022-10-10 10:06:55 -07:00 committed by GitHub
parent 0668600255
commit 25c0a66934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 13 deletions

View file

@ -1,19 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="absl::lts_20211102::InlinedVector&lt;*&gt;">
<DisplayString>{{ size={ storage_.metadata_.value >> 1 } }}</DisplayString>
<Intrinsic Name="_size" Expression="storage_.metadata_.value >> 1"/>
<Intrinsic Name="_is_allocated" Expression="(storage_.metadata_.value &amp; 1) == 1"/>
<Intrinsic Name="_inlined_data" Expression="($T1*)storage_.data_.inlined.inlined_data"/>
<Intrinsic Name="_allocated_data" Expression="storage_.data_.allocated.allocated_data"/>
<DisplayString>{{ size={ _size() }}}</DisplayString>
<Expand>
<Item Name="[capacity]" ExcludeView="simple" Condition="(storage_.metadata_.value &amp; 1) == 0">$T2</Item>
<Item Name="[capacity]" ExcludeView="simple" Condition="(storage_.metadata_.value &amp; 1) == 1">storage_.data_.allocated.allocated_capacity</Item>
<Item Name="[capacity]" ExcludeView="simple" Condition="!_is_allocated()">$T2</Item>
<Item Name="[capacity]" ExcludeView="simple" Condition="_is_allocated()">storage_.data_.allocated.allocated_capacity</Item>
<Item Name="[N]" ExcludeView="simple">$T2</Item>
<Item Name="[allocator]" ExcludeView="simple" Condition="(storage_.metadata_.value &amp; 1) == 1">storage_.metadata_</Item>
<IndexListItems Condition="(storage_.metadata_.value &amp; 1) == 0">
<Size>storage_.metadata_.value &gt;&gt; 1</Size>
<ValueNode>(($T1 &amp;)(storage_.data_.inlined.inlined_data[$i]))</ValueNode>
<Item Name="[size]" ExcludeView="simple">_size()</Item>
<Item Name="[is_allocated]" ExcludeView="simple">_is_allocated()</Item>
<Item Name="[allocator]" ExcludeView="simple" Condition="_is_allocated()">storage_.metadata_</Item>
<IndexListItems Condition="!_is_allocated()">
<Size>_size()</Size>
<ValueNode>_inlined_data()[$i]</ValueNode>
</IndexListItems>
<IndexListItems Condition="(storage_.metadata_.value &amp; 1) == 1">
<Size>storage_.metadata_.value &gt;&gt; 1</Size>
<ValueNode>storage_.data_.allocated.allocated_data[$i]</ValueNode>
<IndexListItems Condition="_is_allocated()">
<Size>_size()</Size>
<ValueNode>_allocated_data()[$i]</ValueNode>
</IndexListItems>
</Expand>
</Type>
@ -45,4 +51,4 @@
<Item Name="[value]" ExcludeView="simple">value.second</Item>
</Expand>
</Type>
</AutoVisualizer>
</AutoVisualizer>

14
cmake/external/gsl.natvis vendored Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="gsl::span&lt;*&gt;">
<Intrinsic Name="_size" Expression="(last_ - first_)"/>
<DisplayString>{{ size={ _size() }}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">_size()</Item>
<IndexListItems Condition="_size() &gt; 0">
<Size>_size()</Size>
<ValueNode>first_[$i]</ValueNode>
</IndexListItems>
</Expand>
</Type>
</AutoVisualizer>

View file

@ -192,7 +192,7 @@
<Type Name="onnx::TypeProto_Sequence">
<Intrinsic Name="_has_element_type" Expression="(_has_bits_.has_bits_[0] &amp; 0x00000001u) != 0"/>
<DisplayString Condition="has_element_type()">{{ elem_type={ *elem_type_ } }}</DisplayString>
<DisplayString Condition="_has_element_type()">{{ elem_type={ *elem_type_ } }}</DisplayString>
<Expand>
<Item Name="[elem_type]" Condition="_has_element_type()" ExcludeView="simple">elem_type_</Item>
<Item Name="[has_element_type]" ExcludeView="simple">_has_element_type()</Item>

View file

@ -115,7 +115,11 @@ if(NOT onnxruntime_DISABLE_ABSEIL)
set(ABSEIL_NATVIS_FILE "abseil-cpp.natvis")
target_sources(
onnxruntime_common
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/${ABSEIL_NATVIS_FILE}>
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/${ABSEIL_NATVIS_FILE}>)
set(GSL_NATVIS_FILE "gsl.natvis")
target_sources(
onnxruntime_common
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/${GSL_NATVIS_FILE}>
)
endif()
endif()