forked from OSchip/llvm-project
DebugInfo: Push header handling down into CompileUnit
This is a preliminary step to handling type units by abstracting over all (type or compile) units. llvm-svn: 193714
This commit is contained in:
parent
6a2aaecd66
commit
6b288cfa7a
|
@ -22,6 +22,8 @@
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/GlobalVariable.h"
|
#include "llvm/IR/GlobalVariable.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
|
#include "llvm/MC/MCSection.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/Target/Mangler.h"
|
#include "llvm/Target/Mangler.h"
|
||||||
#include "llvm/Target/TargetFrameLowering.h"
|
#include "llvm/Target/TargetFrameLowering.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
@ -1900,3 +1902,14 @@ DIE *CompileUnit::getOrCreateStaticMemberDIE(const DIDerivedType DT) {
|
||||||
|
|
||||||
return StaticMemberDIE;
|
return StaticMemberDIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompileUnit::emitHeader(const MCSection *ASection,
|
||||||
|
const MCSymbol *ASectionSym) {
|
||||||
|
Asm->OutStreamer.AddComment("DWARF version number");
|
||||||
|
Asm->EmitInt16(DD->getDwarfVersion());
|
||||||
|
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
|
||||||
|
Asm->EmitSectionOffset(Asm->GetTempSymbol(ASection->getLabelBeginName()),
|
||||||
|
ASectionSym);
|
||||||
|
Asm->OutStreamer.AddComment("Address Size (in bytes)");
|
||||||
|
Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
|
||||||
|
}
|
||||||
|
|
|
@ -315,6 +315,17 @@ public:
|
||||||
/// call insertDIE if MD is not null.
|
/// call insertDIE if MD is not null.
|
||||||
DIE *createAndAddDIE(unsigned Tag, DIE &Parent, const MDNode *MD = NULL);
|
DIE *createAndAddDIE(unsigned Tag, DIE &Parent, const MDNode *MD = NULL);
|
||||||
|
|
||||||
|
/// Compute the size of a header for this unit, not including the initial
|
||||||
|
/// length field.
|
||||||
|
unsigned getHeaderSize() const {
|
||||||
|
return sizeof(int16_t) + // DWARF version number
|
||||||
|
sizeof(int32_t) + // Offset Into Abbrev. Section
|
||||||
|
sizeof(int8_t); // Pointer Size (in bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Emit the header for this unit, not including the initial length field.
|
||||||
|
void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||||
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
|
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
|
||||||
|
|
|
@ -1972,11 +1972,8 @@ void DwarfUnits::computeSizeAndOffsets() {
|
||||||
(*I)->setDebugInfoOffset(SecOffset);
|
(*I)->setDebugInfoOffset(SecOffset);
|
||||||
|
|
||||||
// CU-relative offset is reset to 0 here.
|
// CU-relative offset is reset to 0 here.
|
||||||
unsigned Offset =
|
unsigned Offset = sizeof(int32_t) + // Length of Unit Info
|
||||||
sizeof(int32_t) + // Length of Compilation Unit Info
|
(*I)->getHeaderSize(); // Unit-specific headers
|
||||||
sizeof(int16_t) + // DWARF version number
|
|
||||||
sizeof(int32_t) + // Offset Into Abbrev. Section
|
|
||||||
sizeof(int8_t); // Pointer Size (in bytes)
|
|
||||||
|
|
||||||
// EndOffset here is CU-relative, after laying out
|
// EndOffset here is CU-relative, after laying out
|
||||||
// all of the CU DIE.
|
// all of the CU DIE.
|
||||||
|
@ -2163,20 +2160,10 @@ void DwarfUnits::emitUnits(DwarfDebug *DD,
|
||||||
TheCU->getUniqueID()));
|
TheCU->getUniqueID()));
|
||||||
|
|
||||||
// Emit size of content not including length itself
|
// Emit size of content not including length itself
|
||||||
unsigned ContentSize = Die->getSize() +
|
Asm->OutStreamer.AddComment("Length of Unit");
|
||||||
sizeof(int16_t) + // DWARF version number
|
Asm->EmitInt32(TheCU->getHeaderSize() + Die->getSize());
|
||||||
sizeof(int32_t) + // Offset Into Abbrev. Section
|
|
||||||
sizeof(int8_t); // Pointer Size (in bytes)
|
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Length of Compilation Unit Info");
|
TheCU->emitHeader(ASection, ASectionSym);
|
||||||
Asm->EmitInt32(ContentSize);
|
|
||||||
Asm->OutStreamer.AddComment("DWARF version number");
|
|
||||||
Asm->EmitInt16(DD->getDwarfVersion());
|
|
||||||
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
|
|
||||||
Asm->EmitSectionOffset(Asm->GetTempSymbol(ASection->getLabelBeginName()),
|
|
||||||
ASectionSym);
|
|
||||||
Asm->OutStreamer.AddComment("Address Size (in bytes)");
|
|
||||||
Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
|
|
||||||
|
|
||||||
DD->emitDIE(Die, Abbreviations);
|
DD->emitDIE(Die, Abbreviations);
|
||||||
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(USection->getLabelEndName(),
|
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(USection->getLabelEndName(),
|
||||||
|
|
Loading…
Reference in New Issue