Skip to content

Commit

Permalink
DXIL Debugger use function name for callstack if no debug scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorro666 committed Dec 16, 2024
1 parent 71ba5a9 commit 8a9b344
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,13 +1657,35 @@ void ThreadState::EnterEntryPoint(const Function *function, ShaderDebugState *st

void ThreadState::FillCallstack(ShaderDebugState &state)
{
if(m_FunctionInfo->callstacks.size() == 1)
{
state.callstack = m_FunctionInfo->callstacks.begin()->second;
return;
}

auto it = m_FunctionInfo->callstacks.upper_bound(state.nextInstruction);
if(it == m_FunctionInfo->callstacks.end())
{
RDCWARN("No callstack entry found for instruction %u", state.nextInstruction);
state.callstack.clear();
state.callstack.push_back(m_FunctionInfo->function->name);
return;
}

if(it != m_FunctionInfo->callstacks.begin())
--it;

if(it->first <= m_FunctionInstructionIdx)
{
state.callstack = it->second;
}
else
{
RDCWARN("No callstack entry found for instruction %u", state.nextInstruction);
state.callstack.clear();
state.callstack.push_back(m_FunctionInfo->function->name);
return;
}
}

bool IsNopInstruction(const Instruction &inst)
Expand Down Expand Up @@ -7529,6 +7551,13 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain
}
info.callstacks[instructionIndex] = callstack;
}
// If there is no callstack for the function then use the function name
if(info.callstacks.empty())
{
FunctionInfo::Callstack callstack;
callstack.push_back(f->name);
info.callstacks[0] = callstack;
}
}
}

Expand Down

0 comments on commit 8a9b344

Please sign in to comment.