[haiku-commits] haiku: hrev51856 - src/kits/debugger/debug_info

  • From: rene@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 17 Mar 2018 17:01:20 -0400 (EDT)

hrev51856 adds 1 changeset to branch 'master'
old head: af48b083fdab6dbf2e7a5db26f215aba686a17b8
new head: 364cbeb2e30fef69df025b5528e9172f9b6bee98
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=364cbeb2e30f+%5Eaf48b083fdab

----------------------------------------------------------------------------

364cbeb2e30f: Debugger: Adjust type handling with namespaces.
  
  DwarfImageDebugInfo:
  - In some, but not all cases, gcc5 generates type information where the 
DIEType
    is a child of a namespace rather than of its containing compilation unit.
    This needs to be taken into account when building our name lookup table, as
    we'll otherwise not find the full definition of such types when attempting 
to
    locate them for corresponding variables. Fixes an issue reported by Axel.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51856
Commit:      364cbeb2e30fef69df025b5528e9172f9b6bee98
URL:         http://cgit.haiku-os.org/haiku/commit/?id=364cbeb2e30f
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Sat Mar 17 20:53:34 2018 UTC

----------------------------------------------------------------------------

2 files changed, 44 insertions(+), 1 deletion(-)
.../debugger/debug_info/DwarfImageDebugInfo.cpp  | 41 +++++++++++++++++++-
.../debugger/debug_info/DwarfImageDebugInfo.h    |  4 ++

----------------------------------------------------------------------------

diff --git a/src/kits/debugger/debug_info/DwarfImageDebugInfo.cpp 
b/src/kits/debugger/debug_info/DwarfImageDebugInfo.cpp
index edc3531dbe..084cf2ac5c 100644
--- a/src/kits/debugger/debug_info/DwarfImageDebugInfo.cpp
+++ b/src/kits/debugger/debug_info/DwarfImageDebugInfo.cpp
@@ -1397,7 +1397,6 @@ DwarfImageDebugInfo::_BuildTypeNameTable()
        // iterate through all compilation units
        for (int32 i = 0; CompilationUnit* unit = fFile->CompilationUnitAt(i);
                i++) {
-
                // iterate through all types of the compilation unit
                for (DebugInfoEntryList::ConstIterator it
                                = unit->UnitEntry()->Types().GetIterator();
@@ -1406,6 +1405,19 @@ DwarfImageDebugInfo::_BuildTypeNameTable()
                        if (_RecursiveAddTypeNames(typeEntry, unit) != B_OK)
                                return B_NO_MEMORY;
                }
+
+               for (DebugInfoEntryList::ConstIterator it
+                       = unit->UnitEntry()->OtherChildren().GetIterator();
+                       DebugInfoEntry* child = it.Next();) {
+                       if (child->Tag() != DW_TAG_namespace)
+                               continue;
+
+                       DIENamespace* namespaceEntry = 
dynamic_cast<DIENamespace*>(child);
+                       if (_RecursiveTraverseNamespaceForTypes(namespaceEntry, 
unit)
+                                       != B_OK) {
+                               return B_NO_MEMORY;
+                       }
+               }
        }
 
        return B_OK;
@@ -1455,3 +1467,30 @@ DwarfImageDebugInfo::_RecursiveAddTypeNames(DIEType* 
type, CompilationUnit* unit
 
        return B_OK;
 }
+
+
+status_t
+DwarfImageDebugInfo::_RecursiveTraverseNamespaceForTypes(DIENamespace* nsEntry,
+       CompilationUnit* unit)
+{
+       for (DebugInfoEntryList::ConstIterator it
+                               = nsEntry->Children().GetIterator();
+                       DebugInfoEntry* child = it.Next();) {
+               if (child->Tag() == DW_TAG_namespace) {
+                       DIENamespace* entry = 
dynamic_cast<DIENamespace*>(child);
+                       status_t error = 
_RecursiveTraverseNamespaceForTypes(entry, unit);
+                       if (error != B_OK)
+                               return error;
+                       continue;
+               }
+
+               if (!child->IsType())
+                       continue;
+
+               DIEType* type = dynamic_cast<DIEType*>(child);
+               if (_RecursiveAddTypeNames(type, unit) != B_OK)
+                       return B_NO_MEMORY;
+       }
+
+       return B_OK;
+}
diff --git a/src/kits/debugger/debug_info/DwarfImageDebugInfo.h 
b/src/kits/debugger/debug_info/DwarfImageDebugInfo.h
index be4cfd4807..7e5c92ddba 100644
--- a/src/kits/debugger/debug_info/DwarfImageDebugInfo.h
+++ b/src/kits/debugger/debug_info/DwarfImageDebugInfo.h
@@ -20,6 +20,7 @@
 class Architecture;
 class CompilationUnit;
 class DebuggerInterface;
+class DIENamespace;
 class DIEType;
 class DwarfFunctionDebugInfo;
 class DwarfStackFrameDebugInfo;
@@ -133,6 +134,9 @@ private:
                        status_t                        _BuildTypeNameTable();
                        status_t                        
_RecursiveAddTypeNames(DIEType* type,
                                                                        
CompilationUnit* unit);
+                       status_t                        
_RecursiveTraverseNamespaceForTypes(
+                                                                       
DIENamespace* nsEntry,
+                                                                       
CompilationUnit* unit);
 
 private:
                        BLocker                         fLock;


Other related posts:

  • » [haiku-commits] haiku: hrev51856 - src/kits/debugger/debug_info - rene