From 4777b3362b59b7d03355ab28407426068a8aedde Mon Sep 17 00:00:00 2001 From: fye Date: Thu, 30 Jun 2022 16:59:52 -0700 Subject: [PATCH] debug: fix array upper bound calc --- src/mapleall/maple_ir/src/debug_info.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index 1546454398..20f1e03b1c 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -843,7 +843,12 @@ DBGDie *DebugInfo::GetOrCreateArrayTypeDie(const MIRArrayType *arraytype) { DBGDie *rangedie = module->GetMemPool()->New(module, DW_TAG_subrange_type); (void)GetOrCreatePrimTypeDie(GlobalTables::GetTypeTable().GetUInt32()); rangedie->AddAttr(DW_AT_type, DW_FORM_ref4, PTY_u32); - rangedie->AddAttr(DW_AT_upper_bound, DW_FORM_data4, arraytype->GetSizeArrayItem(0)); + if (theMIRModule->IsCModule() || theMIRModule->IsJavaModule()) { + // The default lower bound value for C, C++, or Java is 0 + rangedie->AddAttr(DW_AT_upper_bound, DW_FORM_data4, arraytype->GetSizeArrayItem(0) - 1); + } else { + rangedie->AddAttr(DW_AT_upper_bound, DW_FORM_data4, arraytype->GetSizeArrayItem(0)); + } die->AddSubVec(rangedie); -- Gitee