Ticket #5495: debug_info_type_match.patch
File debug_info_type_match.patch, 14.5 KB (added by , 13 years ago) |
---|
-
src/apps/debugger/model/TypeLookupConstraints.cpp
1 /* 2 * Copyright 2011, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "TypeLookupConstraints.h" 8 9 10 TypeLookupConstraints::TypeLookupConstraints() 11 : 12 fTypeKindGiven(false), 13 fSubtypeKindGiven(false) 14 { 15 } 16 17 18 TypeLookupConstraints::TypeLookupConstraints(type_kind typeKind) 19 : 20 fTypeKind(typeKind), 21 fTypeKindGiven(true), 22 fSubtypeKindGiven(false) 23 { 24 } 25 26 27 TypeLookupConstraints::TypeLookupConstraints(type_kind typeKind, 28 int32 subTypeKind) 29 : 30 fTypeKind(typeKind), 31 fSubtypeKind(subTypeKind), 32 fTypeKindGiven(true), 33 fSubtypeKindGiven(true) 34 { 35 } 36 37 38 bool 39 TypeLookupConstraints::HasTypeKind() const 40 { 41 return fTypeKindGiven; 42 } 43 44 45 bool 46 TypeLookupConstraints::HasSubtypeKind() const 47 { 48 return fSubtypeKindGiven; 49 } 50 51 52 type_kind 53 TypeLookupConstraints::TypeKind() const 54 { 55 return fTypeKind; 56 } 57 58 59 int32 60 TypeLookupConstraints::SubtypeKind() const 61 { 62 return fSubtypeKind; 63 } 64 65 66 void 67 TypeLookupConstraints::SetTypeKind(type_kind typeKind) 68 { 69 fTypeKind = typeKind; 70 fTypeKindGiven = true; 71 } 72 73 74 void 75 TypeLookupConstraints::SetSubtypeKind(int32 subtypeKind) 76 { 77 fSubtypeKind = subtypeKind; 78 fSubtypeKindGiven = true; 79 } -
src/apps/debugger/model/TypeLookupConstraints.h
1 /* 2 * Copyright 2011, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef TYPE_LOOKUP_CONSTRAINTS_H 6 #define TYPE_LOOKUP_CONSTRAINTS_H 7 8 9 #include "Type.h" 10 11 12 class TypeLookupConstraints { 13 public: 14 TypeLookupConstraints(); 15 // no constraints 16 TypeLookupConstraints(type_kind typeKind); 17 // constrain on type only 18 TypeLookupConstraints(type_kind typeKind, 19 int32 subtypeKind); 20 21 bool HasTypeKind() const; 22 bool HasSubtypeKind() const; 23 type_kind TypeKind() const; 24 int32 SubtypeKind() const; 25 26 void SetTypeKind(type_kind typeKind); 27 void SetSubtypeKind(int32 subtypeKind); 28 29 private: 30 type_kind fTypeKind; 31 int32 fSubtypeKind; 32 bool fTypeKindGiven; 33 bool fSubtypeKindGiven; 34 }; 35 36 #endif // TYPE_LOOKUP_CONSTRAINTS_H -
src/apps/debugger/model/Type.h
29 29 }; 30 30 31 31 32 enum compound_type_kind { 33 COMPOUND_TYPE_CLASS, 34 COMPOUND_TYPE_STRUCT, 35 COMPOUND_TYPE_UNION, 36 COMPOUND_TYPE_INTERFACE 37 }; 38 39 32 40 enum address_type_kind { 33 41 DERIVED_TYPE_POINTER, 34 42 DERIVED_TYPE_REFERENCE -
src/apps/debugger/debug_info/DwarfImageDebugInfo.h
51 51 virtual status_t GetFunctions( 52 52 BObjectList<FunctionDebugInfo>& functions); 53 53 virtual status_t GetType(GlobalTypeCache* cache, 54 const BString& name, Type*& _type); 54 const BString& name, 55 const TypeLookupConstraints& constraints, 56 Type*& _type); 55 57 56 58 virtual AddressSectionType GetAddressSectionType(target_addr_t address); 57 59 -
src/apps/debugger/debug_info/ImageDebugInfo.cpp
78 78 79 79 status_t 80 80 ImageDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, 81 Type*& _type)81 const TypeLookupConstraints& constraints, Type*& _type) 82 82 { 83 83 for (int32 i = 0; SpecificImageDebugInfo* specificInfo 84 84 = fSpecificInfos.ItemAt(i); i++) { 85 status_t error = specificInfo->GetType(cache, name, _type); 85 status_t error = specificInfo->GetType(cache, name, constraints, 86 _type); 86 87 if (error == B_OK || error == B_NO_MEMORY) 87 88 return error; 88 89 } -
src/apps/debugger/debug_info/TeamDebugInfo.cpp
29 29 #include "SpecificImageDebugInfo.h" 30 30 #include "StringUtils.h" 31 31 #include "Type.h" 32 #include "TypeLookupConstraints.h" 32 33 33 34 34 35 // #pragma mark - FunctionHashDefinition … … 362 363 363 364 status_t 364 365 TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, 365 Type*& _type)366 const TypeLookupConstraints& constraints, Type*& _type) 366 367 { 367 368 // maybe the type is already cached 368 369 AutoLocker<GlobalTypeCache> cacheLocker(cache); … … 390 391 // get the type 391 392 status_t error = B_ENTRY_NOT_FOUND; 392 393 for (int32 i = 0; ImageDebugInfo* imageDebugInfo = images.ItemAt(i); i++) { 393 error = imageDebugInfo->GetType(cache, name, type);394 error = imageDebugInfo->GetType(cache, name, constraints, type); 394 395 if (error == B_OK) { 395 396 _type = type; 396 397 break; -
src/apps/debugger/debug_info/DebuggerImageDebugInfo.h
28 28 virtual status_t GetFunctions( 29 29 BObjectList<FunctionDebugInfo>& functions); 30 30 virtual status_t GetType(GlobalTypeCache* cache, 31 const BString& name, Type*& _type); 31 const BString& name, 32 const TypeLookupConstraints& constraints, 33 Type*& _type); 32 34 virtual AddressSectionType GetAddressSectionType(target_addr_t address); 33 35 virtual status_t CreateFrame(Image* image, 34 36 FunctionInstance* functionInstance, -
src/apps/debugger/debug_info/SpecificImageDebugInfo.h
29 29 class StackFrame; 30 30 class Statement; 31 31 class Type; 32 class TypeLookupConstraints; 32 33 class ValueLocation; 33 34 34 35 … … 42 43 // returns references 43 44 44 45 virtual status_t GetType(GlobalTypeCache* cache, 45 const BString& name, Type*& _type) = 0; 46 const BString& name, 47 const TypeLookupConstraints& constraints, 48 Type*& _type) = 0; 46 49 // returns a reference 47 50 virtual AddressSectionType GetAddressSectionType(target_addr_t address) 48 51 = 0; -
src/apps/debugger/debug_info/DwarfTypes.cpp
50 50 } // unnamed namespace 51 51 52 52 53 type_kind dwarf_tag_to_type_kind(int32 tag) 54 { 55 switch (tag) { 56 case DW_TAG_class_type: 57 case DW_TAG_structure_type: 58 case DW_TAG_union_type: 59 case DW_TAG_interface_type: 60 { 61 return TYPE_COMPOUND; 62 } 63 case DW_TAG_base_type: 64 { 65 return TYPE_PRIMITIVE; 66 } 67 case DW_TAG_pointer_type: 68 case DW_TAG_reference_type: 69 { 70 return TYPE_ADDRESS; 71 } 72 case DW_TAG_const_type: 73 case DW_TAG_packed_type: 74 case DW_TAG_volatile_type: 75 case DW_TAG_restrict_type: 76 case DW_TAG_shared_type: 77 { 78 return TYPE_MODIFIED; 79 } 80 case DW_TAG_typedef: 81 { 82 return TYPE_TYPEDEF; 83 } 84 case DW_TAG_array_type: 85 { 86 return TYPE_ARRAY; 87 } 88 case DW_TAG_enumeration_type: 89 { 90 return TYPE_ENUMERATION; 91 } 92 case DW_TAG_subrange_type: 93 { 94 return TYPE_SUBRANGE; 95 } 96 case DW_TAG_unspecified_type: 97 { 98 return TYPE_UNSPECIFIED; 99 } 100 case DW_TAG_subroutine_type: 101 { 102 return TYPE_FUNCTION; 103 } 104 case DW_TAG_ptr_to_member_type: 105 { 106 return TYPE_POINTER_TO_MEMBER; 107 } 108 } 109 110 return TYPE_UNSPECIFIED; 111 } 112 113 114 int32 dwarf_tag_to_subtype_kind(int32 tag) 115 { 116 switch (tag) { 117 case DW_TAG_class_type: 118 { 119 return COMPOUND_TYPE_CLASS; 120 } 121 case DW_TAG_structure_type: 122 { 123 return COMPOUND_TYPE_STRUCT; 124 } 125 case DW_TAG_union_type: 126 { 127 return COMPOUND_TYPE_UNION; 128 } 129 case DW_TAG_interface_type: 130 { 131 return COMPOUND_TYPE_INTERFACE; 132 } 133 case DW_TAG_pointer_type: 134 { 135 return DERIVED_TYPE_POINTER; 136 } 137 case DW_TAG_reference_type: 138 { 139 return DERIVED_TYPE_REFERENCE; 140 } 141 } 142 143 return -1; 144 } 145 146 53 147 // #pragma mark - DwarfTypeContext 54 148 55 149 -
src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
46 46 #include "TargetAddressRangeList.h" 47 47 #include "TeamMemory.h" 48 48 #include "Tracing.h" 49 #include "TypeLookupConstraints.h" 49 50 #include "UnsupportedLanguage.h" 50 51 #include "Variable.h" 51 52 … … 383 384 384 385 status_t 385 386 DwarfImageDebugInfo::GetType(GlobalTypeCache* cache, 386 const BString& name, Type*& _type) 387 const BString& name, const TypeLookupConstraints& constraints, 388 Type*& _type) 387 389 { 388 390 int32 registerCount = fArchitecture->CountRegisters(); 389 391 const Register* registers = fArchitecture->Registers(); … … 412 414 if (typeEntry->IsDeclaration()) 413 415 continue; 414 416 417 if (constraints.HasTypeKind() && 418 dwarf_tag_to_type_kind(typeEntry->Tag()) 419 != constraints.TypeKind()) 420 continue; 421 if (constraints.HasSubtypeKind() && 422 dwarf_tag_to_subtype_kind(typeEntry->Tag()) 423 != constraints.SubtypeKind()) 424 continue; 425 415 426 BString typeEntryName; 416 427 DwarfUtils::GetFullyQualifiedDIEName(typeEntry, typeEntryName); 417 428 if (typeEntryName != name) -
src/apps/debugger/debug_info/DwarfTypeFactory.cpp
27 27 #include "SourceLanguageInfo.h" 28 28 #include "StringUtils.h" 29 29 #include "Tracing.h" 30 #include "TypeLookupConstraints.h" 30 31 #include "ValueLocation.h" 31 32 32 33 … … 314 315 315 316 // If the type entry indicates a declaration only, we try to look the 316 317 // type up globally first. 318 TypeLookupConstraints constraints( 319 dwarf_tag_to_type_kind(typeEntry->Tag())); 320 int32 subtypeKind = dwarf_tag_to_subtype_kind(typeEntry->Tag()); 321 if (subtypeKind >= 0) 322 constraints.SetSubtypeKind(subtypeKind); 317 323 if (typeEntry->IsDeclaration() && name.Length() > 0 318 && fTypeLookup->GetType(fTypeCache, name, globalType) 324 && fTypeLookup->GetType(fTypeCache, name, 325 constraints, globalType) 319 326 == B_OK) { 320 327 DwarfType* globalDwarfType 321 328 = dynamic_cast<DwarfType*>(globalType); -
src/apps/debugger/debug_info/GlobalTypeLookup.h
15 15 16 16 class BString; 17 17 class Type; 18 class TypeLookupConstraints; 18 19 19 20 20 enum global_type_cache_scope { 21 21 GLOBAL_TYPE_CACHE_SCOPE_GLOBAL, 22 22 GLOBAL_TYPE_CACHE_SCOPE_COMPILATION_UNIT … … 62 62 virtual ~GlobalTypeLookup(); 63 63 64 64 virtual status_t GetType(GlobalTypeCache* cache, 65 const BString& name, Type*& _type) = 0; 65 const BString& name, 66 const TypeLookupConstraints& constraints, 67 Type*& _type) = 0; 66 68 // returns a reference 67 69 }; 68 70 -
src/apps/debugger/debug_info/ImageDebugInfo.h
26 26 class LocatableFile; 27 27 class SpecificImageDebugInfo; 28 28 class Type; 29 class TypeLookupConstraints; 29 30 30 31 31 32 class ImageDebugInfo : public BReferenceable { … … 39 40 status_t FinishInit(); 40 41 41 42 status_t GetType(GlobalTypeCache* cache, 42 const BString& name, Type*& _type); 43 const BString& name, 44 const TypeLookupConstraints& constraints, 45 Type*& _type); 43 46 // returns a reference 44 47 AddressSectionType GetAddressSectionType(target_addr_t address) 45 48 const; -
src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp
80 80 81 81 status_t 82 82 DebuggerImageDebugInfo::GetType(GlobalTypeCache* cache, 83 const BString& name, Type*& _type) 83 const BString& name, const TypeLookupConstraints& constraints, 84 Type*& _type) 84 85 { 85 86 return B_UNSUPPORTED; 86 87 } -
src/apps/debugger/debug_info/TeamDebugInfo.h
43 43 status_t Init(); 44 44 45 45 virtual status_t GetType(GlobalTypeCache* cache, 46 const BString& name, Type*& _type); 46 const BString& name, 47 const TypeLookupConstraints& constraints, 48 Type*& _type); 47 49 48 50 status_t LoadImageDebugInfo(const ImageInfo& imageInfo, 49 51 LocatableFile* imageFile, -
src/apps/debugger/debug_info/DwarfTypes.h
41 41 class ValueLocation; 42 42 43 43 44 // conversion functions between model types and dwarf types 45 type_kind dwarf_tag_to_type_kind(int32 tag); 46 int32 dwarf_tag_to_subtype_kind(int32 tag); 47 48 44 49 class DwarfTypeContext : public BReferenceable { 45 50 public: 46 51 DwarfTypeContext(Architecture* architecture, -
src/apps/debugger/Jamfile
134 134 ThreadInfo.cpp 135 135 Type.cpp 136 136 TypeComponentPath.cpp 137 TypeLookupConstraints.cpp 137 138 Variable.cpp 138 139 139 140 # settings