mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 06:29:05 +00:00
Coordinate activities with llvm-gcc4 and dwarf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -34,12 +34,14 @@ namespace llvm {
|
|||||||
//
|
//
|
||||||
class AsmPrinter;
|
class AsmPrinter;
|
||||||
class CompileUnitDesc;
|
class CompileUnitDesc;
|
||||||
|
class DebugInfoDesc;
|
||||||
class DIE;
|
class DIE;
|
||||||
class DwarfWriter;
|
class DwarfWriter;
|
||||||
class DWContext;
|
class GlobalVariableDesc;
|
||||||
class MachineDebugInfo;
|
class MachineDebugInfo;
|
||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class Module;
|
class Module;
|
||||||
|
class SubprogramDesc;
|
||||||
class Type;
|
class Type;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
@@ -116,6 +118,7 @@ namespace llvm {
|
|||||||
unsigned getTag() const { return Tag; }
|
unsigned getTag() const { return Tag; }
|
||||||
unsigned getChildrenFlag() const { return ChildrenFlag; }
|
unsigned getChildrenFlag() const { return ChildrenFlag; }
|
||||||
const std::vector<DIEAbbrevData> &getData() const { return Data; }
|
const std::vector<DIEAbbrevData> &getData() const { return Data; }
|
||||||
|
void setChildrenFlag(unsigned CF) { ChildrenFlag = CF; }
|
||||||
|
|
||||||
/// operator== - Used by UniqueVector to locate entry.
|
/// operator== - Used by UniqueVector to locate entry.
|
||||||
///
|
///
|
||||||
@@ -312,24 +315,21 @@ namespace llvm {
|
|||||||
unsigned AbbrevID; // Decribing abbreviation ID.
|
unsigned AbbrevID; // Decribing abbreviation ID.
|
||||||
unsigned Offset; // Offset in debug info section.
|
unsigned Offset; // Offset in debug info section.
|
||||||
unsigned Size; // Size of instance + children.
|
unsigned Size; // Size of instance + children.
|
||||||
DWContext *Context; // Context for types and values.
|
|
||||||
std::vector<DIE *> Children; // Children DIEs.
|
std::vector<DIE *> Children; // Children DIEs.
|
||||||
std::vector<DIEValue *> Values; // Attributes values.
|
std::vector<DIEValue *> Values; // Attributes values.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIE(unsigned Tag, unsigned ChildrenFlag);
|
DIE(unsigned Tag);
|
||||||
~DIE();
|
~DIE();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
unsigned getAbbrevID() const { return AbbrevID; }
|
unsigned getAbbrevID() const { return AbbrevID; }
|
||||||
unsigned getOffset() const { return Offset; }
|
unsigned getOffset() const { return Offset; }
|
||||||
unsigned getSize() const { return Size; }
|
unsigned getSize() const { return Size; }
|
||||||
DWContext *getContext() const { return Context; }
|
|
||||||
const std::vector<DIE *> &getChildren() const { return Children; }
|
const std::vector<DIE *> &getChildren() const { return Children; }
|
||||||
const std::vector<DIEValue *> &getValues() const { return Values; }
|
const std::vector<DIEValue *> &getValues() const { return Values; }
|
||||||
void setOffset(unsigned O) { Offset = O; }
|
void setOffset(unsigned O) { Offset = O; }
|
||||||
void setSize(unsigned S) { Size = S; }
|
void setSize(unsigned S) { Size = S; }
|
||||||
void setContext(DWContext *C) { Context = C; }
|
|
||||||
|
|
||||||
/// SiblingOffset - Return the offset of the debug information entry's
|
/// SiblingOffset - Return the offset of the debug information entry's
|
||||||
/// sibling.
|
/// sibling.
|
||||||
@@ -375,40 +375,6 @@ namespace llvm {
|
|||||||
void AddChild(DIE *Child);
|
void AddChild(DIE *Child);
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
|
||||||
/// DWContext - Name context for types and values.
|
|
||||||
///
|
|
||||||
class DWContext {
|
|
||||||
private:
|
|
||||||
DwarfWriter &DW; // DwarfWriter for global information.
|
|
||||||
DWContext *Parent; // Next context level searched.
|
|
||||||
DIE *Owner; // Owning debug information entry.
|
|
||||||
std::map<const Type *, DIE*> Types; // Named types in context.
|
|
||||||
std::map<std::string, DIE*> Variables;// Named variables in context.
|
|
||||||
|
|
||||||
public:
|
|
||||||
DWContext(DwarfWriter &D, DWContext *P, DIE *O)
|
|
||||||
: DW(D)
|
|
||||||
, Parent(P)
|
|
||||||
, Owner(O)
|
|
||||||
, Types()
|
|
||||||
, Variables()
|
|
||||||
{
|
|
||||||
Owner->setContext(this);
|
|
||||||
}
|
|
||||||
~DWContext() {}
|
|
||||||
|
|
||||||
/// NewBasicType - Creates a new basic type, if necessary, then adds to the
|
|
||||||
/// context and owner.
|
|
||||||
DIE *NewBasicType(const Type *Ty, unsigned Size, unsigned Align);
|
|
||||||
|
|
||||||
/// NewVariable - Creates a basic variable, if necessary, then adds to the
|
|
||||||
/// context and owner.
|
|
||||||
DIE *NewGlobalVariable(const std::string &Name,
|
|
||||||
const std::string &MangledName,
|
|
||||||
DIE *Type);
|
|
||||||
};
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// DwarfWriter - Emits Dwarf debug and exception handling directives.
|
// DwarfWriter - Emits Dwarf debug and exception handling directives.
|
||||||
//
|
//
|
||||||
@@ -460,6 +426,15 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
UniqueVector<std::string> StringPool;
|
UniqueVector<std::string> StringPool;
|
||||||
|
|
||||||
|
/// DescToDieMap - Tracks the mapping of debug informaton descriptors to
|
||||||
|
/// DIES.
|
||||||
|
std::map<DebugInfoDesc *, DIE *> DescToDieMap;
|
||||||
|
|
||||||
|
/// TypeToDieMap - Type to DIEType map.
|
||||||
|
///
|
||||||
|
// FIXME - Should not be needed.
|
||||||
|
std::map<Type *, DIE *> TypeToDieMap;
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// Properties to be set by the derived class ctor, used to configure the
|
// Properties to be set by the derived class ctor, used to configure the
|
||||||
// Dwarf writer.
|
// Dwarf writer.
|
||||||
@@ -637,6 +612,11 @@ public:
|
|||||||
///
|
///
|
||||||
DWLabel NewString(const std::string &String);
|
DWLabel NewString(const std::string &String);
|
||||||
|
|
||||||
|
/// NewBasicType - Creates a new basic type if necessary, then adds to the
|
||||||
|
/// owner.
|
||||||
|
/// FIXME - Should never be needed.
|
||||||
|
DIE *NewBasicType(DIE *Owner, Type *Ty);
|
||||||
|
|
||||||
/// NewGlobalType - Make the type visible globally using the given name.
|
/// NewGlobalType - Make the type visible globally using the given name.
|
||||||
///
|
///
|
||||||
void NewGlobalType(const std::string &Name, DIE *Type);
|
void NewGlobalType(const std::string &Name, DIE *Type);
|
||||||
@@ -645,19 +625,19 @@ public:
|
|||||||
///
|
///
|
||||||
void NewGlobalEntity(const std::string &Name, DIE *Entity);
|
void NewGlobalEntity(const std::string &Name, DIE *Entity);
|
||||||
|
|
||||||
/// NewGlobalVariable - Add a new global variable DIE to the context.
|
|
||||||
///
|
|
||||||
void NewGlobalVariable(DWContext *Context,
|
|
||||||
const std::string &Name,
|
|
||||||
const std::string &MangledName,
|
|
||||||
const Type *Ty,
|
|
||||||
unsigned Size, unsigned Align);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// NewGlobalVariable - Make a new global variable DIE.
|
||||||
|
///
|
||||||
|
DIE *NewGlobalVariable(GlobalVariableDesc *GVD);
|
||||||
|
|
||||||
|
/// NewSubprogram - Add a new subprogram DIE.
|
||||||
|
///
|
||||||
|
DIE *NewSubprogram(SubprogramDesc *SPD);
|
||||||
|
|
||||||
/// NewCompileUnit - Create new compile unit information.
|
/// NewCompileUnit - Create new compile unit information.
|
||||||
///
|
///
|
||||||
DIE *NewCompileUnit(const CompileUnitDesc *CompileUnit);
|
DIE *NewCompileUnit(CompileUnitDesc *CompileUnit);
|
||||||
|
|
||||||
/// EmitInitial - Emit initial Dwarf declarations.
|
/// EmitInitial - Emit initial Dwarf declarations.
|
||||||
///
|
///
|
||||||
@@ -669,7 +649,7 @@ private:
|
|||||||
|
|
||||||
/// SizeAndOffsetDie - Compute the size and offset of a DIE.
|
/// SizeAndOffsetDie - Compute the size and offset of a DIE.
|
||||||
///
|
///
|
||||||
unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset) const;
|
unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset);
|
||||||
|
|
||||||
/// SizeAndOffsets - Compute the size and offset of all the DIEs.
|
/// SizeAndOffsets - Compute the size and offset of all the DIEs.
|
||||||
///
|
///
|
||||||
@@ -723,10 +703,14 @@ private:
|
|||||||
/// header file.
|
/// header file.
|
||||||
void ConstructCompileUnitDIEs();
|
void ConstructCompileUnitDIEs();
|
||||||
|
|
||||||
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible global
|
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible
|
||||||
/// variables.
|
/// global variables.
|
||||||
void ConstructGlobalDIEs(Module &M);
|
void ConstructGlobalDIEs(Module &M);
|
||||||
|
|
||||||
|
/// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
|
||||||
|
/// subprograms.
|
||||||
|
void ConstructSubprogramDIEs(Module &M);
|
||||||
|
|
||||||
/// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
|
/// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
|
||||||
/// When called it also checks to see if debug info is newly available. if
|
/// When called it also checks to see if debug info is newly available. if
|
||||||
/// so the initial Dwarf headers are emitted.
|
/// so the initial Dwarf headers are emitted.
|
||||||
|
@@ -310,13 +310,16 @@ public:
|
|||||||
class GlobalVariableDesc : public GlobalDesc {
|
class GlobalVariableDesc : public GlobalDesc {
|
||||||
private:
|
private:
|
||||||
GlobalVariable *Global; // llvm global.
|
GlobalVariable *Global; // llvm global.
|
||||||
|
unsigned Line; // Source line number.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlobalVariableDesc();
|
GlobalVariableDesc();
|
||||||
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
GlobalVariable *getGlobalVariable() const { return Global; }
|
GlobalVariable *getGlobalVariable() const { return Global; }
|
||||||
|
unsigned getLine() const { return Line; }
|
||||||
void setGlobalVariable(GlobalVariable *GV) { Global = GV; }
|
void setGlobalVariable(GlobalVariable *GV) { Global = GV; }
|
||||||
|
void setLine(unsigned L) { Line = L; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
// Implement isa/cast/dyncast.
|
||||||
static bool classof(const GlobalVariableDesc *) { return true; }
|
static bool classof(const GlobalVariableDesc *) { return true; }
|
||||||
@@ -350,25 +353,12 @@ public:
|
|||||||
/// subprogram/function.
|
/// subprogram/function.
|
||||||
class SubprogramDesc : public GlobalDesc {
|
class SubprogramDesc : public GlobalDesc {
|
||||||
private:
|
private:
|
||||||
DebugInfoDesc *Context; // Context debug descriptor.
|
// FIXME - Other attributes
|
||||||
std::string Name; // Subprogram name.
|
|
||||||
// FIXME - Use a descriptor.
|
|
||||||
GlobalVariable *TyDesc; // Type debug descriptor.
|
|
||||||
bool IsStatic; // Is the subprogram a static.
|
|
||||||
bool IsDefinition; // Is the subprogram defined in context.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SubprogramDesc();
|
SubprogramDesc();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
DebugInfoDesc *getContext() const { return Context; }
|
|
||||||
const std::string &getName() const { return Name; }
|
|
||||||
bool isStatic() const { return IsStatic; }
|
|
||||||
bool isDefinition() const { return IsDefinition; }
|
|
||||||
void setContext(DebugInfoDesc *C) { Context = C; }
|
|
||||||
void setName(const std::string &N) { Name = N; }
|
|
||||||
void setIsStatic(bool IS) { IsStatic = IS; }
|
|
||||||
void setIsDefinition(bool ID) { IsDefinition = ID; }
|
|
||||||
// FIXME - Other getters/setters.
|
// FIXME - Other getters/setters.
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
// Implement isa/cast/dyncast.
|
||||||
@@ -608,6 +598,10 @@ public:
|
|||||||
unsigned DirectoryID = Directories.insert(Directory);
|
unsigned DirectoryID = Directories.insert(Directory);
|
||||||
return SourceFiles.insert(SourceFileInfo(DirectoryID, Source));
|
return SourceFiles.insert(SourceFileInfo(DirectoryID, Source));
|
||||||
}
|
}
|
||||||
|
unsigned RecordSource(const CompileUnitDesc *CompileUnit) {
|
||||||
|
return RecordSource(CompileUnit->getDirectory(),
|
||||||
|
CompileUnit->getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
/// getDirectories - Return the UniqueVector of std::string representing
|
/// getDirectories - Return the UniqueVector of std::string representing
|
||||||
/// directories.
|
/// directories.
|
||||||
@@ -635,9 +629,24 @@ public:
|
|||||||
///
|
///
|
||||||
const UniqueVector<CompileUnitDesc *> getCompileUnits() const;
|
const UniqueVector<CompileUnitDesc *> getCompileUnits() const;
|
||||||
|
|
||||||
/// getGlobalVariables - Return a vector of debug GlobalVariables.
|
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
|
||||||
|
/// named GlobalVariable.
|
||||||
|
std::vector<GlobalVariable*>
|
||||||
|
getGlobalVariablesUsing(Module &M, const std::string &RootName);
|
||||||
|
|
||||||
|
/// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
|
||||||
///
|
///
|
||||||
std::vector<GlobalVariableDesc *> getGlobalVariables(Module &M);
|
template <class T>std::vector<T *> getAnchoredDescriptors(Module &M) {
|
||||||
|
T Desc;
|
||||||
|
std::vector<GlobalVariable *> Globals =
|
||||||
|
getGlobalVariablesUsing(M, Desc.getAnchorString());
|
||||||
|
std::vector<T *> AnchoredDescs;
|
||||||
|
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
||||||
|
AnchoredDescs.push_back(static_cast<T *>(DR.Deserialize(Globals[i])));
|
||||||
|
}
|
||||||
|
|
||||||
|
return AnchoredDescs;
|
||||||
|
}
|
||||||
|
|
||||||
}; // End class MachineDebugInfo
|
}; // End class MachineDebugInfo
|
||||||
|
|
||||||
|
@@ -774,12 +774,11 @@ unsigned DIEntry::SizeOf(const DwarfWriter &DW, unsigned Form) const {
|
|||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
DIE::DIE(unsigned Tag, unsigned ChildrenFlag)
|
DIE::DIE(unsigned Tag)
|
||||||
: Abbrev(new DIEAbbrev(Tag, ChildrenFlag))
|
: Abbrev(new DIEAbbrev(Tag, DW_CHILDREN_no))
|
||||||
, AbbrevID(0)
|
, AbbrevID(0)
|
||||||
, Offset(0)
|
, Offset(0)
|
||||||
, Size(0)
|
, Size(0)
|
||||||
, Context(NULL)
|
|
||||||
, Children()
|
, Children()
|
||||||
, Values()
|
, Values()
|
||||||
{}
|
{}
|
||||||
@@ -794,8 +793,6 @@ DIE::~DIE() {
|
|||||||
for (unsigned j = 0, M = Values.size(); j < M; ++j) {
|
for (unsigned j = 0, M = Values.size(); j < M; ++j) {
|
||||||
delete Values[j];
|
delete Values[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Context) delete Context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AddUInt - Add an unsigned integer attribute data and value.
|
/// AddUInt - Add an unsigned integer attribute data and value.
|
||||||
@@ -875,115 +872,14 @@ void DIE::Complete(DwarfWriter &DW) {
|
|||||||
/// AddChild - Add a child to the DIE.
|
/// AddChild - Add a child to the DIE.
|
||||||
///
|
///
|
||||||
void DIE::AddChild(DIE *Child) {
|
void DIE::AddChild(DIE *Child) {
|
||||||
|
assert(Abbrev && "Adding children without an abbreviation");
|
||||||
|
Abbrev->setChildrenFlag(DW_CHILDREN_yes);
|
||||||
Children.push_back(Child);
|
Children.push_back(Child);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// NewBasicType - Creates a new basic type if necessary, then adds to the
|
/// DWContext
|
||||||
/// context and owner.
|
|
||||||
DIE *DWContext::NewBasicType(const Type *Ty, unsigned Size, unsigned Align) {
|
|
||||||
DIE *TypeDie = Types[Ty];
|
|
||||||
|
|
||||||
// If first occurance of type.
|
|
||||||
if (!TypeDie) {
|
|
||||||
const char *Name;
|
|
||||||
unsigned Encoding = 0;
|
|
||||||
|
|
||||||
switch (Ty->getTypeID()) {
|
|
||||||
case Type::UByteTyID:
|
|
||||||
Name = "unsigned char";
|
|
||||||
Encoding = DW_ATE_unsigned_char;
|
|
||||||
break;
|
|
||||||
case Type::SByteTyID:
|
|
||||||
Name = "char";
|
|
||||||
Encoding = DW_ATE_signed_char;
|
|
||||||
break;
|
|
||||||
case Type::UShortTyID:
|
|
||||||
Name = "unsigned short";
|
|
||||||
Encoding = DW_ATE_unsigned;
|
|
||||||
break;
|
|
||||||
case Type::ShortTyID:
|
|
||||||
Name = "short";
|
|
||||||
Encoding = DW_ATE_signed;
|
|
||||||
break;
|
|
||||||
case Type::UIntTyID:
|
|
||||||
Name = "unsigned int";
|
|
||||||
Encoding = DW_ATE_unsigned;
|
|
||||||
break;
|
|
||||||
case Type::IntTyID:
|
|
||||||
Name = "int";
|
|
||||||
Encoding = DW_ATE_signed;
|
|
||||||
break;
|
|
||||||
case Type::ULongTyID:
|
|
||||||
Name = "unsigned long long";
|
|
||||||
Encoding = DW_ATE_unsigned;
|
|
||||||
break;
|
|
||||||
case Type::LongTyID:
|
|
||||||
Name = "long long";
|
|
||||||
Encoding = DW_ATE_signed;
|
|
||||||
break;
|
|
||||||
case Type::FloatTyID:
|
|
||||||
Name = "float";
|
|
||||||
Encoding = DW_ATE_float;
|
|
||||||
break;
|
|
||||||
case Type::DoubleTyID:
|
|
||||||
Name = "float";
|
|
||||||
Encoding = DW_ATE_float;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// FIXME - handle more complex types.
|
|
||||||
Name = "unknown";
|
|
||||||
Encoding = DW_ATE_address;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// construct the type DIE.
|
|
||||||
TypeDie = new DIE(DW_TAG_base_type, DW_CHILDREN_no);
|
|
||||||
TypeDie->AddString(DW_AT_name, DW_FORM_string, Name);
|
|
||||||
TypeDie->AddUInt (DW_AT_byte_size, 0, Size);
|
|
||||||
TypeDie->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding);
|
|
||||||
TypeDie->Complete(DW);
|
|
||||||
|
|
||||||
// Add to context owner.
|
|
||||||
Owner->AddChild(TypeDie);
|
|
||||||
|
|
||||||
// Add to map.
|
|
||||||
Types[Ty] = TypeDie;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TypeDie;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// NewGlobalVariable - Creates a global variable, if necessary, then adds in
|
|
||||||
/// the context and owner.
|
|
||||||
DIE *DWContext::NewGlobalVariable(const std::string &Name,
|
|
||||||
const std::string &MangledName,
|
|
||||||
DIE *Type) {
|
|
||||||
DIE *VariableDie = Variables[MangledName];
|
|
||||||
|
|
||||||
// If first occurance of variable.
|
|
||||||
if (!VariableDie) {
|
|
||||||
// FIXME - need source file name line number.
|
|
||||||
VariableDie = new DIE(DW_TAG_variable, DW_CHILDREN_no);
|
|
||||||
VariableDie->AddString (DW_AT_name, DW_FORM_string, Name);
|
|
||||||
VariableDie->AddUInt (DW_AT_decl_file, 0, 0);
|
|
||||||
VariableDie->AddUInt (DW_AT_decl_line, 0, 0);
|
|
||||||
VariableDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
|
|
||||||
VariableDie->AddUInt (DW_AT_external, DW_FORM_flag, 1);
|
|
||||||
// FIXME - needs to be a proper expression.
|
|
||||||
VariableDie->AddObjectLabel(DW_AT_location, DW_FORM_block1, MangledName);
|
|
||||||
VariableDie->Complete(DW);
|
|
||||||
|
|
||||||
// Add to context owner.
|
|
||||||
Owner->AddChild(VariableDie);
|
|
||||||
|
|
||||||
// Add to map.
|
|
||||||
Variables[MangledName] = VariableDie;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VariableDie;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@@ -1088,14 +984,14 @@ unsigned DwarfWriter::SizeSLEB128(int Value) {
|
|||||||
///
|
///
|
||||||
void DwarfWriter::EmitInt8(int Value) const {
|
void DwarfWriter::EmitInt8(int Value) const {
|
||||||
O << Asm->Data8bitsDirective;
|
O << Asm->Data8bitsDirective;
|
||||||
PrintHex(Value);
|
PrintHex(Value & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitInt16 - Emit a short directive and value.
|
/// EmitInt16 - Emit a short directive and value.
|
||||||
///
|
///
|
||||||
void DwarfWriter::EmitInt16(int Value) const {
|
void DwarfWriter::EmitInt16(int Value) const {
|
||||||
O << Asm->Data16bitsDirective;
|
O << Asm->Data16bitsDirective;
|
||||||
PrintHex(Value);
|
PrintHex(Value & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitInt32 - Emit a long directive and value.
|
/// EmitInt32 - Emit a long directive and value.
|
||||||
@@ -1161,8 +1057,8 @@ void DwarfWriter::EmitString(const std::string &String) const {
|
|||||||
void DwarfWriter::PrintLabelName(const char *Tag, unsigned Number) const {
|
void DwarfWriter::PrintLabelName(const char *Tag, unsigned Number) const {
|
||||||
O << Asm->PrivateGlobalPrefix
|
O << Asm->PrivateGlobalPrefix
|
||||||
<< "debug_"
|
<< "debug_"
|
||||||
<< Tag
|
<< Tag;
|
||||||
<< Number;
|
if (Number) O << Number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitLabel - Emit location label for internal use by Dwarf.
|
/// EmitLabel - Emit location label for internal use by Dwarf.
|
||||||
@@ -1240,6 +1136,88 @@ DWLabel DwarfWriter::NewString(const std::string &String) {
|
|||||||
return DWLabel("string", StringID);
|
return DWLabel("string", StringID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// NewBasicType - Creates a new basic type if necessary, then adds to the
|
||||||
|
/// owner.
|
||||||
|
/// FIXME - Should never be needed.
|
||||||
|
DIE *DwarfWriter::NewBasicType(DIE *Owner, Type *Ty) {
|
||||||
|
DIE *&Slot = TypeToDieMap[Ty];
|
||||||
|
if (Slot) return Slot;
|
||||||
|
|
||||||
|
const char *Name;
|
||||||
|
unsigned Size;
|
||||||
|
unsigned Encoding = 0;
|
||||||
|
|
||||||
|
switch (Ty->getTypeID()) {
|
||||||
|
case Type::UByteTyID:
|
||||||
|
Name = "unsigned char";
|
||||||
|
Size = 1;
|
||||||
|
Encoding = DW_ATE_unsigned_char;
|
||||||
|
break;
|
||||||
|
case Type::SByteTyID:
|
||||||
|
Name = "char";
|
||||||
|
Size = 1;
|
||||||
|
Encoding = DW_ATE_signed_char;
|
||||||
|
break;
|
||||||
|
case Type::UShortTyID:
|
||||||
|
Name = "unsigned short";
|
||||||
|
Size = 2;
|
||||||
|
Encoding = DW_ATE_unsigned;
|
||||||
|
break;
|
||||||
|
case Type::ShortTyID:
|
||||||
|
Name = "short";
|
||||||
|
Size = 2;
|
||||||
|
Encoding = DW_ATE_signed;
|
||||||
|
break;
|
||||||
|
case Type::UIntTyID:
|
||||||
|
Name = "unsigned int";
|
||||||
|
Size = 4;
|
||||||
|
Encoding = DW_ATE_unsigned;
|
||||||
|
break;
|
||||||
|
case Type::IntTyID:
|
||||||
|
Name = "int";
|
||||||
|
Size = 4;
|
||||||
|
Encoding = DW_ATE_signed;
|
||||||
|
break;
|
||||||
|
case Type::ULongTyID:
|
||||||
|
Name = "unsigned long long";
|
||||||
|
Size = 7;
|
||||||
|
Encoding = DW_ATE_unsigned;
|
||||||
|
break;
|
||||||
|
case Type::LongTyID:
|
||||||
|
Name = "long long";
|
||||||
|
Size = 7;
|
||||||
|
Encoding = DW_ATE_signed;
|
||||||
|
break;
|
||||||
|
case Type::FloatTyID:
|
||||||
|
Name = "float";
|
||||||
|
Size = 4;
|
||||||
|
Encoding = DW_ATE_float;
|
||||||
|
break;
|
||||||
|
case Type::DoubleTyID:
|
||||||
|
Name = "double";
|
||||||
|
Size = 8;
|
||||||
|
Encoding = DW_ATE_float;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// FIXME - handle more complex types.
|
||||||
|
Name = "unknown";
|
||||||
|
Size = 1;
|
||||||
|
Encoding = DW_ATE_address;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// construct the type DIE.
|
||||||
|
Slot = new DIE(DW_TAG_base_type);
|
||||||
|
Slot->AddString(DW_AT_name, DW_FORM_string, Name);
|
||||||
|
Slot->AddUInt (DW_AT_byte_size, 0, Size);
|
||||||
|
Slot->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding);
|
||||||
|
|
||||||
|
// Add to context owner.
|
||||||
|
Owner->AddChild(Slot);
|
||||||
|
|
||||||
|
return Slot;
|
||||||
|
}
|
||||||
|
|
||||||
/// NewGlobalType - Make the type visible globally using the given name.
|
/// NewGlobalType - Make the type visible globally using the given name.
|
||||||
///
|
///
|
||||||
void DwarfWriter::NewGlobalType(const std::string &Name, DIE *Type) {
|
void DwarfWriter::NewGlobalType(const std::string &Name, DIE *Type) {
|
||||||
@@ -1254,49 +1232,142 @@ void DwarfWriter::NewGlobalEntity(const std::string &Name, DIE *Entity) {
|
|||||||
GlobalEntities[Name] = Entity;
|
GlobalEntities[Name] = Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NewGlobalVariable - Add a new global variable DIE to the context.
|
|
||||||
///
|
|
||||||
void DwarfWriter::NewGlobalVariable(DWContext *Context,
|
|
||||||
const std::string &Name,
|
|
||||||
const std::string &MangledName,
|
|
||||||
const Type *Ty,
|
|
||||||
unsigned Size, unsigned Align) {
|
|
||||||
// Get the DIE type for the global.
|
|
||||||
DIE *Type = Context->NewBasicType(Ty, Size, Align);
|
|
||||||
DIE *Variable = Context->NewGlobalVariable(Name, MangledName, Type);
|
|
||||||
NewGlobalEntity(Name, Variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// NewCompileUnit - Create new compile unit information.
|
/// NewCompileUnit - Create new compile unit information.
|
||||||
///
|
///
|
||||||
DIE *DwarfWriter::NewCompileUnit(const CompileUnitDesc *CompileUnit) {
|
DIE *DwarfWriter::NewCompileUnit(CompileUnitDesc *CompileUnit) {
|
||||||
DIE *Unit = new DIE(DW_TAG_compile_unit, DW_CHILDREN_yes);
|
// Check for pre-existence.
|
||||||
|
DIE *&Slot = DescToDieMap[CompileUnit];
|
||||||
|
if (Slot) return Slot;
|
||||||
|
|
||||||
|
DIE *Unit = new DIE(DW_TAG_compile_unit);
|
||||||
// FIXME - use the correct line set.
|
// FIXME - use the correct line set.
|
||||||
Unit->AddLabel (DW_AT_stmt_list, DW_FORM_data4, DWLabel("line", 0));
|
Unit->AddLabel (DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0));
|
||||||
Unit->AddLabel (DW_AT_high_pc, DW_FORM_addr, DWLabel("text_end", 0));
|
Unit->AddLabel (DW_AT_high_pc, DW_FORM_addr, DWLabel("text_end", 0));
|
||||||
Unit->AddLabel (DW_AT_low_pc, DW_FORM_addr, DWLabel("text_begin", 0));
|
Unit->AddLabel (DW_AT_low_pc, DW_FORM_addr, DWLabel("text_begin", 0));
|
||||||
Unit->AddString(DW_AT_producer, DW_FORM_string, CompileUnit->getProducer());
|
Unit->AddString(DW_AT_producer, DW_FORM_string, CompileUnit->getProducer());
|
||||||
Unit->AddUInt (DW_AT_language, DW_FORM_data1, CompileUnit->getLanguage());
|
Unit->AddUInt (DW_AT_language, DW_FORM_data1, CompileUnit->getLanguage());
|
||||||
Unit->AddString(DW_AT_name, DW_FORM_string, CompileUnit->getFileName());
|
Unit->AddString(DW_AT_name, DW_FORM_string, CompileUnit->getFileName());
|
||||||
Unit->AddString(DW_AT_comp_dir, DW_FORM_string, CompileUnit->getDirectory());
|
Unit->AddString(DW_AT_comp_dir, DW_FORM_string, CompileUnit->getDirectory());
|
||||||
Unit->Complete(*this);
|
|
||||||
|
Slot = Unit;
|
||||||
|
|
||||||
return Unit;
|
return Unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// NewGlobalVariable - Add a new global variable DIE.
|
||||||
|
///
|
||||||
|
DIE *DwarfWriter::NewGlobalVariable(GlobalVariableDesc *GVD) {
|
||||||
|
// Check for pre-existence.
|
||||||
|
DIE *&Slot = DescToDieMap[GVD];
|
||||||
|
if (Slot) return Slot;
|
||||||
|
|
||||||
|
// Get the compile unit context.
|
||||||
|
CompileUnitDesc *CompileUnit =
|
||||||
|
static_cast<CompileUnitDesc *>(GVD->getContext());
|
||||||
|
DIE *Unit = NewCompileUnit(CompileUnit);
|
||||||
|
// Get the global variable itself.
|
||||||
|
GlobalVariable *GV = GVD->getGlobalVariable();
|
||||||
|
// Generate the mangled name.
|
||||||
|
std::string MangledName = Asm->Mang->getValueName(GV);
|
||||||
|
|
||||||
|
// Gather the details (simplify add attribute code.)
|
||||||
|
const std::string &Name = GVD->getName();
|
||||||
|
unsigned FileID = DebugInfo->RecordSource(CompileUnit);
|
||||||
|
unsigned Line = GVD->getLine();
|
||||||
|
|
||||||
|
// FIXME - faking the type for the time being.
|
||||||
|
DIE *Type = NewBasicType(Unit, Type::IntTy);
|
||||||
|
|
||||||
|
DIE *VariableDie = new DIE(DW_TAG_variable);
|
||||||
|
VariableDie->AddString (DW_AT_name, DW_FORM_string, Name);
|
||||||
|
VariableDie->AddUInt (DW_AT_decl_file, 0, FileID);
|
||||||
|
VariableDie->AddUInt (DW_AT_decl_line, 0, Line);
|
||||||
|
VariableDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
|
||||||
|
VariableDie->AddUInt (DW_AT_external, DW_FORM_flag, 1);
|
||||||
|
// FIXME - needs to be a proper expression.
|
||||||
|
VariableDie->AddObjectLabel(DW_AT_location, DW_FORM_block1, MangledName);
|
||||||
|
|
||||||
|
// Add to map.
|
||||||
|
Slot = VariableDie;
|
||||||
|
|
||||||
|
// Add to context owner.
|
||||||
|
Unit->AddChild(VariableDie);
|
||||||
|
|
||||||
|
// Expose as global.
|
||||||
|
NewGlobalEntity(Name, VariableDie);
|
||||||
|
|
||||||
|
return VariableDie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// NewSubprogram - Add a new subprogram DIE.
|
||||||
|
///
|
||||||
|
DIE *DwarfWriter::NewSubprogram(SubprogramDesc *SPD) {
|
||||||
|
// Check for pre-existence.
|
||||||
|
DIE *&Slot = DescToDieMap[SPD];
|
||||||
|
if (Slot) return Slot;
|
||||||
|
|
||||||
|
// Get the compile unit context.
|
||||||
|
CompileUnitDesc *CompileUnit =
|
||||||
|
static_cast<CompileUnitDesc *>(SPD->getContext());
|
||||||
|
DIE *Unit = NewCompileUnit(CompileUnit);
|
||||||
|
|
||||||
|
// Gather the details (simplify add attribute code.)
|
||||||
|
const std::string &Name = SPD->getName();
|
||||||
|
unsigned FileID = DebugInfo->RecordSource(CompileUnit);
|
||||||
|
// FIXME - faking the line for the time being.
|
||||||
|
unsigned Line = 1;
|
||||||
|
|
||||||
|
// FIXME - faking the type for the time being.
|
||||||
|
DIE *Type = NewBasicType(Unit, Type::IntTy);
|
||||||
|
|
||||||
|
DIE *SubprogramDie = new DIE(DW_TAG_variable);
|
||||||
|
SubprogramDie->AddString (DW_AT_name, DW_FORM_string, Name);
|
||||||
|
SubprogramDie->AddUInt (DW_AT_decl_file, 0, FileID);
|
||||||
|
SubprogramDie->AddUInt (DW_AT_decl_line, 0, Line);
|
||||||
|
SubprogramDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
|
||||||
|
SubprogramDie->AddUInt (DW_AT_external, DW_FORM_flag, 1);
|
||||||
|
|
||||||
|
// Add to map.
|
||||||
|
Slot = SubprogramDie;
|
||||||
|
|
||||||
|
// Add to context owner.
|
||||||
|
Unit->AddChild(SubprogramDie);
|
||||||
|
|
||||||
|
// Expose as global.
|
||||||
|
NewGlobalEntity(Name, SubprogramDie);
|
||||||
|
|
||||||
|
return SubprogramDie;
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc
|
/// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc
|
||||||
/// tools to recognize the object file contains Dwarf information.
|
/// tools to recognize the object file contains Dwarf information.
|
||||||
///
|
///
|
||||||
void DwarfWriter::EmitInitial() const {
|
void DwarfWriter::EmitInitial() const {
|
||||||
// Dwarf sections base addresses.
|
// Dwarf sections base addresses.
|
||||||
Asm->SwitchSection(DwarfAbbrevSection, 0);
|
Asm->SwitchSection(DwarfFrameSection, 0);
|
||||||
EmitLabel("abbrev", 0);
|
EmitLabel("section_frame", 0);
|
||||||
Asm->SwitchSection(DwarfInfoSection, 0);
|
Asm->SwitchSection(DwarfInfoSection, 0);
|
||||||
|
EmitLabel("section_info", 0);
|
||||||
EmitLabel("info", 0);
|
EmitLabel("info", 0);
|
||||||
|
Asm->SwitchSection(DwarfAbbrevSection, 0);
|
||||||
|
EmitLabel("section_abbrev", 0);
|
||||||
|
EmitLabel("abbrev", 0);
|
||||||
|
Asm->SwitchSection(DwarfARangesSection, 0);
|
||||||
|
EmitLabel("section_aranges", 0);
|
||||||
|
Asm->SwitchSection(DwarfMacInfoSection, 0);
|
||||||
|
EmitLabel("section_macinfo", 0);
|
||||||
Asm->SwitchSection(DwarfLineSection, 0);
|
Asm->SwitchSection(DwarfLineSection, 0);
|
||||||
|
EmitLabel("section_line", 0);
|
||||||
EmitLabel("line", 0);
|
EmitLabel("line", 0);
|
||||||
|
Asm->SwitchSection(DwarfLocSection, 0);
|
||||||
|
EmitLabel("section_loc", 0);
|
||||||
|
Asm->SwitchSection(DwarfPubNamesSection, 0);
|
||||||
|
EmitLabel("section_pubnames", 0);
|
||||||
|
Asm->SwitchSection(DwarfStrSection, 0);
|
||||||
|
EmitLabel("section_str", 0);
|
||||||
|
Asm->SwitchSection(DwarfRangesSection, 0);
|
||||||
|
EmitLabel("section_ranges", 0);
|
||||||
|
|
||||||
// Standard sections base addresses.
|
|
||||||
Asm->SwitchSection(TextSection, 0);
|
Asm->SwitchSection(TextSection, 0);
|
||||||
EmitLabel("text_begin", 0);
|
EmitLabel("text_begin", 0);
|
||||||
Asm->SwitchSection(DataSection, 0);
|
Asm->SwitchSection(DataSection, 0);
|
||||||
@@ -1358,7 +1429,10 @@ void DwarfWriter::EmitDIE(DIE *Die) const {
|
|||||||
|
|
||||||
/// SizeAndOffsetDie - Compute the size and offset of a DIE.
|
/// SizeAndOffsetDie - Compute the size and offset of a DIE.
|
||||||
///
|
///
|
||||||
unsigned DwarfWriter::SizeAndOffsetDie(DIE *Die, unsigned Offset) const {
|
unsigned DwarfWriter::SizeAndOffsetDie(DIE *Die, unsigned Offset) {
|
||||||
|
// Record the abbreviation.
|
||||||
|
Die->Complete(*this);
|
||||||
|
|
||||||
// Get the abbreviation for this DIE.
|
// Get the abbreviation for this DIE.
|
||||||
unsigned AbbrevID = Die->getAbbrevID();
|
unsigned AbbrevID = Die->getAbbrevID();
|
||||||
const DIEAbbrev &Abbrev = Abbreviations[AbbrevID];
|
const DIEAbbrev &Abbrev = Abbreviations[AbbrevID];
|
||||||
@@ -1551,6 +1625,17 @@ void DwarfWriter::EmitDebugLines() const {
|
|||||||
for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
|
for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
|
||||||
SourceLineInfo *LineInfo = LineInfos[i];
|
SourceLineInfo *LineInfo = LineInfos[i];
|
||||||
|
|
||||||
|
if (DwarfVerbose) {
|
||||||
|
unsigned SourceID = LineInfo->getSourceID();
|
||||||
|
const SourceFileInfo &SourceFile = SourceFiles[SourceID];
|
||||||
|
unsigned DirectoryID = SourceFile.getDirectoryID();
|
||||||
|
O << "\t"
|
||||||
|
<< Asm->CommentString << " "
|
||||||
|
<< Directories[DirectoryID]
|
||||||
|
<< SourceFile.getName() << ":"
|
||||||
|
<< LineInfo->getLine() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Define the line address.
|
// Define the line address.
|
||||||
EmitInt8(0); EOL("Extended Op");
|
EmitInt8(0); EOL("Extended Op");
|
||||||
EmitInt8(4 + 1); EOL("Op size");
|
EmitInt8(4 + 1); EOL("Op size");
|
||||||
@@ -1589,6 +1674,12 @@ void DwarfWriter::EmitDebugLines() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define last address.
|
||||||
|
EmitInt8(0); EOL("Extended Op");
|
||||||
|
EmitInt8(4 + 1); EOL("Op size");
|
||||||
|
EmitInt8(DW_LNE_set_address); EOL("DW_LNE_set_address");
|
||||||
|
EmitReference("text_end", 0); EOL("Location label");
|
||||||
|
|
||||||
// Mark end of matrix.
|
// Mark end of matrix.
|
||||||
EmitInt8(0); EOL("DW_LNE_end_sequence");
|
EmitInt8(0); EOL("DW_LNE_end_sequence");
|
||||||
EmitULEB128Bytes(1); O << "\n";
|
EmitULEB128Bytes(1); O << "\n";
|
||||||
@@ -1727,7 +1818,6 @@ void DwarfWriter::ConstructCompileUnitDIEs() {
|
|||||||
|
|
||||||
for (unsigned i = 1, N = CUW.size(); i <= N; ++i) {
|
for (unsigned i = 1, N = CUW.size(); i <= N; ++i) {
|
||||||
DIE *Unit = NewCompileUnit(CUW[i]);
|
DIE *Unit = NewCompileUnit(CUW[i]);
|
||||||
DWContext *Context = new DWContext(*this, NULL, Unit);
|
|
||||||
CompileUnits.push_back(Unit);
|
CompileUnits.push_back(Unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1735,39 +1825,26 @@ void DwarfWriter::ConstructCompileUnitDIEs() {
|
|||||||
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible global
|
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible global
|
||||||
/// variables.
|
/// variables.
|
||||||
void DwarfWriter::ConstructGlobalDIEs(Module &M) {
|
void DwarfWriter::ConstructGlobalDIEs(Module &M) {
|
||||||
const TargetData &TD = Asm->TM.getTargetData();
|
|
||||||
|
|
||||||
std::vector<GlobalVariableDesc *> GlobalVariables =
|
std::vector<GlobalVariableDesc *> GlobalVariables =
|
||||||
DebugInfo->getGlobalVariables(M);
|
DebugInfo->getAnchoredDescriptors<GlobalVariableDesc>(M);
|
||||||
|
|
||||||
for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) {
|
for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) {
|
||||||
GlobalVariableDesc *GVD = GlobalVariables[i];
|
GlobalVariableDesc *GVD = GlobalVariables[i];
|
||||||
GlobalVariable *GV = GVD->getGlobalVariable();
|
NewGlobalVariable(GVD);
|
||||||
|
|
||||||
if (!GV->hasInitializer()) continue; // External global require no code
|
|
||||||
|
|
||||||
// FIXME - Use global info type information when available.
|
|
||||||
std::string Name = Asm->Mang->getValueName(GV);
|
|
||||||
Constant *C = GV->getInitializer();
|
|
||||||
const Type *Ty = C->getType();
|
|
||||||
unsigned Size = TD.getTypeSize(Ty);
|
|
||||||
unsigned Align = TD.getTypeAlignmentShift(Ty);
|
|
||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
|
||||||
(GV->hasInternalLinkage() || GV->hasWeakLinkage() ||
|
|
||||||
GV->hasLinkOnceLinkage())) {
|
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// FIXME - Get correct compile unit context.
|
|
||||||
assert(CompileUnits.size() && "No compile units");
|
|
||||||
DWContext *Context = CompileUnits[0]->getContext();
|
|
||||||
|
|
||||||
/// Create new global.
|
|
||||||
NewGlobalVariable(Context, GV->getName(), Name, Ty, Size, Align);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ConstructSubprogramDIEs - Create DIEs for each of the externally visible
|
||||||
|
/// subprograms.
|
||||||
|
void DwarfWriter::ConstructSubprogramDIEs(Module &M) {
|
||||||
|
std::vector<SubprogramDesc *> Subprograms =
|
||||||
|
DebugInfo->getAnchoredDescriptors<SubprogramDesc>(M);
|
||||||
|
|
||||||
|
for (unsigned i = 0, N = Subprograms.size(); i < N; ++i) {
|
||||||
|
SubprogramDesc *SPD = Subprograms[i];
|
||||||
|
NewSubprogram(SPD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// ShouldEmitDwarf - Determine if Dwarf declarations should be made.
|
/// ShouldEmitDwarf - Determine if Dwarf declarations should be made.
|
||||||
///
|
///
|
||||||
@@ -1799,6 +1876,8 @@ DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A)
|
|||||||
, GlobalTypes()
|
, GlobalTypes()
|
||||||
, GlobalEntities()
|
, GlobalEntities()
|
||||||
, StringPool()
|
, StringPool()
|
||||||
|
, DescToDieMap()
|
||||||
|
, TypeToDieMap()
|
||||||
, AddressSize(sizeof(int32_t))
|
, AddressSize(sizeof(int32_t))
|
||||||
, hasLEB128(false)
|
, hasLEB128(false)
|
||||||
, hasDotLoc(false)
|
, hasDotLoc(false)
|
||||||
@@ -1849,6 +1928,9 @@ void DwarfWriter::EndModule(Module &M) {
|
|||||||
// Create DIEs for each of the externally visible global variables.
|
// Create DIEs for each of the externally visible global variables.
|
||||||
ConstructGlobalDIEs(M);
|
ConstructGlobalDIEs(M);
|
||||||
|
|
||||||
|
// Create DIEs for each of the externally visible subprograms.
|
||||||
|
ConstructSubprogramDIEs(M);
|
||||||
|
|
||||||
// Compute DIE offsets and sizes.
|
// Compute DIE offsets and sizes.
|
||||||
SizeAndOffsets();
|
SizeAndOffsets();
|
||||||
|
|
||||||
|
@@ -579,6 +579,7 @@ void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) {
|
|||||||
GlobalDesc::ApplyToFields(Visitor);
|
GlobalDesc::ApplyToFields(Visitor);
|
||||||
|
|
||||||
Visitor->Apply(Global);
|
Visitor->Apply(Global);
|
||||||
|
Visitor->Apply(Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getDescString - Return a string used to compose global names and labels.
|
/// getDescString - Return a string used to compose global names and labels.
|
||||||
@@ -607,7 +608,8 @@ void GlobalVariableDesc::dump() {
|
|||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
<< "IsStatic(" << (isStatic() ? "true" : "false") << "), "
|
<< "IsStatic(" << (isStatic() ? "true" : "false") << "), "
|
||||||
<< "IsDefinition(" << (isDefinition() ? "true" : "false") << "), "
|
<< "IsDefinition(" << (isDefinition() ? "true" : "false") << "), "
|
||||||
<< "Global(" << Global << ")\n";
|
<< "Global(" << Global << "), "
|
||||||
|
<< "Line(" << Line << ")\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -910,16 +912,10 @@ void MachineDebugInfo::AnalyzeModule(Module &M) {
|
|||||||
/// SetupCompileUnits - Set up the unique vector of compile units.
|
/// SetupCompileUnits - Set up the unique vector of compile units.
|
||||||
///
|
///
|
||||||
void MachineDebugInfo::SetupCompileUnits(Module &M) {
|
void MachineDebugInfo::SetupCompileUnits(Module &M) {
|
||||||
// Get vector of all debug compile units.
|
std::vector<CompileUnitDesc *>CU = getAnchoredDescriptors<CompileUnitDesc>(M);
|
||||||
CompileUnitDesc CompileUnit;
|
|
||||||
std::vector<GlobalVariable*> Globals =
|
|
||||||
getGlobalVariablesUsing(M, CompileUnit.getAnchorString());
|
|
||||||
|
|
||||||
// Scan all compile unit globals.
|
for (unsigned i = 0, N = CU.size(); i < N; i++) {
|
||||||
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
CompileUnits.insert(CU[i]);
|
||||||
// Add compile unit to result.
|
|
||||||
CompileUnits.insert(
|
|
||||||
static_cast<CompileUnitDesc *>(DR.Deserialize(Globals[i])));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -929,26 +925,10 @@ const UniqueVector<CompileUnitDesc *> MachineDebugInfo::getCompileUnits()const{
|
|||||||
return CompileUnits;
|
return CompileUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getGlobalVariables - Return a vector of debug GlobalVariables.
|
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
|
||||||
///
|
/// named GlobalVariable.
|
||||||
std::vector<GlobalVariableDesc *>
|
std::vector<GlobalVariable*>
|
||||||
MachineDebugInfo::getGlobalVariables(Module &M) {
|
MachineDebugInfo::getGlobalVariablesUsing(Module &M,
|
||||||
// Get vector of all debug global objects.
|
const std::string &RootName) {
|
||||||
GlobalVariableDesc Global;
|
return ::getGlobalVariablesUsing(M, RootName);
|
||||||
std::vector<GlobalVariable*> Globals =
|
|
||||||
getGlobalVariablesUsing(M, Global.getAnchorString());
|
|
||||||
|
|
||||||
// Accumulation of GlobalVariables.
|
|
||||||
std::vector<GlobalVariableDesc *> GlobalVariables;
|
|
||||||
|
|
||||||
// Scan all globals.
|
|
||||||
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
|
||||||
GlobalVariable *GV = Globals[i];
|
|
||||||
GlobalVariableDesc *GVD =
|
|
||||||
static_cast<GlobalVariableDesc *>(DR.Deserialize(GV));
|
|
||||||
GlobalVariables.push_back(GVD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GlobalVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -223,18 +223,17 @@ namespace {
|
|||||||
: DwarfWriter(o, ap)
|
: DwarfWriter(o, ap)
|
||||||
{
|
{
|
||||||
needsSet = true;
|
needsSet = true;
|
||||||
DwarfAbbrevSection = ".section __DWARF,__debug_abbrev";
|
DwarfAbbrevSection = ".section __DWARFA,__debug_abbrev";
|
||||||
DwarfInfoSection = ".section __DWARF,__debug_info";
|
DwarfInfoSection = ".section __DWARFA,__debug_info";
|
||||||
DwarfLineSection = ".section __DWARF,__debug_line";
|
DwarfLineSection = ".section __DWARFA,__debug_line";
|
||||||
DwarfFrameSection =
|
DwarfFrameSection = ".section __DWARFA,__debug_frame";
|
||||||
".section __DWARF,__debug_frame,,coalesced,no_toc+strip_static_syms";
|
DwarfPubNamesSection = ".section __DWARFA,__debug_pubnames";
|
||||||
DwarfPubNamesSection = ".section __DWARF,__debug_pubnames";
|
DwarfPubTypesSection = ".section __DWARFA,__debug_pubtypes";
|
||||||
DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes";
|
DwarfStrSection = ".section __DWARFA,__debug_str";
|
||||||
DwarfStrSection = ".section __DWARF,__debug_str";
|
DwarfLocSection = ".section __DWARFA,__debug_loc";
|
||||||
DwarfLocSection = ".section __DWARF,__debug_loc";
|
DwarfARangesSection = ".section __DWARFA,__debug_aranges";
|
||||||
DwarfARangesSection = ".section __DWARF,__debug_aranges";
|
DwarfRangesSection = ".section __DWARFA,__debug_ranges";
|
||||||
DwarfRangesSection = ".section __DWARF,__debug_ranges";
|
DwarfMacInfoSection = ".section __DWARFA,__debug_macinfo";
|
||||||
DwarfMacInfoSection = ".section __DWARF,__debug_macinfo";
|
|
||||||
TextSection = ".text";
|
TextSection = ".text";
|
||||||
DataSection = ".data";
|
DataSection = ".data";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user