aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-01-05 18:59:44 +0000
committerDevang Patel <dpatel@apple.com>2009-01-05 18:59:44 +0000
commit86ae142c51fc29ab870ebf42f6bf8699bca81512 (patch)
tree1e648dbb6b003a831af7445015f1a3340d58d896
parent0d8484f2edb1069522f5c3de6467433e0fbe9323 (diff)
downloadexternal_llvm-86ae142c51fc29ab870ebf42f6bf8699bca81512.zip
external_llvm-86ae142c51fc29ab870ebf42f6bf8699bca81512.tar.gz
external_llvm-86ae142c51fc29ab870ebf42f6bf8699bca81512.tar.bz2
Construct stuct field DIEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61729 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/DebugInfo.h1
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfWriter.cpp78
2 files changed, 79 insertions, 0 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h
index c97cb26..bc89102 100644
--- a/include/llvm/Analysis/DebugInfo.h
+++ b/include/llvm/Analysis/DebugInfo.h
@@ -228,6 +228,7 @@ namespace llvm {
explicit DISubprogram(GlobalVariable *GV = 0);
std::string getFilename() const { return getStringField(11); }
std::string getDirectory() const { return getStringField(12); }
+ DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
};
/// DIGlobalVariable - This is a wrapper for a global variable.
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 3176c38..022ff9a 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -1591,6 +1591,84 @@ private:
Buffer.AddChild(Enumerator);
}
+ /// ConstructFieldTypeDIE - Construct variable DIE for a struct field.
+ void ConstructFieldTypeDIE(CompileUnit *DW_Unit,
+ DIE &Buffer, DIGlobalVariable *V) {
+
+ DIE *VariableDie = new DIE(DW_TAG_variable);
+ const std::string &LinkageName = V->getLinkageName();
+ if (!LinkageName.empty())
+ AddString(VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
+ LinkageName);
+ // FIXME - Enable this. AddSourceLine(VariableDie, V);
+ // FIXME - Enable this. AddType(VariableDie, V->getType(), DW_Unit);
+ if (!V->isLocalToUnit())
+ AddUInt(VariableDie, DW_AT_external, DW_FORM_flag, 1);
+ AddUInt(VariableDie, DW_AT_declaration, DW_FORM_flag, 1);
+ Buffer.AddChild(VariableDie);
+ }
+
+ /// ConstructFieldTypeDIE - Construct subprogram DIE for a struct field.
+ void ConstructFieldTypeDIE(CompileUnit *DW_Unit,
+ DIE &Buffer, DISubprogram *SP,
+ bool IsConstructor = false) {
+ DIE *Method = new DIE(DW_TAG_subprogram);
+ AddString(Method, DW_AT_name, DW_FORM_string, SP->getName());
+ const std::string &LinkageName = SP->getLinkageName();
+ if (!LinkageName.empty())
+ AddString(Method, DW_AT_MIPS_linkage_name, DW_FORM_string, LinkageName);
+ // FIXME - Enable this. AddSourceLine(Method, SP);
+
+ DICompositeType MTy = SP->getType();
+ DIArray Args = MTy.getTypeArray();
+
+ // Add Return Type.
+ // FIXME - Enable this. if (!IsConstructor)
+ // Fixme - Enable this. AddType(Method, Args.getElement(0), DW_Unit);
+
+ // Add arguments.
+ for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+ DIE *Arg = new DIE(DW_TAG_formal_parameter);
+ // FIXME - Enable this. AddType(Arg, Args.getElement(i), DW_Unit);
+ AddUInt(Arg, DW_AT_artificial, DW_FORM_flag, 1); // ???
+ Method->AddChild(Arg);
+ }
+
+ if (!SP->isLocalToUnit())
+ AddUInt(Method, DW_AT_external, DW_FORM_flag, 1);
+ Buffer.AddChild(Method);
+ }
+
+ /// COnstructFieldTypeDIE - Construct derived type DIE for a struct field.
+ void ConstructFieldTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
+ DIDerivedType *DTy) {
+ unsigned Tag = DTy->getTag();
+ DIE *MemberDie = new DIE(Tag);
+ if (!DTy->getName().empty())
+ AddString(MemberDie, DW_AT_name, DW_FORM_string, DTy->getName());
+ // FIXME - Enable this. AddSourceLine(MemberDie, DTy);
+
+ DIType FromTy = DTy->getTypeDerivedFrom();
+ // FIXME - Enable this. AddType(MemberDie, FromTy, DW_Unit);
+
+ uint64_t Size = DTy->getSizeInBits();
+ uint64_t Offset = DTy->getOffsetInBits();
+
+ // FIXME Handle bitfields
+
+ // Add size.
+ AddUInt(MemberDie, DW_AT_bit_size, 0, Size);
+ // Add computation for offset.
+ DIEBlock *Block = new DIEBlock();
+ AddUInt(Block, 0, DW_FORM_data1, DW_OP_plus_uconst);
+ AddUInt(Block, 0, DW_FORM_udata, Offset >> 3);
+ AddBlock(MemberDie, DW_AT_data_member_location, 0, Block);
+
+ // FIXME Handle DW_AT_accessibility.
+
+ Buffer.AddChild(MemberDie);
+ }
+
/// ConstructType - Adds all the required attributes to the type.
///
void ConstructType(DIE &Buffer, TypeDesc *TyDesc, CompileUnit *Unit) {