Skip to content

Commit ed9c24a

Browse files
committedDec 18, 2024
Use debug location scope to find current debug scope
1 parent a3708cf commit ed9c24a

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed
 

‎renderdoc/driver/shaders/dxil/dxil_debug.cpp

+5-18
Original file line numberDiff line numberDiff line change
@@ -6158,21 +6158,6 @@ void Debugger::CalcActiveMask(rdcarray<bool> &activeMask)
61586158
return;
61596159
}
61606160

6161-
ScopedDebugData *Debugger::FindScopedDebugData(const uint32_t instructionIndex) const
6162-
{
6163-
ScopedDebugData *scope = NULL;
6164-
// Scopes are sorted with increasing minInstruction
6165-
for(ScopedDebugData *s : m_DebugInfo.scopedDebugDatas)
6166-
{
6167-
uint32_t scopeMinInstruction = s->minInstruction;
6168-
if((scopeMinInstruction <= instructionIndex) && (instructionIndex <= s->maxInstruction))
6169-
scope = s;
6170-
else if(scopeMinInstruction > instructionIndex)
6171-
break;
6172-
}
6173-
return scope;
6174-
}
6175-
61766161
ScopedDebugData *Debugger::FindScopedDebugData(const DXIL::Metadata *md) const
61776162
{
61786163
for(ScopedDebugData *s : m_DebugInfo.scopedDebugDatas)
@@ -6205,7 +6190,6 @@ ScopedDebugData *Debugger::AddScopedDebugData(const DXIL::Metadata *scopeMD)
62056190

62066191
scope = new ScopedDebugData();
62076192
scope->md = scopeMD;
6208-
scope->minInstruction = UINT32_MAX;
62096193
scope->maxInstruction = 0;
62106194
// File scope should not have a parent
62116195
if(scopeMD->dwarf->type == DIBase::File)
@@ -6651,14 +6635,18 @@ void Debugger::ParseDebugData()
66516635

66526636
for(uint32_t i = 0; i < countInstructions; ++i)
66536637
{
6638+
if(f->instructions[i]->debugLoc == ~0U)
6639+
continue;
6640+
66546641
uint32_t instructionIndex = i + info.globalInstructionOffset;
66556642

66566643
DXIL::Program::LocalSourceVariable localSrcVar;
66576644
localSrcVar.startInst = instructionIndex;
66586645
localSrcVar.endInst = instructionIndex;
66596646

66606647
// For each instruction - find which scope it belongs
6661-
const ScopedDebugData *scope = FindScopedDebugData(instructionIndex);
6648+
const DebugLocation &debugLoc = m_Program->m_DebugLocations[f->instructions[i]->debugLoc];
6649+
const ScopedDebugData *scope = FindScopedDebugData(GetMDScope(debugLoc.scope));
66626650
// track which mappings we've processed, so if the same variable has mappings in multiple
66636651
// scopes we only pick the innermost.
66646652
rdcarray<LocalMapping> processed;
@@ -7624,7 +7612,6 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain
76247612
continue;
76257613

76267614
currentScope = thisScope;
7627-
thisScope->minInstruction = RDCMIN(thisScope->minInstruction, instructionIndex);
76287615
thisScope->maxInstruction = instructionIndex;
76297616
// Walk upwards from this scope to find where to append to the scope hierarchy
76307617
{

‎renderdoc/driver/shaders/dxil/dxil_debug.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,9 @@ struct ScopedDebugData
477477
rdcstr functionName;
478478
rdcstr fileName;
479479
uint32_t line;
480-
uint32_t minInstruction;
481480
uint32_t maxInstruction;
482481

483-
bool operator<(const ScopedDebugData &o) const
484-
{
485-
if(minInstruction != o.minInstruction)
486-
return minInstruction < o.minInstruction;
487-
if(maxInstruction != o.maxInstruction)
488-
return maxInstruction < o.maxInstruction;
489-
return line < o.line;
490-
}
482+
bool operator<(const ScopedDebugData &o) const { return line < o.line; }
491483
};
492484

493485
struct TypeData
@@ -537,7 +529,6 @@ class Debugger : public DXBCContainerDebugger
537529
const DXIL::Metadata *GetMDScope(const DXIL::Metadata *scopeMD) const;
538530
ScopedDebugData *AddScopedDebugData(const DXIL::Metadata *scopeMD);
539531
ScopedDebugData *FindScopedDebugData(const DXIL::Metadata *md) const;
540-
ScopedDebugData *FindScopedDebugData(const uint32_t instructionIndex) const;
541532
const TypeData &AddDebugType(const DXIL::Metadata *typeMD);
542533
void AddLocalVariable(const DXIL::Metadata *localVariableMD, uint32_t instructionIndex,
543534
bool isDeclare, int32_t byteOffset, uint32_t countBytes, Id debugSSAId,

0 commit comments

Comments
 (0)