Skip to content

Commit

Permalink
initial debug visualizers
Browse files Browse the repository at this point in the history
  • Loading branch information
jxy-s committed Oct 31, 2024
1 parent f0119e6 commit ffc748f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
7 changes: 7 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ filegroup(
]),
)

filegroup(
name = "radiant-natvis",
srcs = [
"radiant/Rad.natvis",
],
)

cc_library(
name = "radiant",
hdrs = [":radiant-hdrs"],
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion default_copts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RAD_DEFAULT_COPTS = select({
})

RAD_DEFAULT_LINKOPTS = select({
"//:msvc": [],
"//:msvc": ["/NATVIS:radiant/Rad.natvis"],
"//:gcc": RAD_GCC_LINKOPTS + RAD_ASAN_LINKOPTS,
"//:clang": RAD_GCC_LINKOPTS,
})
50 changes: 50 additions & 0 deletions radiant/Rad.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Radiant Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

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

<!-- rad::EmptyOptimizedPair -->
<Type Name="rad::EmptyOptimizedPair&lt;*,*,1&gt;">
<DisplayString>{*($T1 *)this}</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)this</ExpandedItem>
</Expand>
</Type>
<Type Name="rad::EmptyOptimizedPair&lt;*,*,0&gt;">
<DisplayString>{m_first}</DisplayString>
<Expand>
<ExpandedItem>m_first</ExpandedItem>
</Expand>
</Type>

<!-- rad::Vector -->
<Type Name="rad::Vector&lt;*&gt;">
<Intrinsic Name="size" Expression="m_storage.m_second.m_size" />
<Intrinsic Name="capacity" Expression="m_storage.m_second.m_capacity" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[capacity]" ExcludeView="simple">capacity()</Item>
<Item Name="[allocator]" ExcludeView="simple">m_storage</Item>
<ArrayItems>
<Size>size()</Size>
<ValuePointer>m_storage.m_second.m_data</ValuePointer>
</ArrayItems>
</Expand>
</Type>

</AutoVisualizer>

0 comments on commit ffc748f

Please sign in to comment.