Add TypeUnit and refactor.
- Pull common base class BaseUnit out of CompilationUnit and adjust the latter to inherit. - Add TypeUnit to represent the top level units for .debug_types.
This commit is contained in:
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "BaseUnit.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include "DebugInfoEntries.h"
|
||||||
|
|
||||||
|
|
||||||
|
BaseUnit::BaseUnit(off_t headerOffset, off_t contentOffset,
|
||||||
|
off_t totalSize, off_t abbreviationOffset, uint8 addressSize,
|
||||||
|
bool isDwarf64)
|
||||||
|
:
|
||||||
|
fHeaderOffset(headerOffset),
|
||||||
|
fContentOffset(contentOffset),
|
||||||
|
fTotalSize(totalSize),
|
||||||
|
fAbbreviationOffset(abbreviationOffset),
|
||||||
|
fAbbreviationTable(NULL),
|
||||||
|
fAddressSize(addressSize),
|
||||||
|
fIsDwarf64(isDwarf64)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BaseUnit::~BaseUnit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BaseUnit::SetAbbreviationTable(AbbreviationTable* abbreviationTable)
|
||||||
|
{
|
||||||
|
fAbbreviationTable = abbreviationTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BaseUnit::AddDebugInfoEntry(DebugInfoEntry* entry, off_t offset)
|
||||||
|
{
|
||||||
|
if (!fEntries.Add(entry))
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
if (!fEntryOffsets.Add(offset)) {
|
||||||
|
fEntries.Remove(fEntries.Count() - 1);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BaseUnit::SetSourceLanguage(const SourceLanguageInfo* language)
|
||||||
|
{
|
||||||
|
fSourceLanguage = language;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
BaseUnit::CountEntries() const
|
||||||
|
{
|
||||||
|
return fEntries.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BaseUnit::GetEntryAt(int index, DebugInfoEntry*& entry,
|
||||||
|
off_t& offset) const
|
||||||
|
{
|
||||||
|
entry = fEntries[index];
|
||||||
|
offset = fEntryOffsets[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DebugInfoEntry*
|
||||||
|
BaseUnit::EntryForOffset(off_t offset) const
|
||||||
|
{
|
||||||
|
if (fEntries.IsEmpty())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// binary search
|
||||||
|
int lower = 0;
|
||||||
|
int upper = fEntries.Count() - 1;
|
||||||
|
while (lower < upper) {
|
||||||
|
int mid = (lower + upper + 1) / 2;
|
||||||
|
if (fEntryOffsets[mid] > offset)
|
||||||
|
upper = mid - 1;
|
||||||
|
else
|
||||||
|
lower = mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fEntryOffsets[lower] == offset ? fEntries[lower] : NULL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef BASE_UNIT_H
|
||||||
|
#define BASE_UNIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
|
|
||||||
|
#include "Types.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AbbreviationTable;
|
||||||
|
class DebugInfoEntry;
|
||||||
|
class SourceLanguageInfo;
|
||||||
|
|
||||||
|
|
||||||
|
enum dwarf_unit_kind {
|
||||||
|
dwarf_unit_kind_compilation = 0,
|
||||||
|
dwarf_unit_kind_type
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BaseUnit {
|
||||||
|
public:
|
||||||
|
BaseUnit(off_t headerOffset,
|
||||||
|
off_t contentOffset,
|
||||||
|
off_t totalSize,
|
||||||
|
off_t abbreviationOffset,
|
||||||
|
uint8 addressSize, bool isDwarf64);
|
||||||
|
virtual ~BaseUnit();
|
||||||
|
|
||||||
|
off_t HeaderOffset() const { return fHeaderOffset; }
|
||||||
|
off_t ContentOffset() const { return fContentOffset; }
|
||||||
|
off_t RelativeContentOffset() const
|
||||||
|
{ return fContentOffset - fHeaderOffset; }
|
||||||
|
off_t TotalSize() const { return fTotalSize; }
|
||||||
|
off_t ContentSize() const
|
||||||
|
{ return fTotalSize
|
||||||
|
- RelativeContentOffset(); }
|
||||||
|
off_t AbbreviationOffset() const
|
||||||
|
{ return fAbbreviationOffset; }
|
||||||
|
|
||||||
|
uint8 AddressSize() const { return fAddressSize; }
|
||||||
|
bool IsDwarf64() const { return fIsDwarf64; }
|
||||||
|
|
||||||
|
AbbreviationTable* GetAbbreviationTable() const
|
||||||
|
{ return fAbbreviationTable; }
|
||||||
|
void SetAbbreviationTable(
|
||||||
|
AbbreviationTable* abbreviationTable);
|
||||||
|
|
||||||
|
const SourceLanguageInfo* SourceLanguage() const
|
||||||
|
{ return fSourceLanguage; }
|
||||||
|
void SetSourceLanguage(
|
||||||
|
const SourceLanguageInfo* language);
|
||||||
|
|
||||||
|
status_t AddDebugInfoEntry(DebugInfoEntry* entry,
|
||||||
|
off_t offset);
|
||||||
|
int CountEntries() const;
|
||||||
|
void GetEntryAt(int index, DebugInfoEntry*& entry,
|
||||||
|
off_t& offset) const;
|
||||||
|
DebugInfoEntry* EntryForOffset(off_t offset) const;
|
||||||
|
|
||||||
|
virtual dwarf_unit_kind Kind() const = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
off_t fHeaderOffset;
|
||||||
|
off_t fContentOffset;
|
||||||
|
off_t fTotalSize;
|
||||||
|
off_t fAbbreviationOffset;
|
||||||
|
AbbreviationTable* fAbbreviationTable;
|
||||||
|
const SourceLanguageInfo* fSourceLanguage;
|
||||||
|
Array<DebugInfoEntry*> fEntries;
|
||||||
|
Array<off_t> fEntryOffsets;
|
||||||
|
uint8 fAddressSize;
|
||||||
|
bool fIsDwarf64;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BASE_UNIT_H
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -30,18 +31,13 @@ CompilationUnit::CompilationUnit(off_t headerOffset, off_t contentOffset,
|
|||||||
off_t totalSize, off_t abbreviationOffset, uint8 addressSize,
|
off_t totalSize, off_t abbreviationOffset, uint8 addressSize,
|
||||||
bool isDwarf64)
|
bool isDwarf64)
|
||||||
:
|
:
|
||||||
fHeaderOffset(headerOffset),
|
BaseUnit(headerOffset, contentOffset, totalSize, abbreviationOffset,
|
||||||
fContentOffset(contentOffset),
|
addressSize, isDwarf64),
|
||||||
fTotalSize(totalSize),
|
|
||||||
fAbbreviationOffset(abbreviationOffset),
|
|
||||||
fAbbreviationTable(NULL),
|
|
||||||
fUnitEntry(NULL),
|
fUnitEntry(NULL),
|
||||||
fAddressRanges(NULL),
|
fAddressRanges(NULL),
|
||||||
fDirectories(10, true),
|
fDirectories(10, true),
|
||||||
fFiles(10, true),
|
fFiles(10, true),
|
||||||
fLineNumberProgram(addressSize),
|
fLineNumberProgram(addressSize)
|
||||||
fAddressSize(addressSize),
|
|
||||||
fIsDwarf64(isDwarf64)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,27 +48,6 @@ CompilationUnit::~CompilationUnit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CompilationUnit::SetAbbreviationTable(AbbreviationTable* abbreviationTable)
|
|
||||||
{
|
|
||||||
fAbbreviationTable = abbreviationTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
CompilationUnit::AddDebugInfoEntry(DebugInfoEntry* entry, off_t offset)
|
|
||||||
{
|
|
||||||
if (!fEntries.Add(entry))
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
if (!fEntryOffsets.Add(offset)) {
|
|
||||||
fEntries.Remove(fEntries.Count() - 1);
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry)
|
CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry)
|
||||||
{
|
{
|
||||||
@@ -80,13 +55,6 @@ CompilationUnit::SetUnitEntry(DIECompileUnitBase* entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CompilationUnit::SetSourceLanguage(const SourceLanguageInfo* language)
|
|
||||||
{
|
|
||||||
fSourceLanguage = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilationUnit::SetAddressRanges(TargetAddressRangeList* ranges)
|
CompilationUnit::SetAddressRanges(TargetAddressRangeList* ranges)
|
||||||
{
|
{
|
||||||
@@ -107,43 +75,6 @@ CompilationUnit::AddressRangeBase() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
CompilationUnit::CountEntries() const
|
|
||||||
{
|
|
||||||
return fEntries.Count();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CompilationUnit::GetEntryAt(int index, DebugInfoEntry*& entry,
|
|
||||||
off_t& offset) const
|
|
||||||
{
|
|
||||||
entry = fEntries[index];
|
|
||||||
offset = fEntryOffsets[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DebugInfoEntry*
|
|
||||||
CompilationUnit::EntryForOffset(off_t offset) const
|
|
||||||
{
|
|
||||||
if (fEntries.IsEmpty())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// binary search
|
|
||||||
int lower = 0;
|
|
||||||
int upper = fEntries.Count() - 1;
|
|
||||||
while (lower < upper) {
|
|
||||||
int mid = (lower + upper + 1) / 2;
|
|
||||||
if (fEntryOffsets[mid] > offset)
|
|
||||||
upper = mid - 1;
|
|
||||||
else
|
|
||||||
lower = mid;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fEntryOffsets[lower] == offset ? fEntries[lower] : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CompilationUnit::AddDirectory(const char* directory)
|
CompilationUnit::AddDirectory(const char* directory)
|
||||||
{
|
{
|
||||||
@@ -204,3 +135,10 @@ CompilationUnit::FileAt(int32 index, const char** _directory) const
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dwarf_unit_kind
|
||||||
|
CompilationUnit::Kind() const
|
||||||
|
{
|
||||||
|
return dwarf_unit_kind_compilation;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,64 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef COMPILATION_UNIT_H
|
#ifndef COMPILATION_UNIT_H
|
||||||
#define COMPILATION_UNIT_H
|
#define COMPILATION_UNIT_H
|
||||||
|
|
||||||
|
|
||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <Array.h>
|
#include "BaseUnit.h"
|
||||||
|
|
||||||
#include "LineNumberProgram.h"
|
#include "LineNumberProgram.h"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|
||||||
class AbbreviationTable;
|
|
||||||
class DebugInfoEntry;
|
|
||||||
class DIECompileUnitBase;
|
class DIECompileUnitBase;
|
||||||
class SourceLanguageInfo;
|
|
||||||
class TargetAddressRangeList;
|
class TargetAddressRangeList;
|
||||||
|
|
||||||
|
|
||||||
class CompilationUnit {
|
class CompilationUnit : public BaseUnit {
|
||||||
public:
|
public:
|
||||||
CompilationUnit(off_t headerOffset,
|
CompilationUnit(off_t headerOffset,
|
||||||
off_t contentOffset,
|
off_t contentOffset,
|
||||||
off_t totalSize,
|
off_t totalSize,
|
||||||
off_t abbreviationOffset,
|
off_t abbreviationOffset,
|
||||||
uint8 addressSize, bool isDwarf64);
|
uint8 addressSize, bool isDwarf64);
|
||||||
~CompilationUnit();
|
virtual ~CompilationUnit();
|
||||||
|
|
||||||
off_t HeaderOffset() const { return fHeaderOffset; }
|
|
||||||
off_t ContentOffset() const { return fContentOffset; }
|
|
||||||
off_t RelativeContentOffset() const
|
|
||||||
{ return fContentOffset - fHeaderOffset; }
|
|
||||||
off_t TotalSize() const { return fTotalSize; }
|
|
||||||
off_t ContentSize() const
|
|
||||||
{ return fTotalSize
|
|
||||||
- RelativeContentOffset(); }
|
|
||||||
off_t AbbreviationOffset() const
|
|
||||||
{ return fAbbreviationOffset; }
|
|
||||||
|
|
||||||
uint8 AddressSize() const { return fAddressSize; }
|
|
||||||
inline target_addr_t MaxAddress() const;
|
inline target_addr_t MaxAddress() const;
|
||||||
bool IsDwarf64() const { return fIsDwarf64; }
|
|
||||||
|
|
||||||
AbbreviationTable* GetAbbreviationTable() const
|
|
||||||
{ return fAbbreviationTable; }
|
|
||||||
void SetAbbreviationTable(
|
|
||||||
AbbreviationTable* abbreviationTable);
|
|
||||||
|
|
||||||
DIECompileUnitBase* UnitEntry() const { return fUnitEntry; }
|
DIECompileUnitBase* UnitEntry() const { return fUnitEntry; }
|
||||||
void SetUnitEntry(DIECompileUnitBase* entry);
|
void SetUnitEntry(DIECompileUnitBase* entry);
|
||||||
|
|
||||||
const SourceLanguageInfo* SourceLanguage() const
|
|
||||||
{ return fSourceLanguage; }
|
|
||||||
void SetSourceLanguage(
|
|
||||||
const SourceLanguageInfo* language);
|
|
||||||
|
|
||||||
TargetAddressRangeList* AddressRanges() const
|
TargetAddressRangeList* AddressRanges() const
|
||||||
{ return fAddressRanges; }
|
{ return fAddressRanges; }
|
||||||
void SetAddressRanges(
|
void SetAddressRanges(
|
||||||
@@ -69,13 +42,6 @@ public:
|
|||||||
LineNumberProgram& GetLineNumberProgram()
|
LineNumberProgram& GetLineNumberProgram()
|
||||||
{ return fLineNumberProgram; }
|
{ return fLineNumberProgram; }
|
||||||
|
|
||||||
status_t AddDebugInfoEntry(DebugInfoEntry* entry,
|
|
||||||
off_t offset);
|
|
||||||
int CountEntries() const;
|
|
||||||
void GetEntryAt(int index, DebugInfoEntry*& entry,
|
|
||||||
off_t& offset) const;
|
|
||||||
DebugInfoEntry* EntryForOffset(off_t offset) const;
|
|
||||||
|
|
||||||
bool AddDirectory(const char* directory);
|
bool AddDirectory(const char* directory);
|
||||||
int32 CountDirectories() const;
|
int32 CountDirectories() const;
|
||||||
const char* DirectoryAt(int32 index) const;
|
const char* DirectoryAt(int32 index) const;
|
||||||
@@ -85,34 +51,26 @@ public:
|
|||||||
const char* FileAt(int32 index,
|
const char* FileAt(int32 index,
|
||||||
const char** _directory = NULL) const;
|
const char** _directory = NULL) const;
|
||||||
|
|
||||||
|
virtual dwarf_unit_kind Kind() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct File;
|
struct File;
|
||||||
typedef BObjectList<BString> DirectoryList;
|
typedef BObjectList<BString> DirectoryList;
|
||||||
typedef BObjectList<File> FileList;
|
typedef BObjectList<File> FileList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
off_t fHeaderOffset;
|
|
||||||
off_t fContentOffset;
|
|
||||||
off_t fTotalSize;
|
|
||||||
off_t fAbbreviationOffset;
|
|
||||||
AbbreviationTable* fAbbreviationTable;
|
|
||||||
DIECompileUnitBase* fUnitEntry;
|
DIECompileUnitBase* fUnitEntry;
|
||||||
const SourceLanguageInfo* fSourceLanguage;
|
|
||||||
TargetAddressRangeList* fAddressRanges;
|
TargetAddressRangeList* fAddressRanges;
|
||||||
Array<DebugInfoEntry*> fEntries;
|
|
||||||
Array<off_t> fEntryOffsets;
|
|
||||||
DirectoryList fDirectories;
|
DirectoryList fDirectories;
|
||||||
FileList fFiles;
|
FileList fFiles;
|
||||||
LineNumberProgram fLineNumberProgram;
|
LineNumberProgram fLineNumberProgram;
|
||||||
uint8 fAddressSize;
|
|
||||||
bool fIsDwarf64;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
target_addr_t
|
target_addr_t
|
||||||
CompilationUnit::MaxAddress() const
|
CompilationUnit::MaxAddress() const
|
||||||
{
|
{
|
||||||
return fAddressSize == 4 ? 0xffffffffULL : 0xffffffffffffffffULL;
|
return AddressSize() == 4 ? 0xffffffffULL : 0xffffffffffffffffULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ MergeObject Debugger_dwarf.o
|
|||||||
AbbreviationTable.cpp
|
AbbreviationTable.cpp
|
||||||
AttributeClasses.cpp
|
AttributeClasses.cpp
|
||||||
AttributeValue.cpp
|
AttributeValue.cpp
|
||||||
|
BaseUnit.cpp
|
||||||
CfaContext.cpp
|
CfaContext.cpp
|
||||||
CfaRuleSet.cpp
|
CfaRuleSet.cpp
|
||||||
CompilationUnit.cpp
|
CompilationUnit.cpp
|
||||||
@@ -29,5 +30,6 @@ MergeObject Debugger_dwarf.o
|
|||||||
DwarfUtils.cpp
|
DwarfUtils.cpp
|
||||||
LineNumberProgram.cpp
|
LineNumberProgram.cpp
|
||||||
SourceLanguageInfo.cpp
|
SourceLanguageInfo.cpp
|
||||||
|
TypeUnit.cpp
|
||||||
TagNames.cpp
|
TagNames.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#include "TypeUnit.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include "DebugInfoEntries.h"
|
||||||
|
|
||||||
|
|
||||||
|
TypeUnit::TypeUnit(off_t headerOffset, off_t contentOffset,
|
||||||
|
off_t totalSize, off_t abbreviationOffset, off_t typeOffset,
|
||||||
|
uint8 addressSize, uint64 signature, bool isDwarf64)
|
||||||
|
:
|
||||||
|
BaseUnit(headerOffset, contentOffset, totalSize, abbreviationOffset,
|
||||||
|
addressSize, isDwarf64),
|
||||||
|
fUnitEntry(NULL),
|
||||||
|
fSignature(signature),
|
||||||
|
fTypeOffset(typeOffset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TypeUnit::~TypeUnit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TypeUnit::SetUnitEntry(DIETypeUnit* entry)
|
||||||
|
{
|
||||||
|
fUnitEntry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DebugInfoEntry*
|
||||||
|
TypeUnit::TypeEntry() const
|
||||||
|
{
|
||||||
|
if (fUnitEntry != NULL)
|
||||||
|
return fUnitEntry->GetType();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dwarf_unit_kind
|
||||||
|
TypeUnit::Kind() const
|
||||||
|
{
|
||||||
|
return dwarf_unit_kind_type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef TYPE_UNIT_H
|
||||||
|
#define TYPE_UNIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
#include "BaseUnit.h"
|
||||||
|
|
||||||
|
|
||||||
|
class DIETypeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
class TypeUnit : public BaseUnit {
|
||||||
|
public:
|
||||||
|
TypeUnit(off_t headerOffset,
|
||||||
|
off_t contentOffset,
|
||||||
|
off_t totalSize,
|
||||||
|
off_t abbreviationOffset,
|
||||||
|
off_t typeOffset,
|
||||||
|
uint8 addressSize,
|
||||||
|
uint64 typeSignature,
|
||||||
|
bool isDwarf64);
|
||||||
|
~TypeUnit();
|
||||||
|
|
||||||
|
uint64 Signature() const { return fSignature; }
|
||||||
|
|
||||||
|
off_t TypeOffset() const { return fTypeOffset; }
|
||||||
|
|
||||||
|
|
||||||
|
DIETypeUnit* UnitEntry() const { return fUnitEntry; }
|
||||||
|
void SetUnitEntry(DIETypeUnit* entry);
|
||||||
|
|
||||||
|
DebugInfoEntry* TypeEntry() const;
|
||||||
|
|
||||||
|
virtual dwarf_unit_kind Kind() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DIETypeUnit* fUnitEntry;
|
||||||
|
uint64 fSignature;
|
||||||
|
off_t fTypeOffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TypeUnitTableEntry {
|
||||||
|
uint64 signature;
|
||||||
|
TypeUnit* unit;
|
||||||
|
TypeUnitTableEntry* next;
|
||||||
|
|
||||||
|
TypeUnitTableEntry(uint64 signature, TypeUnit* unit)
|
||||||
|
:
|
||||||
|
signature(signature),
|
||||||
|
unit(unit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TypeUnitTableHashDefinition {
|
||||||
|
typedef uint64 KeyType;
|
||||||
|
typedef TypeUnitTableEntry ValueType;
|
||||||
|
|
||||||
|
size_t HashKey(uint64 key) const
|
||||||
|
{
|
||||||
|
return (size_t)key;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Hash(TypeUnitTableEntry* value) const
|
||||||
|
{
|
||||||
|
return HashKey(value->signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Compare(uint64 key, TypeUnitTableEntry* value) const
|
||||||
|
{
|
||||||
|
return value->signature == key;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeUnitTableEntry*& GetLink(TypeUnitTableEntry* value) const
|
||||||
|
{
|
||||||
|
return value->next;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TYPE_UNIT_H
|
||||||
Reference in New Issue
Block a user