From cfd08da1036cf72b8e6c6f661260b968f79667e7 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:43:42 -0700 Subject: Clean up `natvis` and use fiddle to generate info needed for `.natvis` debugging (#8192) fixes: #8188 Changes: * Fix Indentation * Add a visualizer for `NodeBase` based on changes to `slang-fiddle` --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-ast-boilerplate.cpp | 1 + source/slang/slang-ast-support-types.h | 12 + source/slang/slang.natvis | 456 ++++++++++++++++----------------- 3 files changed, 235 insertions(+), 234 deletions(-) (limited to 'source') diff --git a/source/slang/slang-ast-boilerplate.cpp b/source/slang/slang-ast-boilerplate.cpp index 0313d4411..54f5f9bb1 100644 --- a/source/slang/slang-ast-boilerplate.cpp +++ b/source/slang/slang-ast-boilerplate.cpp @@ -18,6 +18,7 @@ struct Helper %for _,T in ipairs(Slang.NodeBase.subclasses) do const SyntaxClassInfo $T::kSyntaxClassInfo = { "$T", + $(T.getDebugVisType), ASTNodeType::$T, $(#T.subclasses), % if T.isAbstract then diff --git a/source/slang/slang-ast-support-types.h b/source/slang/slang-ast-support-types.h index 9ad58c776..b69c76307 100644 --- a/source/slang/slang-ast-support-types.h +++ b/source/slang/slang-ast-support-types.h @@ -624,10 +624,22 @@ FIDDLE() namespace Slang typedef SyntaxClassBase ReflectClassInfo; typedef SyntaxClassBase ASTClassInfo; + enum class SyntaxClassInfoDebugVisType + { + Decl, + Expr, + Modifier, + Stmt, + Val, + Scope, + Unknown, + }; + struct SyntaxClassInfo { public: char const* name; + SyntaxClassInfoDebugVisType debugVisType; ASTNodeType firstTag; Count tagCount; void* (*createFunc)(ASTBuilder*); diff --git a/source/slang/slang.natvis b/source/slang/slang.natvis index 3dd3ef1af..edd34f456 100644 --- a/source/slang/slang.natvis +++ b/source/slang/slang.natvis @@ -1,30 +1,39 @@ - + - - - rawVal ? ($T1*)((char*)this + rawVal) : ($T1*)0 - BCPtr nullptr - BCPtr {*($T1*)((char*)this + rawVal)} - - rawVal ? ($T1*)((char*)this + rawVal) : ($T1*)0 - - - - Constant {intOperand} - {(Slang::Val*)nodeOperand} - {nodeOperand} - - *(Slang::Val*)nodeOperand - - - - DeclRef nullptr - - {*declRefBase} - - declRefBase - - + + rawVal ? ($T1*)((char*)this + rawVal) : ($T1*)0 + BCPtr nullptr + BCPtr {*($T1*)((char*)this + rawVal)} + + rawVal ? ($T1*)((char*)this + rawVal) : ($T1*)0 + + + + {astNodeType} + + (Slang::Decl*)this + (Slang::Expr*)this + (Slang::Modifier*)this + (Slang::Stmt*)this + (Slang::Val*)this + (Slang::Scope*)this + + + + Constant {intOperand} + {(Slang::Val*)nodeOperand} + {nodeOperand} + + *(Slang::Val*)nodeOperand + + + + DeclRef nullptr + {*declRefBase} + + declRefBase + + {astNodeType,en}#{_debugUID}({(Decl*)m_operands.m_buffer[0].values.nodeOperand}) {astNodeType,en}({(Decl*)m_operands.m_buffer[0].values.nodeOperand}) @@ -69,140 +78,138 @@ - - {astNodeType,en}#{_debugUID} {*(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand} - - {astNodeType,en} {*(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand} - - - {astNodeType,en}#{_debugUID} {m_operands.m_buffer[0].values.nodeOperand->astNodeType, en}#{m_operands.m_buffer[0].values.nodeOperand->_debugUID} - {astNodeType,en} {m_operands.m_buffer[0].values.nodeOperand->astNodeType, en} - - *(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand - - + + {astNodeType,en}#{_debugUID} {*(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand} + {astNodeType,en} {*(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand} + + + {astNodeType,en}#{_debugUID} {m_operands.m_buffer[0].values.nodeOperand->astNodeType, en}#{m_operands.m_buffer[0].values.nodeOperand->_debugUID} + {astNodeType,en} {m_operands.m_buffer[0].values.nodeOperand->astNodeType, en} + + *(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand + + FuncDecl {nameAndLoc} - - {{name={(char*)(text.m_buffer.pointer+1), s}}} - - - {{name={(char*)((*name).text.m_buffer.pointer+1), s} loc={loc.raw}}} - - - - requirementKey - satisfyingVal - - - - {{{m_op} {(uint32_t)(void*)this, x}}} - {{{m_op} #{_debugUID}}} - - m_op - _debugUID - typeUse.usedValue - - - - - - - - ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 - - - ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 - - - ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 - - child = child->next - - - ((IRStringLit*)this)->value.stringVal.chars,[((IRStringLit*)this)->value.stringVal.numChars]s8 - ((IRIntLit*)this)->value.intVal - - - - - - - pOperandInst = ((IRUse*)(&(typeUse) + 1 + index))->usedValue - pOperandInst - - child = pOperandInst->m_decorationsAndChildren.first - nameDecoration = 0 - - - nameDecoration = child - - - - nameDecoration = child - - - nameDecoration = child - - child = child->next - - *pOperandInst - *pOperandInst - - index = index + 1 - - - - - - - - - - - child = pItem->m_decorationsAndChildren.first - nameDecoration = 0 - - - nameDecoration = child - - - - nameDecoration = child - - - nameDecoration = child - - child = child->next - - *pItem - *pItem - pItem = pItem->next - index = index + 1 - - - - - parent - - - - firstUse - nextUse - user - - - - - - - {{IRUse {usedValue}}} - - usedValue - - - + + {{name={(char*)(text.m_buffer.pointer+1), s}}} + + + {{name={(char*)((*name).text.m_buffer.pointer+1), s} loc={loc.raw}}} + + + + requirementKey + satisfyingVal + + + + {{{m_op} {(uint32_t)(void*)this, x}}} + {{{m_op} #{_debugUID}}} + + m_op + _debugUID + typeUse.usedValue + + + + + + + + ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 + + + ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 + + + ((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.chars,[((Slang::IRStringLit*)(((Slang::IRUse*)(child + 1))->usedValue))->value.stringVal.numChars]s8 + + child = child->next + + + ((IRStringLit*)this)->value.stringVal.chars,[((IRStringLit*)this)->value.stringVal.numChars]s8 + ((IRIntLit*)this)->value.intVal + + + + + + + pOperandInst = ((IRUse*)(&(typeUse) + 1 + index))->usedValue + pOperandInst + + child = pOperandInst->m_decorationsAndChildren.first + nameDecoration = 0 + + + nameDecoration = child + + + + nameDecoration = child + + + nameDecoration = child + + child = child->next + + *pOperandInst + *pOperandInst + + index = index + 1 + + + + + + + + + + + child = pItem->m_decorationsAndChildren.first + nameDecoration = 0 + + + nameDecoration = child + + + + nameDecoration = child + + + nameDecoration = child + + child = child->next + + *pItem + *pItem + pItem = pItem->next + index = index + 1 + + + + + parent + + + + firstUse + nextUse + user + + + + + + + {{IRUse {usedValue}}} + + usedValue + + {astNodeType,en} @@ -286,8 +293,8 @@ (Slang::ContinueStmt*)&astNodeType (Slang::ReturnStmt*)&astNodeType (Slang::ExpressionStmt*)&astNodeType - (Slang::TargetSwitchStmt*)&astNodeType - (Slang::Stmt*)this,! + (Slang::TargetSwitchStmt*)&astNodeType + (Slang::Stmt*)this,! @@ -300,6 +307,7 @@ nameAndLoc.name->text parentDecl Slang::DeclCheckState(checkState.m_raw & ~Slang::DeclCheckStateExt::kBeingCheckedBit) + inferredCapabilityRequirements (Slang::ContainerDecl*)&astNodeType (Slang::ExtensionDecl*)&astNodeType (Slang::StructDecl*)&astNodeType @@ -340,11 +348,9 @@ (Slang::EmptyDecl*)&astNodeType (Slang::SyntaxDecl*)&astNodeType (Slang::DeclGroup*)&astNodeType - (Slang::DeclBase*)this,! - {astNodeType,en} @@ -422,25 +428,21 @@ - - DeclRefType#{_debugUID} {*(Val*)(((Slang::DeclRefType*)this)->m_operands.m_buffer[0].values.nodeOperand)} - DeclRefType {*(Val*)(((Slang::DeclRefType*)this)->m_operands.m_buffer[0].values.nodeOperand)} - DirectRef#{_debugUID} {*(Decl*)m_operands.m_buffer[0].values.nodeOperand} - DirectRef {*(Decl*)m_operands.m_buffer[0].values.nodeOperand} - {astNodeType,en} #{_debugUID} - {astNodeType,en} - + DeclRefType#{_debugUID} {*(Val*)(((Slang::DeclRefType*)this)->m_operands.m_buffer[0].values.nodeOperand)} + DeclRefType {*(Val*)(((Slang::DeclRefType*)this)->m_operands.m_buffer[0].values.nodeOperand)} + DirectRef#{_debugUID} {*(Decl*)m_operands.m_buffer[0].values.nodeOperand} + DirectRef {*(Decl*)m_operands.m_buffer[0].values.nodeOperand} + {astNodeType,en} #{_debugUID} + {astNodeType,en} {astNodeType} - m_operands - SubstitutionSet{declRef,en} @@ -452,7 +454,6 @@ substType = subst->astNodeType shouldBreak = 1 - @@ -491,7 +492,6 @@ *(Decl*)values.nodeOperand - _impl nullptr @@ -507,21 +507,20 @@ - - empty - - - _head != 0 ? _head : 0 - next != 0 ? next : 0 - *this - - - - + + empty + + + _head != 0 ? _head : 0 + next != 0 ? next : 0 + *this + + + + {astNodeType,en}#{_debugUID} ({m_operands.m_buffer[1].values.intOperand} : {*(Type*)m_operands.m_buffer[0].values.nodeOperand}) ConstantIntVal ({m_operands.m_buffer[1].values.intOperand} : {*(Type*)m_operands.m_buffer[0].values.nodeOperand}) - {astNodeType,en}#{_debugUID} {astNodeType,en} @@ -532,7 +531,6 @@ - {astNodeType,en}#{_debugUID} {astNodeType,en} @@ -543,7 +541,6 @@ - {astNodeType,en}#{_debugUID} {astNodeType,en} @@ -554,11 +551,9 @@ - BasicExpressionType ({*(DeclRefBase*)m_operands.m_buffer[0].values.nodeOperand}) - {m_targetSets.map.m_values} @@ -587,7 +582,6 @@ - {{max_size={m_buffer.m_count*Slang::UIntSet::kElementSize}}} @@ -668,55 +662,49 @@ - - - _offset == 0 ? nullptr : ($T1*)((char*)this + _offset) - {($T1*)0} - {($T1*)((char*)this + _offset)} - - _offset == 0 ? nullptr : ($T1*)((char*)this + _offset) - - - - - - "" - {((char*)this + _obj._offset),s8} - - - - - {{ count = 0 }} - {{ count = {*((UInt32*)this - 1)} }} - - *((UInt32*)this - 1) - - *((UInt32*)this - 1) - ($T1*)((char*)this + _obj._offset) - - - - - - {{ count = 0 }} - {{ count = {*((UInt32*)this - 1)} }} - - *((UInt32*)this - 1) - - *((UInt32*)this - 1) - - (Slang::KeyValuePair<$T1,$T2> *) ((char*)this + _obj._offset) - - - - - - + + + + \ No newline at end of file -- cgit v1.2.3