[Haiku-commits] r31282 - haiku/trunk/src/apps/debugger/dwarf

bonefish at BerliOS bonefish at mail.berlios.de
Sun Jun 28 01:38:17 CEST 2009


Author: bonefish
Date: 2009-06-28 01:38:17 +0200 (Sun, 28 Jun 2009)
New Revision: 31282
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31282&view=rev

Modified:
   haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.cpp
   haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.h
   haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp
   haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h
Log:
* Manage CompilationUnits in a BObjectList instead of a DoublyLinkedList for
  nicer access.
* A CompilationUnit does now know its debug info entry.


Modified: haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.cpp	2009-06-27 23:36:50 UTC (rev 31281)
+++ haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.cpp	2009-06-27 23:38:17 UTC (rev 31282)
@@ -14,7 +14,8 @@
 	fContentOffset(contentOffset),
 	fTotalSize(totalSize),
 	fAbbreviationOffset(abbreviationOffset),
-	fAbbreviationTable(NULL)
+	fAbbreviationTable(NULL),
+	fUnitEntry(NULL)
 {
 }
 
@@ -45,6 +46,13 @@
 }
 
 
+void
+CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry)
+{
+	fUnitEntry = entry;
+}
+
+
 int
 CompilationUnit::CountEntries() const
 {

Modified: haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.h
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.h	2009-06-27 23:36:50 UTC (rev 31281)
+++ haiku/trunk/src/apps/debugger/dwarf/CompilationUnit.h	2009-06-27 23:38:17 UTC (rev 31282)
@@ -5,7 +5,7 @@
 #ifndef COMPILATION_UNIT_H
 #define COMPILATION_UNIT_H
 
-#include <util/DoublyLinkedList.h>
+#include <ObjectList.h>
 
 #include "Array.h"
 #include "DwarfTypes.h"
@@ -13,9 +13,10 @@
 
 class AbbreviationTable;
 class DebugInfoEntry;
+class DIECompileUnitBase;
 
 
-class CompilationUnit : public DoublyLinkedListLinkImpl<CompilationUnit> {
+class CompilationUnit {
 public:
 								CompilationUnit(dwarf_off_t headerOffset,
 									dwarf_off_t contentOffset,
@@ -39,6 +40,8 @@
 			void				SetAbbreviationTable(
 									AbbreviationTable* abbreviationTable);
 
+			DIECompileUnitBase*	UnitEntry() const	{ return fUnitEntry; }
+			void				SetUnitEntry(DIECompileUnitBase* entry);
 
 			status_t			AddDebugInfoEntry(DebugInfoEntry* entry,
 									dwarf_off_t offset);
@@ -53,6 +56,7 @@
 			dwarf_off_t			fTotalSize;
 			dwarf_off_t			fAbbreviationOffset;
 			AbbreviationTable*	fAbbreviationTable;
+			DIECompileUnitBase*	fUnitEntry;
 			Array<DebugInfoEntry*> fEntries;
 			Array<dwarf_off_t>	fEntryOffsets;
 };

Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp	2009-06-27 23:36:50 UTC (rev 31281)
+++ haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp	2009-06-27 23:38:17 UTC (rev 31282)
@@ -25,6 +25,7 @@
 	fDebugInfoSection(NULL),
 	fDebugAbbrevSection(NULL),
 	fDebugStringSection(NULL),
+	fCompilationUnits(20, true),
 	fCurrentCompilationUnit(NULL),
 	fFinished(false),
 	fFinishError(B_OK)
@@ -34,9 +35,6 @@
 
 DwarfFile::~DwarfFile()
 {
-	while (CompilationUnit* unit = fCompilationUnits.RemoveHead())
-		delete unit;
-
 	while (AbbreviationTable* table = fAbbreviationTables.RemoveHead())
 		delete table;
 
@@ -133,11 +131,11 @@
 			unitHeaderOffset, unitContentOffset,
 			unitLength + (unitLengthOffset - unitHeaderOffset),
 			abbrevOffset);
-		if (unit == NULL)
+		if (unit == NULL || !fCompilationUnits.AddItem(unit)) {
+			delete unit;
 			return B_NO_MEMORY;
+		}
 
-		fCompilationUnits.Add(unit);
-
 		// parse the debug info for the unit
 		fCurrentCompilationUnit = unit;
 		error = _ParseCompilationUnit(unit);
@@ -159,8 +157,8 @@
 	if (fFinishError != B_OK)
 		return fFinishError;
 
-	for (CompilationUnitList::Iterator it = fCompilationUnits.GetIterator();
-			CompilationUnit* unit = it.Next();) {
+	for (int32 i = 0; CompilationUnit* unit = fCompilationUnits.ItemAt(i);
+			i++) {
 		fCurrentCompilationUnit = unit;
 		status_t error = _FinishCompilationUnit(unit);
 		if (error != B_OK)
@@ -172,6 +170,20 @@
 }
 
 
+int32
+DwarfFile::CountCompilationUnits() const
+{
+	return fCompilationUnits.CountItems();
+}
+
+
+CompilationUnit*
+DwarfFile::CompilationUnitAt(int32 index) const
+{
+	return fCompilationUnits.ItemAt(index);
+}
+
+
 status_t
 DwarfFile::_ParseCompilationUnit(CompilationUnit* unit)
 {
@@ -194,12 +206,15 @@
 	if (error != B_OK)
 		return error;
 
-	if (dynamic_cast<DIECompileUnitBase*>(entry) == NULL) {
+	DIECompileUnitBase* unitEntry = dynamic_cast<DIECompileUnitBase*>(entry);
+	if (unitEntry == NULL) {
 		fprintf(stderr, "No compilation unit entry in .debug_info "
 			"section.\n");
 		return B_BAD_DATA;
 	}
 
+	unit->SetUnitEntry(unitEntry);
+
 printf("remaining bytes in unit: %lld\n", dataReader.BytesRemaining());
 if (dataReader.HasData()) {
 printf("  ");

Modified: haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h	2009-06-27 23:36:50 UTC (rev 31281)
+++ haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h	2009-06-27 23:38:17 UTC (rev 31282)
@@ -5,6 +5,7 @@
 #ifndef DWARF_FILE_H
 #define DWARF_FILE_H
 
+#include <ObjectList.h>
 #include <util/DoublyLinkedList.h>
 
 #include "DebugInfoEntries.h"
@@ -28,9 +29,12 @@
 
 			const char*			Name() const	{ return fName; }
 
+			int32				CountCompilationUnits() const;
+			CompilationUnit*	CompilationUnitAt(int32 index) const;
+
 private:
 			typedef DoublyLinkedList<AbbreviationTable> AbbreviationTableList;
-			typedef DoublyLinkedList<CompilationUnit> CompilationUnitList;
+			typedef BObjectList<CompilationUnit> CompilationUnitList;
 
 private:
 			status_t			_ParseCompilationUnit(CompilationUnit* unit);




More information about the Haiku-commits mailing list