From 17d68fd24c03d4337254d01cfcf8faf926a84f6d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 30 Jul 2013 22:10:10 -0400 Subject: [PATCH] Debugger: Fix handling of modified types with no base type. In the case of a modified type pointing to an unspecified base type, i.e. const void*, gcc appears to omit the DW_AT_type attribute entirely. This had the result that such variables wouldn't appear in the var list. If we encounter such a case, simply assume that the base type is unspecified rather than failing early. --- .../debugger/debug_info/DwarfTypeFactory.cpp | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp index 032c129f5c..fedba9beed 100644 --- a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp +++ b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -767,14 +768,25 @@ DwarfTypeFactory::_CreateModifiedType(const BString& name, { // Get the base type entry. If it is a modified type too or a typedef, // collect all modifiers and iterate until hitting an actual base type. - DIEType* baseTypeEntry; + DIEType* baseTypeEntry = NULL; + DwarfType* baseType = NULL; while (true) { DIEModifiedType* baseTypeOwnerEntry = DwarfUtils::GetDIEByPredicate( typeEntry, HasTypePredicate()); - if (baseTypeOwnerEntry == NULL) - return B_BAD_VALUE; - - baseTypeEntry = baseTypeOwnerEntry->GetType(); + if (baseTypeOwnerEntry == NULL) { + if (typeEntry->GetType() == NULL) { + // in the case of a modified type that points to an + // unspecified type (i.e. const void* in C/C++), + // gcc appears to omit the base type attribute entirely. + status_t result = _CreateUnspecifiedType(name, + NULL, baseType); + if (result != B_OK) + return result; + break; + } else + return B_BAD_VALUE; + } else + baseTypeEntry = baseTypeOwnerEntry->GetType(); // resolve a typedef if (baseTypeEntry->Tag() == DW_TAG_typedef) { @@ -823,11 +835,13 @@ DwarfTypeFactory::_CreateModifiedType(const BString& name, break; } - // create the base type - DwarfType* baseType; - status_t error = CreateType(baseTypeEntry, baseType); - if (error != B_OK) - return error; + if (baseType == NULL) { + // create the base type + status_t error = CreateType(baseTypeEntry, baseType); + if (error != B_OK) + return error; + } + BReference baseTypeReference(baseType, true); DwarfModifiedType* type = new(std::nothrow) DwarfModifiedType(fTypeContext,