using namespace std;
extern int g_verbose;
-// Extract a debug info entry for a given compile unit from the .debug_info and
-// .debug_abbrev data within the SymbolFileDWARF class starting at the given
-// offset
-bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &debug_info_data,
+// Extract a debug info entry for a given DWARFUnit from the data
+// starting at the offset in offset_ptr
+bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &data,
const DWARFUnit *cu,
lldb::offset_t *offset_ptr) {
m_offset = *offset_ptr;
m_parent_idx = 0;
m_sibling_idx = 0;
- const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr);
+ const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
lldbassert(abbr_idx <= UINT16_MAX);
m_abbr_idx = abbr_idx;
if (m_abbr_idx) {
lldb::offset_t offset = *offset_ptr;
-
- const DWARFAbbreviationDeclaration *abbrevDecl =
- cu->GetAbbreviations()->GetAbbreviationDeclaration(m_abbr_idx);
-
+ auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl == nullptr) {
cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
"{0x%8.8x}: invalid abbreviation code %u, please file a bug and "
}
m_tag = abbrevDecl->Tag();
m_has_children = abbrevDecl->HasChildren();
- // Skip all data in the .debug_info for the attributes
+ // Skip all data in the .debug_info or .debug_types for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
uint32_t i;
dw_form_t form;
for (i = 0; i < numAttributes; ++i) {
form = abbrevDecl->GetFormByIndexUnchecked(i);
-
- llvm::Optional<uint8_t> fixed_skip_size = DWARFFormValue::GetFixedSize(form, cu);
+ llvm::Optional<uint8_t> fixed_skip_size =
+ DWARFFormValue::GetFixedSize(form, cu);
if (fixed_skip_size)
offset += *fixed_skip_size;
else {
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
+ // inlined in the .debug_info/.debug_types
case DW_FORM_exprloc:
case DW_FORM_block:
- form_size = debug_info_data.GetULEB128(&offset);
+ form_size = data.GetULEB128(&offset);
break;
case DW_FORM_block1:
- form_size = debug_info_data.GetU8_unchecked(&offset);
+ form_size = data.GetU8_unchecked(&offset);
break;
case DW_FORM_block2:
- form_size = debug_info_data.GetU16_unchecked(&offset);
+ form_size = data.GetU16_unchecked(&offset);
break;
case DW_FORM_block4:
- form_size = debug_info_data.GetU32_unchecked(&offset);
+ form_size = data.GetU32_unchecked(&offset);
break;
// Inlined NULL terminated C-strings
case DW_FORM_string:
- debug_info_data.GetCStr(&offset);
+ data.GetCStr(&offset);
break;
// Compile unit address sized values
case DW_FORM_GNU_addr_index:
case DW_FORM_GNU_str_index:
case DW_FORM_strx:
- debug_info_data.Skip_LEB128(&offset);
+ data.Skip_LEB128(&offset);
break;
case DW_FORM_indirect:
form_is_indirect = true;
- form = debug_info_data.GetULEB128(&offset);
+ form = data.GetULEB128(&offset);
break;
case DW_FORM_strp:
case DW_FORM_sec_offset:
- debug_info_data.GetU32(&offset);
+ data.GetU32(&offset);
break;
case DW_FORM_implicit_const:
lldb::ModuleSP module = dwarf2Data->GetObjectFile()->GetModule();
if (abbrevDecl) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
lldb::offset_t offset = GetFirstAttributeOffset();
- if (!debug_info_data.ValidOffset(offset))
+ if (!data.ValidOffset(offset))
return false;
const uint32_t numAttributes = abbrevDecl->NumAttributes();
dw_attr_t attr;
abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
- if (form_value.ExtractValue(debug_info_data, &offset)) {
+ if (form_value.ExtractValue(data, &offset)) {
switch (attr) {
case DW_AT_low_pc:
lo_pc = form_value.Address();
if (frame_base) {
if (form_value.BlockData()) {
uint32_t block_offset =
- form_value.BlockData() - debug_info_data.GetDataStart();
+ form_value.BlockData() - data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- *frame_base = DWARFExpression(module, debug_info_data, cu,
+ *frame_base = DWARFExpression(module, data, cu,
block_offset, block_length);
} else {
const DWARFDataExtractor &debug_loc_data =
// stream.
void DWARFDebugInfoEntry::Dump(const DWARFUnit *cu, Stream &s,
uint32_t recurse_depth) const {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
lldb::offset_t offset = m_offset;
- if (debug_info_data.ValidOffset(offset)) {
- dw_uleb128_t abbrCode = debug_info_data.GetULEB128(&offset);
+ if (data.ValidOffset(offset)) {
+ dw_uleb128_t abbrCode = data.GetULEB128(&offset);
s.Printf("\n0x%8.8x: ", m_offset);
s.Indent();
if (abbrCode != m_abbr_idx) {
s.Printf("error: DWARF has been modified\n");
} else if (abbrCode) {
- const DWARFAbbreviationDeclaration *abbrevDecl =
- cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode);
-
+ auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl) {
s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag()));
s.Printf(" [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*' : ' ');
- // Dump all data in the .debug_info for the attributes
+ // Dump all data in the .debug_info/.debug_types for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
for (uint32_t i = 0; i < numAttributes; ++i) {
DWARFFormValue form_value(cu);
dw_attr_t attr;
abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
- DumpAttribute(cu, debug_info_data, &offset, s, attr, form_value);
+ DumpAttribute(cu, data, &offset, s, attr, form_value);
}
const DWARFDebugInfoEntry *child = GetFirstChild();
// display of attributes is done (disassemble location lists, show enumeration
// values for attributes, etc).
void DWARFDebugInfoEntry::DumpAttribute(
- const DWARFUnit *cu, const DWARFDataExtractor &debug_info_data,
+ const DWARFUnit *cu, const DWARFDataExtractor &data,
lldb::offset_t *offset_ptr, Stream &s, dw_attr_t attr,
DWARFFormValue &form_value) {
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
s.Printf("[%s", DW_FORM_value_to_name(form_value.Form()));
}
- if (!form_value.ExtractValue(debug_info_data, offset_ptr))
+ if (!form_value.ExtractValue(data, offset_ptr))
return;
if (show_form) {
const uint8_t *blockData = form_value.BlockData();
if (blockData) {
// Location description is inlined in data in the form value
- DWARFDataExtractor locationData(debug_info_data,
+ DWARFDataExtractor locationData(data,
(*offset_ptr) - form_value.Unsigned(),
form_value.Unsigned());
DWARFExpression::PrintDWARFExpression(
uint32_t curr_depth) const {
auto abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
lldb::offset_t offset = GetFirstAttributeOffset();
const uint32_t num_attributes = abbrevDecl->NumAttributes();
}
if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) {
- if (form_value.ExtractValue(debug_info_data, &offset)) {
+ if (form_value.ExtractValue(data, &offset)) {
DWARFDIE spec_die = form_value.Reference();
if (spec_die)
spec_die.GetAttributes(attributes, curr_depth + 1);
if (fixed_skip_size)
offset += *fixed_skip_size;
else
- DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu);
+ DWARFFormValue::SkipValue(form, data, &offset, cu);
}
}
} else {
// GetAttributeValue
//
-// Get the value of an attribute and return the .debug_info offset of the
-// attribute if it was properly extracted into form_value, or zero if we fail
-// since an offset of zero is invalid for an attribute (it would be a compile
-// unit header).
+// Get the value of an attribute and return the .debug_info or .debug_types
+// offset of the attribute if it was properly extracted into form_value,
+// or zero if we fail since an offset of zero is invalid for an attribute (it
+// would be a compile unit header).
dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value,
dw_offset_t *end_attr_offset_ptr,
uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr);
if (attr_idx != DW_INVALID_INDEX) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
lldb::offset_t offset = GetFirstAttributeOffset();
uint32_t idx = 0;
while (idx < attr_idx)
DWARFFormValue::SkipValue(abbrevDecl->GetFormByIndex(idx++),
- debug_info_data, &offset, cu);
+ data, &offset, cu);
const dw_offset_t attr_offset = offset;
form_value.SetUnit(cu);
form_value.SetForm(abbrevDecl->GetFormByIndex(idx));
- if (form_value.ExtractValue(debug_info_data, &offset)) {
+ if (form_value.ExtractValue(data, &offset)) {
if (end_attr_offset_ptr)
*end_attr_offset_ptr = offset;
return attr_offset;