* 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),
|
fContentOffset(contentOffset),
|
||||||
fTotalSize(totalSize),
|
fTotalSize(totalSize),
|
||||||
fAbbreviationOffset(abbreviationOffset),
|
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
|
int
|
||||||
CompilationUnit::CountEntries() const
|
CompilationUnit::CountEntries() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#ifndef COMPILATION_UNIT_H
|
#ifndef COMPILATION_UNIT_H
|
||||||
#define COMPILATION_UNIT_H
|
#define COMPILATION_UNIT_H
|
||||||
|
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <ObjectList.h>
|
||||||
|
|
||||||
#include "Array.h"
|
#include "Array.h"
|
||||||
#include "DwarfTypes.h"
|
#include "DwarfTypes.h"
|
||||||
@@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
class AbbreviationTable;
|
class AbbreviationTable;
|
||||||
class DebugInfoEntry;
|
class DebugInfoEntry;
|
||||||
|
class DIECompileUnitBase;
|
||||||
|
|
||||||
|
|
||||||
class CompilationUnit : public DoublyLinkedListLinkImpl<CompilationUnit> {
|
class CompilationUnit {
|
||||||
public:
|
public:
|
||||||
CompilationUnit(dwarf_off_t headerOffset,
|
CompilationUnit(dwarf_off_t headerOffset,
|
||||||
dwarf_off_t contentOffset,
|
dwarf_off_t contentOffset,
|
||||||
@@ -39,6 +40,8 @@ public:
|
|||||||
void SetAbbreviationTable(
|
void SetAbbreviationTable(
|
||||||
AbbreviationTable* abbreviationTable);
|
AbbreviationTable* abbreviationTable);
|
||||||
|
|
||||||
|
DIECompileUnitBase* UnitEntry() const { return fUnitEntry; }
|
||||||
|
void SetUnitEntry(DIECompileUnitBase* entry);
|
||||||
|
|
||||||
status_t AddDebugInfoEntry(DebugInfoEntry* entry,
|
status_t AddDebugInfoEntry(DebugInfoEntry* entry,
|
||||||
dwarf_off_t offset);
|
dwarf_off_t offset);
|
||||||
@@ -53,6 +56,7 @@ private:
|
|||||||
dwarf_off_t fTotalSize;
|
dwarf_off_t fTotalSize;
|
||||||
dwarf_off_t fAbbreviationOffset;
|
dwarf_off_t fAbbreviationOffset;
|
||||||
AbbreviationTable* fAbbreviationTable;
|
AbbreviationTable* fAbbreviationTable;
|
||||||
|
DIECompileUnitBase* fUnitEntry;
|
||||||
Array<DebugInfoEntry*> fEntries;
|
Array<DebugInfoEntry*> fEntries;
|
||||||
Array<dwarf_off_t> fEntryOffsets;
|
Array<dwarf_off_t> fEntryOffsets;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ DwarfFile::DwarfFile()
|
|||||||
fDebugInfoSection(NULL),
|
fDebugInfoSection(NULL),
|
||||||
fDebugAbbrevSection(NULL),
|
fDebugAbbrevSection(NULL),
|
||||||
fDebugStringSection(NULL),
|
fDebugStringSection(NULL),
|
||||||
|
fCompilationUnits(20, true),
|
||||||
fCurrentCompilationUnit(NULL),
|
fCurrentCompilationUnit(NULL),
|
||||||
fFinished(false),
|
fFinished(false),
|
||||||
fFinishError(B_OK)
|
fFinishError(B_OK)
|
||||||
@@ -34,9 +35,6 @@ DwarfFile::DwarfFile()
|
|||||||
|
|
||||||
DwarfFile::~DwarfFile()
|
DwarfFile::~DwarfFile()
|
||||||
{
|
{
|
||||||
while (CompilationUnit* unit = fCompilationUnits.RemoveHead())
|
|
||||||
delete unit;
|
|
||||||
|
|
||||||
while (AbbreviationTable* table = fAbbreviationTables.RemoveHead())
|
while (AbbreviationTable* table = fAbbreviationTables.RemoveHead())
|
||||||
delete table;
|
delete table;
|
||||||
|
|
||||||
@@ -133,10 +131,10 @@ DwarfFile::Load(const char* fileName)
|
|||||||
unitHeaderOffset, unitContentOffset,
|
unitHeaderOffset, unitContentOffset,
|
||||||
unitLength + (unitLengthOffset - unitHeaderOffset),
|
unitLength + (unitLengthOffset - unitHeaderOffset),
|
||||||
abbrevOffset);
|
abbrevOffset);
|
||||||
if (unit == NULL)
|
if (unit == NULL || !fCompilationUnits.AddItem(unit)) {
|
||||||
|
delete unit;
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
fCompilationUnits.Add(unit);
|
|
||||||
|
|
||||||
// parse the debug info for the unit
|
// parse the debug info for the unit
|
||||||
fCurrentCompilationUnit = unit;
|
fCurrentCompilationUnit = unit;
|
||||||
@@ -159,8 +157,8 @@ DwarfFile::FinishLoading()
|
|||||||
if (fFinishError != B_OK)
|
if (fFinishError != B_OK)
|
||||||
return fFinishError;
|
return fFinishError;
|
||||||
|
|
||||||
for (CompilationUnitList::Iterator it = fCompilationUnits.GetIterator();
|
for (int32 i = 0; CompilationUnit* unit = fCompilationUnits.ItemAt(i);
|
||||||
CompilationUnit* unit = it.Next();) {
|
i++) {
|
||||||
fCurrentCompilationUnit = unit;
|
fCurrentCompilationUnit = unit;
|
||||||
status_t error = _FinishCompilationUnit(unit);
|
status_t error = _FinishCompilationUnit(unit);
|
||||||
if (error != B_OK)
|
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
|
status_t
|
||||||
DwarfFile::_ParseCompilationUnit(CompilationUnit* unit)
|
DwarfFile::_ParseCompilationUnit(CompilationUnit* unit)
|
||||||
{
|
{
|
||||||
@@ -194,12 +206,15 @@ DwarfFile::_ParseCompilationUnit(CompilationUnit* unit)
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
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 "
|
fprintf(stderr, "No compilation unit entry in .debug_info "
|
||||||
"section.\n");
|
"section.\n");
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unit->SetUnitEntry(unitEntry);
|
||||||
|
|
||||||
printf("remaining bytes in unit: %lld\n", dataReader.BytesRemaining());
|
printf("remaining bytes in unit: %lld\n", dataReader.BytesRemaining());
|
||||||
if (dataReader.HasData()) {
|
if (dataReader.HasData()) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#ifndef DWARF_FILE_H
|
#ifndef DWARF_FILE_H
|
||||||
#define DWARF_FILE_H
|
#define DWARF_FILE_H
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
|
|
||||||
#include "DebugInfoEntries.h"
|
#include "DebugInfoEntries.h"
|
||||||
@@ -28,9 +29,12 @@ public:
|
|||||||
|
|
||||||
const char* Name() const { return fName; }
|
const char* Name() const { return fName; }
|
||||||
|
|
||||||
|
int32 CountCompilationUnits() const;
|
||||||
|
CompilationUnit* CompilationUnitAt(int32 index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef DoublyLinkedList<AbbreviationTable> AbbreviationTableList;
|
typedef DoublyLinkedList<AbbreviationTable> AbbreviationTableList;
|
||||||
typedef DoublyLinkedList<CompilationUnit> CompilationUnitList;
|
typedef BObjectList<CompilationUnit> CompilationUnitList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _ParseCompilationUnit(CompilationUnit* unit);
|
status_t _ParseCompilationUnit(CompilationUnit* unit);
|
||||||
|
|||||||
Reference in New Issue
Block a user