diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp index 4cd65c460e..07a6fe7932 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2013, Rene Gollent, rene@gollent.com. + * Copyright 2013-2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -60,6 +60,14 @@ DebuggerImageDebugInfo::GetType(GlobalTypeCache* cache, } +bool +DebuggerImageDebugInfo::HasType(const BString& name, + const TypeLookupConstraints& constraints) const +{ + return false; +} + + AddressSectionType DebuggerImageDebugInfo::GetAddressSectionType(target_addr_t address) { diff --git a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h index e491f50c98..fcc395d16c 100644 --- a/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2013, Rene Gollent, rene@gollent.com. + * Copyright 2013-2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef DEBUGGER_IMAGE_DEBUG_INFO_H @@ -33,6 +33,10 @@ public: const BString& name, const TypeLookupConstraints& constraints, Type*& _type); + virtual bool HasType(const BString& name, + const TypeLookupConstraints& constraints) + const; + virtual AddressSectionType GetAddressSectionType(target_addr_t address); virtual status_t CreateFrame(Image* image, FunctionInstance* functionInstance, diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 78faee2d22..29fb16f07d 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -567,6 +567,39 @@ DwarfImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, } +bool +DwarfImageDebugInfo::HasType(const BString& name, + const TypeLookupConstraints& constraints) const +{ + TypeNameEntry* entry = fTypeNameTable->Lookup(name); + if (entry == NULL) + return false; + + for (int32 i = 0; TypeEntryInfo* info = entry->types.ItemAt(i); i++) { + DIEType* typeEntry = info->type; + if (constraints.HasTypeKind()) { + if (dwarf_tag_to_type_kind(typeEntry->Tag()) + != constraints.TypeKind()) { + continue; + } + + if (!_EvaluateBaseTypeConstraints(typeEntry, constraints)) + continue; + } + + if (constraints.HasSubtypeKind() + && dwarf_tag_to_subtype_kind(typeEntry->Tag()) + != constraints.SubtypeKind()) { + continue; + } + + return true; + } + + return false; +} + + AddressSectionType DwarfImageDebugInfo::GetAddressSectionType(target_addr_t address) { diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h index 41f1198156..db48b9b4fc 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.h +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.h @@ -58,6 +58,9 @@ public: const BString& name, const TypeLookupConstraints& constraints, Type*& _type); + virtual bool HasType(const BString& name, + const TypeLookupConstraints& constraints) + const; virtual AddressSectionType GetAddressSectionType(target_addr_t address); diff --git a/src/apps/debugger/debug_info/GlobalTypeLookup.h b/src/apps/debugger/debug_info/GlobalTypeLookup.h index 6a28117749..f727c41f42 100644 --- a/src/apps/debugger/debug_info/GlobalTypeLookup.h +++ b/src/apps/debugger/debug_info/GlobalTypeLookup.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef GLOBAL_TYPE_LOOKUP_H @@ -69,6 +70,11 @@ public: const TypeLookupConstraints& constraints, Type*& _type) = 0; // returns a reference + + virtual bool HasType(GlobalTypeCache* cache, + const BString& name, + const TypeLookupConstraints& constraints) + = 0; }; diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.cpp b/src/apps/debugger/debug_info/ImageDebugInfo.cpp index c5038734d8..2c7c86c69e 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/ImageDebugInfo.cpp @@ -105,6 +105,20 @@ ImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, } +bool +ImageDebugInfo::HasType(const BString& name, + const TypeLookupConstraints& constraints) const +{ + for (int32 i = 0; SpecificImageDebugInfo* specificInfo + = fSpecificInfos.ItemAt(i); i++) { + if (specificInfo->HasType(name, constraints)) + return true; + } + + return false; +} + + AddressSectionType ImageDebugInfo::GetAddressSectionType(target_addr_t address) const { diff --git a/src/apps/debugger/debug_info/ImageDebugInfo.h b/src/apps/debugger/debug_info/ImageDebugInfo.h index 00a5f9a194..501763068b 100644 --- a/src/apps/debugger/debug_info/ImageDebugInfo.h +++ b/src/apps/debugger/debug_info/ImageDebugInfo.h @@ -45,6 +45,11 @@ public: const TypeLookupConstraints& constraints, Type*& _type); // returns a reference + + bool HasType(const BString& name, + const TypeLookupConstraints& constraints) + const; + AddressSectionType GetAddressSectionType(target_addr_t address) const; diff --git a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h index 40d9f83a88..00110d30b2 100644 --- a/src/apps/debugger/debug_info/SpecificImageDebugInfo.h +++ b/src/apps/debugger/debug_info/SpecificImageDebugInfo.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2013, Rene Gollent, rene@gollent.com. + * Copyright 2013-2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef SPECIFIC_IMAGE_DEBUG_INFO_H @@ -52,6 +52,10 @@ public: const TypeLookupConstraints& constraints, Type*& _type) = 0; // returns a reference + virtual bool HasType(const BString& name, + const TypeLookupConstraints& constraints) + const = 0; + virtual AddressSectionType GetAddressSectionType(target_addr_t address) = 0; diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index 1cdb1934f0..6424786e41 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -380,12 +380,22 @@ TeamDebugInfo::LookupTypeByName(const BString& name, return GetType(fTypeCache, name, constraints, _type); } + +bool +TeamDebugInfo::TypeExistsByName(const BString& name, + const TypeLookupConstraints& constraints) +{ + return HasType(fTypeCache, name, constraints); +} + + status_t TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, const TypeLookupConstraints& constraints, Type*& _type) { // maybe the type is already cached AutoLocker cacheLocker(cache); + Type* type = cache->GetType(name, constraints); if (type != NULL) { type->AcquireReference(); @@ -425,6 +435,47 @@ TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, } +bool +TeamDebugInfo::HasType(GlobalTypeCache* cache, const BString& name, + const TypeLookupConstraints& constraints) +{ + // maybe the type is already cached + AutoLocker cacheLocker(cache); + + Type* type = cache->GetType(name, constraints); + if (type != NULL) + return true; + + cacheLocker.Unlock(); + + // Clone the image list and get references to the images, so we can iterate + // through them without locking. + AutoLocker locker(fLock); + + ImageList images; + for (int32 i = 0; ImageDebugInfo* imageDebugInfo = fImages.ItemAt(i); i++) { + if (images.AddItem(imageDebugInfo)) + imageDebugInfo->AcquireReference(); + } + + locker.Unlock(); + + bool found = false; + for (int32 i = 0; ImageDebugInfo* imageDebugInfo = images.ItemAt(i); i++) { + if (imageDebugInfo->HasType(name, constraints)) { + found = true; + break; + } + } + + // release the references + for (int32 i = 0; ImageDebugInfo* imageDebugInfo = images.ItemAt(i); i++) + imageDebugInfo->ReleaseReference(); + + return found; +} + + status_t TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo, LocatableFile* imageFile, ImageDebugInfoLoadingState& _state, diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.h b/src/apps/debugger/debug_info/TeamDebugInfo.h index b3dff5ed38..e95202a038 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.h +++ b/src/apps/debugger/debug_info/TeamDebugInfo.h @@ -49,10 +49,15 @@ public: const BString& name, const TypeLookupConstraints& constraints, Type*& _type); + virtual bool HasType(GlobalTypeCache* cache, + const BString& name, + const TypeLookupConstraints& constraints); virtual status_t LookupTypeByName(const BString& name, const TypeLookupConstraints& constraints, Type*& _type); + virtual bool TypeExistsByName(const BString& name, + const TypeLookupConstraints& constraints); status_t LoadImageDebugInfo(const ImageInfo& imageInfo, LocatableFile* imageFile, diff --git a/src/apps/debugger/model/TeamTypeInformation.h b/src/apps/debugger/model/TeamTypeInformation.h index 3f6b25e613..6748056ddd 100644 --- a/src/apps/debugger/model/TeamTypeInformation.h +++ b/src/apps/debugger/model/TeamTypeInformation.h @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2014, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef TEAM_TYPE_INFORMATION_H @@ -24,6 +24,10 @@ public: const TypeLookupConstraints& constraints, Type*& _type) = 0; // returns reference + + virtual bool TypeExistsByName(const BString& name, + const TypeLookupConstraints& constraints) + = 0; };