ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei, arphaman.
Herald added a reviewer: shafik.
Herald added a project: All.
ayermolo published this revision for review.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.
The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part pre-requisite is to enable 64bit offset support in LLDB with
this patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138618
Files:
lldb/include/lldb/Core/dwarf.h
lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
Index: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
===================================================================
--- lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
@@ -45,6 +45,26 @@
EncodeDecode(DIERef(200, DIERef::Section::DebugTypes, 0x11223344));
}
+TEST(DWARFIndexCachingTest, DIERefEncodeDecodeMax) {
+ // Tests DIERef::Encode(...) and DIERef::Decode(...)
+ EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugInfo,
+ DIERef::k_die_offset_mask));
+ EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugTypes,
+ DIERef::k_die_offset_mask));
+ EncodeDecode(
+ DIERef(100, DIERef::Section::DebugInfo, DIERef::k_die_offset_mask));
+ EncodeDecode(
+ DIERef(200, DIERef::Section::DebugTypes, DIERef::k_die_offset_mask));
+ EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo,
+ DIERef::k_dwo_num_mask));
+ EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes,
+ DIERef::k_dwo_num_mask));
+ EncodeDecode(
+ DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo, 0x11223344));
+ EncodeDecode(
+ DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes, 0x11223344));
+}
+
static void EncodeDecode(const NameToDIE &object, ByteOrder byte_order) {
const uint8_t addr_size = 8;
DataEncoder encoder(byte_order, addr_size);
Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
@@ -4,9 +4,9 @@
# RUN: -o exit | FileCheck %s
# CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK: Function: id = {0x4000000000000028}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
-# CHECK: Blocks: id = {0x4000000000000028}, range = [0x00000000-0x00000003)
-# CHECK-NEXT: id = {0x4000000000000037}, range = [0x00000001-0x00000002)
+# CHECK: Function: id = {0x2000000000000028}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
+# CHECK: Blocks: id = {0x2000000000000028}, range = [0x00000000-0x00000003)
+# CHECK-NEXT: id = {0x2000000000000037}, range = [0x00000001-0x00000002)
.text
rnglists:
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -8,7 +8,7 @@
# RUN: -o exit | FileCheck %s
# Failure was the block range 1..2 was not printed plus:
-# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x0000003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
+# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x000000000000003f}: DIE has DW_AT_ranges(0xc) attribute, but range extraction failed (missing or invalid range list table), please file a bug and attach the file at the start of this error message
# CHECK-LABEL: image lookup -v -s lookup_rnglists
# CHECK: Function: id = {0x00000029}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
@@ -22,7 +22,7 @@
# RUN: cat %t.error | FileCheck --check-prefix=ERROR %s
# RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# ERROR: error: {{.*}} {0x0000003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x00000000), please file a bug and attach the file at the start of this error message
+# ERROR: error: {{.*}} {0x000000000000003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x00000000), please file a bug and attach the file at the start of this error message
# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
# RUN: --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -31,7 +31,7 @@
# RUN: cat %t.error | FileCheck --check-prefix=ERRORBASE %s
# RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# ERRORBASE: error: {{.*}}-rnglistbase {0x00000043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message
+# ERRORBASE: error: {{.*}}-rnglistbase {0x0000000000000043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message
.text
rnglists:
Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp
===================================================================
--- lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -773,7 +773,7 @@
// function.)
if (stack.empty()) {
LLDB_LOGF(log,
- "DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx32
+ "DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx64
", startaddr: %" PRIx64
" encountered DW_CFA_restore_state but state stack "
"is empty. Corrupt unwind info?",
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -9,6 +9,7 @@
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
+#include "DIERef.h"
#include "SymbolFileDWARF.h"
class SymbolFileDWARFDwo : public SymbolFileDWARF {
@@ -40,7 +41,9 @@
DWARFDIE
GetDIE(const DIERef &die_ref) override;
- llvm::Optional<uint32_t> GetDwoNum() override { return GetID() >> 32; }
+ llvm::Optional<uint32_t> GetDwoNum() override {
+ return DIERef(GetID()).dwo_num();
+ }
lldb::offset_t
GetVendorDWARFOpcodeSize(const lldb_private::DataExtractor &data,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -8,6 +8,7 @@
#include "SymbolFileDWARFDwo.h"
+#include "DIERef.h"
#include "lldb/Core/Section.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -28,7 +29,7 @@
: SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section_list*/ false)),
m_base_symbol_file(base_symbol_file) {
- SetID(user_id_t(id) << 32);
+ SetID(DIERef(id, DIERef::Section(0), 0).get_id());
// Parsing of the dwarf unit index is not thread-safe, so we need to prime it
// to enable subsequent concurrent lookups.
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -9,6 +9,7 @@
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
+#include "DIERef.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Utility/RangeMap.h"
#include "llvm/Support/Chrono.h"
@@ -208,7 +209,9 @@
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) {
- return (uint32_t)((uid >> 32ull) - 1ull);
+ llvm::Optional<uint32_t> OsoNum = DIERef(uid).oso_num();
+ lldbassert(OsoNum && "Invalid OSO Index");
+ return *OsoNum;
}
static SymbolFileDWARF *GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file);
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "SymbolFileDWARFDebugMap.h"
+#include "DIERef.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
@@ -210,7 +211,9 @@
// Set the ID of the symbol file DWARF to the index of the OSO
// shifted left by 32 bits to provide a unique prefix for any
// UserID's that get created in the symbol file.
- oso_symfile->SetID(((uint64_t)m_cu_idx + 1ull) << 32ull);
+ oso_symfile->SetID(DIERef(DIERef::IndexType::OSONum, m_cu_idx,
+ DIERef::Section(0), 0)
+ .get_id());
}
return symfile;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -13,6 +13,7 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/Threading.h"
+#include "DIERef.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
@@ -587,6 +588,15 @@
}
}
+ constexpr uint64_t MaxDebugInfoSize = (1ull) << DW_DIE_OFFSET_MAX_BITSIZE;
+ if (debug_info_file_size >= MaxDebugInfoSize) {
+ m_objfile_sp->GetModule()->ReportWarning(
+ "SymbolFileDWARF can't load this DWARF. It's larger then "
+ "0x%16.16" PRIx64 "",
+ MaxDebugInfoSize);
+ return 0;
+ }
+
if (debug_abbrev_file_size > 0 && debug_info_file_size > 0)
abilities |= CompileUnits | Functions | Blocks | GlobalVariables |
LocalVariables | VariableTypes;
@@ -1397,13 +1407,13 @@
}
user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
- if (GetDebugMapSymfile())
- return GetID() | ref.die_offset();
+ if (GetDebugMapSymfile()) {
+ DIERef die_ref(GetID());
+ die_ref.set_die_offset(ref.die_offset());
+ return die_ref.get_id();
+ }
- lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff);
- return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() |
- lldb::user_id_t(GetDwoNum().has_value()) << 62 |
- lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
+ return DIERef(GetDwoNum(), ref.section(), ref.die_offset()).get_id();
}
llvm::Optional<SymbolFileDWARF::DecodedUID>
@@ -1418,25 +1428,18 @@
// references to other DWARF objects and we must be ready to receive a
// "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
// instance.
+ DIERef die_ref(uid);
if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
debug_map->GetOSOIndexFromUserID(uid));
return DecodedUID{
- *dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
+ *dwarf, {llvm::None, DIERef::Section::DebugInfo, die_ref.die_offset()}};
}
- dw_offset_t die_offset = uid;
- if (die_offset == DW_INVALID_OFFSET)
- return llvm::None;
-
- DIERef::Section section =
- uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
- llvm::Optional<uint32_t> dwo_num;
- bool dwo_valid = uid >> 62 & 1;
- if (dwo_valid)
- dwo_num = uid >> 32 & 0x3fffffff;
+ if (die_ref.die_offset() == DW_INVALID_OFFSET)
+ return llvm::None;
- return DecodedUID{*this, {dwo_num, section, die_offset}};
+ return DecodedUID{*this, die_ref};
}
DWARFDIE
@@ -1520,7 +1523,8 @@
Log *log = GetLog(DWARFLog::DebugInfo);
if (log)
GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
+ log,
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%16.16" PRIx64 ") %s '%s'",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
// We might be coming in in the middle of a type tree (a class within a
@@ -1537,8 +1541,9 @@
if (log)
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' "
- "resolve parent forward type for 0x%8.8x",
+ "SymbolFileDWARF::ResolveTypeUID (die = 0x%16.16" PRIx64
+ ") %s '%s' "
+ "resolve parent forward type for 0x%16.16" PRIx64 "",
die.GetOffset(), die.GetTagAsCString(), die.GetName(),
decl_ctx_die.GetOffset());
} break;
@@ -1629,7 +1634,7 @@
return type;
GetObjectFile()->GetModule()->ReportError(
- "Parsing a die that is being parsed die: 0x%8.8x: %s %s",
+ "Parsing a die that is being parsed die: 0x%16.16" PRIx64 ": %s %s",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
} else
@@ -1694,7 +1699,7 @@
DWARFDIE
SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
if (die_ref.dwo_num()) {
- SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x3fffffff
+ SymbolFileDWARF *dwarf = *die_ref.dwo_num() == DIERef::k_dwo_num_mask
? m_dwp_symfile.get()
: this->DebugInfo()
.GetUnitAtIndex(*die_ref.dwo_num())
@@ -1744,7 +1749,7 @@
const char *dwo_name = GetDWOName(*dwarf_cu, cu_die);
if (!dwo_name) {
- unit.SetDwoError(Status("missing DWO name in skeleton DIE 0x%8.8" PRIx32,
+ unit.SetDwoError(Status("missing DWO name in skeleton DIE 0x%16.16" PRIx64,
cu_die.GetOffset()));
return nullptr;
}
@@ -1761,8 +1766,9 @@
if (!comp_dir) {
unit.SetDwoError(
Status("unable to locate relative .dwo debug file \"%s\" for "
- "skeleton DIE 0x%8.8" PRIx32 " without valid DW_AT_comp_dir "
- "attribute", dwo_name, cu_die.GetOffset()));
+ "skeleton DIE 0x%16.16" PRIx64 " without valid DW_AT_comp_dir "
+ "attribute",
+ dwo_name, cu_die.GetOffset()));
return nullptr;
}
@@ -1781,8 +1787,8 @@
if (!FileSystem::Instance().Exists(dwo_file)) {
unit.SetDwoError(
Status("unable to locate .dwo debug file \"%s\" for skeleton DIE "
- "0x%8.8" PRIx32, dwo_file.GetPath().c_str(),
- cu_die.GetOffset()));
+ "0x%16.16" PRIx64,
+ dwo_file.GetPath().c_str(), cu_die.GetOffset()));
if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
GetObjectFile()->GetModule()->ReportWarning(
@@ -1801,8 +1807,9 @@
dwo_file_data_offset);
if (dwo_obj_file == nullptr) {
unit.SetDwoError(
- Status("unable to load object file for .dwo debug file \"%s\" for "
- "unit DIE 0x%8.8" PRIx32, dwo_name, cu_die.GetOffset()));
+ Status("unable to load object file for .dwo debug file \"%s\" for "
+ "unit DIE 0x%16.16" PRIx64,
+ dwo_name, cu_die.GetOffset()));
return nullptr;
}
@@ -1878,7 +1885,8 @@
nullptr, nullptr, nullptr);
if (!module_sp) {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: unable to locate module needed for external types: "
+ "0x%16.16" PRIx64
+ ": unable to locate module needed for external types: "
"%s\nerror: %s\nDebugging will be degraded due to missing "
"types. Rebuilding the project will regenerate the needed "
"module files.",
@@ -1903,7 +1911,8 @@
if (dwo_id != dwo_dwo_id) {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: Module %s is out-of-date (hash mismatch). Type information "
+ "0x%16.16" PRIx64 ": Module %s is out-of-date (hash mismatch). Type "
+ "information "
"from this module may be incomplete or inconsistent with the rest of "
"the program. Rebuilding the project will regenerate the needed "
"module files.",
@@ -2083,7 +2092,7 @@
}
} else {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: compile unit %u failed to create a valid "
+ "0x%16.16" PRIx64 ": compile unit %u failed to create a valid "
"lldb_private::CompileUnit class.",
cu_offset, cu_idx);
}
@@ -3026,7 +3035,7 @@
log,
"SymbolFileDWARF::"
"FindDefinitionTypeForDWARFDeclContext(tag=%s, "
- "qualified-name='%s') ignoring die=0x%8.8x (%s)",
+ "qualified-name='%s') ignoring die=0x%16.16" PRIx64 " (%s)",
DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
type_die.GetName());
@@ -3041,7 +3050,7 @@
log,
"SymbolFileDWARF::"
"FindDefinitionTypeForDWARFDeclContext(tag=%s, "
- "qualified-name='%s') trying die=0x%8.8x (%s)",
+ "qualified-name='%s') trying die=0x%16.16" PRIx64 " (%s)",
DW_TAG_value_to_name(dwarf_decl_ctx[0].tag),
dwarf_decl_ctx.GetQualifiedName(), type_die.GetOffset(),
type_dwarf_decl_ctx.GetQualifiedName());
@@ -3148,7 +3157,7 @@
return 0;
size_t functions_added = 0;
- const dw_offset_t function_die_offset = func.GetID();
+ const dw_offset_t function_die_offset = DIERef(func.GetID()).die_offset();
DWARFDIE function_die =
dwarf_cu->GetNonSkeletonUnit().GetDIE(function_die_offset);
if (function_die) {
@@ -3438,8 +3447,8 @@
StreamString strm;
location->DumpLocation(&strm, eDescriptionLevelFull, nullptr);
GetObjectFile()->GetModule()->ReportError(
- "0x%8.8x: %s has an invalid location: %s", die.GetOffset(),
- die.GetTagAsCString(), strm.GetData());
+ "0x%16.16" PRIx64 ": %s has an invalid location: %s",
+ die.GetOffset(), die.GetTagAsCString(), strm.GetData());
}
if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
is_static_lifetime = true;
@@ -4124,8 +4133,8 @@
dwp_file_data_offset);
if (!dwp_obj_file)
return;
- m_dwp_symfile =
- std::make_shared<SymbolFileDWARFDwo>(*this, dwp_obj_file, 0x3fffffff);
+ m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>(
+ *this, dwp_obj_file, DIERef::k_dwo_num_mask);
}
});
return m_dwp_symfile;
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -142,7 +142,9 @@
if (log) {
m_module.LogMessage(
- log, "ManualDWARFIndex::IndexUnit for unit at .debug_info[0x%8.8x]",
+ log,
+ "ManualDWARFIndex::IndexUnit for unit at .debug_info[0x%16.16" PRIx64
+ "]",
unit.GetOffset());
}
@@ -524,7 +526,10 @@
kDataIDEnd = 255u,
};
-constexpr uint32_t CURRENT_CACHE_VERSION = 1;
+
+// Version 2 changes the encoding of DIERef objects used in the DWARF manual
+// index name tables. See DIERef class for details.
+constexpr uint32_t CURRENT_CACHE_VERSION = 2;
bool ManualDWARFIndex::IndexSet::Decode(const DataExtractor &data,
lldb::offset_t *offset_ptr) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -87,11 +87,11 @@
DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(*m_dwo_id);
if (!dwo_cu) {
- SetDwoError(
- Status("unable to load .dwo file from \"%s\" due to ID (0x%16.16" PRIx64
- ") mismatch for skeleton DIE at 0x%8.8" PRIx32,
- dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath().c_str(),
- *m_dwo_id, m_first_die.GetOffset()));
+ SetDwoError(Status(
+ "unable to load .dwo file from \"%s\" due to ID (0x%16.16" PRIx64
+ ") mismatch for skeleton DIE at 0x%8.8" PRIx32,
+ dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath().c_str(),
+ *m_dwo_id, (uint32_t)m_first_die.GetOffset()));
return; // Can't fetch the compile unit from the dwo file.
}
dwo_cu->SetUserData(this);
@@ -101,7 +101,8 @@
// Can't fetch the compile unit DIE from the dwo file.
SetDwoError(
Status("unable to extract compile unit DIE from .dwo file for skeleton "
- "DIE at 0x%8.8" PRIx32, m_first_die.GetOffset()));
+ "DIE at 0x%8.8" PRIx32,
+ (uint32_t)m_first_die.GetOffset()));
return;
}
@@ -212,7 +213,8 @@
llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
- LLDB_SCOPED_TIMERF("%8.8x: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset());
+ LLDB_SCOPED_TIMERF("%16.16" PRIx64 ": DWARFUnit::ExtractDIEsIfNeeded()",
+ GetOffset());
// Set the offset to that of the first DIE and calculate the start of the
// next compilation unit header.
@@ -636,7 +638,7 @@
if (!ContainsDIEOffset(die_offset)) {
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
+ "GetDIE for DIE 0x%" PRIx64 " is outside of its CU 0x%" PRIx64,
die_offset, GetOffset());
return DWARFDIE(); // Not found
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
@@ -15,9 +15,10 @@
using namespace lldb_private;
void DWARFTypeUnit::Dump(Stream *s) const {
- s->Printf("0x%8.8x: Type Unit: length = 0x%8.8x, version = 0x%4.4x, "
- "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
- "{0x%8.8x})\n",
- GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
- GetAddressByteSize(), GetNextUnitOffset());
+ s->Printf(
+ "0x%16.16" PRIx64 ": Type Unit: length = 0x%8.8x, version = 0x%4.4x, "
+ "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
+ "{0x%16.16" PRIx64 "})\n",
+ GetOffset(), (uint32_t)GetLength(), GetVersion(),
+ (uint32_t)GetAbbrevOffset(), GetAddressByteSize(), GetNextUnitOffset());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -102,6 +102,6 @@
void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const {
m_module.ReportErrorIfModifyDetected(
"the DWARF debug information has been modified (accelerator table had "
- "bad die 0x%8.8x for '%s')\n",
+ "bad die 0x%16.16" PRIx64 " for '%s')\n",
ref.die_offset(), name.str().c_str());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -35,7 +35,8 @@
typedef collection::const_iterator const_iterator;
DWARFDebugInfoEntry()
- : m_offset(DW_INVALID_OFFSET), m_sibling_idx(0), m_has_children(false) {}
+ : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
+ m_has_children(false) {}
explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -164,14 +165,16 @@
static DWARFDeclContext
GetDWARFDeclContextStatic(const DWARFDebugInfoEntry *die, DWARFUnit *cu);
- dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
- uint32_t m_parent_idx = 0; // How many to subtract from "this" to get the
- // parent. If zero this die has no parent
- uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
- // If it is zero, then the DIE doesn't have children, or the
- // DWARF claimed it had children but the DIE only contained
- // a single NULL terminating child.
- m_has_children : 1;
+ // Up to 2TB offset within the .debug_info/.debug_types
+ dw_offset_t m_offset : DW_DIE_OFFSET_MAX_BITSIZE;
+ // How many to subtract from "this" to get the parent. If zero this die has no
+ // parent
+ dw_offset_t m_parent_idx : 64 - DW_DIE_OFFSET_MAX_BITSIZE;
+ // How many to add to "this" to get the sibling.
+ // If it is zero, then the DIE doesn't have children,
+ // or the DWARF claimed it had children but the DIE
+ // only contained a single NULL terminating child.
+ uint32_t m_sibling_idx : 31, m_has_children : 1;
uint16_t m_abbr_idx = 0;
/// A copy of the DW_TAG value so we don't have to go through the compile
/// unit abbrev table
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -60,7 +60,8 @@
const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl == nullptr) {
cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: invalid abbreviation code %u, please file a bug and "
+ "{0x%16.16" PRIx64
+ "}: invalid abbreviation code %u, please file a bug and "
"attach the file at the start of this error message",
m_offset, (unsigned)abbr_idx);
// WE can't parse anymore if the DWARF is borked...
@@ -190,7 +191,8 @@
default:
cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: Unsupported DW_FORM_0x%x, please file a bug and "
+ "{0x%16.16" PRIx64
+ "}: Unsupported DW_FORM_0x%x, please file a bug and "
"attach the file at the start of this error message",
m_offset, (unsigned)form);
*offset_ptr = m_offset;
@@ -215,7 +217,8 @@
if (expected_ranges)
return std::move(*expected_ranges);
unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: DIE has DW_AT_ranges(%s 0x%" PRIx64 ") attribute, but "
+ "{0x%16.16" PRIx64 "}: DIE has DW_AT_ranges(%s 0x%" PRIx64
+ ") attribute, but "
"range extraction failed (%s), please file a bug "
"and attach the file at the start of this error message",
die.GetOffset(),
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -128,7 +128,7 @@
});
uint32_t idx = std::distance(m_units.begin(), pos);
if (idx == 0)
- return DW_INVALID_OFFSET;
+ return DW_INVALID_INDEX;
return idx - 1;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -18,10 +18,11 @@
using namespace lldb_private;
void DWARFCompileUnit::Dump(Stream *s) const {
- s->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, "
+ s->Printf("0x%16.16" PRIx64
+ ": Compile Unit: length = 0x%8.8x, version = 0x%4.4x, "
"abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
- "{0x%8.8x})\n",
- GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
+ "{0x%16.16" PRIx64 "})\n",
+ GetOffset(), GetLength(), GetVersion(), (uint32_t)GetAbbrevOffset(),
GetAddressByteSize(), GetNextUnitOffset());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -258,7 +258,7 @@
return;
die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
"Unable to complete the Decl context for DIE '%s' at offset "
- "0x%8.8x.\nPlease file a bug report.",
+ "0x%16.16" PRIx64 ".\nPlease file a bug report.",
type_name_cstr ? type_name_cstr : "", die.GetOffset());
}
@@ -428,7 +428,8 @@
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
"DWARFASTParserClang::ParseTypeFromDWARF "
- "(die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')",
+ "(die = 0x%16.16" PRIx64 ", decl_ctx = %p (die 0x%16.16" PRIx64
+ ")) %s name = '%s')",
die.GetOffset(), static_cast<void *>(context), context_die.GetOffset(),
die.GetTagAsCString(), die.GetName());
}
@@ -505,7 +506,8 @@
}
default:
dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
+ "{0x%16.16" PRIx64
+ "}: unhandled type tag 0x%4.4x (%s), please file a bug and "
"attach the file at the start of this error message",
die.GetOffset(), tag, DW_TAG_value_to_name(tag));
break;
@@ -674,7 +676,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = 0x%16.16" PRIx64 ") %s '%s' "
"is Objective-C 'id' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
@@ -685,7 +687,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = 0x%16.16" PRIx64 ") %s '%s' "
"is Objective-C 'Class' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
@@ -696,7 +698,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = 0x%16.16" PRIx64 ") %s '%s' "
"is Objective-C 'selector' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
@@ -717,7 +719,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
+ "SymbolFileDWARF::ParseType (die = 0x%16.16" PRIx64 ") %s "
"'%s' is 'objc_object*', which we overrode to "
"'id'.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
@@ -771,7 +773,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "SymbolFileDWARF(%p) - 0x%16.16" PRIx64 ": %s type \"%s\" is a "
"forward declaration, complete type is 0x%8.8" PRIx64,
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
@@ -841,7 +843,8 @@
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+ "DWARF DIE at 0x%16.16" PRIx64
+ " named \"%s\" was not able to start its "
"definition.\nPlease file a bug and attach the file at the "
"start of this error message",
die.GetOffset(), attrs.name.GetCString());
@@ -1004,7 +1007,8 @@
m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
+ "{0x%16.16" PRIx64
+ "}: invalid Objective-C method 0x%4.4x (%s), "
"please file a bug and attach the file at the start of "
"this error message",
die.GetOffset(), tag, DW_TAG_value_to_name(tag));
@@ -1057,7 +1061,7 @@
LinkDeclContextToDIE(spec_clang_decl_ctx, die);
} else {
dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x"
+ "0x%8.8" PRIx64 ": DW_AT_specification(0x%16.16" PRIx64 ""
") has no decl\n",
die.GetID(), spec_die.GetOffset());
}
@@ -1076,7 +1080,7 @@
LinkDeclContextToDIE(abs_clang_decl_ctx, die);
} else {
dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x"
+ "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%16.16" PRIx64 ""
") has no decl\n",
die.GetID(), abs_die.GetOffset());
}
@@ -1428,14 +1432,14 @@
Type *base_class_type = die.ResolveTypeUID(encoding_form.Reference());
if (base_class_type == nullptr) {
- module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to "
- "resolve the base class at 0x%8.8x"
- " from enclosing type 0x%8.8x. \nPlease file "
- "a bug and attach the file at the start of "
- "this error message",
- die.GetOffset(),
- encoding_form.Reference().GetOffset(),
- parent_die.GetOffset());
+ module_sp->ReportError(
+ "0x%16.16" PRIx64 ": DW_TAG_inheritance failed to "
+ "resolve the base class at 0x%16.16" PRIx64 ""
+ " from enclosing type 0x%16.16" PRIx64 ". \nPlease file "
+ "a bug and attach the file at the start of "
+ "this error message",
+ die.GetOffset(), encoding_form.Reference().GetOffset(),
+ parent_die.GetOffset());
return;
}
@@ -1695,7 +1699,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
+ "SymbolFileDWARF(%p) - 0x%16.16" PRIx64 ": %s type \"%s\" is an "
"incomplete objc type, complete type is 0x%8.8" PRIx64,
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
@@ -1720,7 +1724,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "SymbolFileDWARF(%p) - 0x%16.16" PRIx64 ": %s type \"%s\" is a "
"forward declaration, trying to find complete type",
static_cast<void *>(this), die.GetOffset(), DW_TAG_value_to_name(tag),
attrs.name.GetCString());
@@ -1752,7 +1756,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "SymbolFileDWARF(%p) - 0x%16.16" PRIx64 ": %s type \"%s\" is a "
"forward declaration, complete type is 0x%8.8" PRIx64,
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
@@ -1806,7 +1810,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
+ "SymbolFileDWARF(%p) - 0x%16.16" PRIx64 ": %s type \"%s\" "
"clang::ClassTemplateDecl failed to return a decl.",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString());
@@ -1866,7 +1870,8 @@
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+ "DWARF DIE at 0x%16.16" PRIx64
+ " named \"%s\" was not able to start its "
"definition.\nPlease file a bug and attach the file at the "
"start of this error message",
die.GetOffset(), attrs.name.GetCString());
@@ -2675,11 +2680,12 @@
Type *member_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
if (!member_type) {
- module_sp->ReportError("0x%8.8" PRIx64
- ": DW_TAG_APPLE_property '%s' refers to type 0x%8.8x"
- " which was unable to be parsed",
- die.GetID(), propAttrs.prop_name,
- attrs.encoding_form.Reference().GetOffset());
+ module_sp->ReportError(
+ "0x%8.8" PRIx64
+ ": DW_TAG_APPLE_property '%s' refers to type 0x%16.16" PRIx64 ""
+ " which was unable to be parsed",
+ die.GetID(), propAttrs.prop_name,
+ attrs.encoding_form.Reference().GetOffset());
return;
}
@@ -2815,12 +2821,13 @@
if (!member_type) {
if (attrs.name)
module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
+ "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%16.16" PRIx64
+ ""
" which was unable to be parsed",
die.GetID(), attrs.name, attrs.encoding_form.Reference().GetOffset());
else
module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
+ "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%16.16" PRIx64 ""
" which was unable to be parsed",
die.GetID(), attrs.encoding_form.Reference().GetOffset());
return;
@@ -2991,11 +2998,11 @@
(member_array_size != 0 ||
attrs.member_byte_offset > parent_byte_size)) {
module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
+ "0x%8.8" PRIx64
+ ": DW_TAG_member '%s' refers to type 0x%16.16" PRIx64 ""
" which extends beyond the bounds of 0x%8.8" PRIx64,
die.GetID(), attrs.name,
- attrs.encoding_form.Reference().GetOffset(),
- parent_die.GetID());
+ attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
}
member_clang_type =
Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -10,6 +10,7 @@
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/LLDBAssert.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/FormatProviders.h"
#include <cassert>
@@ -26,17 +27,59 @@
class DIERef {
public:
enum Section : uint8_t { DebugInfo, DebugTypes };
+ enum IndexType : uint8_t { DWONum, OSONum };
- DIERef(llvm::Optional<uint32_t> dwo_num, Section section,
+ DIERef(llvm::Optional<uint32_t> dwo_oso_num, Section section,
dw_offset_t die_offset)
- : m_dwo_num(dwo_num.value_or(0)), m_dwo_num_valid(bool(dwo_num)),
- m_section(section), m_die_offset(die_offset) {
- assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
+ : m_die_offset(die_offset), m_dwo_oso_num(dwo_oso_num.value_or(0)),
+ m_dwo_num_valid(dwo_oso_num ? true : false), m_oso_num_valid(0),
+ m_section(section) {
+ assert(this->dwo_num() == dwo_oso_num && "Dwo number out of range?");
+ }
+
+ DIERef(IndexType Type, llvm::Optional<uint32_t> dwo_oso_num, Section section,
+ dw_offset_t die_offset)
+ : m_die_offset(die_offset),
+ m_dwo_oso_num(Type == IndexType::DWONum ? dwo_oso_num.value_or(0) : 0),
+ m_dwo_num_valid(Type == IndexType::DWONum ? bool(dwo_oso_num) : false),
+ m_oso_num_valid(Type == IndexType::OSONum ? bool(dwo_oso_num) : false),
+ m_section(section) {
+ assert(((this->dwo_num() == dwo_oso_num && Type == IndexType::DWONum) ||
+ (this->oso_num() == dwo_oso_num && Type == IndexType::OSONum)) &&
+ "DWO/OSO number out of range?");
+ }
+
+ DIERef(lldb::user_id_t uid) {
+ m_die_offset = uid & k_die_offset_mask;
+ m_dwo_num_valid = (uid & k_dwo_num_valid_bit) != 0;
+ m_oso_num_valid = (uid & k_oso_num_valid_bit) != 0;
+ m_dwo_oso_num =
+ m_dwo_num_valid ? (uid >> k_die_offset_bit_size) & k_dwo_num_mask : 0;
+ m_section =
+ (uid & k_section_bit) != 0 ? Section::DebugTypes : Section::DebugInfo;
+ }
+
+ lldb::user_id_t get_id() const {
+ return lldb::user_id_t(dwo_num().value_or(0)) << k_die_offset_bit_size |
+ die_offset() | (m_dwo_num_valid ? k_dwo_num_valid_bit : 0) |
+ (m_oso_num_valid ? k_oso_num_valid_bit : 0) |
+ (section() == Section::DebugTypes ? k_section_bit : 0);
+ }
+
+ void set_die_offset(dw_offset_t offset) {
+ lldbassert(offset <= DW_INVALID_OFFSET);
+ m_die_offset = offset;
}
llvm::Optional<uint32_t> dwo_num() const {
if (m_dwo_num_valid)
- return m_dwo_num;
+ return m_dwo_oso_num;
+ return llvm::None;
+ }
+
+ llvm::Optional<uint32_t> oso_num() const {
+ if (m_oso_num_valid)
+ return m_dwo_oso_num;
return llvm::None;
}
@@ -47,8 +90,10 @@
bool operator<(DIERef other) const {
if (m_dwo_num_valid != other.m_dwo_num_valid)
return m_dwo_num_valid < other.m_dwo_num_valid;
- if (m_dwo_num_valid && (m_dwo_num != other.m_dwo_num))
- return m_dwo_num < other.m_dwo_num;
+ if (m_oso_num_valid != other.m_oso_num_valid)
+ return m_oso_num_valid < other.m_oso_num_valid;
+ if (m_dwo_num_valid && (m_dwo_oso_num != other.m_dwo_oso_num))
+ return m_dwo_oso_num < other.m_dwo_oso_num;
if (m_section != other.m_section)
return m_section < other.m_section;
return m_die_offset < other.m_die_offset;
@@ -85,11 +130,34 @@
///
void Encode(lldb_private::DataEncoder &encoder) const;
+ static constexpr uint64_t k_die_offset_bit_size = DW_DIE_OFFSET_MAX_BITSIZE;
+ static constexpr uint64_t k_dwo_num_bit_size =
+ 64 - DW_DIE_OFFSET_MAX_BITSIZE - /* size of control bits */ 3;
+
+ static constexpr uint64_t k_dwo_num_valid_bit =
+ (1ull << (k_dwo_num_bit_size + k_die_offset_bit_size));
+ static constexpr uint64_t k_oso_num_valid_bit =
+ (1ull << (k_dwo_num_bit_size + k_die_offset_bit_size + 1));
+ static constexpr uint64_t k_section_bit =
+ (1ull << (k_dwo_num_bit_size + k_die_offset_bit_size + 2));
+
+ static constexpr uint64_t
+ k_dwo_num_mask = (~0ull) >> (64 - k_dwo_num_bit_size); // 0x1fffff;
+ static constexpr uint64_t k_die_offset_mask = (~0ull) >>
+ (64 - k_die_offset_bit_size);
+
private:
- uint32_t m_dwo_num : 30;
- uint32_t m_dwo_num_valid : 1;
- uint32_t m_section : 1;
- dw_offset_t m_die_offset;
+ // Allow 2TB of .debug_info/.debug_types offset
+ dw_offset_t m_die_offset : k_die_offset_bit_size;
+ // Used for DWO index or for .o file index on mac
+ dw_offset_t m_dwo_oso_num : k_dwo_num_bit_size;
+ // Set to 1 if m_file_index is a DWO number
+ dw_offset_t m_dwo_num_valid : 1;
+ // Set to 1 if m_file_index is a N_OSO index for mac debugging without a dSYM
+ // file
+ dw_offset_t m_oso_num_valid : 1;
+ // Set to 0 for .debug_info 1 for .debug_types,
+ dw_offset_t m_section : 1;
};
static_assert(sizeof(DIERef) == 8);
Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
@@ -22,34 +22,16 @@
OS << "/" << format_hex_no_prefix(ref.die_offset(), 8);
}
-constexpr uint32_t k_dwo_num_mask = 0x3FFFFFFF;
-constexpr uint32_t k_dwo_num_valid_bitmask = (1u << 30);
-constexpr uint32_t k_section_bitmask = (1u << 31);
-
llvm::Optional<DIERef> DIERef::Decode(const DataExtractor &data,
lldb::offset_t *offset_ptr) {
- const uint32_t bitfield_storage = data.GetU32(offset_ptr);
- uint32_t dwo_num = bitfield_storage & k_dwo_num_mask;
- bool dwo_num_valid = (bitfield_storage & (k_dwo_num_valid_bitmask)) != 0;
- Section section = (Section)((bitfield_storage & (k_section_bitmask)) != 0);
+ DIERef die_ref(data.GetU64(offset_ptr));
+
// DIE offsets can't be zero and if we fail to decode something from data,
// it will return 0
- dw_offset_t die_offset = data.GetU32(offset_ptr);
- if (die_offset == 0)
+ if (!die_ref.die_offset())
return llvm::None;
- if (dwo_num_valid)
- return DIERef(dwo_num, section, die_offset);
- else
- return DIERef(llvm::None, section, die_offset);
-}
-void DIERef::Encode(DataEncoder &encoder) const {
- uint32_t bitfield_storage = m_dwo_num;
- if (m_dwo_num_valid)
- bitfield_storage |= k_dwo_num_valid_bitmask;
- if (m_section)
- bitfield_storage |= k_section_bitmask;
- encoder.AppendU32(bitfield_storage);
- static_assert(sizeof(m_die_offset) == 4, "m_die_offset must be 4 bytes");
- encoder.AppendU32(m_die_offset);
+ return die_ref;
}
+
+void DIERef::Encode(DataEncoder &encoder) const { encoder.AppendU64(get_id()); }
Index: lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
===================================================================
--- lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -127,7 +127,7 @@
void GetFDEIndex();
- bool FDEToUnwindPlan(uint32_t offset, Address startaddr,
+ bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr,
UnwindPlan &unwind_plan);
const CIE *GetCIE(dw_offset_t cie_offset);
@@ -158,7 +158,7 @@
Type m_type;
CIESP
- ParseCIE(const uint32_t cie_offset);
+ ParseCIE(const dw_offset_t cie_offset);
lldb::RegisterKind GetRegisterKind() const {
return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF;
Index: lldb/include/lldb/Core/dwarf.h
===================================================================
--- lldb/include/lldb/Core/dwarf.h
+++ lldb/include/lldb/Core/dwarf.h
@@ -30,11 +30,12 @@
// any addresses in the compile units that get
// parsed
-typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any
+typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any
// offset into the file
/* Constants */
-#define DW_INVALID_OFFSET (~(dw_offset_t)0)
+#define DW_DIE_OFFSET_MAX_BITSIZE 40
+#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1)
#define DW_INVALID_INDEX 0xFFFFFFFFul
// #define DW_ADDR_none 0x0
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits