[haiku-commits] haiku: hrev51717 - in src: kits/debugger/files kits/debugger/debug_info apps/debugger/user_interface/gui/team_window kits/debugger/dwarf kits/debugger/controllers

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 29 Dec 2017 05:28:00 +0100 (CET)

hrev51717 adds 1 changeset to branch 'master'
old head: 8bb774fc375e2645c85f91c7dd629740e9f76cce
new head: 3d9b569384e6a7339f1c18fc2786f3cda396f593
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=3d9b569384e6+%5E8bb774fc375e

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

3d9b569384e6: Debugger: Further work on memory leak hunting.
  
  TeamWindow:
  - Properly delete stack frame selection entries in destructor.
  
  TeamDebugger:
  - The reference to TeamDebugInfo wasn't correctly initialized to own,
    leading to TeamDebugInfo never being destroyed.
  
  FunctionInstance:
  - Also clear source code reference in destructor.
  
  ImageDebugInfo:
  - Release references to specific infos in destructor. These are acquired
    on our behalf when loading the image info, but were never released,
    leading to the latter never being freed.
  
  DwarfManager:
  - Release references to files in destructor.
  
  FileManager:
  - Release entries in various destructors.
  
  Somewhat improves the situation in #13800, but is still far from complete,
  as a thorough review of this nature hasn't ever really been done.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

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

Revision:    hrev51717
Commit:      3d9b569384e6a7339f1c18fc2786f3cda396f593
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3d9b569384e6
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Fri Dec 29 04:22:13 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13800

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

6 files changed, 36 insertions(+), 4 deletions(-)
.../user_interface/gui/team_window/TeamWindow.cpp     | 10 ++++++++++
src/kits/debugger/controllers/TeamDebugger.cpp        |  2 +-
src/kits/debugger/debug_info/FunctionInstance.cpp     |  1 +
src/kits/debugger/debug_info/ImageDebugInfo.cpp       |  8 +++++++-
src/kits/debugger/dwarf/DwarfManager.cpp              |  4 +++-
src/kits/debugger/files/FileManager.cpp               | 15 ++++++++++++++-

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

diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp 
b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
index 5a82a3b..50f72f9 100644
--- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
@@ -282,6 +282,16 @@ TeamWindow::~TeamWindow()
        _SetActiveThread(NULL);
 
        delete fFilePanel;
+
+       ThreadStackFrameSelectionEntry* entry
+               = fThreadSelectionInfoTable->Clear(true);
+
+       while (entry != NULL) {
+               ThreadStackFrameSelectionEntry* next = entry->next;
+               delete entry;
+               entry = next;
+       }
+
        delete fThreadSelectionInfoTable;
 
        if (fActiveSourceWorker > 0)
diff --git a/src/kits/debugger/controllers/TeamDebugger.cpp 
b/src/kits/debugger/controllers/TeamDebugger.cpp
index d5b3cda..49f152e 100644
--- a/src/kits/debugger/controllers/TeamDebugger.cpp
+++ b/src/kits/debugger/controllers/TeamDebugger.cpp
@@ -366,7 +366,7 @@ TeamDebugger::Init(DebuggerInterface* interface, thread_id 
threadID, int argc,
                fFileManager);
        if (teamDebugInfo == NULL)
                return B_NO_MEMORY;
-       BReference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo);
+       BReference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo, true);
 
        error = teamDebugInfo->Init();
        if (error != B_OK)
diff --git a/src/kits/debugger/debug_info/FunctionInstance.cpp 
b/src/kits/debugger/debug_info/FunctionInstance.cpp
index b7398f7..1ecbd3a 100644
--- a/src/kits/debugger/debug_info/FunctionInstance.cpp
+++ b/src/kits/debugger/debug_info/FunctionInstance.cpp
@@ -32,6 +32,7 @@ FunctionInstance::FunctionInstance(ImageDebugInfo* 
imageDebugInfo,
 FunctionInstance::~FunctionInstance()
 {
        SetFunction(NULL);
+       SetSourceCode(NULL, FUNCTION_SOURCE_NOT_LOADED);
        fFunctionDebugInfo->ReleaseReference();
 }
 
diff --git a/src/kits/debugger/debug_info/ImageDebugInfo.cpp 
b/src/kits/debugger/debug_info/ImageDebugInfo.cpp
index 2c7c86c..88f6cde 100644
--- a/src/kits/debugger/debug_info/ImageDebugInfo.cpp
+++ b/src/kits/debugger/debug_info/ImageDebugInfo.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2010-2013, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2010-2017, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
@@ -27,12 +27,18 @@ ImageDebugInfo::~ImageDebugInfo()
 {
        for (int32 i = 0; FunctionInstance* function = fFunctions.ItemAt(i); 
i++)
                function->ReleaseReference();
+
+       for (int32 i = 0; SpecificImageDebugInfo* info = 
fSpecificInfos.ItemAt(i);
+                       i++) {
+               info->ReleaseReference();
+       }
 }
 
 
 bool
 ImageDebugInfo::AddSpecificInfo(SpecificImageDebugInfo* info)
 {
+       // NB: on success we take over the caller's reference to the info object
        return fSpecificInfos.AddItem(info);
 }
 
diff --git a/src/kits/debugger/dwarf/DwarfManager.cpp 
b/src/kits/debugger/dwarf/DwarfManager.cpp
index 9f36611..9b5a07e 100644
--- a/src/kits/debugger/dwarf/DwarfManager.cpp
+++ b/src/kits/debugger/dwarf/DwarfManager.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2014, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2014-2017, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
@@ -25,6 +25,8 @@ DwarfManager::DwarfManager(uint8 addressSize)
 
 DwarfManager::~DwarfManager()
 {
+       while (DwarfFile* file = fFiles.RemoveHead())
+               file->ReleaseReference();
 }
 
 
diff --git a/src/kits/debugger/files/FileManager.cpp 
b/src/kits/debugger/files/FileManager.cpp
index bce3c02..fb614f1 100644
--- a/src/kits/debugger/files/FileManager.cpp
+++ b/src/kits/debugger/files/FileManager.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2011-2016, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2011-2017, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
@@ -118,6 +118,12 @@ public:
 
        ~Domain()
        {
+               LocatableEntry* entry = fEntries.Clear(true);
+               while (entry != NULL) {
+                       LocatableEntry* next = entry->fNext;
+                       entry->ReleaseReference();
+                       entry = next;
+               }
        }
 
        status_t Init()
@@ -555,6 +561,13 @@ FileManager::~FileManager()
 {
        delete fTargetDomain;
        delete fSourceDomain;
+
+       SourceFileEntry* entry = fSourceFiles->Clear();
+       while (entry != NULL) {
+               SourceFileEntry* next = entry->next;
+               delete entry;
+               next = entry;
+       }
        delete fSourceFiles;
 }
 


Other related posts:

  • » [haiku-commits] haiku: hrev51717 - in src: kits/debugger/files kits/debugger/debug_info apps/debugger/user_interface/gui/team_window kits/debugger/dwarf kits/debugger/controllers - anevilyak