2011-09-13 19:42:23 +00:00
|
|
|
//===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H
|
|
|
|
#define LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H
|
|
|
|
|
|
|
|
#include "DWARFDebugAbbrev.h"
|
|
|
|
#include "DWARFDebugInfoEntry.h"
|
2012-09-04 08:12:33 +00:00
|
|
|
#include "DWARFDebugRangeList.h"
|
2013-01-25 22:50:58 +00:00
|
|
|
#include "DWARFRelocMap.h"
|
2011-09-13 19:42:23 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2013-01-02 23:52:13 +00:00
|
|
|
class DWARFDebugAbbrev;
|
|
|
|
class StringRef;
|
2011-09-13 19:42:23 +00:00
|
|
|
class raw_ostream;
|
|
|
|
|
|
|
|
class DWARFCompileUnit {
|
2013-08-23 06:56:01 +00:00
|
|
|
DWARFCompileUnit(DWARFCompileUnit const &) LLVM_DELETED_FUNCTION;
|
|
|
|
DWARFCompileUnit &operator=(DWARFCompileUnit const &) LLVM_DELETED_FUNCTION;
|
|
|
|
|
2013-01-02 23:52:13 +00:00
|
|
|
const DWARFDebugAbbrev *Abbrev;
|
|
|
|
StringRef InfoSection;
|
|
|
|
StringRef AbbrevSection;
|
|
|
|
StringRef RangeSection;
|
|
|
|
StringRef StringSection;
|
2013-01-07 19:32:41 +00:00
|
|
|
StringRef StringOffsetSection;
|
2013-01-15 23:56:56 +00:00
|
|
|
StringRef AddrOffsetSection;
|
2013-01-02 23:52:13 +00:00
|
|
|
const RelocAddrMap *RelocMap;
|
|
|
|
bool isLittleEndian;
|
2011-09-13 19:42:23 +00:00
|
|
|
|
|
|
|
uint32_t Offset;
|
|
|
|
uint32_t Length;
|
|
|
|
uint16_t Version;
|
|
|
|
const DWARFAbbreviationDeclarationSet *Abbrevs;
|
|
|
|
uint8_t AddrSize;
|
|
|
|
uint64_t BaseAddr;
|
2013-07-15 08:43:35 +00:00
|
|
|
// The compile unit debug information entry items.
|
2011-09-13 19:42:23 +00:00
|
|
|
std::vector<DWARFDebugInfoEntryMinimal> DieArray;
|
|
|
|
public:
|
2013-01-02 23:52:13 +00:00
|
|
|
|
|
|
|
DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef AS,
|
2013-01-15 23:56:56 +00:00
|
|
|
StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
|
2013-01-07 19:32:41 +00:00
|
|
|
const RelocAddrMap *M, bool LE) :
|
2013-01-02 23:52:13 +00:00
|
|
|
Abbrev(DA), InfoSection(IS), AbbrevSection(AS),
|
2013-01-07 19:32:41 +00:00
|
|
|
RangeSection(RS), StringSection(SS), StringOffsetSection(SOS),
|
2013-01-15 23:56:56 +00:00
|
|
|
AddrOffsetSection(AOS), RelocMap(M), isLittleEndian(LE) {
|
2011-09-13 19:42:23 +00:00
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
2013-01-02 23:52:13 +00:00
|
|
|
StringRef getStringSection() const { return StringSection; }
|
2013-01-07 19:32:41 +00:00
|
|
|
StringRef getStringOffsetSection() const { return StringOffsetSection; }
|
2013-01-15 23:56:56 +00:00
|
|
|
StringRef getAddrOffsetSection() const { return AddrOffsetSection; }
|
2013-01-02 23:52:13 +00:00
|
|
|
const RelocAddrMap *getRelocMap() const { return RelocMap; }
|
2011-09-13 19:42:23 +00:00
|
|
|
DataExtractor getDebugInfoExtractor() const;
|
|
|
|
|
|
|
|
bool extract(DataExtractor debug_info, uint32_t* offset_ptr);
|
|
|
|
uint32_t extract(uint32_t offset, DataExtractor debug_info_data,
|
|
|
|
const DWARFAbbreviationDeclarationSet *abbrevs);
|
|
|
|
|
|
|
|
/// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
|
2012-07-04 09:42:54 +00:00
|
|
|
/// hasn't already been done. Returns the number of DIEs parsed at this call.
|
2013-07-15 08:43:35 +00:00
|
|
|
size_t extractDIEsIfNeeded(bool CUDieOnly);
|
2012-09-04 08:12:33 +00:00
|
|
|
/// extractRangeList - extracts the range list referenced by this compile
|
|
|
|
/// unit from .debug_ranges section. Returns true on success.
|
|
|
|
/// Requires that compile unit is already extracted.
|
|
|
|
bool extractRangeList(uint32_t RangeListOffset,
|
|
|
|
DWARFDebugRangeList &RangeList) const;
|
2011-09-13 19:42:23 +00:00
|
|
|
void clear();
|
|
|
|
void dump(raw_ostream &OS);
|
|
|
|
uint32_t getOffset() const { return Offset; }
|
|
|
|
/// Size in bytes of the compile unit header.
|
|
|
|
uint32_t getSize() const { return 11; }
|
|
|
|
bool containsDIEOffset(uint32_t die_offset) const {
|
|
|
|
return die_offset >= getFirstDIEOffset() &&
|
|
|
|
die_offset < getNextCompileUnitOffset();
|
|
|
|
}
|
|
|
|
uint32_t getFirstDIEOffset() const { return Offset + getSize(); }
|
|
|
|
uint32_t getNextCompileUnitOffset() const { return Offset + Length + 4; }
|
|
|
|
/// Size in bytes of the .debug_info data associated with this compile unit.
|
|
|
|
size_t getDebugInfoSize() const { return Length + 4 - getSize(); }
|
|
|
|
uint32_t getLength() const { return Length; }
|
|
|
|
uint16_t getVersion() const { return Version; }
|
|
|
|
const DWARFAbbreviationDeclarationSet *getAbbreviations() const {
|
|
|
|
return Abbrevs;
|
|
|
|
}
|
|
|
|
uint8_t getAddressByteSize() const { return AddrSize; }
|
|
|
|
uint64_t getBaseAddress() const { return BaseAddr; }
|
|
|
|
|
|
|
|
void setBaseAddress(uint64_t base_addr) {
|
|
|
|
BaseAddr = base_addr;
|
|
|
|
}
|
|
|
|
|
2011-09-15 18:02:20 +00:00
|
|
|
const DWARFDebugInfoEntryMinimal *
|
|
|
|
getCompileUnitDIE(bool extract_cu_die_only = true) {
|
|
|
|
extractDIEsIfNeeded(extract_cu_die_only);
|
2013-07-15 08:43:35 +00:00
|
|
|
return DieArray.empty() ? NULL : &DieArray[0];
|
2011-09-15 18:02:20 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 07:03:58 +00:00
|
|
|
const char *getCompilationDir();
|
|
|
|
|
2011-09-13 19:42:23 +00:00
|
|
|
/// setDIERelations - We read in all of the DIE entries into our flat list
|
|
|
|
/// of DIE entries and now we need to go back through all of them and set the
|
|
|
|
/// parent, sibling and child pointers for quick DIE navigation.
|
|
|
|
void setDIERelations();
|
|
|
|
|
2011-09-14 20:52:27 +00:00
|
|
|
void buildAddressRangeTable(DWARFDebugAranges *debug_aranges,
|
|
|
|
bool clear_dies_if_already_not_parsed);
|
2012-09-04 08:12:33 +00:00
|
|
|
|
|
|
|
/// getInlinedChainForAddress - fetches inlined chain for a given address.
|
2013-08-06 10:49:15 +00:00
|
|
|
/// Returns empty chain if there is no subprogram containing address. The
|
|
|
|
/// chain is valid as long as parsed compile unit DIEs are not cleared.
|
|
|
|
DWARFDebugInfoEntryInlinedChain getInlinedChainForAddress(uint64_t Address);
|
2013-07-15 08:43:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// extractDIEsToVector - Appends all parsed DIEs to a vector.
|
|
|
|
void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
|
|
|
|
std::vector<DWARFDebugInfoEntryMinimal> &DIEs) const;
|
|
|
|
/// clearDIEs - Clear parsed DIEs to keep memory usage low.
|
|
|
|
void clearDIEs(bool KeepCUDie);
|
2011-09-13 19:42:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|