Skip to content

Commit 7185031

Browse files
Add clrjit.natvis file (#52668)
* Add clrjit.natvis file * Review comments * pass /NATVIS flag to linker * Include clrjit.natvis only for windows * Update src/coreclr/jit/CMakeLists.txt Co-authored-by: Jeremy Koritzinsky <[email protected]> * Add the missing review comment * minor typo Co-authored-by: Jeremy Koritzinsky <[email protected]>
1 parent c538a9b commit 7185031

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

src/coreclr/jit/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ if (CLR_CMAKE_TARGET_WIN32)
251251
vartype.h
252252
)
253253

254+
# Append clrjit.natvis file
255+
list (APPEND JIT_SOURCES
256+
clrjit.natvis)
257+
254258
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
255259
list (APPEND JIT_HEADERS
256260
emitarm.h
@@ -362,6 +366,15 @@ convert_to_absolute_path(JIT_ARM_SOURCES ${JIT_ARM_SOURCES})
362366
convert_to_absolute_path(JIT_I386_SOURCES ${JIT_I386_SOURCES})
363367
convert_to_absolute_path(JIT_ARM64_SOURCES ${JIT_ARM64_SOURCES})
364368

369+
# Include natvis file for Windows
370+
if (CLR_CMAKE_HOST_WIN32)
371+
set(JIT_NATVIS_SOURCE
372+
clrjit.natvis
373+
)
374+
convert_to_absolute_path(JIT_NATVIS_SOURCE ${JIT_NATVIS_SOURCE})
375+
add_linker_flag("/NATVIS:${JIT_NATVIS_SOURCE}")
376+
endif(CLR_CMAKE_HOST_WIN32)
377+
365378
set(JIT_DLL_MAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/dllmain.cpp)
366379

367380
if(CLR_CMAKE_TARGET_WIN32)

src/coreclr/jit/clrjit.natvis

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
Licensed to the .NET Foundation under one or more agreements.
5+
The .NET Foundation licenses this file to you under the MIT license.
6+
-->
7+
8+
9+
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
10+
11+
<Type Name="Compiler">
12+
<DisplayString>[{info.compFullName,sb} ({info.compMethodHashPrivate,x})]</DisplayString>
13+
<StringView>info.compFullName,sb</StringView>
14+
</Type>
15+
16+
<Type Name="BasicBlock">
17+
<DisplayString Condition="bbJumpKind==BBJ_COND || bbJumpKind==BBJ_ALWAYS || bbJumpKind==BBJ_LEAVE || bbJumpKind==BBJ_EHCATCHRET || bbJumpKind==BBJ_CALLFINALLY">BB{bbNum,d}->BB{bbJumpDest->bbNum,d}; {bbJumpKind,en}</DisplayString>
18+
<DisplayString>BB{bbNum,d}; {bbJumpKind,en}</DisplayString>
19+
</Type>
20+
21+
<Type Name="EHblkDsc">
22+
<DisplayString>type={ebdHandlerType}</DisplayString>
23+
</Type>
24+
25+
<!-- GenTree -->
26+
<Type Name="GenTree">
27+
<DisplayString>[{gtOper,en}, {gtType,en}}]</DisplayString>
28+
</Type>
29+
<Type Name="GenTreeIntCon">
30+
<DisplayString>[IntCon={((GenTreeIntCon*)this)-&gt;gtIconVal, d}]</DisplayString>
31+
</Type>
32+
<Type Name="GenTreeDblCon">
33+
<DisplayString>[DblCon={((GenTreeDblCon*)this)-&gt;gtDconVal, g}]</DisplayString>
34+
</Type>
35+
<Type Name="GenTreeStrCon">
36+
<DisplayString>CNS_STR</DisplayString>
37+
</Type>
38+
<Type Name="GenTreeLngCon">
39+
<DisplayString>[LngCon={((GenTreeLngCon*)this)-&gt;gtLconVal, l}]</DisplayString>
40+
</Type>
41+
<Type Name="GenTreeOp">
42+
<DisplayString Condition="this->gtOper==GT_ASG">[{this-&gt;gtOp1,na}={this-&gt;gtOp2,na}]</DisplayString>
43+
<DisplayString Condition="this->gtOper==GT_CAST">[{((GenTreeCast*)this)-&gt;gtCastType,en} &lt;- {((GenTreeUnOp*)this)-&gt;gtOp1-&gt;gtType,en}]</DisplayString>
44+
<DisplayString>[{gtOper,en}, {gtType,en}]</DisplayString>
45+
</Type>
46+
47+
<Type Name="LclVarDsc">
48+
<DisplayString Condition="lvReason==0">[{lvType,en}]</DisplayString>
49+
<DisplayString>[{lvType,en}-{lvReason,s}]</DisplayString>
50+
</Type>
51+
52+
<Type Name="GenTreeLclVar" Inheritable="false">
53+
<DisplayString>[{gtOper,en}, {gtType,en} V{((GenTreeLclVar*)this)-&gt;_gtLclNum,u}]</DisplayString>
54+
</Type>
55+
56+
<!-- Register allocation -->
57+
<Type Name="LinearScan">
58+
<DisplayString>LinearScan</DisplayString>
59+
<Expand>
60+
<Item Name="AvailableRegs mask">this-&gt;m_AvailableRegs</Item>
61+
<CustomListItems>
62+
<Variable Name="reg" InitialValue="this->m_AvailableRegs" />
63+
<Variable Name="regIndex" InitialValue="0" />
64+
<Loop Condition="reg != 0">
65+
<Item Condition="(reg &amp; 1) != 0">((regNumber)regIndex),en</Item>
66+
<Exec>regIndex++</Exec>
67+
<Exec>reg = reg >> 1</Exec>
68+
</Loop>
69+
</CustomListItems>
70+
<Item Name="RegistersWithConstants mask">this-&gt;m_RegistersWithConstants</Item>
71+
<CustomListItems>
72+
<Variable Name="reg" InitialValue="this->m_RegistersWithConstants" />
73+
<Variable Name="regIndex" InitialValue="0" />
74+
<Loop Condition="reg != 0">
75+
<Item Condition="(reg &amp; 1) != 0">((regNumber)regIndex),en</Item>
76+
<Exec>regIndex++</Exec>
77+
<Exec>reg = reg >> 1</Exec>
78+
</Loop>
79+
</CustomListItems>
80+
</Expand>
81+
</Type>
82+
83+
<Type Name="RefPosition">
84+
<DisplayString>[#{rpNum,d} - {refType,en}]</DisplayString>
85+
<Expand>
86+
<Item Name="Referent" Condition="this->isPhysRegRef">(RegRecord*)this-&gt;referent</Item>
87+
<Item Name="Referent" Condition="!this->isPhysRegRef">(Interval*)this-&gt;referent</Item>
88+
<CustomListItems>
89+
<Variable Name="reg" InitialValue="this->registerAssignment" />
90+
<Variable Name="regIndex" InitialValue="0" />
91+
<Loop Condition="reg != 0">
92+
<Item Condition="(reg &amp; 1) != 0">((regNumber)regIndex),en</Item>
93+
<Exec>regIndex++</Exec>
94+
<Exec>reg = reg >> 1</Exec>
95+
</Loop>
96+
</CustomListItems>
97+
</Expand>
98+
</Type>
99+
100+
<Type Name="Interval">
101+
<DisplayString Condition="this->isLocalVar">[V{this->varNum,d}, #{this->intervalIndex, d}, reg={(regNumber)physReg, en}]</DisplayString>
102+
<DisplayString Condition="this->isConstant">[C{this->intervalIndex, d}, reg={(regNumber)physReg, en}]</DisplayString>
103+
<DisplayString>[I{this->intervalIndex, d}, reg={(regNumber)physReg, en}]</DisplayString>
104+
</Type>
105+
106+
<Type Name="RegRecord">
107+
<DisplayString>[reg={((regNumber)regNum),en}, type={registerType, en}]</DisplayString>
108+
<Expand>
109+
<Item Name="[Assigned]">assignedInterval</Item>
110+
<Item Name="[Previous]">previousInterval</Item>
111+
</Expand>
112+
</Type>
113+
114+
<!-- Emitter -->
115+
<Type Name="insGroup">
116+
<DisplayString Condition="igFlags &amp; 0x200">IG{igNum,d} [extend]</DisplayString>
117+
<DisplayString>IG{igNum,d}</DisplayString>
118+
</Type>
119+
120+
<!-- utils -->
121+
<Type Name="jitstd::list&lt;*&gt;">
122+
<DisplayString Condition="m_nSize > 0">Size={m_nSize}</DisplayString>
123+
<DisplayString Condition="m_nSize == 0">Empty</DisplayString>
124+
<Expand>
125+
<LinkedListItems>
126+
<Size>m_nSize</Size>
127+
<HeadPointer>this->m_pHead</HeadPointer>
128+
<NextPointer>this-&gt;m_pNext</NextPointer>
129+
<ValueNode>this-&gt;m_value</ValueNode>
130+
</LinkedListItems>
131+
</Expand>
132+
</Type>
133+
134+
</AutoVisualizer>

0 commit comments

Comments
 (0)