From 98527f749182177cbe71514237db8f61bac2fe1a Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 3 Aug 2022 12:13:20 -0700 Subject: [PATCH 1/2] dwarf handle maple function type --- src/mapleall/maple_ir/src/debug_info.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index 004cf96ff5..2ae1ec86b8 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -1068,15 +1068,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); -- Gitee From 0c546c021a71bf7e0e26f58b3b6de1bb56dc3509 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 3 Aug 2022 16:56:35 -0700 Subject: [PATCH 2/2] skip anonymous enum name in dwarf --- src/mapleall/maple_ir/src/debug_info.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index 2ae1ec86b8..0ebfb6c993 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); -- Gitee