@@ -6674,123 +6674,40 @@ const TypeData &Debugger::AddDebugType(const DXIL::Metadata *typeMD)
6674
6674
return m_DebugInfo.types [typeMD];
6675
6675
}
6676
6676
6677
- void Debugger::AddLocalVariable (const DXIL::Metadata *localVariableMD, uint32_t instructionIndex,
6678
- bool isDeclare, int32_t byteOffset, uint32_t countBytes,
6679
- Id debugVarSSAId, const rdcstr &debugVarSSAName)
6677
+ void Debugger::AddLocalVariable (const DXIL::SourceMappingInfo &srcMapping, uint32_t instructionIndex)
6680
6678
{
6681
- RDCASSERT (localVariableMD);
6682
- RDCASSERTEQUAL (localVariableMD->dwarf ->type , DIBase::Type::LocalVariable);
6683
- const DILocalVariable *localVariable = localVariableMD->dwarf ->As <DILocalVariable>();
6679
+ ScopedDebugData *scope = AddScopedDebugData (srcMapping.localVariable ->scope );
6684
6680
6685
- ScopedDebugData *scope = AddScopedDebugData (localVariable->scope );
6686
-
6687
- rdcstr sourceVarName = m_Program->GetDebugVarName (localVariable);
6688
6681
LocalMapping localMapping;
6689
- localMapping.variable = localVariable;
6690
- localMapping.sourceVarName = sourceVarName;
6691
- localMapping.debugVarSSAName = debugVarSSAName;
6692
- localMapping.debugVarSSAId = debugVarSSAId;
6693
- localMapping.byteOffset = byteOffset;
6694
- localMapping.countBytes = countBytes;
6682
+ localMapping.sourceVarName = m_Program->GetDebugVarName (srcMapping.localVariable );
6683
+ localMapping.variable = srcMapping.localVariable ;
6684
+ localMapping.debugVarSSAName = srcMapping.dbgVarName ;
6685
+ localMapping.debugVarSSAId = srcMapping.dbgVarId ;
6686
+ localMapping.byteOffset = srcMapping.srcByteOffset ;
6687
+ localMapping.countBytes = srcMapping.srcCountBytes ;
6688
+ localMapping.isDeclare = srcMapping.isDeclare ;
6695
6689
localMapping.instIndex = instructionIndex;
6696
- localMapping.isDeclare = isDeclare;
6697
6690
6698
6691
scope->localMappings .push_back (localMapping);
6699
6692
6700
- const DXIL::Metadata *typeMD = localVariable->type ;
6693
+ const DXIL::Metadata *typeMD = srcMapping. localVariable ->type ;
6701
6694
if (m_DebugInfo.types .count (typeMD) == 0 )
6702
6695
AddDebugType (typeMD);
6703
6696
6704
- if (m_DebugInfo.locals .count (localVariable) == 0 )
6705
- m_DebugInfo.locals [localVariable] = localMapping;
6697
+ if (m_DebugInfo.locals .count (srcMapping. localVariable ) == 0 )
6698
+ m_DebugInfo.locals [srcMapping. localVariable ] = localMapping;
6706
6699
}
6707
6700
6708
6701
void Debugger::ParseDbgOpDeclare (const DXIL::Instruction &inst, uint32_t instructionIndex)
6709
6702
{
6710
- // arg 0 contains the SSA Id of the alloca result which represents the local variable (a pointer)
6711
- const Metadata *allocaInstMD = cast<Metadata>(inst.args [0 ]);
6712
- RDCASSERT (allocaInstMD);
6713
- const Instruction *allocaInst = cast<Instruction>(allocaInstMD->value );
6714
- RDCASSERT (allocaInst);
6715
- RDCASSERTEQUAL (allocaInst->op , Operation::Alloca);
6716
- Id resultId = Program::GetResultSSAId (*allocaInst);
6717
- rdcstr resultName;
6718
- Program::MakeResultId (*allocaInst, resultName);
6719
- int32_t byteOffset = 0 ;
6720
-
6721
- // arg 1 is DILocalVariable metadata
6722
- const Metadata *localVariableMD = cast<Metadata>(inst.args [1 ]);
6723
-
6724
- // arg 2 is DIExpression metadata
6725
- const Metadata *expressionMD = cast<Metadata>(inst.args [2 ]);
6726
- uint32_t countBytes = 0 ;
6727
- if (expressionMD)
6728
- {
6729
- if (expressionMD->dwarf ->type == DIBase::Type::Expression)
6730
- {
6731
- const DIExpression *expression = expressionMD->dwarf ->As <DXIL::DIExpression>();
6732
- switch (expression->op )
6733
- {
6734
- case DXIL::DW_OP::DW_OP_bit_piece:
6735
- byteOffset += (uint32_t )(expression->evaluated .bit_piece .offset / 8 );
6736
- countBytes = (uint32_t )(expression->evaluated .bit_piece .size / 8 );
6737
- break ;
6738
- case DXIL::DW_OP::DW_OP_none: break ;
6739
- case DXIL::DW_OP::DW_OP_nop: break ;
6740
- default : RDCERR (" Unhandled DIExpression op %s" , ToStr (expression->op ).c_str ()); break ;
6741
- }
6742
- }
6743
- else
6744
- {
6745
- RDCERR (" Unhandled Expression Metadata %s" , ToStr (expressionMD->dwarf ->type ).c_str ());
6746
- }
6747
- }
6748
-
6749
- AddLocalVariable (localVariableMD, instructionIndex, true , byteOffset, countBytes, resultId,
6750
- resultName);
6703
+ DXIL::SourceMappingInfo sourceMappingInfo = m_Program->ParseDbgOpDeclare (inst);
6704
+ AddLocalVariable (sourceMappingInfo, instructionIndex);
6751
6705
}
6752
6706
6753
6707
void Debugger::ParseDbgOpValue (const DXIL::Instruction &inst, uint32_t instructionIndex)
6754
6708
{
6755
- // arg 0 is metadata containing the new value
6756
- const Metadata *valueMD = cast<Metadata>(inst.args [0 ]);
6757
- Id resultId = GetSSAId (valueMD->value );
6758
- rdcstr resultName = m_Program->GetArgumentName (valueMD->value );
6759
- // arg 1 is i64 byte offset in the source variable where the new value is written
6760
- int64_t value = 0 ;
6761
- RDCASSERT (getival<int64_t >(inst.args [1 ], value));
6762
- int32_t byteOffset = (int32_t )(value);
6763
-
6764
- // arg 2 is DILocalVariable metadata
6765
- const Metadata *localVariableMD = cast<Metadata>(inst.args [2 ]);
6766
-
6767
- // arg 3 is DIExpression metadata
6768
- uint32_t countBytes = 0 ;
6769
- const Metadata *expressionMD = cast<Metadata>(inst.args [3 ]);
6770
- if (expressionMD)
6771
- {
6772
- if (expressionMD->dwarf ->type == DIBase::Type::Expression)
6773
- {
6774
- const DIExpression *expression = expressionMD->dwarf ->As <DXIL::DIExpression>();
6775
- switch (expression->op )
6776
- {
6777
- case DXIL::DW_OP::DW_OP_bit_piece:
6778
- byteOffset += (uint32_t )(expression->evaluated .bit_piece .offset / 8 );
6779
- countBytes = (uint32_t )(expression->evaluated .bit_piece .size / 8 );
6780
- break ;
6781
- case DXIL::DW_OP::DW_OP_none: break ;
6782
- case DXIL::DW_OP::DW_OP_nop: break ;
6783
- default : RDCERR (" Unhandled DIExpression op %s" , ToStr (expression->op ).c_str ()); break ;
6784
- }
6785
- }
6786
- else
6787
- {
6788
- RDCERR (" Unhandled Expression Metadata %s" , ToStr (expressionMD->dwarf ->type ).c_str ());
6789
- }
6790
- }
6791
-
6792
- AddLocalVariable (localVariableMD, instructionIndex, false , byteOffset, countBytes, resultId,
6793
- resultName);
6709
+ DXIL::SourceMappingInfo sourceMappingInfo = m_Program->ParseDbgOpValue (inst);
6710
+ AddLocalVariable (sourceMappingInfo, instructionIndex);
6794
6711
}
6795
6712
6796
6713
void Debugger::ParseDebugData ()
0 commit comments