Prefer DebugFunction name over function OpName when available

This commit is contained in:
baldurk
2022-09-15 11:20:49 +01:00
parent 58437e426f
commit 4fbd1a08ac
3 changed files with 34 additions and 5 deletions
@@ -100,10 +100,10 @@ bool ThreadState::Finished() const
return killed || callstack.empty();
}
void ThreadState::FillCallstack(ShaderDebugState &state)
void ThreadState::FillCallstack(rdcarray<Id> &funcs)
{
for(const StackFrame *frame : callstack)
state.callstack.push_back(debugger.GetHumanName(frame->function));
funcs.push_back(frame->function);
}
void ThreadState::EnterFunction(const rdcarray<Id> &arguments)
+4 -1
View File
@@ -182,7 +182,7 @@ struct ThreadState
ShaderVariable CalcDeriv(DerivDir dir, DerivType type, const rdcarray<ThreadState> &workgroup,
Id val);
void FillCallstack(ShaderDebugState &state);
void FillCallstack(rdcarray<Id> &funcs);
bool Finished() const;
@@ -392,6 +392,7 @@ private:
void MakeSignatureNames(const rdcarray<SPIRVInterfaceAccess> &sigList, rdcarray<rdcstr> &sigNames);
void FillCallstack(ThreadState &thread, ShaderDebugState &state);
void FillDebugSourceVars(rdcarray<InstructionSourceInfo> &instInfo);
void FillDefaultSourceVars(rdcarray<InstructionSourceInfo> &instInfo);
@@ -471,6 +472,8 @@ private:
SparseIdMap<int32_t> sources;
SparseIdMap<rdcstr> filenames;
SparseIdMap<Id> funcToDebugFunc;
std::map<size_t, ScopeData *> lineScope;
std::map<size_t, InlineData *> lineInline;
@@ -1422,6 +1422,27 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s
return ret;
}
void Debugger::FillCallstack(ThreadState &thread, ShaderDebugState &state)
{
rdcarray<Id> funcs;
thread.FillCallstack(funcs);
for(Id f : funcs)
{
if(m_DebugInfo.valid)
{
auto it = m_DebugInfo.funcToDebugFunc.find(f);
if(it != m_DebugInfo.funcToDebugFunc.end())
{
state.callstack.push_back(m_DebugInfo.scopes[it->second].name);
continue;
}
}
state.callstack.push_back(GetHumanName(f));
}
}
void Debugger::FillDebugSourceVars(rdcarray<InstructionSourceInfo> &instInfo)
{
for(InstructionSourceInfo &i : instInfo)
@@ -1804,7 +1825,7 @@ rdcarray<ShaderDebugState> Debugger::ContinueDebug()
if(lane == activeLaneIndex)
{
thread.EnterEntryPoint(&initial);
thread.FillCallstack(initial);
FillCallstack(thread, initial);
initial.nextInstruction = thread.nextInstruction;
}
else
@@ -1902,7 +1923,7 @@ rdcarray<ShaderDebugState> Debugger::ContinueDebug()
else if(thread.callstack.size() < prevStackSize && funcRet != ~0U)
instOffs = instructionOffsets[funcRet];
thread.FillCallstack(state);
FillCallstack(thread, state);
if(m_DebugInfo.valid)
{
@@ -3133,6 +3154,11 @@ void Debugger::RegisterOp(Iter it)
};
break;
}
case ShaderDbg::FunctionDefinition:
{
m_DebugInfo.funcToDebugFunc[dbg.arg<Id>(1)] = dbg.arg<Id>(0);
break;
}
case ShaderDbg::Function:
{
rdcstr name = strings[dbg.arg<Id>(0)];