#include "DIERef.h"
#include "DWARFCompileUnit.h"
#include "DWARFFormValue.h"
+#include "DWARFDebugInfo.h"
+#include "SymbolFileDWARF.h"
+#include "SymbolFileDWARFDebugMap.h"
DIERef::DIERef() :
cu_offset(DW_INVALID_OFFSET),
die_offset(DW_INVALID_OFFSET)
{}
-DIERef::DIERef(dw_offset_t d) :
- cu_offset(DW_INVALID_OFFSET),
- die_offset(d)
-{}
-
DIERef::DIERef(dw_offset_t c, dw_offset_t d) :
cu_offset(c),
die_offset(d)
{}
-DIERef::DIERef(lldb::user_id_t uid) :
- cu_offset(uid>>32),
+DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf) :
+ cu_offset(DW_INVALID_OFFSET),
die_offset(uid&0xffffffff)
-{}
+{
+ SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
+ if (debug_map)
+ {
+ const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
+ SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
+ if (actual_dwarf)
+ {
+ DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
+ if (debug_info)
+ {
+ DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIEOffset(die_offset);
+ if (dwarf_cu)
+ {
+ cu_offset = dwarf_cu->GetOffset();
+ return;
+ }
+ }
+ }
+ die_offset = DW_INVALID_OFFSET;
+ }
+ else
+ {
+ cu_offset = uid>>32;
+ }
+}
DIERef::DIERef(const DWARFFormValue& form_value) :
cu_offset(DW_INVALID_OFFSET),
}
lldb::user_id_t
-DIERef::GetUID() const
+DIERef::GetUID(SymbolFileDWARF *dwarf) const
{
- return ((lldb::user_id_t)cu_offset) << 32 | die_offset;
+ //----------------------------------------------------------------------
+ // Each SymbolFileDWARF will set its ID to what is expected.
+ //
+ // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
+ // ID set to the compile unit index.
+ //
+ // SymbolFileDWARFDwo sets the ID to the compile unit offset.
+ //----------------------------------------------------------------------
+ if (dwarf)
+ return dwarf->GetID() | die_offset;
+ else
+ return LLDB_INVALID_UID;
}
+
#include "lldb/lldb-defines.h"
class DWARFFormValue;
+class SymbolFileDWARF;
struct DIERef
{
DIERef();
- explicit
- DIERef(dw_offset_t d);
-
DIERef(dw_offset_t c, dw_offset_t d);
+ //----------------------------------------------------------------------
+ // In order to properly decode a lldb::user_id_t back into a DIERef we
+ // need the DWARF file since it knows if DWARF in .o files is being used
+ // (MacOSX) or if DWO files are being used. The encoding of the user ID
+ // differs between the two types of DWARF.
+ //----------------------------------------------------------------------
explicit
- DIERef(lldb::user_id_t uid);
+ DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf);
explicit
DIERef(const DWARFFormValue& form_value);
+ //----------------------------------------------------------------------
+ // In order to properly encode a DIERef unto a lldb::user_id_t we need
+ // the DWARF file since it knows if DWARF in .o files is being used
+ // (MacOSX) or if DWO files are being used. The encoding of the user ID
+ // differs between the two types of DWARF.
+ //----------------------------------------------------------------------
lldb::user_id_t
- GetUID() const;
+ GetUID(SymbolFileDWARF *dwarf) const;
bool
operator< (const DIERef &ref) const
const size_t num_attributes = die.GetAttributes (attributes);
uint32_t encoding = 0;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+ DWARFFormValue encoding_uid;
if (num_attributes > 0)
{
break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
case DW_AT_encoding: encoding = form_value.Unsigned(); break;
- case DW_AT_type: encoding_uid = DIERef(form_value).GetUID(); break;
+ case DW_AT_type: encoding_uid = form_value; break;
default:
case DW_AT_sibling:
break;
}
}
- DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
+ DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid.Reference());
switch (tag)
{
die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
+ encoding_uid.Clear();
resolve_state = Type::eResolveStateFull;
}
die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
+ encoding_uid.Clear();
resolve_state = Type::eResolveStateFull;
}
else if (type_name_const_str == g_objc_type_name_selector)
die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
+ encoding_uid.Clear();
resolve_state = Type::eResolveStateFull;
}
}
- else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid != LLDB_INVALID_UID)
+ else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid.IsValid())
{
// Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id".
- const DWARFDIE encoding_die = die.GetDIE(encoding_uid);
+ const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type)
{
die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
+ encoding_uid.Clear();
resolve_state = Type::eResolveStateFull;
}
}
type_name_const_str,
byte_size,
NULL,
- encoding_uid,
+ DIERef(encoding_uid).GetUID(dwarf),
encoding_data_type,
&decl,
clang_type,
// a complete type for this die
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(
- dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID())));
+ dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
if (defn_decl_ctx)
LinkDeclContextToDIE(defn_decl_ctx, die);
return type_sp;
"Type already in the forward declaration map!");
// Can't assume m_ast.GetSymbolFile() is actually a SymbolFileDWARF, it can be a
// SymbolFileDWARFDebugMap for Apple binaries.
- //assert(((SymbolFileDWARF*)m_ast.GetSymbolFile())->UserIDMatches(die.GetDIERef().GetUID()) &&
- // "Adding incorrect type to forward declaration map");
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = clang_type.GetOpaqueQualType();
dwarf->GetForwardDeclClangTypeToDie()[ClangUtil::RemoveFastQualifiers(clang_type)
.GetOpaqueQualType()] = die.GetDIERef();
// so lets use it and cache the fact that we found
// a complete type for this die
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(
- dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID())));
+ clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
if (defn_decl_ctx)
LinkDeclContextToDIE(defn_decl_ctx, die);
return type_sp;
{
if (encoding_form.IsValid())
{
- Type *enumerator_type = dwarf->ResolveTypeUID(DIERef(encoding_form).GetUID());
+ Type *enumerator_type = dwarf->ResolveTypeUID(DIERef(encoding_form));
if (enumerator_type)
enumerator_clang_type = enumerator_type->GetFullCompilerType ();
}
type_name_const_str,
byte_size,
NULL,
- DIERef(encoding_form).GetUID(),
+ DIERef(encoding_form).GetUID(dwarf),
Type::eEncodingIsUID,
&decl,
clang_type,
Type *func_type = NULL;
if (type_die_form.IsValid())
- func_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID());
+ func_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
if (func_type)
return_clang_type = func_type->GetForwardCompilerType ();
if (debug_map_symfile)
{
class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(class_type->GetID()));
- class_type_die = class_symfile->DebugInfo()->GetDIE (DIERef(class_type->GetID()));
+ class_type_die = class_symfile->DebugInfo()->GetDIE (DIERef(class_type->GetID(), dwarf));
}
else
{
class_symfile = dwarf;
- class_type_die = dwarf->DebugInfo()->GetDIE (DIERef(class_type->GetID()));
+ class_type_die = dwarf->DebugInfo()->GetDIE (DIERef(class_type->GetID(), dwarf));
}
if (class_type_die)
{
DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
- Type *element_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID());
+ Type *element_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
if (element_type)
{
empty_name,
array_element_bit_stride / 8,
NULL,
- DIERef(type_die_form).GetUID(),
+ DIERef(type_die_form).GetUID(dwarf),
Type::eEncodingIsUID,
&decl,
clang_type,
}
}
- Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form).GetUID());
- Type *class_type = dwarf->ResolveTypeUID(DIERef(containing_type_die_form).GetUID());
+ Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
+ Type *class_type = dwarf->ResolveTypeUID(DIERef(containing_type_die_form));
CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType ();
CompilerType class_clang_type = class_type->GetLayoutCompilerType ();
case DW_AT_type:
if (attributes.ExtractFormValueAtIndex(i, form_value))
{
- lldb_type = die.ResolveTypeUID(DIERef(form_value).GetUID());
+ lldb_type = die.ResolveTypeUID(DIERef(form_value));
if (lldb_type)
clang_type = lldb_type->GetForwardCompilerType ();
}
// Handle static members
if (is_external && member_byte_offset == UINT32_MAX)
{
- Type *var_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+ Type *var_type = die.ResolveTypeUID(DIERef(encoding_form));
if (var_type)
{
if (is_artificial == false)
{
- Type *member_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+ Type *member_type = die.ResolveTypeUID(DIERef(encoding_form));
clang::FieldDecl *field_decl = NULL;
if (tag == DW_TAG_member)
}
}
- Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form).GetUID());
+ Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form));
if (base_class_type == NULL)
{
module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " from enclosing type 0x%8.8x. \nPlease file a bug and attach the file at the start of this error message",
// being in the formal parameter DIE...
if (name == NULL || ::strcmp(name, "this")==0)
{
- Type *this_type = die.ResolveTypeUID (DIERef(param_type_die_form).GetUID());
+ Type *this_type = die.ResolveTypeUID (DIERef(param_type_die_form));
if (this_type)
{
uint32_t encoding_mask = this_type->GetEncodingMask();
if (!skip)
{
- Type *type = die.ResolveTypeUID(DIERef(param_type_die_form).GetUID());
+ Type *type = die.ResolveTypeUID(DIERef(param_type_die_form));
if (type)
{
function_param_types.push_back (type->GetForwardCompilerType ());
DWARFFormValue form_value;
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
- return dwarf->ResolveTypeUID(DIERef(form_value).GetUID());
+ return dwarf->ResolveTypeUID(dwarf->GetDIE (DIERef(form_value)), true);
}
}
}
case DW_TAG_imported_declaration:
{
SymbolFileDWARF *dwarf = die.GetDWARF();
- lldb::user_id_t imported_uid = die.GetAttributeValueAsReference(DW_AT_import, DW_INVALID_OFFSET);
-
- if (dwarf->UserIDMatches(imported_uid))
+ DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
+ if (imported_uid)
{
- CompilerDecl imported_decl = dwarf->GetDeclForUID(imported_uid);
+ CompilerDecl imported_decl = imported_uid.GetDecl();
if (imported_decl)
{
clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
case DW_TAG_imported_module:
{
SymbolFileDWARF *dwarf = die.GetDWARF();
- lldb::user_id_t imported_uid = die.GetAttributeValueAsReference(DW_AT_import, DW_INVALID_OFFSET);
+ DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
- if (dwarf->UserIDMatches(imported_uid))
+ if (imported_uid)
{
- CompilerDeclContext imported_decl = dwarf->GetDeclContextForUID(imported_uid);
- if (imported_decl)
+ CompilerDeclContext imported_decl_ctx = imported_uid.GetDeclContext();
+ if (imported_decl_ctx)
{
clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
- if (clang::NamespaceDecl *ns_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(imported_decl))
+ if (clang::NamespaceDecl *ns_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(imported_decl_ctx))
decl = m_ast.CreateUsingDirectiveDeclaration(decl_context, ns_decl);
}
}
}
}
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", dwarf->MakeUserID(die.GetOffset()),
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(),
DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
switch (tag)
break;
}
- type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, byte_size,
+ type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size,
NULL, encoding_uid, encoding_data_type, &decl, compiler_type, resolve_state));
dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
}
}
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
DW_TAG_value_to_name(tag), type_name_cstr);
bool compiler_type_was_created = false;
compiler_type = m_ast.CreateStructType(go_kind, type_name_const_str, byte_size);
}
- type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, byte_size,
+ type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size,
NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
Type::eResolveStateForward));
}
}
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
DW_TAG_value_to_name(tag), type_name_cstr);
std::vector<CompilerType> function_param_types;
compiler_type = m_ast.CreateFunctionType(type_name_const_str, function_param_types.data(),
function_param_types.size(), is_variadic);
- type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str, 0, NULL,
+ type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL,
LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
Type::eResolveStateFull));
assert(type_sp.get());
}
}
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", dwarf->MakeUserID(die.GetOffset()),
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
DW_TAG_value_to_name(tag), type_name_cstr);
Type *element_type = dwarf->ResolveTypeUID(type_die_offset);
{
compiler_type = m_ast.CreateArrayType(type_name_const_str, array_element_type, 0);
}
- type_sp.reset(new Type(dwarf->MakeUserID(die.GetOffset()), dwarf, type_name_const_str,
+ type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
byte_stride, NULL, type_die_offset, Type::eEncodingIsUID, &decl,
compiler_type, Type::eResolveStateFull));
type_sp->SetEncodingType(element_type);
else if (sc.function != NULL && sc_parent_die)
{
symbol_context_scope =
- sc.function->GetBlock(true).FindBlockByID(dwarf->MakeUserID(sc_parent_die.GetOffset()));
+ sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
if (symbol_context_scope == NULL)
symbol_context_scope = sc.function;
}
if (num_attributes > 0)
{
Declaration decl;
- dw_offset_t param_type_die_offset = DW_INVALID_OFFSET;
+ DWARFFormValue param_type_die_offset;
uint32_t i;
for (i = 0; i < num_attributes; ++i)
// = form_value.AsCString();
break;
case DW_AT_type:
- param_type_die_offset = form_value.Reference();
+ param_type_die_offset = form_value;
break;
case DW_AT_location:
// if (form_value.BlockData())
}
}
- Type *type = parent_die.ResolveTypeUID(param_type_die_offset);
+ Type *type = parent_die.ResolveTypeUID(DIERef(param_type_die_offset));
if (type)
{
function_param_types.push_back(type->GetForwardCompilerType());
Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
- log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", dwarf->MakeUserID(die.GetOffset()),
+ log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", die.GetID(),
DW_TAG_value_to_name(tag), type->GetName().AsCString());
assert(compiler_type);
DWARFAttributes attributes;
Declaration decl;
const char *name = NULL;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+ DWARFFormValue encoding_uid;
uint32_t member_byte_offset = UINT32_MAX;
uint32_t i;
for (i = 0; i < num_attributes; ++i)
name = form_value.AsCString();
break;
case DW_AT_type:
- encoding_uid = form_value.Reference();
+ encoding_uid = form_value;
break;
case DW_AT_data_member_location:
if (form_value.BlockData())
}
}
- Type *member_type = die.ResolveTypeUID(encoding_uid);
+ Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid));
if (member_type)
{
CompilerType member_go_type = member_type->GetFullCompilerType();
if (dwarf->FixupAddress(func_range.GetBaseAddress()))
{
- const user_id_t func_user_id = dwarf->MakeUserID(die.GetOffset());
+ const user_id_t func_user_id = die.GetID();
func_sp.reset(new Function(sc.comp_unit,
- dwarf->MakeUserID(func_user_id), // UserID is the DIE offset
- dwarf->MakeUserID(func_user_id), func_name, func_type,
+ func_user_id, // UserID is the DIE offset
+ func_user_id,
+ func_name,
+ func_type,
func_range)); // first address range
if (func_sp.get() != NULL)
dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
ConstString linkage_name;
- lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
+ DWARFFormValue type_attr_value;
lldb::addr_t data_offset = LLDB_INVALID_ADDRESS;
DWARFExpression length_expression(die.GetCU());
linkage_name.SetCString(form_value.AsCString());
break;
case DW_AT_type:
- type_die_offset = form_value.Reference();
+ type_attr_value = form_value;
break;
case DW_AT_data_member_location:
data_offset = form_value.Unsigned();
}
}
- Type *element_type = dwarf->ResolveTypeUID(type_die_offset);
+ DIERef type_die_ref(type_attr_value);
+ Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
if (!element_type)
return nullptr;
Declaration decl;
TypeSP type_sp(new Type(die.GetID(), dwarf, array_compiler_type.GetTypeName(), -1, nullptr,
- dwarf->MakeUserID(type_die_offset), Type::eEncodingIsUID, &decl,
+ type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl,
array_compiler_type, Type::eResolveStateFull));
type_sp->SetEncodingType(element_type);
return type_sp;
dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
Declaration decl;
- lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
+ DWARFFormValue type_attr_value;
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes(attributes);
switch (attr)
{
case DW_AT_type:
- type_die_offset = form_value.Reference();
+ type_attr_value = form_value;
break;
default:
assert(false && "Unsupported attribute for DW_TAG_array_type");
}
}
- Type *pointee_type = dwarf->ResolveTypeUID(type_die_offset);
+ DIERef type_die_ref(type_attr_value);
+ Type *pointee_type = dwarf->ResolveTypeUID(type_die_ref);
if (!pointee_type)
return nullptr;
CompilerType pointee_compiler_type = pointee_type->GetForwardCompilerType();
CompilerType reference_compiler_type = m_ast.CreateReferenceType(pointee_compiler_type);
TypeSP type_sp(new Type(die.GetID(), dwarf, reference_compiler_type.GetTypeName(), -1, nullptr,
- dwarf->MakeUserID(type_die_offset), Type::eEncodingIsUID, &decl,
+ type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl,
reference_compiler_type, Type::eResolveStateFull));
type_sp->SetEncodingType(pointee_type);
return type_sp;
case DW_TAG_member:
{
const char *name = nullptr;
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+ DWARFFormValue encoding_uid;
uint32_t member_byte_offset = UINT32_MAX;
DWARFExpression member_location_expression(dwarf_cu);
bool artificial = true;
name = form_value.AsCString();
break;
case DW_AT_type:
- encoding_uid = form_value.Reference();
+ encoding_uid = form_value;
break;
case DW_AT_data_member_location:
if (form_value.BlockData())
m_ast.SetDynamicTypeId(compiler_type, member_location_expression);
else
{
- if (Type *member_type = die.ResolveTypeUID(encoding_uid))
+ if (Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid)))
m_ast.AddMemberToObject(compiler_type, ConstString(name), member_type->GetFullCompilerType(),
member_byte_offset);
}
}
case DW_TAG_inheritance:
{
- lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+ DWARFFormValue encoding_uid;
uint32_t member_byte_offset = UINT32_MAX;
DWARFAttributes attributes;
switch (attributes.AttributeAtIndex(i))
{
case DW_AT_type:
- encoding_uid = form_value.Reference();
+ encoding_uid = form_value;
break;
case DW_AT_data_member_location:
member_byte_offset = form_value.Unsigned();
}
}
}
- if (Type *base_type = die.ResolveTypeUID(encoding_uid))
+ if (Type *base_type = die.ResolveTypeUID(DIERef(encoding_uid)))
m_ast.AddBaseClassToObject(compiler_type, base_type->GetFullCompilerType(), member_byte_offset);
break;
}
{
dw_offset_t local_id = m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
if (m_dwarf2Data)
- return m_dwarf2Data->MakeUserID(local_id);
+ return DIERef(local_id, local_id).GetUID(m_dwarf2Data);
else
return local_id;
}
{
// Don't specify the compile unit offset as we don't know it because the DIE belongs to
// a different compile unit in the same symbol file.
- return m_dwarf2Data->DebugInfo()->GetDIE (DIERef(die_offset));
+ return m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset);
}
}
return DWARFDIE(); // Not found
#include "DWARFDIE.h"
+#include "DWARFASTParser.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
return fail_value;
}
+DWARFDIE
+DWARFDIE::GetAttributeValueAsReferenceDIE (const dw_attr_t attr) const
+{
+ if (IsValid())
+ {
+ DWARFCompileUnit *cu = GetCU();
+ SymbolFileDWARF *dwarf = cu->GetSymbolFileDWARF();
+ const bool check_specification_or_abstract_origin = true;
+ DWARFFormValue form_value;
+ if (m_die->GetAttributeValue(dwarf, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
+ return dwarf->GetDIE(DIERef(form_value));
+ }
+ return DWARFDIE();
+}
+
uint64_t
DWARFDIE::GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const
{
if (cu->ContainsDIEOffset(block_die->GetOffset()))
return DWARFDIE(cu, block_die);
else
- return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die);
+ return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die);
}
}
}
lldb::user_id_t
DWARFDIE::GetID () const
{
- const dw_offset_t die_offset = GetOffset();
- if (die_offset != DW_INVALID_OFFSET)
- {
- lldb::user_id_t id = 0;
- SymbolFileDWARF *dwarf = GetDWARF();
- if (dwarf)
- id = dwarf->MakeUserID(die_offset);
- else
- id = die_offset;
-
- if (m_cu)
- {
- lldb::user_id_t cu_id = m_cu->GetID()&0xffffffff00000000ull;
- assert ((id&0xffffffff00000000ull) == 0 ||
- (cu_id&0xffffffff00000000ll) == 0 ||
- (id&0xffffffff00000000ull) == (cu_id&0xffffffff00000000ll));
- id |= cu_id;
- }
- return id;
- }
- return LLDB_INVALID_UID;
+ return GetDIERef().GetUID(GetDWARF());
}
const char *
}
lldb_private::Type *
-DWARFDIE::ResolveTypeUID (lldb::user_id_t uid) const
+DWARFDIE::ResolveTypeUID (const DIERef &die_ref) const
{
SymbolFileDWARF *dwarf = GetDWARF();
if (dwarf)
- return dwarf->ResolveTypeUID(uid);
+ return dwarf->ResolveTypeUID(dwarf->GetDIE(die_ref), true);
else
return nullptr;
}
}
+CompilerDecl
+DWARFDIE::GetDecl () const
+{
+ DWARFASTParser *dwarf_ast = GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclForUIDFromDWARF(*this);
+ else
+ return CompilerDecl();
+}
+
+CompilerDeclContext
+DWARFDIE::GetDeclContext () const
+{
+ DWARFASTParser *dwarf_ast = GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextForUIDFromDWARF(*this);
+ else
+ return CompilerDeclContext();
+}
+
+CompilerDeclContext
+DWARFDIE::GetContainingDeclContext () const
+{
+ DWARFASTParser *dwarf_ast = GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this);
+ else
+ return CompilerDeclContext();
+}
+
bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs)
{
return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
//----------------------------------------------------------------------
// Tests
//----------------------------------------------------------------------
- operator bool () const
+ explicit operator bool () const
{
return IsValid();
}
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;
+ ResolveTypeUID (const DIERef &die_ref) const;
//----------------------------------------------------------------------
// Functions for obtaining DIE relations and references
uint64_t
GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const;
+ DWARFDIE
+ GetAttributeValueAsReferenceDIE (const dw_attr_t attr) const;
+
uint64_t
GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const;
void
Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
+ lldb_private::CompilerDecl
+ GetDecl () const;
+
+ lldb_private::CompilerDeclContext
+ GetDeclContext() const;
+
+ lldb_private::CompilerDeclContext
+ GetContainingDeclContext() const;
+
protected:
DWARFCompileUnit *m_cu;
DWARFDebugInfoEntry *m_die;
using namespace lldb_private;
using namespace std;
-bool
-DWARFDIECollection::Insert(const DWARFDIE &die)
-{
- iterator end_pos = m_dies.end();
- iterator insert_pos = upper_bound(m_dies.begin(), end_pos, die);
- if (insert_pos != end_pos && (*insert_pos == die))
- return false;
- m_dies.insert(insert_pos, die);
- return true;
-}
-
void
DWARFDIECollection::Append (const DWARFDIE &die)
{
DWARFDIE
GetDIEAtIndex (uint32_t idx) const;
- bool
- Insert(const DWARFDIE &die);
-
size_t
Size() const;
}
DWARFCompileUnit *
-DWARFDebugInfo::GetCompileUnitContainingDIE (const DIERef& die_ref)
+DWARFDebugInfo::GetCompileUnit (const DIERef& die_ref)
{
- dw_offset_t search_offset = die_ref.die_offset;
- bool is_cu_offset = false;
- if (m_dwarf2Data->GetID() == 0 && die_ref.cu_offset != DW_INVALID_OFFSET)
- {
- is_cu_offset = true;
- search_offset = die_ref.cu_offset;
- }
+ if (die_ref.cu_offset == DW_INVALID_OFFSET)
+ return GetCompileUnitContainingDIEOffset(die_ref.die_offset);
+ else
+ return GetCompileUnit(die_ref.cu_offset);
+}
+
+DWARFCompileUnit*
+DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset)
+{
+ ParseCompileUnitHeadersIfNeeded();
DWARFCompileUnitSP cu_sp;
- if (search_offset != DW_INVALID_OFFSET)
- {
- ParseCompileUnitHeadersIfNeeded();
- // Watch out for single compile unit executable as they are pretty common
- const size_t num_cus = m_compile_units.size();
- if (num_cus == 1)
- {
- if ((is_cu_offset && m_compile_units[0]->GetOffset() == search_offset) ||
- (!is_cu_offset && m_compile_units[0]->ContainsDIEOffset(search_offset)))
- {
- cu_sp = m_compile_units[0];
- }
- }
- else if (num_cus)
+ // Watch out for single compile unit executable as they are pretty common
+ const size_t num_cus = m_compile_units.size();
+ if (num_cus == 1)
+ {
+ if (m_compile_units[0]->ContainsDIEOffset(die_offset))
+ return m_compile_units[0].get();
+ }
+ else if (num_cus)
+ {
+ CompileUnitColl::const_iterator end_pos = m_compile_units.end();
+ CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
+ CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, die_offset, OffsetLessThanCompileUnitOffset);
+ if (pos != begin_pos)
{
- CompileUnitColl::const_iterator end_pos = m_compile_units.end();
- CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
- CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, search_offset, OffsetLessThanCompileUnitOffset);
- if (pos != begin_pos)
- {
- --pos;
- if ((is_cu_offset && (*pos)->GetOffset() == search_offset) ||
- (!is_cu_offset && (*pos)->ContainsDIEOffset(search_offset)))
- {
- cu_sp = *pos;
- }
- }
+ --pos;
+ if ((*pos)->ContainsDIEOffset(die_offset))
+ return (*pos).get();
}
}
- return cu_sp.get();
+
+ return nullptr;
+}
+
+DWARFDIE
+DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset)
+{
+ DWARFCompileUnit* cu = GetCompileUnitContainingDIEOffset(die_offset);
+ if (cu)
+ return cu->GetDIE(die_offset);
+ return DWARFDIE();
}
//----------------------------------------------------------------------
DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef& die_ref)
{
- DWARFCompileUnit *cu = GetCompileUnitContainingDIE(die_ref);
+ DWARFCompileUnit *cu = GetCompileUnit(die_ref);
if (cu)
return cu->GetDIE (die_ref.die_offset);
return DWARFDIE(); // Not found
size_t GetNumCompileUnits();
bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
- DWARFCompileUnit* GetCompileUnit (dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
- DWARFCompileUnit* GetCompileUnitContainingDIE (const DIERef& die_ref);
-
+ DWARFCompileUnit* GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
+ DWARFCompileUnit* GetCompileUnitContainingDIEOffset (dw_offset_t die_offset);
+ DWARFCompileUnit* GetCompileUnit(const DIERef& die_ref);
+ DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
DWARFDIE GetDIE (const DIERef& die_ref);
void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth);
DWARFAttributes& attrs,
uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!!
+ dw_offset_t GetAttributeValue(SymbolFileDWARF* dwarf2Data,
+ const DWARFCompileUnit* cu,
+ const dw_attr_t attr,
+ DWARFFormValue& formValue,
+ dw_offset_t* end_attr_offset_ptr = nullptr,
+ bool check_specification_or_abstract_origin = false) const;
+
const char* GetAttributeValueAsString(
SymbolFileDWARF* dwarf2Data,
const DWARFCompileUnit* cu,
DWARFDebugInfoEntry::collection &die_collection);
protected:
- dw_offset_t GetAttributeValue(SymbolFileDWARF* dwarf2Data,
- const DWARFCompileUnit* cu,
- const dw_attr_t attr,
- DWARFFormValue& formValue,
- dw_offset_t* end_attr_offset_ptr = nullptr,
- bool check_specification_or_abstract_origin = false) const;
dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent
{
}
+void
+DWARFFormValue::Clear()
+{
+ m_cu = nullptr;
+ m_form = 0;
+ memset(&m_value, 0, sizeof(m_value));
+}
+
bool
DWARFFormValue::ExtractValue(const DWARFDataExtractor& data, lldb::offset_t* offset_ptr)
{
static FixedFormSizes GetFixedFormSizesForAddressSize (uint8_t addr_size, bool is_dwarf64);
static int Compare (const DWARFFormValue& a,
const DWARFFormValue& b);
+ void Clear();
protected:
const DWARFCompileUnit* m_cu; // Compile unit for this form
dw_form_t m_form; // Form for this value
TypeList *
SymbolFileDWARF::GetTypeList ()
{
- if (GetDebugMapSymfile ())
- return m_debug_map_symfile->GetTypeList();
- return m_obj_file->GetModule()->GetTypeList();
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
+ if (debug_map_symfile)
+ return debug_map_symfile->GetTypeList();
+ else
+ return m_obj_file->GetModule()->GetTypeList();
}
void
UniqueDWARFASTTypeMap &
SymbolFileDWARF::GetUniqueDWARFASTTypeMap ()
{
- if (GetDebugMapSymfile ())
- return m_debug_map_symfile->GetUniqueDWARFASTTypeMap ();
- return m_unique_ast_type_map;
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
+ if (debug_map_symfile)
+ return debug_map_symfile->GetUniqueDWARFASTTypeMap ();
+ else
+ return m_unique_ast_type_map;
}
TypeSystem *
SymbolFileDWARF::GetTypeSystemForLanguage (LanguageType language)
{
- SymbolFileDWARFDebugMap * debug_map_symfile = GetDebugMapSymfile ();
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
TypeSystem *type_system;
if (debug_map_symfile)
{
DWARFDebugInfo* info = DebugInfo();
if (info)
{
- if (GetDebugMapSymfile ())
- {
- // The debug map symbol file made the compile units for this DWARF
- // file which is .o file with DWARF in it, and we should have
- // only 1 compile unit which is at offset zero in the DWARF.
- // TODO: modify to support LTO .o files where each .o file might
- // have multiple DW_TAG_compile_unit tags.
-
- DWARFCompileUnit *dwarf_cu = info->GetCompileUnit(0);
- if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
- dwarf_cu->SetUserData(comp_unit);
- return dwarf_cu;
- }
- else
- {
- // Just a normal DWARF file whose user ID for the compile unit is
- // the DWARF offset itself
-
- DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
- if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
- dwarf_cu->SetUserData(comp_unit);
- return dwarf_cu;
+ // Just a normal DWARF file whose user ID for the compile unit is
+ // the DWARF offset itself
- }
+ DWARFCompileUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
+ if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
+ dwarf_cu->SetUserData(comp_unit);
+ return dwarf_cu;
}
return NULL;
}
{
return dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu, cu_idx);
}
- else if (GetDebugMapSymfile ())
+ else if (dwarf_cu->GetOffset() == 0 && GetDebugMapSymfile ())
{
// Let the debug map create the compile unit
cu_sp = m_debug_map_symfile->GetCompileUnit(this);
bool
SymbolFileDWARF::FixupAddress (Address &addr)
{
- SymbolFileDWARFDebugMap * debug_map_symfile = GetDebugMapSymfile ();
+ SymbolFileDWARFDebugMap * debug_map_symfile = GetDebugMapSymfile();
if (debug_map_symfile)
{
return debug_map_symfile->LinkOSOAddress(addr);
lldb::offset_t offset = cu_line_offset;
DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info);
- if (m_debug_map_symfile)
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
+ if (debug_map_symfile)
{
// We have an object file that has a line table with addresses
// that are not linked. We need to link the line table and convert
// the addresses that are relative to the .o file into addresses
// for the main executable.
- sc.comp_unit->SetLineTable (m_debug_map_symfile->LinkOSOLineTable (this, line_table_ap.get()));
+ sc.comp_unit->SetLineTable (debug_map_symfile->LinkOSOLineTable (this, line_table_ap.get()));
}
else
{
CompilerDecl
SymbolFileDWARF::GetDeclForUID (lldb::user_id_t type_uid)
{
- if (UserIDMatches(type_uid))
- {
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- {
- DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
- if (die)
- {
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclForUIDFromDWARF(die);
- }
- }
- }
+ DWARFDIE die = GetDIE(DIERef(type_uid, this));
+ if (die)
+ return die.GetDecl();
return CompilerDecl();
}
CompilerDeclContext
SymbolFileDWARF::GetDeclContextForUID (lldb::user_id_t type_uid)
{
- if (UserIDMatches(type_uid))
- {
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- {
- DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
- if (die)
- {
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
- }
- }
- }
+ DWARFDIE die = GetDIE(DIERef(type_uid, this));
+ if (die)
+ return die.GetDeclContext();
return CompilerDeclContext();
}
CompilerDeclContext
SymbolFileDWARF::GetDeclContextContainingUID (lldb::user_id_t type_uid)
{
- if (UserIDMatches(type_uid))
- {
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- {
- DWARFDIE die = debug_info->GetDIE(DIERef(type_uid));
- if (die)
- {
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
- }
- }
- }
+ DWARFDIE die = GetDIE (DIERef(type_uid, this));
+ if (die)
+ return die.GetContainingDeclContext();
return CompilerDeclContext();
}
Type*
SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid)
{
- if (UserIDMatches(type_uid))
+ DWARFDIE type_die = GetDIE (DIERef(type_uid, this));
+ if (type_die)
{
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- {
- DWARFDIE type_die = debug_info->GetDIE (DIERef(type_uid));
- if (type_die)
- {
- const bool assert_not_being_parsed = true;
- return ResolveTypeUID (type_die, assert_not_being_parsed);
- }
- }
+ const bool assert_not_being_parsed = true;
+ return ResolveTypeUID (type_die, assert_not_being_parsed);
}
return NULL;
}
Type*
+SymbolFileDWARF::ResolveTypeUID (const DIERef &die_ref)
+{
+ return ResolveType (GetDIE(die_ref), true);
+}
+
+Type*
SymbolFileDWARF::ResolveTypeUID (const DWARFDIE &die, bool assert_not_being_parsed)
{
if (die)
return true;
}
- DWARFDebugInfo* debug_info = DebugInfo();
- DWARFDIE dwarf_die = debug_info->GetDIE(die_it->getSecond());
-
- assert(UserIDMatches(die_it->getSecond().GetUID()) && "CompleteType called on the wrong SymbolFile");
-
- // Once we start resolving this type, remove it from the forward declaration
- // map in case anyone child members or other types require this type to get resolved.
- // The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition
- // are done.
- GetForwardDeclClangTypeToDie().erase (die_it);
+ DWARFDIE dwarf_die = GetDIE(die_it->getSecond());
+ if (dwarf_die)
+ {
+ // Once we start resolving this type, remove it from the forward declaration
+ // map in case anyone child members or other types require this type to get resolved.
+ // The type will get resolved when all of the calls to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition
+ // are done.
+ GetForwardDeclClangTypeToDie().erase (die_it);
- Type *type = GetDIEToType().lookup (dwarf_die.GetDIE());
+ Type *type = GetDIEToType().lookup (dwarf_die.GetDIE());
- Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
- if (log)
- GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
- "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
- dwarf_die.GetID(),
- dwarf_die.GetTagAsCString(),
- type->GetName().AsCString());
- assert (compiler_type);
- DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->CompleteTypeFromDWARF (dwarf_die, type, compiler_type);
+ Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
+ if (log)
+ GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
+ "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
+ dwarf_die.GetID(),
+ dwarf_die.GetTagAsCString(),
+ type->GetName().AsCString());
+ assert (compiler_type);
+ DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
+ if (dwarf_ast)
+ return dwarf_ast->CompleteTypeFromDWARF (dwarf_die, type, compiler_type);
+ }
return false;
}
{
if (die)
{
- Type *type = GetDIEToType().lookup (die.GetDIE());
-
- if (type == NULL)
- type = GetTypeForDIE (die, resolve_function_context).get();
+ Type *type = GetTypeForDIE (die, resolve_function_context).get();
if (assert_not_being_parsed)
{
return lldb::ModuleSP();
}
+DWARFDIE
+SymbolFileDWARF::GetDIE (const DIERef &die_ref)
+{
+ DWARFDebugInfo * debug_info = DebugInfo();
+ if (debug_info)
+ return debug_info->GetDIE(die_ref);
+ else
+ return DWARFDIE();
+}
+
+
std::unique_ptr<SymbolFileDWARFDwo>
SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
{
sc.module_sp = m_obj_file->GetModule();
assert (sc.module_sp);
- DWARFDebugInfo* debug_info = DebugInfo();
bool done = false;
for (size_t i=0; i<num_die_matches && !done; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
const size_t num_matches = die_offsets.size();
if (num_matches)
{
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
if (num_die_matches)
{
const uint32_t initial_types_size = types.GetSize();
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_die_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
if (num_die_matches)
{
size_t num_matches = 0;
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_die_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
const size_t num_matches = die_offsets.size();
if (num_matches)
{
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
if (num_matches)
{
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE type_die = debug_info->GetDIE (die_ref);
+ DWARFDIE type_die = GetDIE (die_ref);
if (type_die)
{
if (num_matches)
{
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE type_die = debug_info->GetDIE (die_ref);
+ DWARFDIE type_die = GetDIE (die_ref);
if (type_die)
{
if (sc.function)
{
- DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID()));
+ DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID(), this));
const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress (DW_AT_low_pc, LLDB_INVALID_ADDRESS);
if (func_lo_pc != LLDB_INVALID_ADDRESS)
const size_t num_matches = die_offsets.size();
if (num_matches)
{
- DWARFDebugInfo* debug_info = DebugInfo();
for (size_t i=0; i<num_matches; ++i)
{
const DIERef& die_ref = die_offsets[i];
- DWARFDIE die = debug_info->GetDIE (die_ref);
+ DWARFDIE die = GetDIE (die_ref);
if (die)
{
VariableSP var_sp (ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
}
break;
case DW_AT_specification:
- {
- DWARFDebugInfo* debug_info = DebugInfo();
- if (debug_info)
- spec_die = debug_info->GetDIE(DIERef(form_value));
- }
+ spec_die = GetDIE(DIERef(form_value));
break;
case DW_AT_start_scope:
{
scope = eValueTypeVariableStatic;
- SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ();
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
if (debug_map_symfile)
{
if (symbol_context_scope)
{
- SymbolFileTypeSP type_sp(new SymbolFileType(*this, DIERef(type_die_form).GetUID()));
+ SymbolFileTypeSP type_sp(new SymbolFileType(*this, DIERef(type_die_form).GetUID(this)));
if (const_value.Form() && type_sp && type_sp->GetType())
location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), die.GetCU()->GetAddressByteSize());
// a concrete block counterpart in the current function. We need
// to find the concrete block so we can correctly add the
// variable to it
- const DWARFDIE concrete_block_die = FindBlockContainingSpecification (DIERef(sc.function->GetID()),
+ const DWARFDIE concrete_block_die = FindBlockContainingSpecification (DIERef(sc.function->GetID(), this),
sc_parent_die.GetOffset());
if (concrete_block_die)
block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die.GetID());
SymbolFileDWARFDebugMap *
-SymbolFileDWARF::GetDebugMapSymfile ()
+SymbolFileDWARF::GetDebugMapSymfile()
{
if (m_debug_map_symfile == NULL && !m_debug_map_module_wp.expired())
{
friend class SymbolFileDWARFDebugMap;
friend class SymbolFileDWARFDwo;
friend class DebugMapModule;
+ friend class DIERef;
friend class DWARFCompileUnit;
+ friend class DWARFDIE;
friend class DWARFASTParserClang;
friend class DWARFASTParserGo;
friend class DWARFASTParserJava;
GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu,
uint32_t cu_idx = UINT32_MAX);
- lldb::user_id_t
- MakeUserID (dw_offset_t die_offset) const
- {
- return GetID() | die_offset;
- }
-
size_t
GetObjCMethodDIEOffsets (lldb_private::ConstString class_name,
DIEArray &method_die_offsets);
lldb::ModuleSP
GetDWOModule (lldb_private::ConstString name);
+ DWARFDIE
+ GetDIE(const DIERef &die_ref);
+
virtual std::unique_ptr<SymbolFileDWARFDwo>
GetDwoSymbolFileForCompileUnit(DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die);
bool *type_is_new);
lldb_private::Type *
- ResolveTypeUID (const DWARFDIE &die,
- bool assert_not_being_parsed);
+ ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed);
+
+ lldb_private::Type *
+ ResolveTypeUID(const DIERef &die_ref);
lldb::VariableSP
ParseVariableDIE(const lldb_private::SymbolContext& sc,
GetUniqueDWARFASTTypeMap ();
bool
- UserIDMatches (lldb::user_id_t uid) const
- {
- const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull;
- if (high_uid != 0 && GetID() != 0)
- return high_uid == GetID();
- return true;
- }
-
- bool
DIEDeclContextsMatch (const DWARFDIE &die1,
const DWARFDIE &die2);
kNumFlags
};
- friend class DWARFCompileUnit;
- friend class SymbolFileDWARF;
friend class DebugMapModule;
+ friend class DIERef;
friend class DWARFASTParserClang;
+ friend class DWARFCompileUnit;
+ friend class SymbolFileDWARF;
struct OSOInfo
{
lldb::ModuleSP module_sp;