diff --git a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp index ed28f8820c..032c129f5c 100644 --- a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp +++ b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp @@ -301,7 +301,6 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type) // try the type cache first BString name; DwarfUtils::GetFullyQualifiedDIEName(typeEntry, name); -// TODO: The DIE may not have a name (e.g. pointer and reference types don't). TypeLookupConstraints constraints( dwarf_tag_to_type_kind(typeEntry->Tag())); diff --git a/src/apps/debugger/dwarf/DwarfUtils.cpp b/src/apps/debugger/dwarf/DwarfUtils.cpp index f32816101e..88fd0de2f9 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.cpp +++ b/src/apps/debugger/dwarf/DwarfUtils.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011-2012, Rene Gollent, rene@gollent.com. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -39,6 +39,67 @@ DwarfUtils::GetDIEName(const DebugInfoEntry* entry, BString& _name) } +/*static*/ void +DwarfUtils::GetDIETypeName(const DebugInfoEntry* entry, BString& _name) +{ + const DIEType* type = dynamic_cast(entry); + if (type == NULL) + return; + + const DIEModifiedType* modifiedType = dynamic_cast( + type); + BString typeName; + BString modifier; + + if (modifiedType != NULL) { + const DIEType* baseType = type; + while ((modifiedType = dynamic_cast( + baseType)) != NULL) { + switch (modifiedType->Tag()) { + case DW_TAG_pointer_type: + modifier.Prepend("*"); + break; + case DW_TAG_reference_type: + modifier.Prepend("&"); + break; + case DW_TAG_const_type: + modifier.Prepend(" const "); + break; + default: + break; + } + + baseType = modifiedType->GetType(); + } + type = baseType; + } + + // if the parameter has no type associated, + // then it's the unspecified type. + if (type == NULL) + typeName = "void"; + else + GetFullyQualifiedDIEName(type, typeName); + + if (modifier.Length() > 0) { + if (modifier[modifier.Length() - 1] == ' ') + modifier.Truncate(modifier.Length() - 1); + + // if the modifier has a leading const, treat it + // as the degenerate case and prepend it to the + // type name since that's the more typically used + // representation in source + if (modifier[0] == ' ') { + typeName.Prepend("const "); + modifier.Remove(0, 7); + } + typeName += modifier; + } + + _name = typeName; +} + + /*static*/ void DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) { @@ -62,9 +123,13 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) } } - // we found no name for this entry whatsoever, abort. - if (name == NULL) + if (name == NULL) { + if (dynamic_cast(entry) != NULL) + GetDIETypeName(entry, _name); + + // we found no name for this entry whatsoever, abort. return; + } generatedName = name; @@ -98,51 +163,7 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) BString paramName; BString modifier; DIEType* type = parameter->GetType(); - if (DIEModifiedType* modifiedType = dynamic_cast( - type)) { - DIEType* baseType = type; - while ((modifiedType = dynamic_cast( - baseType)) != NULL) { - switch (modifiedType->Tag()) { - case DW_TAG_pointer_type: - modifier.Prepend("*"); - break; - case DW_TAG_reference_type: - modifier.Prepend("&"); - break; - case DW_TAG_const_type: - modifier.Prepend(" const "); - break; - default: - break; - } - - baseType = modifiedType->GetType(); - } - type = baseType; - } - - // if the parameter has no type associated, - // then it's the unspecified type. - if (type == NULL) - paramName = "void"; - else - GetFullyQualifiedDIEName(type, paramName); - - if (modifier.Length() > 0) { - if (modifier[modifier.Length() - 1] == ' ') - modifier.Truncate(modifier.Length() - 1); - - // if the modifier has a leading const, treat it - // as the degenerate case and prepend it to the - // type name since that's the more typically used - // representation in source - if (modifier[0] == ' ') { - paramName.Prepend("const "); - modifier.Remove(0, 7); - } - paramName += modifier; - } + GetDIETypeName(type, paramName); if (firstParameter) firstParameter = false; @@ -158,7 +179,6 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) generatedName += "void"; generatedName += ")"; } - _name = generatedName; } diff --git a/src/apps/debugger/dwarf/DwarfUtils.h b/src/apps/debugger/dwarf/DwarfUtils.h index 092aa75643..1bedfd0802 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.h +++ b/src/apps/debugger/dwarf/DwarfUtils.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef DWARF_UTILS_H @@ -17,6 +18,8 @@ class DwarfUtils { public: static void GetDIEName(const DebugInfoEntry* entry, BString& _name); + static void GetDIETypeName(const DebugInfoEntry* entry, + BString& _name); static void GetFullDIEName(const DebugInfoEntry* entry, BString& _name); static void GetFullyQualifiedDIEName(