|
12 | 12 |
|
13 | 13 | #include <algorithm>
|
14 | 14 |
|
| 15 | +#include "llvm/Support/LEB128.h" |
| 16 | + |
15 | 17 | #include "lldb/Core/Module.h"
|
16 | 18 | #include "lldb/Expression/DWARFExpression.h"
|
17 | 19 | #include "lldb/Symbol/ObjectFile.h"
|
@@ -239,15 +241,14 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
|
239 | 241 | std::vector<DIERef> die_refs;
|
240 | 242 | bool set_frame_base_loclist_addr = false;
|
241 | 243 |
|
242 |
| - lldb::offset_t offset; |
243 |
| - const DWARFAbbreviationDeclaration *abbrevDecl = |
244 |
| - GetAbbreviationDeclarationPtr(cu, offset); |
| 244 | + auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); |
245 | 245 |
|
246 | 246 | SymbolFileDWARF *dwarf2Data = cu->GetSymbolFileDWARF();
|
247 | 247 | lldb::ModuleSP module = dwarf2Data->GetObjectFile()->GetModule();
|
248 | 248 |
|
249 | 249 | if (abbrevDecl) {
|
250 | 250 | const DWARFDataExtractor &debug_info_data = cu->GetData();
|
| 251 | + lldb::offset_t offset = GetFirstAttributeOffset(); |
251 | 252 |
|
252 | 253 | if (!debug_info_data.ValidOffset(offset))
|
253 | 254 | return false;
|
@@ -561,13 +562,10 @@ void DWARFDebugInfoEntry::DumpAttribute(
|
561 | 562 | size_t DWARFDebugInfoEntry::GetAttributes(
|
562 | 563 | const DWARFUnit *cu, DWARFAttributes &attributes,
|
563 | 564 | uint32_t curr_depth) const {
|
564 |
| - const DWARFAbbreviationDeclaration *abbrevDecl = nullptr; |
565 |
| - lldb::offset_t offset = 0; |
566 |
| - if (cu) |
567 |
| - abbrevDecl = GetAbbreviationDeclarationPtr(cu, offset); |
568 |
| - |
| 565 | + auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); |
569 | 566 | if (abbrevDecl) {
|
570 | 567 | const DWARFDataExtractor &debug_info_data = cu->GetData();
|
| 568 | + lldb::offset_t offset = GetFirstAttributeOffset(); |
571 | 569 |
|
572 | 570 | const uint32_t num_attributes = abbrevDecl->NumAttributes();
|
573 | 571 | for (uint32_t i = 0; i < num_attributes; ++i) {
|
@@ -631,15 +629,14 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
|
631 | 629 | form_value, end_attr_offset_ptr,
|
632 | 630 | check_specification_or_abstract_origin);
|
633 | 631 |
|
634 |
| - lldb::offset_t offset; |
635 |
| - const DWARFAbbreviationDeclaration *abbrevDecl = |
636 |
| - GetAbbreviationDeclarationPtr(cu, offset); |
| 632 | + auto abbrevDecl = GetAbbreviationDeclarationPtr(cu); |
637 | 633 |
|
638 | 634 | if (abbrevDecl) {
|
639 | 635 | uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr);
|
640 | 636 |
|
641 | 637 | if (attr_idx != DW_INVALID_INDEX) {
|
642 | 638 | const DWARFDataExtractor &debug_info_data = cu->GetData();
|
| 639 | + lldb::offset_t offset = GetFirstAttributeOffset(); |
643 | 640 |
|
644 | 641 | uint32_t idx = 0;
|
645 | 642 | while (idx < attr_idx)
|
@@ -1244,35 +1241,17 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
|
1244 | 1241 | return found_address;
|
1245 | 1242 | }
|
1246 | 1243 |
|
| 1244 | +lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const { |
| 1245 | + return GetOffset() + llvm::getULEB128Size(m_abbr_idx); |
| 1246 | +} |
| 1247 | + |
1247 | 1248 | const DWARFAbbreviationDeclaration *
|
1248 |
| -DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr( |
1249 |
| - const DWARFUnit *cu, lldb::offset_t &offset) const { |
| 1249 | +DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(const DWARFUnit *cu) const { |
1250 | 1250 | if (cu) {
|
1251 |
| - offset = GetOffset(); |
1252 |
| - |
1253 | 1251 | const DWARFAbbreviationDeclarationSet *abbrev_set = cu->GetAbbreviations();
|
1254 |
| - if (abbrev_set) { |
1255 |
| - const DWARFAbbreviationDeclaration *abbrev_decl = |
1256 |
| - abbrev_set->GetAbbreviationDeclaration(m_abbr_idx); |
1257 |
| - if (abbrev_decl) { |
1258 |
| - // Make sure the abbreviation code still matches. If it doesn't and the |
1259 |
| - // DWARF data was mmap'ed, the backing file might have been modified |
1260 |
| - // which is bad news. |
1261 |
| - const uint64_t abbrev_code = cu->GetData().GetULEB128(&offset); |
1262 |
| - |
1263 |
| - if (abbrev_decl->Code() == abbrev_code) |
1264 |
| - return abbrev_decl; |
1265 |
| - |
1266 |
| - SymbolFileDWARF *dwarf2Data = cu->GetSymbolFileDWARF(); |
1267 |
| - |
1268 |
| - dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected( |
1269 |
| - "0x%8.8x: the DWARF debug information has been modified (abbrev " |
1270 |
| - "code was %u, and is now %u)", |
1271 |
| - GetOffset(), (uint32_t)abbrev_decl->Code(), (uint32_t)abbrev_code); |
1272 |
| - } |
1273 |
| - } |
| 1252 | + if (abbrev_set) |
| 1253 | + return abbrev_set->GetAbbreviationDeclaration(m_abbr_idx); |
1274 | 1254 | }
|
1275 |
| - offset = DW_INVALID_OFFSET; |
1276 | 1255 | return nullptr;
|
1277 | 1256 | }
|
1278 | 1257 |
|
|
0 commit comments