diff options
author | Argiris Kirtzidis <akyrtzi@gmail.com> | 2008-06-18 19:27:37 +0000 |
---|---|---|
committer | Argiris Kirtzidis <akyrtzi@gmail.com> | 2008-06-18 19:27:37 +0000 |
commit | 03449656a5e0c47b8f1720bb4750b91aae70eb15 (patch) | |
tree | 41c1b8962812c6225aee710a17fa3015181c3103 /lib | |
parent | f6237db5574a192ec5b94766334fa76bc5447d96 (diff) | |
download | external_llvm-03449656a5e0c47b8f1720bb4750b91aae70eb15.zip external_llvm-03449656a5e0c47b8f1720bb4750b91aae70eb15.tar.gz external_llvm-03449656a5e0c47b8f1720bb4750b91aae70eb15.tar.bz2 |
Fix the source line debug information for the Windows platform.
According to DWARF-2 specification, the line information is provided through an offset in the .debug_line section.
Replace the label reference that is used with a section offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52468 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/DwarfWriter.cpp | 93 |
1 files changed, 88 insertions, 5 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index fc7ba6d..784bf93 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -296,6 +296,7 @@ public: isString, isLabel, isAsIsLabel, + isSectionOffset, isDelta, isEntry, isBlock @@ -505,6 +506,56 @@ public: }; //===----------------------------------------------------------------------===// +/// DIESectionOffset - A section offset DIE. +// +class DIESectionOffset : public DIEValue { +public: + const DWLabel Label; + const DWLabel Section; + bool IsEH : 1; + bool UseSet : 1; + + DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec, + bool isEH = false, bool useSet = true) + : DIEValue(isSectionOffset), Label(Lab), Section(Sec), + IsEH(isEH), UseSet(useSet) {} + + // Implement isa/cast/dyncast. + static bool classof(const DIESectionOffset *) { return true; } + static bool classof(const DIEValue *D) { return D->Type == isSectionOffset; } + + /// EmitValue - Emit section offset. + /// + virtual void EmitValue(DwarfDebug &DD, unsigned Form); + + /// SizeOf - Determine size of section offset value in bytes. + /// + virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const; + + /// Profile - Used to gather unique data for the value folding set. + /// + static void Profile(FoldingSetNodeID &ID, const DWLabel &Label, + const DWLabel &Section) { + ID.AddInteger(isSectionOffset); + Label.Profile(ID); + Section.Profile(ID); + // IsEH and UseSet are specific to the Label/Section that we will emit + // the offset for; so Label/Section are enough for uniqueness. + } + virtual void Profile(FoldingSetNodeID &ID) { Profile(ID, Label, Section); } + +#ifndef NDEBUG + virtual void print(std::ostream &O) { + O << "Off: "; + Label.print(O); + O << "-"; + Section.print(O); + O << "-" << IsEH << "-" << UseSet; + } +#endif +}; + +//===----------------------------------------------------------------------===// /// DIEDelta - A simple label difference DIE. /// class DIEDelta : public DIEValue { @@ -1275,6 +1326,24 @@ public: Die->AddValue(Attribute, Form, Value); } + /// AddSectionOffset - Add a section offset label attribute data and value. + /// + void AddSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, + const DWLabel &Label, const DWLabel &Section, + bool isEH = false, bool useSet = true) { + FoldingSetNodeID ID; + DIESectionOffset::Profile(ID, Label, Section); + void *Where; + DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where); + if (!Value) { + Value = new DIESectionOffset(Label, Section, isEH, useSet); + ValuesSet.InsertNode(Value, Where); + Values.push_back(Value); + } + + Die->AddValue(Attribute, Form, Value); + } + /// AddDelta - Add a label delta attribute data and value. /// void AddDelta(DIE *Die, unsigned Attribute, unsigned Form, @@ -1714,11 +1783,8 @@ private: CompileUnit *NewCompileUnit(CompileUnitDesc *UnitDesc, unsigned ID) { // Construct debug information entry. DIE *Die = new DIE(DW_TAG_compile_unit); - if (TAI->isAbsoluteDebugSectionOffsets()) - 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), - DWLabel("section_line", 0)); + AddSectionOffset(Die, DW_AT_stmt_list, DW_FORM_data4, + DWLabel("section_line", 0), DWLabel("section_line", 0), false); AddString(Die, DW_AT_producer, DW_FORM_string, UnitDesc->getProducer()); AddUInt (Die, DW_AT_language, DW_FORM_data1, UnitDesc->getLanguage()); AddString(Die, DW_AT_name, DW_FORM_string, UnitDesc->getFileName()); @@ -3617,6 +3683,23 @@ unsigned DIEObjectLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const { /// EmitValue - Emit delta value. /// +void DIESectionOffset::EmitValue(DwarfDebug &DD, unsigned Form) { + bool IsSmall = Form == DW_FORM_data4; + DD.EmitSectionOffset(Label.Tag, Section.Tag, + Label.Number, Section.Number, IsSmall, IsEH, UseSet); +} + +/// SizeOf - Determine size of delta value in bytes. +/// +unsigned DIESectionOffset::SizeOf(const DwarfDebug &DD, unsigned Form) const { + if (Form == DW_FORM_data4) return 4; + return DD.getTargetData()->getPointerSize(); +} + +//===----------------------------------------------------------------------===// + +/// EmitValue - Emit delta value. +/// void DIEDelta::EmitValue(DwarfDebug &DD, unsigned Form) { bool IsSmall = Form == DW_FORM_data4; DD.EmitDifference(LabelHi, LabelLo, IsSmall); |