Major DWARF cleanup.

Added a new class called DWARFDIE that contains a DWARFCompileUnit and DWARFDebugInfoEntry so that these items always stay together.

There were many places where we just handed out DWARFDebugInfoEntry pointers and then use them with a compile unit that may or may not be the correct one. Clients outside of DWARFCompileUnit and DWARFDebugInfoEntry should all be dealing with DWARFDIE instances instead of playing with DWARFCompileUnit/DWARFDebugInfoEntry pairs manually.

This paves to the way for some modifications that are coming for DWO.

llvm-svn: 246100
This commit is contained in:
Greg Clayton 2015-08-26 22:57:51 +00:00
parent 8cd9d7acb2
commit 6071e6fc94
34 changed files with 2070 additions and 1947 deletions

View File

@ -14,6 +14,9 @@
// Get the DWARF constant definitions from llvm
#include "llvm/Support/Dwarf.h"
#include "lldb/Core/RangeMap.h"
// and stuff them in our default namespace
using namespace llvm::dwarf;
@ -59,5 +62,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for
//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty
//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args)
typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList;
#endif // DebugBase_dwarf_h_

View File

@ -35,10 +35,8 @@
// Forward definitions for DWARF plug-in for type parsing
class DWARFCompileUnit;
class DWARFDebugInfoEntry;
class DWARFDIE;
class DWARFDIECollection;
class SymbolFileDWARF;
namespace lldb_private {
@ -502,35 +500,25 @@ public:
lldb::TypeSP
ParseTypeFromDWARF (const SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
Log *log,
bool *type_is_new_ptr) override;
Function *
ParseFunctionFromDWARF (const SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die) override;
const DWARFDIE &die) override;
bool
CompleteTypeFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die,
CompleteTypeFromDWARF (const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) override;
CompilerDeclContext
GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die) override;
GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override;
CompilerDeclContext
GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die) override;
GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override;
//------------------------------------------------------------------
// ClangASTContext callbacks for external source lookups.
@ -551,9 +539,7 @@ public:
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
clang::NamespaceDecl *
ResolveNamespaceDIE (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry *die);
ResolveNamespaceDIE (const DWARFDIE &die);
//----------------------------------------------------------------------
// CompilerDeclContext override functions
@ -1141,19 +1127,14 @@ protected:
// DWARF parsing functions
bool
ParseTemplateDIE (SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
ParseTemplateDIE (const DWARFDIE &die,
ClangASTContext::TemplateParameterInfos &template_param_infos);
bool
ParseTemplateParameterInfos (SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die,
ParseTemplateParameterInfos (const DWARFDIE &parent_die,
ClangASTContext::TemplateParameterInfos &template_param_infos);
clang::ClassTemplateDecl *
ParseClassTemplateDecl (SymbolFileDWARF *dwarf,
clang::DeclContext *decl_ctx,
ParseClassTemplateDecl (clang::DeclContext *decl_ctx,
lldb::AccessType access_type,
const char *parent_name,
int tag_decl_kind,
@ -1164,9 +1145,7 @@ protected:
size_t
ParseChildMembers (const lldb_private::SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
lldb_private::CompilerType &class_clang_type,
const lldb::LanguageType class_language,
std::vector<clang::CXXBaseSpecifier *>& base_classes,
@ -1180,9 +1159,7 @@ protected:
size_t
ParseChildParameters (const lldb_private::SymbolContext& sc,
clang::DeclContext *containing_decl_ctx,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die,
const DWARFDIE &parent_die,
bool skip_artificial,
bool &is_static,
bool &is_variadic,
@ -1193,9 +1170,7 @@ protected:
void
ParseChildArrayInfo (const lldb_private::SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die,
const DWARFDIE &parent_die,
int64_t& first_index,
std::vector<uint64_t>& element_orders,
uint32_t& byte_stride,
@ -1207,29 +1182,19 @@ protected:
lldb_private::CompilerType &clang_type,
bool is_signed,
uint32_t enumerator_byte_size,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die);
const DWARFDIE &parent_die);
clang::DeclContext *
GetClangDeclContextForDIE (SymbolFileDWARF *dwarf,
DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die);
GetClangDeclContextForDIE (const DWARFDIE &die);
clang::DeclContext *
GetClangDeclContextContainingDIE (SymbolFileDWARF *dwarf,
DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die,
const DWARFDebugInfoEntry **decl_ctx_die);
GetClangDeclContextContainingDIE (const DWARFDIE &die,
DWARFDIE *decl_ctx_die);
bool
CopyUniqueClassMethodTypes (SymbolFileDWARF *dwarf,
SymbolFileDWARF *src_symfile,
CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die,
const DWARFDIE &dst_class_die,
Type *class_type,
DWARFCompileUnit* src_cu,
const DWARFDebugInfoEntry *src_class_die,
DWARFCompileUnit* dst_cu,
const DWARFDebugInfoEntry *dst_class_die,
DWARFDIECollection &failures);
clang::DeclContext *
@ -1244,12 +1209,7 @@ protected:
void
LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
const DWARFDebugInfoEntry *die)
{
m_die_to_decl_ctx[die] = decl_ctx;
// There can be many DIEs for a single decl context
m_decl_ctx_to_die[decl_ctx].insert(die);
}
const DWARFDIE &die);
typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;

View File

@ -18,8 +18,7 @@
#include "clang/AST/CharUnits.h"
#include "clang/AST/Type.h"
class SymbolFileDWARF;
class DWARFCompileUnit;
class DWARFDIE;
class DWARFDebugInfoEntry;
namespace lldb_private {
@ -45,22 +44,16 @@ public:
//----------------------------------------------------------------------
virtual lldb::TypeSP
ParseTypeFromDWARF (const SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
Log *log,
bool *type_is_new_ptr) = 0;
virtual Function *
ParseFunctionFromDWARF (const SymbolContext& sc,
SymbolFileDWARF *dwarf,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die) = 0;
const DWARFDIE &die) = 0;
virtual bool
CompleteTypeFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die,
CompleteTypeFromDWARF (const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type)
{
@ -68,17 +61,13 @@ public:
}
virtual CompilerDeclContext
GetDeclContextForUIDFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die)
GetDeclContextForUIDFromDWARF (const DWARFDIE &die)
{
return CompilerDeclContext();
}
virtual CompilerDeclContext
GetDeclContextContainingUIDFromDWARF (SymbolFileDWARF *dwarf,
DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry* die)
GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die)
{
return CompilerDeclContext();
}

View File

@ -290,6 +290,8 @@
2669424C1A6DC2AC0063BE93 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266941FC1A6DC2AC0063BE93 /* Platform.cpp */; };
2669424D1A6DC32B0063BE93 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; };
266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */; };
266E82971B8CE3AC008FCA06 /* DWARFDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */; settings = {ASSET_TAGS = (); }; };
266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */; settings = {ASSET_TAGS = (); }; };
2670F8121862B44A006B332C /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; };
2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; };
26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; };
@ -1631,6 +1633,9 @@
266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = "<group>"; };
266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystem.cpp; path = source/Target/OperatingSystem.cpp; sourceTree = "<group>"; };
266DFE9813FD658300D0C574 /* OperatingSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OperatingSystem.h; path = include/lldb/Target/OperatingSystem.h; sourceTree = "<group>"; };
266E82951B8CE346008FCA06 /* DWARFDIE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DWARFDIE.h; sourceTree = "<group>"; };
266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFDIE.cpp; sourceTree = "<group>"; };
266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFAttribute.cpp; sourceTree = "<group>"; };
266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = "<group>"; };
26709E311964A34000B94724 /* LaunchServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LaunchServices.framework; path = /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework; sourceTree = "<absolute>"; };
2670F8111862B44A006B332C /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = /usr/lib/libncurses.dylib; sourceTree = "<absolute>"; };
@ -3079,6 +3084,7 @@
260C89B310F57C5600BB2B04 /* DWARFAbbreviationDeclaration.cpp */,
260C89B410F57C5600BB2B04 /* DWARFAbbreviationDeclaration.h */,
260C89B610F57C5600BB2B04 /* DWARFAttribute.h */,
266E829C1B8E542C008FCA06 /* DWARFAttribute.cpp */,
260C89B710F57C5600BB2B04 /* DWARFCompileUnit.cpp */,
260C89B810F57C5600BB2B04 /* DWARFCompileUnit.h */,
26AB92101819D74600E63F3E /* DWARFDataExtractor.cpp */,
@ -3109,6 +3115,8 @@
26B1EFAD154638AF00E2DAC7 /* DWARFDeclContext.h */,
260C89CF10F57C5600BB2B04 /* DWARFDefines.cpp */,
260C89D010F57C5600BB2B04 /* DWARFDefines.h */,
266E82951B8CE346008FCA06 /* DWARFDIE.h */,
266E82961B8CE3AC008FCA06 /* DWARFDIE.cpp */,
260C89D110F57C5600BB2B04 /* DWARFDIECollection.cpp */,
260C89D210F57C5600BB2B04 /* DWARFDIECollection.h */,
260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */,
@ -6096,6 +6104,7 @@
2689004413353E0400698AC0 /* Module.cpp in Sources */,
2689004513353E0400698AC0 /* ModuleChild.cpp in Sources */,
23EDE33319269E7C00F6A132 /* NativeRegisterContext.cpp in Sources */,
266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */,
2689004613353E0400698AC0 /* ModuleList.cpp in Sources */,
2689004713353E0400698AC0 /* PluginManager.cpp in Sources */,
AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */,
@ -6258,6 +6267,7 @@
268900CD13353E5F00698AC0 /* UniqueDWARFASTType.cpp in Sources */,
944372DC171F6B4300E57C32 /* RegisterContextDummy.cpp in Sources */,
268900CE13353E5F00698AC0 /* SymbolFileSymtab.cpp in Sources */,
266E82971B8CE3AC008FCA06 /* DWARFDIE.cpp in Sources */,
268900CF13353E5F00698AC0 /* SymbolVendorMacOSX.cpp in Sources */,
268900D013353E6F00698AC0 /* Block.cpp in Sources */,
268900D113353E6F00698AC0 /* ClangASTContext.cpp in Sources */,

View File

@ -52,7 +52,7 @@ public:
virtual void
DidLaunch() override;
virtual lldb::ThreadPlanSP
lldb::ThreadPlanSP
GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
bool stop_others) override;

View File

@ -54,7 +54,7 @@ public:
virtual void
DidLaunch() override;
virtual lldb::ThreadPlanSP
lldb::ThreadPlanSP
GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
bool stop_others) override;

View File

@ -2,6 +2,7 @@ set(LLVM_NO_RTTI 1)
add_lldb_library(lldbPluginSymbolFileDWARF
DWARFAbbreviationDeclaration.cpp
DWARFAttribute.cpp
DWARFCompileUnit.cpp
DWARFDataExtractor.cpp
DWARFDebugAbbrev.cpp
@ -17,6 +18,7 @@ add_lldb_library(lldbPluginSymbolFileDWARF
DWARFDebugRanges.cpp
DWARFDeclContext.cpp
DWARFDefines.cpp
DWARFDIE.cpp
DWARFDIECollection.cpp
DWARFFormValue.cpp
DWARFLocationDescription.cpp

View File

@ -0,0 +1,90 @@
//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "DWARFAttribute.h"
#include "DWARFDebugInfo.h"
#include "DWARFCompileUnit.h"
DWARFAttributes::DWARFAttributes() :
m_infos()
{
}
DWARFAttributes::~DWARFAttributes()
{
}
uint32_t
DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const
{
collection::const_iterator end = m_infos.end();
collection::const_iterator beg = m_infos.begin();
collection::const_iterator pos;
for (pos = beg; pos != end; ++pos)
{
if (pos->attr.get_attr() == attr)
return std::distance(beg, pos);
}
return UINT32_MAX;
}
void
DWARFAttributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
{
AttributeValue attr_value = { cu, attr_die_offset, { attr, form } };
m_infos.push_back(attr_value);
}
bool
DWARFAttributes::ContainsAttribute(dw_attr_t attr) const
{
return FindAttributeIndex(attr) != UINT32_MAX;
}
bool
DWARFAttributes::RemoveAttribute(dw_attr_t attr)
{
uint32_t attr_index = FindAttributeIndex(attr);
if (attr_index != UINT32_MAX)
{
m_infos.erase(m_infos.begin() + attr_index);
return true;
}
return false;
}
bool
DWARFAttributes::ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const
{
const DWARFCompileUnit *cu = CompileUnitAtIndex(i);
form_value.SetCompileUnit(cu);
form_value.SetForm(FormAtIndex(i));
lldb::offset_t offset = DIEOffsetAtIndex(i);
return form_value.ExtractValue(cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset);
}
uint64_t
DWARFAttributes::FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const
{
const uint32_t attr_idx = FindAttributeIndex (attr);
if (attr_idx != UINT32_MAX)
return FormValueAsUnsignedAtIndex (attr_idx, fail_value);
return fail_value;
}
uint64_t
DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const
{
DWARFFormValue form_value;
if (ExtractFormValueAtIndex(i, form_value))
return form_value.Reference();
return fail_value;
}

View File

@ -10,36 +10,72 @@
#ifndef SymbolFileDWARF_DWARFAttribute_h_
#define SymbolFileDWARF_DWARFAttribute_h_
#include "llvm/ADT/SmallVector.h"
#include "DWARFDefines.h"
#include <vector>
class DWARFCompileUnit;
class DWARFFormValue;
class DWARFAttribute
{
public:
DWARFAttribute(dw_attr_t attr, dw_form_t form) :
m_attr_form ( attr << 16 | form )
m_attr (attr),
m_form (form)
{
}
void set(dw_attr_t attr, dw_form_t form) { m_attr_form = (attr << 16) | form; }
void set_attr(dw_attr_t attr) { m_attr_form = (m_attr_form & 0x0000ffffu) | (attr << 16); }
void set_form(dw_form_t form) { m_attr_form = (m_attr_form & 0xffff0000u) | form; }
dw_attr_t get_attr() const { return m_attr_form >> 16; }
dw_form_t get_form() const { return (dw_form_t)m_attr_form; }
void get(dw_attr_t& attr, dw_form_t& form) const
void set (dw_attr_t attr, dw_form_t form) { m_attr = attr; m_form = form; }
void set_attr (dw_attr_t attr) { m_attr = attr; }
void set_form (dw_form_t form) { m_form = form; }
dw_attr_t get_attr () const { return m_attr; }
dw_form_t get_form () const { return m_form; }
void get (dw_attr_t& attr, dw_form_t& form) const
{
uint32_t attr_form = m_attr_form;
attr = attr_form >> 16;
form = (dw_form_t)attr_form;
attr = m_attr;
form = m_form;
}
bool operator == (const DWARFAttribute& rhs) const { return m_attr_form == rhs.m_attr_form; }
bool operator == (const DWARFAttribute& rhs) const { return m_attr == rhs.m_attr && m_form == rhs.m_form; }
typedef std::vector<DWARFAttribute> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
protected:
uint32_t m_attr_form; // Upper 16 bits is attribute, lower 16 bits is form
dw_attr_t m_attr;
dw_form_t m_form;
};
class DWARFAttributes
{
public:
DWARFAttributes();
~DWARFAttributes();
void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form);
const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; }
dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr.get_attr(); }
dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
bool ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const;
uint64_t FormValueAsUnsignedAtIndex (uint32_t i, uint64_t fail_value) const;
uint64_t FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const;
uint32_t FindAttributeIndex(dw_attr_t attr) const;
bool ContainsAttribute(dw_attr_t attr) const;
bool RemoveAttribute(dw_attr_t attr);
void Clear() { m_infos.clear(); }
size_t Size() const { return m_infos.size(); }
protected:
struct AttributeValue
{
const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values
dw_offset_t die_offset;
DWARFAttribute attr;
};
typedef llvm::SmallVector<AttributeValue, 8> collection;
collection m_infos;
};
#endif // SymbolFileDWARF_DWARFAttribute_h_

View File

@ -376,6 +376,15 @@ DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size)
g_default_addr_size = addr_size;
}
lldb::user_id_t
DWARFCompileUnit::GetID () const
{
if (m_dwarf2Data)
return m_dwarf2Data->MakeUserID(GetOffset());
else
return GetOffset();
}
void
DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges)
@ -392,7 +401,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
const dw_offset_t cu_offset = GetOffset();
if (die)
{
DWARFDebugRanges::RangeList ranges;
DWARFRangeList ranges;
const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false);
if (num_ranges > 0)
{
@ -402,7 +411,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// this with recent GCC builds.
for (size_t i=0; i<num_ranges; ++i)
{
const DWARFDebugRanges::RangeList::Entry &range = ranges.GetEntryRef(i);
const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
}
@ -416,7 +425,7 @@ DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
// and then throwing them all away to keep memory usage down.
const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
die = DIE();
die = DIEPtr();
if (die)
die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
@ -496,7 +505,7 @@ DWARFCompileUnit::GetFunctionAranges ()
"DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
GetOffset());
}
const DWARFDebugInfoEntry* die = DIE();
const DWARFDebugInfoEntry* die = DIEPtr();
if (die)
die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
const bool minimize = false;
@ -505,74 +514,58 @@ DWARFCompileUnit::GetFunctionAranges ()
return *m_func_aranges_ap.get();
}
bool
DWARFCompileUnit::LookupAddress
(
const dw_addr_t address,
DWARFDebugInfoEntry** function_die_handle,
DWARFDebugInfoEntry** block_die_handle
)
DWARFDIE
DWARFCompileUnit::LookupAddress (const dw_addr_t address)
{
bool success = false;
if (function_die_handle != NULL && DIE())
if (DIE())
{
const DWARFDebugAranges &func_aranges = GetFunctionAranges ();
// Re-check the aranges auto pointer contents in case it was created above
if (!func_aranges.IsEmpty())
{
*function_die_handle = GetDIEPtr(func_aranges.FindAddress(address));
if (*function_die_handle != NULL)
{
success = true;
if (block_die_handle != NULL)
{
DWARFDebugInfoEntry* child = (*function_die_handle)->GetFirstChild();
while (child)
{
if (child->LookupAddress(address, m_dwarf2Data, this, NULL, block_die_handle))
break;
child = child->GetSibling();
}
}
}
}
return GetDIE(func_aranges.FindAddress(address));
}
return success;
return DWARFDIE();
}
//----------------------------------------------------------------------
// Compare function DWARFDebugAranges::Range structures
//----------------------------------------------------------------------
static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2)
static bool CompareDIEOffset (const DWARFDebugInfoEntry& die, const dw_offset_t die_offset)
{
return die1.GetOffset() < die2.GetOffset();
return die.GetOffset() < die_offset;
}
//----------------------------------------------------------------------
// GetDIEPtr()
// GetDIE()
//
// Get the DIE (Debug Information Entry) with the specified offset.
// Get the DIE (Debug Information Entry) with the specified offset by
// first checking if the DIE is contained within this compile unit and
// grabbing the DIE from this compile unit. Otherwise we grab the DIE
// from the DWARF file.
//----------------------------------------------------------------------
DWARFDebugInfoEntry*
DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset)
DWARFDIE
DWARFCompileUnit::GetDIE (dw_offset_t die_offset)
{
if (die_offset != DW_INVALID_OFFSET)
{
ExtractDIEsIfNeeded (false);
DWARFDebugInfoEntry compare_die;
compare_die.SetOffset(die_offset);
DWARFDebugInfoEntry::iterator end = m_die_array.end();
DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
if (pos != end)
if (ContainsDIEOffset(die_offset))
{
if (die_offset == (*pos).GetOffset())
return &(*pos);
ExtractDIEsIfNeeded (false);
DWARFDebugInfoEntry::iterator end = m_die_array.end();
DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
if (pos != end)
{
if (die_offset == (*pos).GetOffset())
return DWARFDIE(this, &(*pos));
}
}
else
{
return m_dwarf2Data->DebugInfo()->GetDIE (die_offset);
}
}
return NULL; // Not found in any compile units
return DWARFDIE(); // Not found
}
//----------------------------------------------------------------------
@ -581,30 +574,36 @@ DWARFCompileUnit::GetDIEPtr(dw_offset_t die_offset)
// Get the DIE (Debug Information Entry) that contains the specified
// .debug_info offset.
//----------------------------------------------------------------------
const DWARFDebugInfoEntry*
DWARFCompileUnit::GetDIEPtrContainingOffset(dw_offset_t die_offset)
DWARFDIE
DWARFCompileUnit::GetDIEContainingOffset(dw_offset_t die_offset)
{
if (die_offset != DW_INVALID_OFFSET)
{
ExtractDIEsIfNeeded (false);
DWARFDebugInfoEntry compare_die;
compare_die.SetOffset(die_offset);
DWARFDebugInfoEntry::iterator end = m_die_array.end();
DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, compare_die, CompareDIEOffset);
if (pos != end)
if (ContainsDIEOffset(die_offset))
{
if (die_offset >= (*pos).GetOffset())
ExtractDIEsIfNeeded (false);
DWARFDebugInfoEntry::iterator end = m_die_array.end();
DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
if (pos != end)
{
DWARFDebugInfoEntry::iterator next = pos + 1;
if (next != end)
if (die_offset >= (*pos).GetOffset())
{
if (die_offset < (*next).GetOffset())
return &(*pos);
DWARFDebugInfoEntry::iterator next = pos + 1;
if (next != end)
{
if (die_offset < (*next).GetOffset())
return DWARFDIE(this, &(*pos));
}
}
}
}
else
{
return m_dwarf2Data->DebugInfo()->GetDIEContainingOffset (die_offset);
}
}
return NULL; // Not found in any compile units
return DWARFDIE(); // Not found
}
@ -618,7 +617,7 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die
for (pos = m_die_array.begin(); pos != end; ++pos)
{
if (pos->Tag() == tag)
dies.Append (&(*pos));
dies.Append (DWARFDIE(this, &(*pos)));
}
// Return the number of DIEs added to the collection
@ -703,7 +702,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
continue;
}
DWARFDebugInfoEntry::Attributes attributes;
DWARFAttributes attributes;
const char *name = NULL;
const char *mangled_cstr = NULL;
bool is_declaration = false;
@ -713,7 +712,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
bool is_global_or_static_variable = false;
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes);
const size_t num_attributes = die.GetAttributes(this, fixed_form_sizes, attributes);
if (num_attributes > 0)
{
for (uint32_t i=0; i<num_attributes; ++i)
@ -723,24 +722,24 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
switch (attr)
{
case DW_AT_name:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
name = form_value.AsCString(m_dwarf2Data);
if (attributes.ExtractFormValueAtIndex(i, form_value))
name = form_value.AsCString();
break;
case DW_AT_declaration:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
if (attributes.ExtractFormValueAtIndex(i, form_value))
is_declaration = form_value.Unsigned() != 0;
break;
// case DW_AT_artificial:
// if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
// if (attributes.ExtractFormValueAtIndex(i, form_value))
// is_artificial = form_value.Unsigned() != 0;
// break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
mangled_cstr = form_value.AsCString(m_dwarf2Data);
if (attributes.ExtractFormValueAtIndex(i, form_value))
mangled_cstr = form_value.AsCString();
break;
case DW_AT_low_pc:
@ -802,7 +801,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
break;
case DW_AT_specification:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
if (attributes.ExtractFormValueAtIndex(i, form_value))
specification_die_offset = form_value.Reference();
break;
}
@ -850,18 +849,9 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
{
if (specification_die_offset != DW_INVALID_OFFSET)
{
const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
if (specification_die)
{
parent = specification_die->GetParent();
if (parent)
{
parent_tag = parent->Tag();
if (parent_tag == DW_TAG_class_type || parent_tag == DW_TAG_structure_type)
is_method = true;
}
}
DWARFDIE specification_die = m_dwarf2Data->DebugInfo()->GetDIE (specification_die_offset);
if (specification_die.GetParent().IsStructOrClass())
is_method = true;
}
}
}
@ -1133,3 +1123,18 @@ DWARFCompileUnit::GetIsOptimized ()
return false;
}
}
DWARFFormValue::FixedFormSizes
DWARFCompileUnit::GetFixedFormSizes ()
{
return DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), IsDWARF64());
}
TypeSystem *
DWARFCompileUnit::GetTypeSystem ()
{
if (m_dwarf2Data)
return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType());
else
return nullptr;
}

View File

@ -12,6 +12,7 @@
#include "lldb/lldb-enumerations.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFDIE.h"
#include "SymbolFileDWARF.h"
class NameToDIE;
@ -32,16 +33,13 @@ public:
bool Extract(const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr);
size_t ExtractDIEsIfNeeded (bool cu_die_only);
bool LookupAddress(
const dw_addr_t address,
DWARFDebugInfoEntry** function_die,
DWARFDebugInfoEntry** block_die);
DWARFDIE LookupAddress(const dw_addr_t address);
size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const;
void Clear();
bool Verify(lldb_private::Stream *s) const;
void Dump(lldb_private::Stream *s) const;
dw_offset_t GetOffset() const { return m_offset; }
lldb::user_id_t GetID () const;
uint32_t Size() const { return m_is_dwarf64 ? 23 : 11; /* Size in bytes of the compile unit header */ }
bool ContainsDIEOffset(dw_offset_t die_offset) const { return die_offset >= GetFirstDIEOffset() && die_offset < GetNextCompileUnitOffset(); }
dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
@ -58,6 +56,12 @@ public:
void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges);
lldb_private::TypeSystem *
GetTypeSystem();
DWARFFormValue::FixedFormSizes
GetFixedFormSizes ();
void
SetBaseAddress(dw_addr_t base_addr)
{
@ -73,8 +77,14 @@ public:
return &m_die_array[0];
}
DWARFDIE
DIE ()
{
return DWARFDIE(this, DIEPtr());
}
const DWARFDebugInfoEntry*
DIE()
DIEPtr()
{
ExtractDIEsIfNeeded (false);
if (m_die_array.empty())
@ -111,11 +121,11 @@ public:
return &m_die_array[idx];
}
DWARFDebugInfoEntry*
GetDIEPtr (dw_offset_t die_offset);
DWARFDIE
GetDIE (dw_offset_t die_offset);
const DWARFDebugInfoEntry*
GetDIEPtrContainingOffset (dw_offset_t die_offset);
DWARFDIE
GetDIEContainingOffset (dw_offset_t die_offset);
static uint8_t
GetAddressByteSize(const DWARFCompileUnit* cu);

View File

@ -0,0 +1,416 @@
//===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "DWARFDIE.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFDebugRanges.h"
#include "DWARFDeclContext.h"
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
#include "DWARFLocationDescription.h"
#include "DWARFLocationList.h"
#include "SymbolFileDWARF.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ObjectFile.h"
dw_tag_t
DWARFDIE::Tag() const
{
if (m_die)
return m_die->Tag();
else
return 0;
}
const char *
DWARFDIE::GetTagAsCString () const
{
return lldb_private::DW_TAG_value_to_name (Tag());
}
DWARFDIE
DWARFDIE::GetParent () const
{
if (IsValid())
return DWARFDIE(m_cu, m_die->GetParent());
else
return DWARFDIE();
}
DWARFDIE
DWARFDIE::GetFirstChild () const
{
if (IsValid())
return DWARFDIE(m_cu, m_die->GetFirstChild());
else
return DWARFDIE();
}
DWARFDIE
DWARFDIE::GetSibling () const
{
if (IsValid())
return DWARFDIE(m_cu, m_die->GetSibling());
else
return DWARFDIE();
}
DWARFDIE
DWARFDIE::GetReferencedDIE (const dw_attr_t attr) const
{
const dw_offset_t die_offset = GetAttributeValueAsReference (attr, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
return GetDIE(die_offset);
else
return DWARFDIE();
}
DWARFDIE
DWARFDIE::GetDIE (dw_offset_t die_offset) const
{
if (IsValid())
return m_cu->GetDIE(die_offset);
else
return DWARFDIE();
}
const char *
DWARFDIE::GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const
{
if (IsValid())
return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr, fail_value);
else
return fail_value;
}
uint64_t
DWARFDIE::GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const
{
if (IsValid())
return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr, fail_value);
else
return fail_value;
}
int64_t
DWARFDIE::GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const
{
if (IsValid())
return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr, fail_value);
else
return fail_value;
}
uint64_t
DWARFDIE::GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const
{
if (IsValid())
return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, fail_value);
else
return fail_value;
}
DWARFDIE
DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const
{
if (IsValid())
{
SymbolFileDWARF *dwarf= GetDWARF();
DWARFCompileUnit *cu = GetCU();
DWARFDebugInfoEntry* function_die = nullptr;
DWARFDebugInfoEntry* block_die = nullptr;
if (m_die->LookupAddress (file_addr,
dwarf,
cu,
&function_die,
&block_die))
{
if (block_die && block_die != function_die)
{
if (cu->ContainsDIEOffset(block_die->GetOffset()))
return DWARFDIE(cu, block_die);
else
return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(block_die->GetOffset()), block_die);
}
}
}
return DWARFDIE();
}
lldb::user_id_t
DWARFDIE::GetID () const
{
const dw_offset_t die_offset = GetOffset();
if (die_offset != DW_INVALID_OFFSET)
{
SymbolFileDWARF *dwarf = GetDWARF();
if (dwarf)
return dwarf->MakeUserID(die_offset);
else
return die_offset;
}
return LLDB_INVALID_UID;
}
const char *
DWARFDIE::GetName () const
{
if (IsValid())
return m_die->GetName (GetDWARF(), m_cu);
else
return nullptr;
}
const char *
DWARFDIE::GetMangledName () const
{
if (IsValid())
return m_die->GetMangledName (GetDWARF(), m_cu);
else
return nullptr;
}
const char *
DWARFDIE::GetPubname () const
{
if (IsValid())
return m_die->GetPubname (GetDWARF(), m_cu);
else
return nullptr;
}
const char *
DWARFDIE::GetQualifiedName (std::string &storage) const
{
if (IsValid())
return m_die->GetQualifiedName (GetDWARF(), m_cu, storage);
else
return nullptr;
}
lldb::LanguageType
DWARFDIE::GetLanguage () const
{
if (IsValid())
return m_cu->GetLanguageType();
else
return lldb::eLanguageTypeUnknown;
}
lldb::ModuleSP
DWARFDIE::GetModule () const
{
SymbolFileDWARF *dwarf = GetDWARF();
if (dwarf)
return dwarf->GetObjectFile()->GetModule();
else
return lldb::ModuleSP();
}
lldb_private::CompileUnit *
DWARFDIE::GetLLDBCompileUnit () const
{
if (IsValid())
return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
else
return nullptr;
}
lldb_private::Type *
DWARFDIE::ResolveType () const
{
if (IsValid())
return GetDWARF()->ResolveType(*this, true);
else
return nullptr;
}
lldb_private::Type *
DWARFDIE::ResolveTypeUID (lldb::user_id_t uid) const
{
SymbolFileDWARF *dwarf = GetDWARF();
if (dwarf)
return dwarf->ResolveTypeUID(uid);
else
return nullptr;
}
void
DWARFDIE::GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const
{
if (IsValid())
{
DWARFDIE parent_decl_ctx_die = m_die->GetParentDeclContextDIE (GetDWARF(), GetCU());
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE())
{
decl_context_dies.Append(parent_decl_ctx_die);
parent_decl_ctx_die.GetDeclContextDIEs (decl_context_dies);
}
}
}
void
DWARFDIE::GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const
{
if (IsValid())
{
m_die->GetDWARFDeclContext (GetDWARF(), GetCU(), dwarf_decl_ctx);
}
else
{
dwarf_decl_ctx.Clear();
}
}
DWARFDIE
DWARFDIE::GetParentDeclContextDIE () const
{
if (IsValid())
return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu);
else
return DWARFDIE();
}
dw_offset_t
DWARFDIE::GetOffset () const
{
if (IsValid())
return m_die->GetOffset();
else
return DW_INVALID_OFFSET;
}
dw_offset_t
DWARFDIE::GetCompileUnitRelativeOffset () const
{
if (IsValid())
return m_die->GetOffset() - m_cu->GetOffset();
else
return DW_INVALID_OFFSET;
}
SymbolFileDWARF *
DWARFDIE::GetDWARF () const
{
if (m_cu)
return m_cu->GetSymbolFileDWARF();
else
return nullptr;
}
lldb_private::TypeSystem *
DWARFDIE::GetTypeSystem () const
{
if (m_cu)
return m_cu->GetTypeSystem();
else
return nullptr;
}
bool
DWARFDIE::IsStructOrClass () const
{
const dw_tag_t tag = Tag();
return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
}
bool
DWARFDIE::HasChildren () const
{
if (m_die)
return m_die->HasChildren();
else
return false;
}
bool
DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type () const
{
if (IsValid())
return GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
else
return false;
}
size_t
DWARFDIE::GetAttributes (DWARFAttributes &attributes, uint32_t depth) const
{
if (IsValid())
{
return m_die->GetAttributes (m_cu,
m_cu->GetFixedFormSizes(),
attributes,
depth);
}
if (depth == 0)
attributes.Clear();
return 0;
}
bool
DWARFDIE::GetDIENamesAndRanges (const char * &name,
const char * &mangled,
DWARFRangeList& ranges,
int& decl_file,
int& decl_line,
int& decl_column,
int& call_file,
int& call_line,
int& call_column,
lldb_private::DWARFExpression *frame_base) const
{
if (IsValid())
{
return m_die->GetDIENamesAndRanges (GetDWARF(),
GetCU(),
name,
mangled,
ranges,
decl_file,
decl_line,
decl_column,
call_file,
call_line,
call_column,
frame_base);
}
else
return false;
}
void
DWARFDIE::Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const
{
if (s && IsValid())
m_die->Dump (GetDWARF(), GetCU(), *s, recurse_depth);
}
bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs)
{
return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
}
bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs)
{
return lhs.GetDIE() != rhs.GetDIE() || lhs.GetCU() != rhs.GetCU();
}

View File

@ -0,0 +1,261 @@
//===-- DWARFDIE.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_DWARFDIE_h_
#define SymbolFileDWARF_DWARFDIE_h_
#include "lldb/lldb-types.h"
#include "lldb/Core/dwarf.h"
class DWARFAttributes;
class DWARFCompileUnit;
class DWARFDebugInfoEntry;
class DWARFDeclContext;
class DWARFDIECollection;
class SymbolFileDWARF;
class DWARFDIE
{
public:
DWARFDIE () :
m_cu (nullptr),
m_die (nullptr)
{
}
DWARFDIE (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
m_cu (cu),
m_die (die)
{
}
DWARFDIE (const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
m_cu (const_cast<DWARFCompileUnit *>(cu)),
m_die (die)
{
}
DWARFDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
m_cu (cu),
m_die (const_cast<DWARFDebugInfoEntry *>(die))
{
}
DWARFDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
m_cu (const_cast<DWARFCompileUnit *>(cu)),
m_die (const_cast<DWARFDebugInfoEntry *>(die))
{
}
//----------------------------------------------------------------------
// Tests
//----------------------------------------------------------------------
operator bool () const
{
return IsValid();
}
bool
IsValid() const
{
return m_cu && m_die;
}
bool
IsStructOrClass () const;
bool
HasChildren () const;
bool
Supports_DW_AT_APPLE_objc_complete_type () const;
//----------------------------------------------------------------------
// Accessors
//----------------------------------------------------------------------
SymbolFileDWARF *
GetDWARF () const;
DWARFCompileUnit *
GetCU() const
{
return m_cu;
}
DWARFDebugInfoEntry *
GetDIE() const
{
return m_die;
}
lldb_private::TypeSystem *
GetTypeSystem () const;
void
Set (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
{
if (cu && die)
{
m_cu = cu;
m_die = die;
}
else
{
Clear();
}
}
void
Clear ()
{
m_cu = nullptr;
m_die = nullptr;
}
//----------------------------------------------------------------------
// Accessing information about a DIE
//----------------------------------------------------------------------
dw_tag_t
Tag() const;
const char *
GetTagAsCString () const;
dw_offset_t
GetOffset () const;
dw_offset_t
GetCompileUnitRelativeOffset () const;
//----------------------------------------------------------------------
// Get the LLDB user ID for this DIE. This is often just the DIE offset,
// but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
// we are doing Darwin DWARF in .o file, or DWARF stand alone debug
// info.
//----------------------------------------------------------------------
lldb::user_id_t
GetID() const;
const char *
GetName () const;
const char *
GetMangledName () const;
const char *
GetPubname () const;
const char *
GetQualifiedName (std::string &storage) const;
lldb::LanguageType
GetLanguage () const;
lldb::ModuleSP
GetModule () const;
lldb_private::CompileUnit *
GetLLDBCompileUnit () const;
lldb_private::Type *
ResolveType () const;
// Resolve a type by UID using this DIE's DWARF file
lldb_private::Type *
ResolveTypeUID (lldb::user_id_t uid) const;
//----------------------------------------------------------------------
// Functions for obtaining DIE relations and references
//----------------------------------------------------------------------
DWARFDIE
GetParent () const;
DWARFDIE
GetFirstChild () const;
DWARFDIE
GetSibling () const;
DWARFDIE
GetReferencedDIE (const dw_attr_t attr) const;
//----------------------------------------------------------------------
// Get a another DIE from the same DWARF file as this DIE. This will
// check the current DIE's compile unit first to see if "die_offset" is
// in the same compile unit, and fall back to checking the DWARF file.
//----------------------------------------------------------------------
DWARFDIE
GetDIE (dw_offset_t die_offset) const;
DWARFDIE
LookupDeepestBlock (lldb::addr_t file_addr) const;
DWARFDIE
GetParentDeclContextDIE () const;
//----------------------------------------------------------------------
// DeclContext related functions
//----------------------------------------------------------------------
void
GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const;
void
GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const;
//----------------------------------------------------------------------
// Getting attribute values from the DIE.
//
// GetAttributeValueAsXXX() functions should only be used if you are
// looking for one or two attributes on a DIE. If you are trying to
// parse all attributes, use GetAttributes (...) instead
//----------------------------------------------------------------------
const char *
GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const;
uint64_t
GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const;
int64_t
GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const;
uint64_t
GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const;
size_t
GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const;
bool
GetDIENamesAndRanges (const char * &name,
const char * &mangled,
DWARFRangeList& ranges,
int& decl_file,
int& decl_line,
int& decl_column,
int& call_file,
int& call_line,
int& call_column,
lldb_private::DWARFExpression *frame_base) const;
//----------------------------------------------------------------------
// Pretty printing
//----------------------------------------------------------------------
void
Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
protected:
DWARFCompileUnit *m_cu;
DWARFDebugInfoEntry *m_die;
};
bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs);
bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs);
#endif // SymbolFileDWARF_DWARFDIE_h_

View File

@ -19,7 +19,7 @@ using namespace lldb_private;
using namespace std;
bool
DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die)
DWARFDIECollection::Insert(const DWARFDIE &die)
{
iterator end_pos = m_dies.end();
iterator insert_pos = upper_bound(m_dies.begin(), end_pos, die);
@ -30,17 +30,17 @@ DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die)
}
void
DWARFDIECollection::Append (const DWARFDebugInfoEntry *die)
DWARFDIECollection::Append (const DWARFDIE &die)
{
m_dies.push_back (die);
}
const DWARFDebugInfoEntry *
DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const
DWARFDIE
DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const
{
if (idx < m_dies.size())
return m_dies[idx];
return NULL;
return DWARFDIE();
}
@ -55,8 +55,6 @@ DWARFDIECollection::Dump(Stream *s, const char* title) const
{
if (title && title[0] != '\0')
s->Printf( "%s\n", title);
const_iterator end_pos = m_dies.end();
const_iterator pos;
for (pos = m_dies.begin(); pos != end_pos; ++pos)
s->Printf( "0x%8.8x\n", (*pos)->GetOffset());
for (const auto &die : m_dies)
s->Printf( "0x%8.8x\n", die.GetDIE()->GetOffset());
}

View File

@ -10,7 +10,7 @@
#ifndef SymbolFileDWARF_DWARFDIECollection_h_
#define SymbolFileDWARF_DWARFDIECollection_h_
#include "SymbolFileDWARF.h"
#include "DWARFDIE.h"
#include <vector>
class DWARFDIECollection
@ -25,22 +25,22 @@ public:
}
void
Append (const DWARFDebugInfoEntry *die);
Append (const DWARFDIE &die);
void
Dump(lldb_private::Stream *s, const char* title) const;
const DWARFDebugInfoEntry*
GetDIEPtrAtIndex(uint32_t idx) const;
DWARFDIE
GetDIEAtIndex (uint32_t idx) const;
bool
Insert(const DWARFDebugInfoEntry *die);
Insert(const DWARFDIE &die);
size_t
Size() const;
protected:
typedef std::vector<const DWARFDebugInfoEntry *> collection;
typedef std::vector<DWARFDIE> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;

View File

@ -107,50 +107,41 @@ DWARFDebugInfo::GetCompileUnitAranges ()
//----------------------------------------------------------------------
// LookupAddress
//----------------------------------------------------------------------
bool
DWARFDebugInfo::LookupAddress
(
const dw_addr_t address,
const dw_offset_t hint_die_offset,
DWARFCompileUnitSP& cu_sp,
DWARFDebugInfoEntry** function_die,
DWARFDebugInfoEntry** block_die
)
DWARFDIE
DWARFDebugInfo::LookupAddress (const dw_addr_t address,
const dw_offset_t hint_die_offset)
{
DWARFDIE die;
DWARFCompileUnit *cu = nullptr;
if (hint_die_offset != DW_INVALID_OFFSET)
cu_sp = GetCompileUnit(hint_die_offset);
{
cu = GetCompileUnit(hint_die_offset);
}
else
{
DWARFDebugAranges &cu_aranges = GetCompileUnitAranges ();
const dw_offset_t cu_offset = cu_aranges.FindAddress (address);
cu_sp = GetCompileUnit(cu_offset);
cu = GetCompileUnit(cu_offset);
}
if (cu_sp.get())
if (cu)
{
if (cu_sp->LookupAddress(address, function_die, block_die))
return true;
cu_sp.reset();
die = cu->LookupAddress(address);
}
else
{
// The hint_die_offset may have been a pointer to the actual item that
// we are looking for
DWARFDebugInfoEntry* die_ptr = GetDIEPtr(hint_die_offset, &cu_sp);
if (die_ptr)
die = GetDIE(hint_die_offset);
if (die)
{
if (cu_sp.get())
{
if (function_die || block_die)
return die_ptr->LookupAddress(address, m_dwarf2Data, cu_sp.get(), function_die, block_die);
DWARFDebugInfoEntry* function_die = nullptr;
// We only wanted the compile unit that contained this address
return true;
}
if (die.GetDIE()->LookupAddress (address, die.GetDWARF(), die.GetCU(), &function_die, nullptr))
die.Set (die.GetCU(), function_die);
}
}
return false;
return die;
}
@ -219,7 +210,7 @@ OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& c
return offset < cu_sp->GetOffset();
}
DWARFCompileUnitSP
DWARFCompileUnit *
DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr)
{
DWARFCompileUnitSP cu_sp;
@ -256,11 +247,11 @@ DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr)
}
if (idx_ptr)
*idx_ptr = cu_idx;
return cu_sp;
return cu_sp.get();
}
DWARFCompileUnitSP
DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset)
DWARFCompileUnit *
DWARFDebugInfo::GetCompileUnitContainingDIE (dw_offset_t die_offset)
{
DWARFCompileUnitSP cu_sp;
if (die_offset != DW_INVALID_OFFSET)
@ -287,7 +278,7 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset)
}
}
}
return cu_sp;
return cu_sp.get();
}
//----------------------------------------------------------------------
@ -295,50 +286,23 @@ DWARFDebugInfo::GetCompileUnitContainingDIE(dw_offset_t die_offset)
//
// Get the DIE (Debug Information Entry) with the specified offset.
//----------------------------------------------------------------------
DWARFDebugInfoEntry*
DWARFDebugInfo::GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr)
DWARFDIE
DWARFDebugInfo::GetDIE(dw_offset_t die_offset)
{
DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset));
if (cu_sp_ptr)
*cu_sp_ptr = cu_sp;
if (cu_sp.get())
return cu_sp->GetDIEPtr(die_offset);
return NULL; // Not found in any compile units
DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_offset);
if (cu)
return cu->GetDIE (die_offset);
return DWARFDIE(); // Not found
}
DWARFDebugInfoEntry*
DWARFDebugInfo::GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle)
DWARFDIE
DWARFDebugInfo::GetDIEContainingOffset (dw_offset_t die_offset)
{
assert (cu_handle);
DWARFDebugInfoEntry* die = NULL;
if (*cu_handle)
die = (*cu_handle)->GetDIEPtr(die_offset);
DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_offset);
if (cu)
return cu->GetDIEContainingOffset (die_offset);
if (die == NULL)
{
DWARFCompileUnitSP cu_sp (GetCompileUnitContainingDIE(die_offset));
if (cu_sp.get())
{
*cu_handle = cu_sp.get();
die = cu_sp->GetDIEPtr(die_offset);
}
}
if (die == NULL)
*cu_handle = NULL;
return die;
}
const DWARFDebugInfoEntry*
DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr)
{
DWARFCompileUnitSP cu_sp(GetCompileUnitContainingDIE(die_offset));
if (cu_sp_ptr)
*cu_sp_ptr = cu_sp;
if (cu_sp.get())
return cu_sp->GetDIEPtrContainingOffset(die_offset);
return NULL; // Not found in any compile units
return DWARFDIE(); // Not found
}
@ -391,7 +355,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user
depth = 0;
// Call the callback function with no DIE pointer for the compile unit
// and get the offset that we are to continue to parse from
offset = callback(dwarf2Data, cu, NULL, offset, depth, userData);
offset = callback(dwarf2Data, cu.get(), NULL, offset, depth, userData);
// Make sure we are within our compile unit
if (offset < next_cu_offset)
@ -402,7 +366,7 @@ DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* user
while (!done && die.Extract(dwarf2Data, cu.get(), &offset))
{
// Call the callback function with DIE pointer that falls within the compile unit
offset = callback(dwarf2Data, cu, &die, offset, depth, userData);
offset = callback(dwarf2Data, cu.get(), &die, offset, depth, userData);
if (die.IsNULL())
{
@ -469,7 +433,7 @@ typedef struct DumpInfo
static dw_offset_t DumpCallback
(
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnitSP& cu_sp,
DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t curr_depth,
@ -477,9 +441,6 @@ static dw_offset_t DumpCallback
)
{
DumpInfo* dumpInfo = (DumpInfo*)userData;
const DWARFCompileUnit* cu = cu_sp.get();
Stream *s = dumpInfo->strm;
bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
@ -696,11 +657,11 @@ DWARFDebugInfo::Dump (Stream *s, const uint32_t die_offset, const uint32_t recur
for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos)
{
const DWARFCompileUnitSP& cu_sp = *pos;
DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL, 0, curr_depth, &dumpInfo);
DumpCallback(m_dwarf2Data, cu_sp.get(), NULL, 0, curr_depth, &dumpInfo);
const DWARFDebugInfoEntry* die = cu_sp->DIE();
const DWARFDIE die = cu_sp->DIE();
if (die)
die->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth);
die.Dump(s, recurse_depth);
}
}
@ -726,7 +687,7 @@ typedef struct FindCallbackStringInfoTag
static dw_offset_t FindCallbackString
(
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnitSP& cu_sp,
DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t curr_depth,
@ -734,7 +695,6 @@ static dw_offset_t FindCallbackString
)
{
FindCallbackStringInfo* info = (FindCallbackStringInfo*)userData;
const DWARFCompileUnit* cu = cu_sp.get();
if (die)
{

View File

@ -16,6 +16,7 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-private.h"
#include "SymbolFileDWARF.h"
#include "DWARFDIE.h"
typedef std::multimap<const char*, dw_offset_t, CStringCompareFunctionObject> CStringToDIEMap;
typedef CStringToDIEMap::iterator CStringToDIEMapIter;
@ -28,7 +29,7 @@ class DWARFDebugInfo
public:
typedef dw_offset_t (*Callback)(
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnitSP& cu_shared_ptr,
DWARFCompileUnit* cu_shared_ptr,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t depth,
@ -37,24 +38,19 @@ public:
DWARFDebugInfo();
void SetDwarfData(SymbolFileDWARF* dwarf2Data);
bool LookupAddress(
const dw_addr_t address,
const dw_offset_t cu_offset, // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually
DWARFCompileUnitSP& cu_shared_ptr,
DWARFDebugInfoEntry** function_die,
DWARFDebugInfoEntry** block_die);
DWARFDIE
LookupAddress(const dw_addr_t address,
const dw_offset_t cu_offset); // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually
void AddCompileUnit(DWARFCompileUnitSP& cu);
size_t GetNumCompileUnits();
bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
DWARFCompileUnit* GetCompileUnitAtIndex(uint32_t idx);
DWARFCompileUnitSP GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
DWARFCompileUnitSP GetCompileUnitContainingDIE(dw_offset_t die_offset);
DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
DWARFCompileUnit* GetCompileUnit (dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
DWARFCompileUnit* GetCompileUnitContainingDIE (dw_offset_t die_offset);
DWARFDebugInfoEntry* GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr);
DWARFDebugInfoEntry* GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle);
const DWARFDebugInfoEntry* GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr);
DWARFDIE GetDIE (dw_offset_t die_offset);
DWARFDIE GetDIEContainingOffset (dw_offset_t die_offset);
void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth);
static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData);

View File

@ -34,86 +34,6 @@ using namespace lldb_private;
using namespace std;
extern int g_verbose;
DWARFDebugInfoEntry::Attributes::Attributes() :
m_infos()
{
}
DWARFDebugInfoEntry::Attributes::~Attributes()
{
}
uint32_t
DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const
{
collection::const_iterator end = m_infos.end();
collection::const_iterator beg = m_infos.begin();
collection::const_iterator pos;
for (pos = beg; pos != end; ++pos)
{
if (pos->attr == attr)
return std::distance(beg, pos);
}
return UINT32_MAX;
}
void
DWARFDebugInfoEntry::Attributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
{
Info info = { cu, attr_die_offset, attr, form };
m_infos.push_back(info);
}
bool
DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const
{
return FindAttributeIndex(attr) != UINT32_MAX;
}
bool
DWARFDebugInfoEntry::Attributes::RemoveAttribute(dw_attr_t attr)
{
uint32_t attr_index = FindAttributeIndex(attr);
if (attr_index != UINT32_MAX)
{
m_infos.erase(m_infos.begin() + attr_index);
return true;
}
return false;
}
bool
DWARFDebugInfoEntry::Attributes::ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const
{
form_value.SetCompileUnit(CompileUnitAtIndex(i));
form_value.SetForm(FormAtIndex(i));
lldb::offset_t offset = DIEOffsetAtIndex(i);
return form_value.ExtractValue(dwarf2Data->get_debug_info_data(), &offset);
}
uint64_t
DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const
{
const uint32_t attr_idx = FindAttributeIndex (attr);
if (attr_idx != UINT32_MAX)
return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value);
return fail_value;
}
uint64_t
DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const
{
DWARFFormValue form_value;
if (ExtractFormValueAtIndex(dwarf2Data, i, form_value))
return form_value.Reference();
return fail_value;
}
bool
DWARFDebugInfoEntry::FastExtract
(
@ -530,8 +450,8 @@ DWARFDebugInfoEntry::DumpAncestry
// else if (a_tag > b_tag)
// return 1;
//
// DWARFDebugInfoEntry::Attributes a_attrs;
// DWARFDebugInfoEntry::Attributes b_attrs;
// DWARFAttributes a_attrs;
// DWARFAttributes b_attrs;
// size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs);
// size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs);
// if (a_attr_count != b_attr_count)
@ -743,7 +663,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
const DWARFCompileUnit* cu,
const char * &name,
const char * &mangled,
DWARFDebugRanges::RangeList& ranges,
DWARFRangeList& ranges,
int& decl_file,
int& decl_line,
int& decl_column,
@ -823,13 +743,13 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
case DW_AT_name:
if (name == NULL)
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (mangled == NULL)
mangled = form_value.AsCString(dwarf2Data);
mangled = form_value.AsCString();
break;
case DW_AT_abstract_origin:
@ -914,9 +834,9 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
if (lo_pc != LLDB_INVALID_ADDRESS)
{
if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
ranges.Append(DWARFDebugRanges::Range (lo_pc, hi_pc - lo_pc));
ranges.Append(DWARFRangeList::Entry (lo_pc, hi_pc - lo_pc));
else
ranges.Append(DWARFDebugRanges::Range (lo_pc, 0));
ranges.Append(DWARFRangeList::Entry (lo_pc, 0));
}
}
@ -933,14 +853,12 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges
std::vector<dw_offset_t>::const_iterator end = die_offsets.end();
for (pos = die_offsets.begin(); pos != end; ++pos)
{
DWARFCompileUnitSP cu_sp_ptr;
const DWARFDebugInfoEntry* die = NULL;
dw_offset_t die_offset = *pos;
if (die_offset != DW_INVALID_OFFSET)
{
die = dwarf2Data->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_offset);
if (die)
die->GetDIENamesAndRanges(dwarf2Data, cu_sp_ptr.get(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
}
}
}
@ -1097,7 +1015,7 @@ DWARFDebugInfoEntry::DumpAttribute
// Always dump form value if verbose is enabled
if (verbose)
{
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
}
@ -1130,7 +1048,7 @@ DWARFDebugInfoEntry::DumpAttribute
if (blockData)
{
if (!verbose)
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
// Location description is inlined in data in the form value
DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
@ -1147,13 +1065,13 @@ DWARFDebugInfoEntry::DumpAttribute
if (dwarf2Data)
{
if ( !verbose )
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
}
else
{
if ( !verbose )
form_value.Dump(s, NULL);
form_value.Dump(s);
}
}
}
@ -1163,7 +1081,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_specification:
{
uint64_t abstract_die_offset = form_value.Reference();
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
// *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
if ( verbose ) s.PutCString(" ( ");
GetName(dwarf2Data, cu, abstract_die_offset, s);
@ -1175,7 +1093,7 @@ DWARFDebugInfoEntry::DumpAttribute
{
uint64_t type_die_offset = form_value.Reference();
if (!verbose)
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
s.PutCString(" ( ");
AppendTypeName(dwarf2Data, cu, type_die_offset, s);
s.PutCString(" )");
@ -1185,7 +1103,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_ranges:
{
if ( !verbose )
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
lldb::offset_t ranges_offset = form_value.Unsigned();
dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
if (dwarf2Data)
@ -1195,7 +1113,7 @@ DWARFDebugInfoEntry::DumpAttribute
default:
if ( !verbose )
form_value.Dump(s, dwarf2Data);
form_value.Dump(s);
break;
}
@ -1209,17 +1127,19 @@ DWARFDebugInfoEntry::DumpAttribute
// take precedence (this can happen for declaration attributes).
//----------------------------------------------------------------------
size_t
DWARFDebugInfoEntry::GetAttributes
(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
DWARFFormValue::FixedFormSizes fixed_form_sizes,
DWARFDebugInfoEntry::Attributes& attributes,
uint32_t curr_depth
) const
DWARFDebugInfoEntry::GetAttributes (const DWARFCompileUnit* cu,
DWARFFormValue::FixedFormSizes fixed_form_sizes,
DWARFAttributes& attributes,
uint32_t curr_depth) const
{
lldb::offset_t offset;
const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
SymbolFileDWARF* dwarf2Data = nullptr;
const DWARFAbbreviationDeclaration* abbrevDecl = nullptr;
lldb::offset_t offset = 0;
if (cu)
{
dwarf2Data = cu->GetSymbolFileDWARF();
abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
}
if (abbrevDecl)
{
@ -1262,21 +1182,10 @@ DWARFDebugInfoEntry::GetAttributes
DWARFFormValue form_value (cu, form);
if (form_value.ExtractValue(debug_info_data, &offset))
{
const DWARFDebugInfoEntry* die = NULL;
dw_offset_t die_offset = form_value.Reference();
if (cu->ContainsDIEOffset(die_offset))
{
die = const_cast<DWARFCompileUnit*>(cu)->GetDIEPtr(die_offset);
if (die)
die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes, curr_depth + 1);
}
else
{
DWARFCompileUnitSP cu_sp_ptr;
die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr);
if (die)
die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes, curr_depth + 1);
}
DWARFDIE spec_die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(die_offset);
if (spec_die)
spec_die.GetAttributes(attributes, curr_depth + 1);
}
}
else
@ -1363,7 +1272,7 @@ DWARFDebugInfoEntry::GetAttributeValueAsString
{
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
return form_value.AsCString(dwarf2Data);
return form_value.AsCString();
return fail_value;
}
@ -1450,7 +1359,7 @@ DWARFDebugInfoEntry::GetAttributeHighPC
{
dw_form_t form = form_value.Form();
if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
return form_value.Address(dwarf2Data);
return form_value.Address();
// DWARF4 can specify the hi_pc as an <offset-from-lowpc>
return lo_pc + form_value.Unsigned();
@ -1491,7 +1400,7 @@ DWARFDebugInfoEntry::GetAttributeAddressRange
size_t
DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
DWARFDebugRanges::RangeList &ranges,
DWARFRangeList &ranges,
bool check_hi_lo_pc) const
{
ranges.Clear();
@ -1515,7 +1424,7 @@ DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data,
if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS))
{
if (lo_pc < hi_pc)
ranges.Append(DWARFDebugRanges::RangeList::Entry(lo_pc, hi_pc - lo_pc));
ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
}
}
return ranges.GetSize();
@ -1586,20 +1495,18 @@ DWARFDebugInfoEntry::GetName
{
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
return form_value.AsCString(dwarf2Data);
return form_value.AsCString();
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
{
DWARFCompileUnitSP cu_sp_ptr;
const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
if (die)
return die->GetName(dwarf2Data, cu_sp_ptr.get());
return die.GetName();
}
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
{
DWARFCompileUnitSP cu_sp_ptr;
const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
if (die)
return die->GetName(dwarf2Data, cu_sp_ptr.get());
return die.GetName();
}
return nullptr;
}
@ -1623,15 +1530,15 @@ DWARFDebugInfoEntry::GetMangledName
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
if (substitute_name_allowed && name == nullptr)
{
if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
}
return name;
}
@ -1657,19 +1564,16 @@ DWARFDebugInfoEntry::GetPubname
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
name = form_value.AsCString(dwarf2Data);
name = form_value.AsCString();
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
{
// The specification DIE may be in another compile unit so we need
// to get a die and its compile unit.
DWARFCompileUnitSP cu_sp_ptr;
const DWARFDebugInfoEntry* die = const_cast<SymbolFileDWARF*>(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(), &cu_sp_ptr);
DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
if (die)
return die->GetPubname(dwarf2Data, cu_sp_ptr.get());
name = die.GetPubname();
}
return name;
}
@ -1713,7 +1617,7 @@ DWARFDebugInfoEntry::GetName
DWARFFormValue form_value;
if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
{
const char* name = form_value.AsCString(dwarf2Data);
const char* name = form_value.AsCString();
if (name)
{
s.PutCString(name);
@ -1914,16 +1818,12 @@ DWARFDebugInfoEntry::BuildFunctionAddressRangeTable
}
void
DWARFDebugInfoEntry::GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
DWARFDebugInfoEntry::GetDeclContextDIEs (DWARFCompileUnit* cu,
DWARFDIECollection &decl_context_dies) const
{
const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
if (parent_decl_ctx_die && parent_decl_ctx_die != this)
{
decl_context_dies.Append(parent_decl_ctx_die);
parent_decl_ctx_die->GetDeclContextDIEs (dwarf2Data, cu, decl_context_dies);
}
DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
die.GetDeclContextDIEs(decl_context_dies);
}
void
@ -1935,11 +1835,11 @@ DWARFDebugInfoEntry::GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
if (tag != DW_TAG_compile_unit)
{
dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu));
const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
if (parent_decl_ctx_die && parent_decl_ctx_die != this)
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this)
{
if (parent_decl_ctx_die->Tag() != DW_TAG_compile_unit)
parent_decl_ctx_die->GetDWARFDeclContext (dwarf2Data, cu, dwarf_decl_ctx);
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit)
parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext (parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
}
}
}
@ -1956,30 +1856,30 @@ DWARFDebugInfoEntry::MatchesDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
return this_dwarf_decl_ctx == dwarf_decl_ctx;
}
const DWARFDebugInfoEntry *
DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu) const
{
DWARFDebugInfoEntry::Attributes attributes;
GetAttributes(dwarf2Data, cu, DWARFFormValue::FixedFormSizes(), attributes);
DWARFAttributes attributes;
GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetParentDeclContextDIE (dwarf2Data, cu, attributes);
}
const DWARFDebugInfoEntry *
DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
const DWARFDebugInfoEntry::Attributes& attributes) const
const DWARFAttributes& attributes) const
{
const DWARFDebugInfoEntry * die = this;
while (die != NULL)
DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
while (die)
{
// If this is the original DIE that we are searching for a declaration
// for, then don't look in the cache as we don't want our own decl
// context to be our decl context...
if (die != this)
if (die.GetDIE() != this)
{
switch (die->Tag())
switch (die.Tag())
{
case DW_TAG_compile_unit:
case DW_TAG_namespace:
@ -1995,33 +1895,33 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
dw_offset_t die_offset;
die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET);
die_offset = attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset);
DWARFDIE spec_die = cu->GetDIE (die_offset);
if (spec_die)
{
const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu);
if (spec_die_decl_ctx_die)
return spec_die_decl_ctx_die;
}
{
DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
if (decl_ctx_die)
return decl_ctx_die;
}
}
die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET);
die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, DW_INVALID_OFFSET);
if (die_offset != DW_INVALID_OFFSET)
{
const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset);
DWARFDIE abs_die = cu->GetDIE (die_offset);
if (abs_die)
{
const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu);
if (abs_die_decl_ctx_die)
return abs_die_decl_ctx_die;
DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
if (decl_ctx_die)
return decl_ctx_die;
}
}
die = die->GetParent();
die = die.GetParent();
}
return NULL;
return DWARFDIE();
}
@ -2030,15 +1930,15 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
std::string &storage) const
{
DWARFDebugInfoEntry::Attributes attributes;
GetAttributes(dwarf2Data, cu, DWARFFormValue::FixedFormSizes(), attributes);
DWARFAttributes attributes;
GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
return GetQualifiedName (dwarf2Data, cu, attributes, storage);
}
const char*
DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
const DWARFDebugInfoEntry::Attributes& attributes,
const DWARFAttributes& attributes,
std::string &storage) const
{
@ -2046,47 +1946,47 @@ DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
if (name)
{
const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
storage.clear();
// TODO: change this to get the correct decl context parent....
while (parent_decl_ctx_die)
{
const dw_tag_t parent_tag = parent_decl_ctx_die->Tag();
const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
switch (parent_tag)
{
case DW_TAG_namespace:
{
const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
if (namespace_name)
{
storage.insert (0, "::");
storage.insert (0, namespace_name);
}
else
{
storage.insert (0, "(anonymous namespace)::");
}
parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
}
{
const char *namespace_name = parent_decl_ctx_die.GetName ();
if (namespace_name)
{
storage.insert (0, "::");
storage.insert (0, namespace_name);
}
else
{
storage.insert (0, "(anonymous namespace)::");
}
parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
}
break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
{
const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
if (class_union_struct_name)
{
storage.insert (0, "::");
storage.insert (0, class_union_struct_name);
}
parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
}
{
const char *class_union_struct_name = parent_decl_ctx_die.GetName ();
if (class_union_struct_name)
{
storage.insert (0, "::");
storage.insert (0, class_union_struct_name);
}
parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
}
break;
default:
parent_decl_ctx_die = NULL;
parent_decl_ctx_die.Clear();
break;
}
}
@ -2234,7 +2134,7 @@ DWARFDebugInfoEntry::LookupAddress
dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
if (debug_ranges_offset != DW_INVALID_OFFSET)
{
DWARFDebugRanges::RangeList ranges;
DWARFRangeList ranges;
DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
debug_ranges->FindRanges(debug_ranges_offset, ranges);
// All DW_AT_ranges are relative to the base address of the

View File

@ -57,38 +57,6 @@ public:
typedef offset_collection::iterator offset_collection_iterator;
typedef offset_collection::const_iterator offset_collection_const_iterator;
class Attributes
{
public:
Attributes();
~Attributes();
void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form);
const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; }
dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr; }
dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].form; }
bool ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const;
uint64_t FormValueAsUnsignedAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const;
uint64_t FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const;
uint32_t FindAttributeIndex(dw_attr_t attr) const;
bool ContainsAttribute(dw_attr_t attr) const;
bool RemoveAttribute(dw_attr_t attr);
void Clear() { m_infos.clear(); }
size_t Size() const { return m_infos.size(); }
protected:
struct Info
{
const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values
dw_offset_t die_offset;
dw_attr_t attr;
dw_form_t form;
};
typedef llvm::SmallVector<Info, 8> collection;
collection m_infos;
};
struct CompareState
{
CompareState() :
@ -159,10 +127,9 @@ public:
DWARFDebugInfoEntry** block_die);
size_t GetAttributes(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
DWARFFormValue::FixedFormSizes fixed_form_sizes,
DWARFDebugInfoEntry::Attributes& attrs,
DWARFAttributes& attrs,
uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!!
dw_offset_t GetAttributeValue(
@ -212,7 +179,7 @@ public:
size_t GetAttributeAddressRanges (
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
DWARFDebugRanges::RangeList &ranges,
DWARFRangeList &ranges,
bool check_hi_lo_pc) const;
dw_offset_t GetAttributeValueAsLocation(
@ -255,7 +222,7 @@ public:
const char * GetQualifiedName (
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
const DWARFDebugInfoEntry::Attributes& attributes,
const DWARFAttributes& attributes,
std::string &storage) const;
// static int Compare(
@ -310,7 +277,7 @@ public:
const DWARFCompileUnit* cu,
const char * &name,
const char * &mangled,
DWARFDebugRanges::RangeList& rangeList,
DWARFRangeList& rangeList,
int& decl_file,
int& decl_line,
int& decl_column,
@ -375,8 +342,7 @@ public:
const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
void GetDeclContextDIEs (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
void GetDeclContextDIEs (DWARFCompileUnit* cu,
DWARFDIECollection &decl_context_dies) const;
void GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
@ -388,11 +354,11 @@ public:
DWARFCompileUnit* cu,
const DWARFDeclContext &dwarf_decl_ctx) const;
const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu) const;
const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFDIE GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
DWARFCompileUnit* cu,
const DWARFDebugInfoEntry::Attributes& attributes) const;
const DWARFAttributes& attributes) const;
void
SetParent (DWARFDebugInfoEntry* parent)

View File

@ -100,17 +100,17 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
size_t die_idx;
for (die_idx = 0; die_idx < die_count; ++die_idx)
{
const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx);
DWARFDebugInfoEntry::Attributes attributes;
DWARFDIE die = dies.GetDIEAtIndex(die_idx);
DWARFAttributes attributes;
const char *name = NULL;
const char *mangled = NULL;
bool add_die = false;
const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes);
const size_t num_attributes = die.GetDIE()->GetAttributes(die.GetCU(), fixed_form_sizes, attributes);
if (num_attributes > 0)
{
uint32_t i;
dw_tag_t tag = die->Tag();
dw_tag_t tag = die.Tag();
for (i=0; i<num_attributes; ++i)
{
@ -119,14 +119,14 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
switch (attr)
{
case DW_AT_name:
if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
name = form_value.AsCString(dwarf2Data);
if (attributes.ExtractFormValueAtIndex(i, form_value))
name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
mangled = form_value.AsCString(dwarf2Data);
if (attributes.ExtractFormValueAtIndex(i, form_value))
mangled = form_value.AsCString();
break;
case DW_AT_low_pc:
@ -139,10 +139,10 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
case DW_AT_location:
if (tag == DW_TAG_variable)
{
const DWARFDebugInfoEntry* parent_die = die->GetParent();
while ( parent_die != NULL )
DWARFDIE parent_die = die.GetParent();
while ( parent_die )
{
switch (parent_die->Tag())
switch (parent_die.Tag())
{
case DW_TAG_subprogram:
case DW_TAG_lexical_block:
@ -152,31 +152,16 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
// if the location describes a hard coded address, but we don't want the performance
// penalty of that right now.
add_die = false;
// if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
// {
// // If we have valid block data, then we have location expression bytes
// // that are fixed (not a location list).
// const uint8_t *block_data = form_value.BlockData();
// if (block_data)
// {
// uint32_t block_length = form_value.Unsigned();
// if (block_length == 1 + attributes.CompileUnitAtIndex(i)->GetAddressByteSize())
// {
// if (block_data[0] == DW_OP_addr)
// add_die = true;
// }
// }
// }
parent_die = NULL; // Terminate the while loop.
parent_die.Clear(); // Terminate the while loop.
break;
case DW_TAG_compile_unit:
add_die = true;
parent_die = NULL; // Terminate the while loop.
parent_die.Clear(); // Terminate the while loop.
break;
default:
parent_die = parent_die->GetParent(); // Keep going in the while loop.
parent_die = parent_die.GetParent(); // Keep going in the while loop.
break;
}
}
@ -188,7 +173,7 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
if (add_die && (name || mangled))
{
pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, mangled ? mangled : name);
pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), mangled ? mangled : name);
}
}
@ -230,13 +215,11 @@ DWARFDebugPubnames::GeneratePubBaseTypes(SymbolFileDWARF* dwarf2Data)
size_t die_idx;
for (die_idx = 0; die_idx < die_count; ++die_idx)
{
const DWARFDebugInfoEntry *die = dies.GetDIEPtrAtIndex(die_idx);
const char *name = die->GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, NULL);
DWARFDIE die = dies.GetDIEAtIndex (die_idx);
const char *name = die.GetName();
if (name)
{
pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, name);
}
pubnames_set.AddDescriptor(die.GetCompileUnitRelativeOffset(), name);
}
if (pubnames_set.NumDescriptors() > 0)

View File

@ -27,7 +27,7 @@ DWARFDebugRanges::~DWARFDebugRanges()
void
DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data)
{
RangeList range_list;
DWARFRangeList range_list;
lldb::offset_t offset = 0;
dw_offset_t debug_ranges_offset = offset;
while (Extract(dwarf2Data, &offset, range_list))
@ -38,52 +38,8 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data)
}
}
//void
//DWARFDebugRanges::RangeList::AddOffset(dw_addr_t offset)
//{
// if (!ranges.empty())
// {
// Range::iterator pos = ranges.begin();
// Range::iterator end_pos = ranges.end();
// for (pos = ranges.begin(); pos != end_pos; ++pos)
// {
// // assert for unsigned overflows
// assert (~pos->begin_offset >= offset);
// assert (~pos->end_offset >= offset);
// pos->begin_offset += offset;
// pos->end_offset += offset;
// }
// }
//}
//
//void
//DWARFDebugRanges::RangeList::SubtractOffset(dw_addr_t offset)
//{
// if (!ranges.empty())
// {
// Range::iterator pos = ranges.begin();
// Range::iterator end_pos = ranges.end();
// for (pos = ranges.begin(); pos != end_pos; ++pos)
// {
// assert (pos->begin_offset >= offset);
// assert (pos->end_offset >= offset);
// pos->begin_offset -= offset;
// pos->end_offset -= offset;
// }
// }
//}
//
//
//const DWARFDebugRanges::Range*
//DWARFDebugRanges::RangeList::RangeAtIndex(size_t i) const
//{
// if (i < ranges.size())
// return &ranges[i];
// return NULL;
//}
bool
DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, RangeList &range_list)
DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_ptr, DWARFRangeList &range_list)
{
range_list.Clear();
@ -118,13 +74,13 @@ DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, lldb::offset_t *offset_pt
break;
default:
assert(!"DWARFDebugRanges::RangeList::Extract() unsupported address size.");
assert(!"DWARFRangeList::Extract() unsupported address size.");
break;
}
// Filter out empty ranges
if (begin < end)
range_list.Append(Range(begin, end - begin));
range_list.Append(DWARFRangeList::Entry(begin, end - begin));
}
// Make sure we consumed at least something
@ -178,7 +134,7 @@ DWARFDebugRanges::Dump(Stream &s, const DWARFDataExtractor& debug_ranges_data, l
}
bool
DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, RangeList& range_list) const
DWARFDebugRanges::FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const
{
range_map_const_iterator pos = m_range_map.find(debug_ranges_offset);
if (pos != m_range_map.end())

View File

@ -11,34 +11,30 @@
#define SymbolFileDWARF_DWARFDebugRanges_h_
#include "SymbolFileDWARF.h"
#include "DWARFDIE.h"
#include <map>
#include <vector>
#include "lldb/Core/RangeMap.h"
class DWARFDebugRanges
{
public:
typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> RangeList;
typedef RangeList::Entry Range;
DWARFDebugRanges();
~DWARFDebugRanges();
void Extract(SymbolFileDWARF* dwarf2Data);
static void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor& debug_ranges_data, lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
bool FindRanges(dw_offset_t debug_ranges_offset, DWARFDebugRanges::RangeList& range_list) const;
bool FindRanges(dw_offset_t debug_ranges_offset, DWARFRangeList& range_list) const;
protected:
bool
Extract (SymbolFileDWARF* dwarf2Data,
lldb::offset_t *offset_ptr,
RangeList &range_list);
DWARFRangeList &range_list);
typedef std::map<dw_offset_t, RangeList> range_map;
typedef range_map::iterator range_map_iterator;
typedef range_map::const_iterator range_map_const_iterator;
typedef std::map<dw_offset_t, DWARFRangeList> range_map;
typedef range_map::iterator range_map_iterator;
typedef range_map::const_iterator range_map_const_iterator;
range_map m_range_map;
};

View File

@ -108,6 +108,13 @@ public:
return lldb_private::ConstString (GetQualifiedName ());
}
void
Clear()
{
m_entries.clear();
m_qualified_name.clear();
}
protected:
typedef std::vector<Entry> collection;
collection m_entries;

View File

@ -342,7 +342,7 @@ DWARFFormValue::SkipValue(dw_form_t form, const DWARFDataExtractor& debug_info_d
void
DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const
DWARFFormValue::Dump(Stream &s) const
{
uint64_t uvalue = Unsigned();
bool cu_relative_offset = false;
@ -359,7 +359,7 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const
case DW_FORM_data4: s.PutHex32(uvalue); break;
case DW_FORM_ref_sig8:
case DW_FORM_data8: s.PutHex64(uvalue); break;
case DW_FORM_string: s.QuotedCString(AsCString(symbol_file)); break;
case DW_FORM_string: s.QuotedCString(AsCString()); break;
case DW_FORM_exprloc:
case DW_FORM_block:
case DW_FORM_block1:
@ -395,18 +395,18 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const
case DW_FORM_sdata: s.PutSLEB128(uvalue); break;
case DW_FORM_udata: s.PutULEB128(uvalue); break;
case DW_FORM_strp:
if (symbol_file)
{
if (verbose)
s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
const char* dbg_str = AsCString(symbol_file);
const char* dbg_str = AsCString();
if (dbg_str)
{
if (verbose)
s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
s.QuotedCString(dbg_str);
}
else
{
s.PutHex32(uvalue);
}
else
{
s.PutHex32(uvalue);
}
}
break;
@ -444,8 +444,10 @@ DWARFFormValue::Dump(Stream &s, SymbolFileDWARF* symbol_file) const
}
const char*
DWARFFormValue::AsCString(SymbolFileDWARF* symbol_file) const
DWARFFormValue::AsCString() const
{
SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF();
if (m_form == DW_FORM_string)
{
return m_value.value.cstr;
@ -471,8 +473,10 @@ DWARFFormValue::AsCString(SymbolFileDWARF* symbol_file) const
}
dw_addr_t
DWARFFormValue::Address(SymbolFileDWARF* symbol_file) const
DWARFFormValue::Address() const
{
SymbolFileDWARF* symbol_file = m_cu->GetSymbolFileDWARF();
if (m_form == DW_FORM_addr)
return Unsigned();
@ -571,8 +575,7 @@ DWARFFormValue::IsDataForm(const dw_form_t form)
int
DWARFFormValue::Compare (const DWARFFormValue& a_value,
const DWARFFormValue& b_value,
SymbolFileDWARF* symbol_file)
const DWARFFormValue& b_value)
{
dw_form_t a_form = a_value.Form();
dw_form_t b_form = b_value.Form();
@ -619,8 +622,8 @@ DWARFFormValue::Compare (const DWARFFormValue& a_value,
case DW_FORM_strp:
case DW_FORM_GNU_str_index:
{
const char *a_string = a_value.AsCString(symbol_file);
const char *b_string = b_value.AsCString(symbol_file);
const char *a_string = a_value.AsCString();
const char *b_string = b_value.AsCString();
if (a_string == b_string)
return 0;
else if (a_string && b_string)

View File

@ -14,7 +14,6 @@
#include "DWARFDataExtractor.h"
class DWARFCompileUnit;
class SymbolFileDWARF;
class DWARFFormValue
{
@ -81,7 +80,7 @@ public:
dw_form_t Form() const { return m_form; }
void SetForm(dw_form_t form) { m_form = form; }
const ValueType& Value() const { return m_value; }
void Dump(lldb_private::Stream &s, SymbolFileDWARF* symbol_file) const;
void Dump(lldb_private::Stream &s) const;
bool ExtractValue(const lldb_private::DWARFDataExtractor& data,
lldb::offset_t* offset_ptr);
const uint8_t* BlockData() const;
@ -92,16 +91,15 @@ public:
void SetUnsigned(uint64_t uval) { m_value.value.uval = uval; }
int64_t Signed() const { return m_value.value.sval; }
void SetSigned(int64_t sval) { m_value.value.sval = sval; }
const char* AsCString(SymbolFileDWARF* symbol_file) const;
dw_addr_t Address(SymbolFileDWARF* symbol_file) const;
const char* AsCString() const;
dw_addr_t Address() const;
bool SkipValue(const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr) const;
static bool SkipValue(const dw_form_t form, const lldb_private::DWARFDataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu);
static bool IsBlockForm(const dw_form_t form);
static bool IsDataForm(const dw_form_t form);
static FixedFormSizes GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
static int Compare (const DWARFFormValue& a,
const DWARFFormValue& b,
SymbolFileDWARF* symbol_file);
const DWARFFormValue& b);
protected:
const DWARFCompileUnit* m_cu; // Compile unit for this form
dw_form_t m_form; // Form for this value

File diff suppressed because it is too large Load Diff

View File

@ -148,16 +148,9 @@ public:
CompleteType (lldb_private::CompilerType& clang_type) override;
lldb_private::Type *
ResolveType (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry* type_die,
ResolveType (const DWARFDIE &die,
bool assert_not_being_parsed = true);
lldb_private::Type *
GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const;
void
ClearDIEBeingParsed (const DWARFDebugInfoEntry* type_die);
lldb_private::CompilerDeclContext
GetDeclContextForUID (lldb::user_id_t uid) override;
@ -281,9 +274,8 @@ public:
static bool
SupportedVersion(uint16_t version);
const DWARFDebugInfoEntry *
GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die);
DWARFDIE
GetDeclContextDIEContainingDIE (const DWARFDIE &die);
lldb_private::Flags&
GetFlags ()
@ -317,8 +309,8 @@ public:
bool
Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu);
static const DWARFDebugInfoEntry *
GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die);
static DWARFDIE
GetParentSymbolContextDIE(const DWARFDIE &die);
protected:
@ -348,8 +340,7 @@ protected:
bool
DIEInDeclContext (const lldb_private::CompilerDeclContext *parent_decl_ctx,
DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die);
const DWARFDIE &die);
DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF);
@ -364,81 +355,62 @@ protected:
GetNextUnparsedDWARFCompileUnit (DWARFCompileUnit* prev_cu);
bool
GetFunction (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry* func_die,
GetFunction (const DWARFDIE &die,
lldb_private::SymbolContext& sc);
lldb_private::Function *
ParseCompileUnitFunction (const lldb_private::SymbolContext& sc,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die);
const DWARFDIE &die);
size_t
ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
lldb_private::Block *parent_block,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
lldb::addr_t subprogram_low_pc,
uint32_t depth);
size_t
ParseTypes (const lldb_private::SymbolContext& sc,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
bool parse_siblings,
bool parse_children);
lldb::TypeSP
ParseType (const lldb_private::SymbolContext& sc,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
bool *type_is_new);
lldb_private::Type *
ResolveTypeUID (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry* die,
ResolveTypeUID (const DWARFDIE &die,
bool assert_not_being_parsed);
lldb::VariableSP
ParseVariableDIE(const lldb_private::SymbolContext& sc,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
const DWARFDIE &die,
const lldb::addr_t func_low_pc);
size_t
ParseVariables(const lldb_private::SymbolContext& sc,
DWARFCompileUnit* dwarf_cu,
const lldb::addr_t func_low_pc,
const DWARFDebugInfoEntry *die,
bool parse_siblings,
bool parse_children,
lldb_private::VariableList* cc_variable_list = NULL);
ParseVariables (const lldb_private::SymbolContext& sc,
const DWARFDIE &orig_die,
const lldb::addr_t func_low_pc,
bool parse_siblings,
bool parse_children,
lldb_private::VariableList* cc_variable_list = NULL);
bool
ClassOrStructIsVirtual (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die);
ClassOrStructIsVirtual (const DWARFDIE &die);
// Given a die_offset, figure out the symbol context representing that die.
bool
ResolveFunction (dw_offset_t offset,
DWARFCompileUnit *&dwarf_cu,
bool include_inlines,
lldb_private::SymbolContextList& sc_list);
bool
ResolveFunction (DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die,
ResolveFunction (const DWARFDIE &die,
bool include_inlines,
lldb_private::SymbolContextList& sc_list);
bool
FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die,
const DWARFCompileUnit *dwarf_cu,
uint32_t name_type_mask,
const char *partial_name,
const char *base_name_start,
const char *base_name_end);
void
FindFunctions(const lldb_private::ConstString &name,
const NameToDIE &name_to_die,
@ -461,7 +433,7 @@ protected:
FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx);
lldb::TypeSP
FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die,
FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const lldb_private::ConstString &type_name,
bool must_be_implementation);
@ -478,8 +450,7 @@ protected:
lldb_private::SymbolContextList& sc_list);
lldb::TypeSP
GetTypeForDIE (DWARFCompileUnit *cu,
const DWARFDebugInfoEntry* die);
GetTypeForDIE (const DWARFDIE &die);
uint32_t
FindTypes (std::vector<dw_offset_t> die_offsets,
@ -501,16 +472,13 @@ protected:
SymbolFileDWARFDebugMap *
GetDebugMapSymfile ();
const DWARFDebugInfoEntry *
DWARFDIE
FindBlockContainingSpecification (dw_offset_t func_die_offset,
dw_offset_t spec_block_die_offset,
DWARFCompileUnit **dwarf_cu_handle);
dw_offset_t spec_block_die_offset);
const DWARFDebugInfoEntry *
FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
dw_offset_t spec_block_die_offset,
DWARFCompileUnit **dwarf_cu_handle);
DWARFDIE
FindBlockContainingSpecification (const DWARFDIE &die,
dw_offset_t spec_block_die_offset);
UniqueDWARFASTTypeMap &
GetUniqueDWARFASTTypeMap ();
@ -525,12 +493,11 @@ protected:
}
bool
DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugInfoEntry *die1,
DWARFCompileUnit* cu2, const DWARFDebugInfoEntry *die2);
DIEDeclContextsMatch (const DWARFDIE &die1,
const DWARFDIE &die2);
bool
ClassContainsSelector (DWARFCompileUnit *dwarf_cu,
const DWARFDebugInfoEntry *class_die,
ClassContainsSelector (const DWARFDIE &class_die,
const lldb_private::ConstString &selector);
bool
@ -546,8 +513,7 @@ protected:
typedef std::map<uint64_t, ClangModuleInfo> ExternalTypeModuleMap;
void
GetTypes (DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
GetTypes (const DWARFDIE &die,
dw_offset_t min_die_offset,
dw_offset_t max_die_offset,
uint32_t type_mask,

View File

@ -1225,7 +1225,7 @@ SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWAR
}
TypeSP
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die,
SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const ConstString &type_name,
bool must_be_implementation)
{

View File

@ -266,7 +266,7 @@ protected:
Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso);
lldb::TypeSP
FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die,
FindCompleteObjCDefinitionTypeForDIE (const DWARFDIE &die,
const lldb_private::ConstString &type_name,
bool must_be_implementation);

View File

@ -18,55 +18,50 @@
#include "DWARFDebugInfoEntry.h"
bool
UniqueDWARFASTTypeList::Find
(
SymbolFileDWARF *symfile,
const DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry
) const
UniqueDWARFASTTypeList::Find (const DWARFDIE &die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry) const
{
collection::const_iterator pos, end = m_collection.end();
for (pos = m_collection.begin(); pos != end; ++pos)
for (const UniqueDWARFASTType &udt : m_collection)
{
// Make sure the tags match
if (pos->m_die->Tag() == die->Tag())
if (udt.m_die.Tag() == die.Tag())
{
// Validate byte sizes of both types only if both are valid.
if (pos->m_byte_size < 0 || byte_size < 0 || pos->m_byte_size == byte_size)
if (udt.m_byte_size < 0 || byte_size < 0 || udt.m_byte_size == byte_size)
{
// Make sure the file and line match
if (pos->m_declaration == decl)
if (udt.m_declaration == decl)
{
// The type has the same name, and was defined on the same
// file and line. Now verify all of the parent DIEs match.
const DWARFDebugInfoEntry *parent_arg_die = die->GetParent();
const DWARFDebugInfoEntry *parend_pos_die = pos->m_die->GetParent();
DWARFDIE parent_arg_die = die.GetParent();
DWARFDIE parent_pos_die = udt.m_die.GetParent();
bool match = true;
bool done = false;
while (!done && match && parent_arg_die && parend_pos_die)
while (!done && match && parent_arg_die && parent_pos_die)
{
if (parent_arg_die->Tag() == parend_pos_die->Tag())
const dw_tag_t parent_arg_tag = parent_arg_die.Tag();
const dw_tag_t parent_pos_tag = parent_pos_die.Tag();
if (parent_arg_tag == parent_pos_tag)
{
const dw_tag_t tag = parent_arg_die->Tag();
switch (tag)
switch (parent_arg_tag)
{
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_namespace:
{
const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu);
const char *parent_arg_die_name = parent_arg_die.GetName();
if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct
{
match = false;
}
else
{
const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu);
if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name))
const char *parent_pos_die_name = parent_pos_die.GetName();
if (parent_pos_die_name == NULL || ((parent_arg_die_name != parent_pos_die_name) && strcmp (parent_arg_die_name, parent_pos_die_name)))
match = false;
}
}
@ -77,13 +72,13 @@ UniqueDWARFASTTypeList::Find
break;
}
}
parent_arg_die = parent_arg_die->GetParent();
parend_pos_die = parend_pos_die->GetParent();
parent_arg_die = parent_arg_die.GetParent();
parent_pos_die = parent_pos_die.GetParent();
}
if (match)
{
entry = *pos;
entry = udt;
return true;
}
}

View File

@ -19,6 +19,7 @@
// Project includes
#include "lldb/Symbol/Declaration.h"
#include "DWARFDIE.h"
class DWARFCompileUnit;
class DWARFDebugInfoEntry;
@ -32,23 +33,17 @@ public:
//------------------------------------------------------------------
UniqueDWARFASTType () :
m_type_sp (),
m_symfile (NULL),
m_cu (NULL),
m_die (NULL),
m_die (),
m_declaration (),
m_byte_size (-1) // Set to negative value to make sure we have a valid value
{
}
UniqueDWARFASTType (lldb::TypeSP &type_sp,
SymbolFileDWARF *symfile,
DWARFCompileUnit *cu,
DWARFDebugInfoEntry *die,
const DWARFDIE &die,
const lldb_private::Declaration &decl,
int32_t byte_size) :
m_type_sp (type_sp),
m_symfile (symfile),
m_cu (cu),
m_die (die),
m_declaration (decl),
m_byte_size (byte_size)
@ -57,8 +52,6 @@ public:
UniqueDWARFASTType (const UniqueDWARFASTType &rhs) :
m_type_sp (rhs.m_type_sp),
m_symfile (rhs.m_symfile),
m_cu (rhs.m_cu),
m_die (rhs.m_die),
m_declaration (rhs.m_declaration),
m_byte_size (rhs.m_byte_size)
@ -75,8 +68,6 @@ public:
if (this != &rhs)
{
m_type_sp = rhs.m_type_sp;
m_symfile = rhs.m_symfile;
m_cu = rhs.m_cu;
m_die = rhs.m_die;
m_declaration = rhs.m_declaration;
m_byte_size = rhs.m_byte_size;
@ -85,9 +76,7 @@ public:
}
lldb::TypeSP m_type_sp;
SymbolFileDWARF *m_symfile;
const DWARFCompileUnit *m_cu;
const DWARFDebugInfoEntry *m_die;
DWARFDIE m_die;
lldb_private::Declaration m_declaration;
int32_t m_byte_size;
};
@ -117,9 +106,7 @@ public:
}
bool
Find (SymbolFileDWARF *symfile,
const DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die,
Find (const DWARFDIE &die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry) const;
@ -149,10 +136,8 @@ public:
}
bool
Find (const lldb_private::ConstString &name,
SymbolFileDWARF *symfile,
const DWARFCompileUnit *cu,
const DWARFDebugInfoEntry *die,
Find (const lldb_private::ConstString &name,
const DWARFDIE &die,
const lldb_private::Declaration &decl,
const int32_t byte_size,
UniqueDWARFASTType &entry) const
@ -161,7 +146,7 @@ public:
collection::const_iterator pos = m_collection.find (unique_name_cstr);
if (pos != m_collection.end())
{
return pos->second.Find (symfile, cu, die, decl, byte_size, entry);
return pos->second.Find (die, decl, byte_size, entry);
}
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -17,5 +17,4 @@ TypeSystem::TypeSystem() :
TypeSystem::~TypeSystem()
{
}

View File

@ -2177,7 +2177,7 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr)
{
SymbolContext sc;
uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
uint32_t resolved_mask = temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc);
temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc);
if (sc.function)
{
function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this);
@ -2225,7 +2225,7 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr)
AddressRange range(resolved_addr, i*2);
uint32_t insn_size = 0;
uint32_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache);
disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache);
uint32_t num_insns = disasm_sp->GetInstructionList().GetSize();
if (num_insns)