diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index 004cf96ff55e568f9a5bce14799ebb15621e3d26..0ebfb6c9934319aaffba1a00e51d1511bb3347ad 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -1039,7 +1039,11 @@ DBGDie *DebugInfo::GetOrCreateEnumTypeDie(unsigned idx) { DBGDie *die = module->GetMemPool()->New(module, DW_TAG_enumeration_type); PrimType pty = mirEnum->GetPrimType(); - (void)(die->AddAttr(DW_AT_name, DW_FORM_strp, sid)); + // check if it is an anonymous enum + const std::string &name = GlobalTables::GetStrTable().GetStringFromStrIdx(mirEnum->GetNameIdx()); + size_t pos = name.find("unnamed_enum."); + uint32 stridx = (pos == std::string::npos) ? sid : 0; + (void)(die->AddAttr(DW_AT_name, DW_FORM_strp, stridx)); (void)(die->AddAttr(DW_AT_encoding, DW_FORM_data4, GetAteFromPTY(pty))); (void)(die->AddAttr(DW_AT_byte_size, DW_FORM_data1, GetPrimTypeSize(pty))); MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(pty); @@ -1068,15 +1072,18 @@ DBGDie *DebugInfo::GetOrCreatePointTypeDie(const MIRPtrType *ptrType) { } MIRType *type = ptrType->GetPointedType(); - // for <* void> + // for <* void> and if ((type != nullptr) && (type->GetPrimType() == PTY_void || type->GetKind() == kTypeFunction)) { - DBGDie *die = module->GetMemPool()->New(module, DW_TAG_pointer_type); - die->AddAttr(DW_AT_byte_size, DW_FORM_data4, k8BitSize); + DBGDie *die = nullptr; if (type->GetKind() == kTypeFunction) { - DBGDie *pdie = GetOrCreateTypeDie(type); + // for maple's function pointer type, function type should be used in dwarf + die = GetOrCreateTypeDie(type); die->AddAttr(DW_AT_type, DW_FORM_ref4, type->GetTypeIndex().GetIdx()); - tyIdxDieIdMap[type->GetTypeIndex().GetIdx()] = pdie->GetId(); + tyIdxDieIdMap[type->GetTypeIndex().GetIdx()] = die->GetId(); + } else { + die = module->GetMemPool()->New(module, DW_TAG_pointer_type); + die->AddAttr(DW_AT_byte_size, DW_FORM_data4, k8BitSize); } tyIdxDieIdMap[ptrType->GetTypeIndex().GetIdx()] = die->GetId(); compUnit->AddSubVec(die);