[haiku-commits] r42373 - in haiku/trunk/src/apps/debugger: debug_info model

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 4 Jul 2011 16:55:13 +0200 (CEST)

Author: anevilyak
Date: 2011-07-04 16:55:13 +0200 (Mon, 04 Jul 2011)
New Revision: 42373
Changeset: https://dev.haiku-os.org/changeset/42373

Modified:
   haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
   haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h
   haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.cpp
   haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.h
Log:
Add a constraint field which allows one to specify a particular base type name.
This is necessary for looking up pointer and array types.



Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp    
2011-07-04 14:05:42 UTC (rev 42372)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp    
2011-07-04 14:55:13 UTC (rev 42373)
@@ -51,6 +51,23 @@
 #include "Variable.h"
 
 
+namespace {
+
+
+// #pragma mark - HasTypePredicate
+
+
+template<typename EntryType>
+struct HasTypePredicate {
+       inline bool operator()(EntryType* entry) const
+       {
+               return entry->GetType() != NULL;
+       }
+};
+
+}
+
+
 // #pragma mark - BasicTargetInterface
 
 
@@ -414,10 +431,16 @@
                        if (typeEntry->IsDeclaration())
                                continue;
 
-                       if (constraints.HasTypeKind()
-                               && dwarf_tag_to_type_kind(typeEntry->Tag())
+                       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())
@@ -1012,3 +1035,49 @@
 
        return B_OK;
 }
+
+
+bool
+DwarfImageDebugInfo::_EvaluateBaseTypeConstraints(DIEType* type,
+       const TypeLookupConstraints& constraints)
+{
+       if (constraints.HasBaseTypeName()) {
+               BString baseEntryName;
+               DIEType* baseTypeOwnerEntry = NULL;
+
+               switch (constraints.TypeKind()) {
+                       case TYPE_ADDRESS:
+                       {
+                               DIEAddressingType* addressType =
+                                       dynamic_cast<DIEAddressingType*>(type);
+                               if (addressType != NULL) {
+                                       baseTypeOwnerEntry = 
DwarfUtils::GetDIEByPredicate(
+                                               addressType, 
HasTypePredicate<DIEAddressingType>());
+                               }
+                               break;
+                       }
+                       case TYPE_ARRAY:
+                       {
+                               DIEArrayType* arrayType =
+                                       dynamic_cast<DIEArrayType*>(type);
+                               if (arrayType != NULL) {
+                                       baseTypeOwnerEntry = 
DwarfUtils::GetDIEByPredicate(
+                                               arrayType, 
HasTypePredicate<DIEArrayType>());
+                               }
+                               break;
+                       }
+                       default:
+                               break;
+               }
+
+               if (baseTypeOwnerEntry != NULL) {
+                       DwarfUtils::GetFullyQualifiedDIEName(baseTypeOwnerEntry,
+                               baseEntryName);
+                       if (!baseEntryName.IsEmpty() && baseEntryName
+                               != constraints.BaseTypeName())
+                               return false;
+               }
+       }
+
+       return true;
+}

Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h      
2011-07-04 14:05:42 UTC (rev 42372)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h      
2011-07-04 14:55:13 UTC (rev 42373)
@@ -19,6 +19,7 @@
 
 class Architecture;
 class CompilationUnit;
+class DIEType;
 class DwarfStackFrameDebugInfo;
 class DwarfFile;
 class ElfSegment;
@@ -99,6 +100,9 @@
                                                                        const 
EntryListWrapper& variableEntries,
                                                                        const 
EntryListWrapper& blockEntries);
 
+                       bool                            
_EvaluateBaseTypeConstraints(DIEType* type,
+                                                                       const 
TypeLookupConstraints& constraints);
+
 private:
                        BLocker                         fLock;
                        ImageInfo                       fImageInfo;

Modified: haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.cpp       
2011-07-04 14:05:42 UTC (rev 42372)
+++ haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.cpp       
2011-07-04 14:55:13 UTC (rev 42373)
@@ -30,7 +30,8 @@
        fTypeKind(typeKind),
        fSubtypeKind(subTypeKind),
        fTypeKindGiven(true),
-       fSubtypeKindGiven(true)
+       fSubtypeKindGiven(true),
+       fBaseTypeName()
 {
 }
 
@@ -49,6 +50,13 @@
 }
 
 
+bool
+TypeLookupConstraints::HasBaseTypeName() const
+{
+       return fBaseTypeName.Length() > 0;
+}
+
+
 type_kind
 TypeLookupConstraints::TypeKind() const
 {
@@ -63,6 +71,13 @@
 }
 
 
+const BString&
+TypeLookupConstraints::BaseTypeName() const
+{
+       return fBaseTypeName;
+}
+
+
 void
 TypeLookupConstraints::SetTypeKind(type_kind typeKind)
 {
@@ -77,3 +92,10 @@
        fSubtypeKind = subtypeKind;
        fSubtypeKindGiven = true;
 }
+
+
+void
+TypeLookupConstraints::SetBaseTypeName(const BString& name)
+{
+       fBaseTypeName = name;
+}

Modified: haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.h
===================================================================
--- haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.h 2011-07-04 
14:05:42 UTC (rev 42372)
+++ haiku/trunk/src/apps/debugger/model/TypeLookupConstraints.h 2011-07-04 
14:55:13 UTC (rev 42373)
@@ -6,6 +6,8 @@
 #define TYPE_LOOKUP_CONSTRAINTS_H
 
 
+#include <String.h>
+
 #include "Type.h"
 
 
@@ -20,17 +22,21 @@
 
                bool                                    HasTypeKind() const;
                bool                                    HasSubtypeKind() const;
+               bool                                    HasBaseTypeName() const;
                type_kind                               TypeKind() const;
                int32                                   SubtypeKind() const;
+               const BString&                  BaseTypeName() const;
 
                void                                    SetTypeKind(type_kind 
typeKind);
                void                                    SetSubtypeKind(int32 
subtypeKind);
+               void                                    SetBaseTypeName(const 
BString& name);
 
 private:
                type_kind                               fTypeKind;
                int32                                   fSubtypeKind;
                bool                                    fTypeKindGiven;
                bool                                    fSubtypeKindGiven;
+               BString                                 fBaseTypeName;
 };
 
 #endif // TYPE_LOOKUP_CONSTRAINTS_H


Other related posts:

  • » [haiku-commits] r42373 - in haiku/trunk/src/apps/debugger: debug_info model - anevilyak