diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index a0f15fbbdc4a4fc56e0ca2bd2d27017b6218dcf1..0a0d17620df94bdacc84efd21ff0441f9119b9fd 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -620,6 +620,10 @@ DBGDie *DebugInfo::CreateVarDie(MIRSymbol *sym) { bool isLocal = sym->IsLocal(); GStrIdx strIdx = sym->GetNameStrIdx(); + if (sym->IsPUStatic()) { + strIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(sym->GetName()); + } + if (isLocal) { MIRFunction *func = GetCurFunction(); if ((funcLstrIdxDieIdMap[func]).size() && @@ -656,7 +660,15 @@ DBGDie *DebugInfo::CreateVarDie(MIRSymbol *sym, GStrIdx strIdx) { bool isLocal = sym->IsLocal(); if (isLocal) { - die->AddSimpLocAttr(DW_AT_location, DW_FORM_exprloc, kDbgDefaultVal); + if (sym->IsPUStatic()) { + // Use actual internal sym by cg + PUIdx pIdx = GetCurFunction()->GetPuidx(); + std::string ptrName = sym->GetName() + std::to_string(pIdx); + uint64 idx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(ptrName).GetIdx(); + die->AddGlobalLocAttr(DW_AT_location, DW_FORM_exprloc, idx); + } else { + die->AddSimpLocAttr(DW_AT_location, DW_FORM_exprloc, kDbgDefaultVal); + } } else { // global var just use its name as address in .s uint64 idx = strIdx.GetIdx();