diff --git a/src/hir2mpl/common/src/enhance_c_checker.cpp b/src/hir2mpl/common/src/enhance_c_checker.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_be/include/cg/valid_bitmask_imm.txt b/src/mapleall/maple_be/include/cg/valid_bitmask_imm.txt old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_be/src/cg/x86_64/x64_cg.cpp b/src/mapleall/maple_be/src/cg/x86_64/x64_cg.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/debug_info.h b/src/mapleall/maple_ir/include/debug_info.h index dd55274ecf28c3d70d4bb364cb5cd7632ad92574..1768950da33c4f32e4746ce8a8e41a9c8902e088 100644 --- a/src/mapleall/maple_ir/include/debug_info.h +++ b/src/mapleall/maple_ir/include/debug_info.h @@ -769,6 +769,7 @@ class DebugInfo { DBGDie *GetOrCreateArrayTypeDie(const MIRArrayType *arrayType); DBGDie *GetOrCreateStructTypeDie(const MIRType *type); DBGDie *GetOrCreateTypedefDie(GStrIdx stridx, TyIdx tyidx); + DBGDie *GetOrCreateEnumTypeDie(unsigned idx); GStrIdx GetPrimTypeCName(PrimType pty); diff --git a/src/mapleall/maple_ir/include/dex2mpl/dexintrinsic.def b/src/mapleall/maple_ir/include/dex2mpl/dexintrinsic.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsic_c.def b/src/mapleall/maple_ir/include/intrinsic_c.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsic_dai.def b/src/mapleall/maple_ir/include/intrinsic_dai.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsic_java.def b/src/mapleall/maple_ir/include/intrinsic_java.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsic_js.def b/src/mapleall/maple_ir/include/intrinsic_js.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsic_vector.def b/src/mapleall/maple_ir/include/intrinsic_vector.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/intrinsics.def b/src/mapleall/maple_ir/include/intrinsics.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/mir_builder.h b/src/mapleall/maple_ir/include/mir_builder.h old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/mir_nodes.h b/src/mapleall/maple_ir/include/mir_nodes.h old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/mir_parser.h b/src/mapleall/maple_ir/include/mir_parser.h old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/opcodes.def b/src/mapleall/maple_ir/include/opcodes.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/include/simplifyintrinsics.def b/src/mapleall/maple_ir/include/simplifyintrinsics.def old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index dfce87265f628a868c88c93d2f7a98c02d0334b1..93535b621aa3e06777c8b72f5e88ca4d0ff25f83 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -351,12 +351,17 @@ void DebugInfo::AddAliasDies(MapleMap &aliasMap) { // create alias die using maple var except name DBGDie *vdie = CreateVarDie(var, i.first); - // use src code type name for type if provided if (i.second.atk == kATKString) { + // use src code type GStrIdx idx(i.second.index); DBGDie *typedefDie = GetOrCreateTypedefDie(idx, var->GetTyIdx()); // use negtive number to indicate DIE id instead of tyidx in normal cases (void)(vdie->SetAttr(DW_AT_type, -typedefDie->GetId())); + } else if (i.second.atk == kATKEnum) { + // use src code enum type + DBGDie *enumDie = GetOrCreateEnumTypeDie(i.second.index); + // use negtive number to indicate DIE id instead of tyidx in normal cases + (void)(vdie->SetAttr(DW_AT_type, -enumDie->GetId())); } // link vdie's ExprLoc to mdie's @@ -473,6 +478,13 @@ void DebugInfo::BuildDebugInfo() { compUnit->AddSubVec(die); } + // setup debug info for enum types + unsigned size = GlobalTables::GetEnumTable().enumTable.size(); + for (unsigned i = 0; i < size; ++i) { + DBGDie *die = GetOrCreateEnumTypeDie(i); + compUnit->AddSubVec(die); + } + // setup debug info for functions for (auto func : GlobalTables::GetFunctionTable().GetFuncTable()) { // the first one in funcTable is nullptr @@ -929,6 +941,38 @@ DBGDie *DebugInfo::GetOrCreateTypedefDie(GStrIdx stridx, TyIdx tyidx) { return die; } +DBGDie *DebugInfo::GetOrCreateEnumTypeDie(unsigned idx) { + MIREnum *mirEnum = GlobalTables::GetEnumTable().enumTable[idx]; + uint32 sid = mirEnum->nameStrIdx.GetIdx(); + auto it = globalStridxDieIdMap.find(sid); + if (it != globalStridxDieIdMap.end()) { + return idDieMap[it->second]; + } + + DBGDie *die = module->GetMemPool()->New(module, DW_TAG_enumeration_type); + + PrimType pty = mirEnum->primType; + (void)(die->AddAttr(DW_AT_name, DW_FORM_strp, sid)); + (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); + (void) GetOrCreateTypeDie(type); + (void)(die->AddAttr(DW_AT_type, DW_FORM_ref4, type->GetTypeIndex().GetIdx())); + (void)(die->AddAttr(DW_AT_decl_file, DW_FORM_data1, 0)); + (void)(die->AddAttr(DW_AT_decl_line, DW_FORM_data1, 0)); + (void)(die->AddAttr(DW_AT_decl_column, DW_FORM_data1, 0)); + + for (auto it : mirEnum->elements) { + DBGDie *elem = module->GetMemPool()->New(module, DW_TAG_enumerator); + (void)(elem->AddAttr(DW_AT_name, DW_FORM_strp, it.first.GetIdx())); + (void)(elem->AddAttr(DW_AT_const_value, DW_FORM_data8, it.second.GetExtValue())); + die->AddSubVec(elem); + } + + globalStridxDieIdMap[sid] = die->GetId(); + return die; +} + DBGDie *DebugInfo::GetOrCreatePointTypeDie(const MIRPtrType *ptrType) { uint32 tid = ptrType->GetTypeIndex().GetIdx(); if (tyIdxDieIdMap.find(tid) != tyIdxDieIdMap.end()) { diff --git a/src/mapleall/maple_ir/src/mir_builder.cpp b/src/mapleall/maple_ir/src/mir_builder.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/src/mir_module.cpp b/src/mapleall/maple_ir/src/mir_module.cpp index b05900e3c885e50b0cee8fe8c1c792750e058659..e46542a958073584c49124fd0d8c30d17ec55996 100644 --- a/src/mapleall/maple_ir/src/mir_module.cpp +++ b/src/mapleall/maple_ir/src/mir_module.cpp @@ -292,8 +292,8 @@ void MIRModule::DumpGlobals(bool emitStructureType) const { s->Dump(false, 0); } } - if (scope) { - scope->Dump(0, false); + if (scope && !scope->IsEmpty()) { + scope->Dump(0, /* isLocal */ false); } } } diff --git a/src/mapleall/maple_ir/src/mir_nodes.cpp b/src/mapleall/maple_ir/src/mir_nodes.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_ir/src/mir_parser.cpp b/src/mapleall/maple_ir/src/mir_parser.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/irmap_build.cpp b/src/mapleall/maple_me/src/irmap_build.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/irmap_emit.cpp b/src/mapleall/maple_me/src/irmap_emit.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/me_function.cpp b/src/mapleall/maple_me/src/me_function.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/me_safety_warning.cpp b/src/mapleall/maple_me/src/me_safety_warning.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/me_stmt_pre.cpp b/src/mapleall/maple_me/src/me_stmt_pre.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/me_value_range_prop.cpp b/src/mapleall/maple_me/src/me_value_range_prop.cpp old mode 100755 new mode 100644 diff --git a/src/mapleall/maple_me/src/pme_emit.cpp b/src/mapleall/maple_me/src/pme_emit.cpp old mode 100755 new mode 100644