- if (AbbrevDecl) {
- uint16_t tag = AbbrevDecl->getTag();
-
- bool isCompileUnitTag = tag == DW_TAG_compile_unit;
- if(cu && isCompileUnitTag)
- const_cast<DWARFCompileUnit*>(cu)->setBaseAddress(0);
-
- // Skip all data in the .debug_info for the attributes
- const uint32_t numAttributes = AbbrevDecl->getNumAttributes();
- for (uint32_t i = 0; i != numAttributes; ++i) {
- uint16_t attr = AbbrevDecl->getAttrByIndex(i);
- uint16_t form = AbbrevDecl->getFormByIndex(i);
-
- if (isCompileUnitTag &&
- ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) {
- DWARFFormValue form_value(form);
- if (form_value.extractValue(debug_info_data, &offset, cu)) {
- if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
- const_cast<DWARFCompileUnit*>(cu)
- ->setBaseAddress(form_value.getUnsigned());
- }
- } else {
- bool form_is_indirect = false;
- do {
- form_is_indirect = false;
- register uint32_t form_size = 0;
- switch (form) {
- // Blocks if inlined data that have a length field and the data
- // bytes // inlined in the .debug_info
- case DW_FORM_block:
- form_size = debug_info_data.getULEB128(&offset);
- break;
- case DW_FORM_block1:
- form_size = debug_info_data.getU8(&offset);
- break;
- case DW_FORM_block2:
- form_size = debug_info_data.getU16(&offset);
- break;
- case DW_FORM_block4:
- form_size = debug_info_data.getU32(&offset);
- break;
-
- // Inlined NULL terminated C-strings
- case DW_FORM_string:
- debug_info_data.getCStr(&offset);
- break;
-
- // Compile unit address sized values
- case DW_FORM_addr:
- case DW_FORM_ref_addr:
- form_size = cu_addr_size;
- break;
-
- // 1 byte values
- case DW_FORM_data1:
- case DW_FORM_flag:
- case DW_FORM_ref1:
- form_size = 1;
- break;
-
- // 2 byte values
- case DW_FORM_data2:
- case DW_FORM_ref2:
- form_size = 2;
- break;
-
- // 4 byte values
- case DW_FORM_strp:
- form_size = 4;
- break;
-
- case DW_FORM_data4:
- case DW_FORM_ref4:
- form_size = 4;
- break;
-
- // 8 byte values
- case DW_FORM_data8:
- case DW_FORM_ref8:
- form_size = 8;
- break;
-
- // signed or unsigned LEB 128 values
- case DW_FORM_sdata:
- case DW_FORM_udata:
- case DW_FORM_ref_udata:
- debug_info_data.getULEB128(&offset);
- break;
-
- case DW_FORM_indirect:
- form = debug_info_data.getULEB128(&offset);
- form_is_indirect = true;
- break;
-
- default:
- *offset_ptr = offset;
- return false;
- }
-
- offset += form_size;
- } while (form_is_indirect);
- }
- }
- *offset_ptr = offset;
- return true;
- }
- } else {
- AbbrevDecl = NULL;
- *offset_ptr = offset;
- return true; // NULL debug tag entry
- }
+ uint32_t AttrIdx = AbbrevDecl->findAttributeIndex(Attr);
+ if (AttrIdx == -1U)
+ return false;
+
+ DataExtractor DebugInfoData = U->getDebugInfoExtractor();
+ uint32_t DebugInfoOffset = getOffset();
+
+ // Skip the abbreviation code so we are at the data for the attributes
+ DebugInfoData.getULEB128(&DebugInfoOffset);
+
+ // Skip preceding attribute values.
+ for (uint32_t i = 0; i < AttrIdx; ++i) {
+ DWARFFormValue::skipValue(AbbrevDecl->getFormByIndex(i),
+ DebugInfoData, &DebugInfoOffset, U);