forked from OSchip/llvm-project
Fix DWARF debugging information on x86/Linux and (hopefully)
Mingw32/Cygwin targets. This fixes PR978 llvm-svn: 35000
This commit is contained in:
parent
17cdad0687
commit
942fda027f
|
|
@ -246,6 +246,10 @@ namespace llvm {
|
||||||
|
|
||||||
//===--- Dwarf Emission Directives -----------------------------------===//
|
//===--- Dwarf Emission Directives -----------------------------------===//
|
||||||
|
|
||||||
|
/// AbsoluteSectionOffsets - True if we should emit abolute section
|
||||||
|
/// offsets. Defaults to false.
|
||||||
|
bool AbsoluteSectionOffsets;
|
||||||
|
|
||||||
/// HasLEB128 - True if target asm supports leb128 directives.
|
/// HasLEB128 - True if target asm supports leb128 directives.
|
||||||
///
|
///
|
||||||
bool HasLEB128; // Defaults to false.
|
bool HasLEB128; // Defaults to false.
|
||||||
|
|
@ -266,6 +270,9 @@ namespace llvm {
|
||||||
///
|
///
|
||||||
bool DwarfRequiresFrameSection; // Defaults to true.
|
bool DwarfRequiresFrameSection; // Defaults to true.
|
||||||
|
|
||||||
|
/// DwarfSectionOffsetDirective - Special section offset directive.
|
||||||
|
const char* DwarfSectionOffsetDirective; // Defaults to NULL
|
||||||
|
|
||||||
/// DwarfAbbrevSection - Section directive for Dwarf abbrev.
|
/// DwarfAbbrevSection - Section directive for Dwarf abbrev.
|
||||||
///
|
///
|
||||||
const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
|
const char *DwarfAbbrevSection; // Defaults to ".debug_abbrev".
|
||||||
|
|
@ -494,6 +501,9 @@ namespace llvm {
|
||||||
const char *getHiddenDirective() const {
|
const char *getHiddenDirective() const {
|
||||||
return HiddenDirective;
|
return HiddenDirective;
|
||||||
}
|
}
|
||||||
|
bool isAbsoluteSectionOffsets() const {
|
||||||
|
return AbsoluteSectionOffsets;
|
||||||
|
}
|
||||||
bool hasLEB128() const {
|
bool hasLEB128() const {
|
||||||
return HasLEB128;
|
return HasLEB128;
|
||||||
}
|
}
|
||||||
|
|
@ -509,6 +519,9 @@ namespace llvm {
|
||||||
bool getDwarfRequiresFrameSection() const {
|
bool getDwarfRequiresFrameSection() const {
|
||||||
return DwarfRequiresFrameSection;
|
return DwarfRequiresFrameSection;
|
||||||
}
|
}
|
||||||
|
const char *getDwarfSectionOffsetDirective() const {
|
||||||
|
return DwarfSectionOffsetDirective;
|
||||||
|
}
|
||||||
const char *getDwarfAbbrevSection() const {
|
const char *getDwarfAbbrevSection() const {
|
||||||
return DwarfAbbrevSection;
|
return DwarfAbbrevSection;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -823,7 +823,11 @@ public:
|
||||||
void PrintLabelName(DWLabel Label) const {
|
void PrintLabelName(DWLabel Label) const {
|
||||||
PrintLabelName(Label.Tag, Label.Number);
|
PrintLabelName(Label.Tag, Label.Number);
|
||||||
}
|
}
|
||||||
void PrintLabelName(const char *Tag, unsigned Number) const {
|
void PrintLabelName(const char *Tag, unsigned Number,
|
||||||
|
bool isInSection = false) const {
|
||||||
|
if (isInSection && TAI->getDwarfSectionOffsetDirective())
|
||||||
|
O << TAI->getDwarfSectionOffsetDirective() << Tag;
|
||||||
|
else
|
||||||
O << TAI->getPrivateGlobalPrefix() << Tag;
|
O << TAI->getPrivateGlobalPrefix() << Tag;
|
||||||
if (Number) O << Number;
|
if (Number) O << Number;
|
||||||
}
|
}
|
||||||
|
|
@ -908,6 +912,43 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmitSectionOffset(const char* Label, const char* Section,
|
||||||
|
unsigned LabelNumber, unsigned SectionNumber,
|
||||||
|
bool IsSmall = false) const {
|
||||||
|
if (TAI->needsSet()) {
|
||||||
|
static unsigned SetCounter = 1;
|
||||||
|
|
||||||
|
O << "\t.set\t";
|
||||||
|
PrintLabelName("set", SetCounter);
|
||||||
|
O << ",";
|
||||||
|
PrintLabelName(Label, LabelNumber, true);
|
||||||
|
if (!TAI->isAbsoluteSectionOffsets()) {
|
||||||
|
O << "-";
|
||||||
|
PrintLabelName(Section, SectionNumber);
|
||||||
|
}
|
||||||
|
O << "\n";
|
||||||
|
|
||||||
|
if (IsSmall || TAI->getAddressSize() == sizeof(int32_t))
|
||||||
|
O << TAI->getData32bitsDirective();
|
||||||
|
else
|
||||||
|
O << TAI->getData64bitsDirective();
|
||||||
|
|
||||||
|
PrintLabelName("set", SetCounter);
|
||||||
|
++SetCounter;
|
||||||
|
} else {
|
||||||
|
if (IsSmall || TAI->getAddressSize() == sizeof(int32_t))
|
||||||
|
O << TAI->getData32bitsDirective();
|
||||||
|
else
|
||||||
|
O << TAI->getData64bitsDirective();
|
||||||
|
|
||||||
|
PrintLabelName(Label, LabelNumber, true);
|
||||||
|
if (!TAI->isAbsoluteSectionOffsets()) {
|
||||||
|
O << "-";
|
||||||
|
PrintLabelName(Section, SectionNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||||
/// frame.
|
/// frame.
|
||||||
void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
|
void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
|
||||||
|
|
@ -1649,6 +1690,9 @@ private:
|
||||||
CompileUnit *NewCompileUnit(CompileUnitDesc *UnitDesc, unsigned ID) {
|
CompileUnit *NewCompileUnit(CompileUnitDesc *UnitDesc, unsigned ID) {
|
||||||
// Construct debug information entry.
|
// Construct debug information entry.
|
||||||
DIE *Die = new DIE(DW_TAG_compile_unit);
|
DIE *Die = new DIE(DW_TAG_compile_unit);
|
||||||
|
if (TAI->isAbsoluteSectionOffsets())
|
||||||
|
AddLabel(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0));
|
||||||
|
else
|
||||||
AddDelta(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0),
|
AddDelta(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0),
|
||||||
DWLabel("section_line", 0));
|
DWLabel("section_line", 0));
|
||||||
AddString(Die, DW_AT_producer, DW_FORM_string, UnitDesc->getProducer());
|
AddString(Die, DW_AT_producer, DW_FORM_string, UnitDesc->getProducer());
|
||||||
|
|
@ -2065,7 +2109,7 @@ private:
|
||||||
|
|
||||||
Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info");
|
Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info");
|
||||||
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
|
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
|
||||||
EmitDifference("abbrev_begin", 0, "section_abbrev", 0, true);
|
EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true);
|
||||||
Asm->EOL("Offset Into Abbrev. Section");
|
Asm->EOL("Offset Into Abbrev. Section");
|
||||||
Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Address Size (in bytes)");
|
Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Address Size (in bytes)");
|
||||||
|
|
||||||
|
|
@ -2324,7 +2368,7 @@ private:
|
||||||
|
|
||||||
EmitLabel("frame_begin", SubprogramCount);
|
EmitLabel("frame_begin", SubprogramCount);
|
||||||
|
|
||||||
EmitDifference("frame_common_begin", 0, "section_frame", 0, true);
|
EmitSectionOffset("frame_common_begin", "section_frame", 0, 0, true);
|
||||||
Asm->EOL("FDE CIE offset");
|
Asm->EOL("FDE CIE offset");
|
||||||
|
|
||||||
EmitReference("func_begin", SubprogramCount);
|
EmitReference("func_begin", SubprogramCount);
|
||||||
|
|
@ -2359,7 +2403,7 @@ private:
|
||||||
|
|
||||||
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF Version");
|
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF Version");
|
||||||
|
|
||||||
EmitDifference("info_begin", Unit->getID(), "section_info", 0, true);
|
EmitSectionOffset("info_begin", "section_info", Unit->getID(), 0, true);
|
||||||
Asm->EOL("Offset of Compilation Unit Info");
|
Asm->EOL("Offset of Compilation Unit Info");
|
||||||
|
|
||||||
EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),true);
|
EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),true);
|
||||||
|
|
@ -2787,8 +2831,8 @@ private:
|
||||||
|
|
||||||
EmitLabel("eh_frame_begin", SubprogramCount);
|
EmitLabel("eh_frame_begin", SubprogramCount);
|
||||||
|
|
||||||
EmitDifference("eh_frame_begin", SubprogramCount,
|
EmitSectionOffset("eh_frame_begin", "section_eh_frame",
|
||||||
"section_eh_frame", 0, true);
|
SubprogramCount, 0, true);
|
||||||
Asm->EOL("FDE CIE offset");
|
Asm->EOL("FDE CIE offset");
|
||||||
|
|
||||||
EmitReference("eh_func_begin", SubprogramCount, true);
|
EmitReference("eh_func_begin", SubprogramCount, true);
|
||||||
|
|
@ -2951,8 +2995,8 @@ private:
|
||||||
// Emit the landng pad site information.
|
// Emit the landng pad site information.
|
||||||
for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
|
for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
|
||||||
const LandingPadInfo &LandingPad = LandingPads[i];
|
const LandingPadInfo &LandingPad = LandingPads[i];
|
||||||
EmitDifference("label", LandingPad.BeginLabel,
|
EmitSectionOffset("label", "eh_func_begin",
|
||||||
"eh_func_begin", SubprogramCount);
|
LandingPad.BeginLabel, SubprogramCount);
|
||||||
Asm->EOL("Region start");
|
Asm->EOL("Region start");
|
||||||
|
|
||||||
EmitDifference("label", LandingPad.EndLabel,
|
EmitDifference("label", LandingPad.EndLabel,
|
||||||
|
|
@ -2965,8 +3009,8 @@ private:
|
||||||
else
|
else
|
||||||
Asm->EmitInt64(0);
|
Asm->EmitInt64(0);
|
||||||
} else {
|
} else {
|
||||||
EmitDifference("label", LandingPad.LandingPadLabel,
|
EmitSectionOffset("label", "eh_func_begin",
|
||||||
"eh_func_begin", SubprogramCount);
|
LandingPad.LandingPadLabel, SubprogramCount);
|
||||||
}
|
}
|
||||||
Asm->EOL("Landing pad");
|
Asm->EOL("Landing pad");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,13 @@ TargetAsmInfo::TargetAsmInfo() :
|
||||||
UsedDirective(0),
|
UsedDirective(0),
|
||||||
WeakRefDirective(0),
|
WeakRefDirective(0),
|
||||||
HiddenDirective("\t.hidden\t"),
|
HiddenDirective("\t.hidden\t"),
|
||||||
|
AbsoluteSectionOffsets(false),
|
||||||
HasLEB128(false),
|
HasLEB128(false),
|
||||||
HasDotLoc(false),
|
HasDotLoc(false),
|
||||||
HasDotFile(false),
|
HasDotFile(false),
|
||||||
SupportsExceptionHandling(false),
|
SupportsExceptionHandling(false),
|
||||||
DwarfRequiresFrameSection(true),
|
DwarfRequiresFrameSection(true),
|
||||||
|
DwarfSectionOffsetDirective(0),
|
||||||
DwarfAbbrevSection(".debug_abbrev"),
|
DwarfAbbrevSection(".debug_abbrev"),
|
||||||
DwarfInfoSection(".debug_info"),
|
DwarfInfoSection(".debug_info"),
|
||||||
DwarfLineSection(".debug_line"),
|
DwarfLineSection(".debug_line"),
|
||||||
|
|
@ -106,3 +108,4 @@ unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
|
||||||
// Multiply by the worst-case length for each instruction.
|
// Multiply by the worst-case length for each instruction.
|
||||||
return NumInsts * MaxInstLength;
|
return NumInsts * MaxInstLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
|
||||||
case X86Subtarget::isELF:
|
case X86Subtarget::isELF:
|
||||||
// Set up DWARF directives
|
// Set up DWARF directives
|
||||||
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
||||||
|
AbsoluteSectionOffsets = true;
|
||||||
// bool HasLEB128; // Defaults to false.
|
// bool HasLEB128; // Defaults to false.
|
||||||
// hasDotLoc - True if target asm supports .loc directives.
|
// hasDotLoc - True if target asm supports .loc directives.
|
||||||
// bool HasDotLoc; // Defaults to false.
|
// bool HasDotLoc; // Defaults to false.
|
||||||
|
|
@ -130,9 +131,11 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
|
||||||
|
|
||||||
// Set up DWARF directives
|
// Set up DWARF directives
|
||||||
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
||||||
|
AbsoluteSectionOffsets = true;
|
||||||
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
|
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
|
||||||
WeakRefDirective = "\t.weak\t";
|
WeakRefDirective = "\t.weak\t";
|
||||||
DwarfRequiresFrameSection = false;
|
DwarfRequiresFrameSection = false;
|
||||||
|
DwarfSectionOffsetDirective = "\t.secrel32\t";
|
||||||
DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
|
DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
|
||||||
DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
|
DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
|
||||||
DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
|
DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue