* Manage CompilationUnits in a BObjectList instead of a DoublyLinkedList for
nicer access. * A CompilationUnit does now know its debug info entry. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31282 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,7 +14,8 @@ CompilationUnit::CompilationUnit(dwarf_off_t headerOffset,
|
||||
fContentOffset(contentOffset),
|
||||
fTotalSize(totalSize),
|
||||
fAbbreviationOffset(abbreviationOffset),
|
||||
fAbbreviationTable(NULL)
|
||||
fAbbreviationTable(NULL),
|
||||
fUnitEntry(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,6 +46,13 @@ CompilationUnit::AddDebugInfoEntry(DebugInfoEntry* entry, dwarf_off_t offset)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry)
|
||||
{
|
||||
fUnitEntry = entry;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CompilationUnit::CountEntries() const
|
||||
{
|
||||
|
||||
@@ -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 @@ public:
|
||||
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 @@ private:
|
||||
dwarf_off_t fTotalSize;
|
||||
dwarf_off_t fAbbreviationOffset;
|
||||
AbbreviationTable* fAbbreviationTable;
|
||||
DIECompileUnitBase* fUnitEntry;
|
||||
Array<DebugInfoEntry*> fEntries;
|
||||
Array<dwarf_off_t> fEntryOffsets;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ DwarfFile::DwarfFile()
|
||||
fDebugInfoSection(NULL),
|
||||
fDebugAbbrevSection(NULL),
|
||||
fDebugStringSection(NULL),
|
||||
fCompilationUnits(20, true),
|
||||
fCurrentCompilationUnit(NULL),
|
||||
fFinished(false),
|
||||
fFinishError(B_OK)
|
||||
@@ -34,9 +35,6 @@ DwarfFile::DwarfFile()
|
||||
|
||||
DwarfFile::~DwarfFile()
|
||||
{
|
||||
while (CompilationUnit* unit = fCompilationUnits.RemoveHead())
|
||||
delete unit;
|
||||
|
||||
while (AbbreviationTable* table = fAbbreviationTables.RemoveHead())
|
||||
delete table;
|
||||
|
||||
@@ -133,10 +131,10 @@ DwarfFile::Load(const char* fileName)
|
||||
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;
|
||||
@@ -159,8 +157,8 @@ DwarfFile::FinishLoading()
|
||||
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 @@ DwarfFile::FinishLoading()
|
||||
}
|
||||
|
||||
|
||||
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 @@ DwarfFile::_ParseCompilationUnit(CompilationUnit* unit)
|
||||
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(" ");
|
||||
|
||||
@@ -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 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user