mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-18 17:39:04 +00:00
Expand subprogram and added block descriptor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26782 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
26c2e73da6
commit
9d0ff8e6f9
@ -55,7 +55,7 @@ class StructType;
|
||||
// Debug info constants.
|
||||
|
||||
enum {
|
||||
LLVMDebugVersion = 1 // Current version of debug information.
|
||||
LLVMDebugVersion = 2 // Current version of debug information.
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -274,8 +274,8 @@ class TypeDesc : public DebugInfoDesc {
|
||||
private:
|
||||
DebugInfoDesc *Context; // Context debug descriptor.
|
||||
std::string Name; // Type name (may be empty.)
|
||||
CompileUnitDesc *File; // Declared compile unit (may be NULL.)
|
||||
int Line; // Declared line# (may be zero.)
|
||||
CompileUnitDesc *File; // Defined compile unit (may be NULL.)
|
||||
unsigned Line; // Defined line# (may be zero.)
|
||||
uint64_t Size; // Type bit size (may be zero.)
|
||||
uint64_t Align; // Type bit alignment (may be zero.)
|
||||
uint64_t Offset; // Type bit offset (may be zero.)
|
||||
@ -287,14 +287,14 @@ public:
|
||||
DebugInfoDesc *getContext() const { return Context; }
|
||||
const std::string &getName() const { return Name; }
|
||||
CompileUnitDesc *getFile() const { return File; }
|
||||
int getLine() const { return Line; }
|
||||
unsigned getLine() const { return Line; }
|
||||
uint64_t getSize() const { return Size; }
|
||||
uint64_t getAlign() const { return Align; }
|
||||
uint64_t getOffset() const { return Offset; }
|
||||
void setContext(DebugInfoDesc *C) { Context = C; }
|
||||
void setName(const std::string &N) { Name = N; }
|
||||
void setFile(CompileUnitDesc *U) { File = U; }
|
||||
void setLine(int L) { Line = L; }
|
||||
void setLine(unsigned L) { Line = L; }
|
||||
void setSize(uint64_t S) { Size = S; }
|
||||
void setAlign(uint64_t A) { Align = A; }
|
||||
void setOffset(uint64_t O) { Offset = O; }
|
||||
@ -504,6 +504,8 @@ class GlobalDesc : public AnchoredDesc {
|
||||
private:
|
||||
DebugInfoDesc *Context; // Context debug descriptor.
|
||||
std::string Name; // Global name.
|
||||
CompileUnitDesc *File; // Defined compile unit (may be NULL.)
|
||||
unsigned Line; // Defined line# (may be zero.)
|
||||
TypeDesc *TyDesc; // Type debug descriptor.
|
||||
bool IsStatic; // Is the global a static.
|
||||
bool IsDefinition; // Is the global defined in context.
|
||||
@ -515,11 +517,15 @@ public:
|
||||
// Accessors
|
||||
DebugInfoDesc *getContext() const { return Context; }
|
||||
const std::string &getName() const { return Name; }
|
||||
CompileUnitDesc *getFile() const { return File; }
|
||||
unsigned getLine() const { return Line; }
|
||||
TypeDesc *getTypeDesc() const { return TyDesc; }
|
||||
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 setFile(CompileUnitDesc *U) { File = U; }
|
||||
void setLine(unsigned L) { Line = L; }
|
||||
void setTypeDesc(TypeDesc *T) { TyDesc = T; }
|
||||
void setIsStatic(bool IS) { IsStatic = IS; }
|
||||
void setIsDefinition(bool ID) { IsDefinition = ID; }
|
||||
@ -535,16 +541,13 @@ public:
|
||||
class GlobalVariableDesc : public GlobalDesc {
|
||||
private:
|
||||
GlobalVariable *Global; // llvm global.
|
||||
unsigned Line; // Source line number.
|
||||
|
||||
public:
|
||||
GlobalVariableDesc();
|
||||
|
||||
// Accessors.
|
||||
GlobalVariable *getGlobalVariable() const { return Global; }
|
||||
unsigned getLine() const { return Line; }
|
||||
void setGlobalVariable(GlobalVariable *GV) { Global = GV; }
|
||||
void setLine(unsigned L) { Line = L; }
|
||||
|
||||
// Implement isa/cast/dyncast.
|
||||
static bool classof(const GlobalVariableDesc *) { return true; }
|
||||
@ -577,19 +580,20 @@ public:
|
||||
/// subprogram/function.
|
||||
class SubprogramDesc : public GlobalDesc {
|
||||
private:
|
||||
// FIXME - Other attributes
|
||||
std::vector<DebugInfoDesc *> Elements;// Information about args, variables
|
||||
// and blocks.
|
||||
|
||||
public:
|
||||
SubprogramDesc();
|
||||
|
||||
// Accessors
|
||||
// FIXME - Other getters/setters.
|
||||
std::vector<DebugInfoDesc *> &getElements() { return Elements; }
|
||||
|
||||
// Implement isa/cast/dyncast.
|
||||
static bool classof(const SubprogramDesc *) { return true; }
|
||||
static bool classof(const DebugInfoDesc *D);
|
||||
|
||||
/// ApplyToFields - Target the visitor to the fields of the SubprogramDesc.
|
||||
/// ApplyToFields - Target the visitor to the fields of the SubprogramDesc.
|
||||
///
|
||||
virtual void ApplyToFields(DIVisitor *Visitor);
|
||||
|
||||
@ -611,6 +615,40 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// BlockDesc - This descriptor groups variables and blocks nested in a block.
|
||||
///
|
||||
class BlockDesc : public DebugInfoDesc {
|
||||
private:
|
||||
std::vector<DebugInfoDesc *> Elements;// Information about nested variables
|
||||
// and blocks.
|
||||
public:
|
||||
BlockDesc();
|
||||
|
||||
// Accessors
|
||||
std::vector<DebugInfoDesc *> &getElements() { return Elements; }
|
||||
|
||||
// Implement isa/cast/dyncast.
|
||||
static bool classof(const BlockDesc *) { return true; }
|
||||
static bool classof(const DebugInfoDesc *D);
|
||||
|
||||
/// ApplyToFields - Target the visitor to the fields of the BlockDesc.
|
||||
///
|
||||
virtual void ApplyToFields(DIVisitor *Visitor);
|
||||
|
||||
/// getDescString - Return a string used to compose global names and labels.
|
||||
///
|
||||
virtual const char *getDescString() const;
|
||||
|
||||
/// getTypeString - Return a string used to label this descriptor's type.
|
||||
///
|
||||
virtual const char *getTypeString() const;
|
||||
|
||||
#ifndef NDEBUG
|
||||
virtual void dump();
|
||||
#endif
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// DIDeserializer - This class is responsible for casting GlobalVariables
|
||||
/// into DebugInfoDesc objects.
|
||||
|
@ -1518,19 +1518,19 @@ DIE *DwarfWriter::NewSubprogram(SubprogramDesc *SPD) {
|
||||
|
||||
// Gather the details (simplify add attribute code.)
|
||||
const std::string &Name = SPD->getName();
|
||||
unsigned FileID = Unit->getID();
|
||||
// FIXME - faking the line for the time being.
|
||||
unsigned Line = 1;
|
||||
|
||||
// FIXME - faking the type for the time being.
|
||||
DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy);
|
||||
CompileUnitDesc *FileDesc = static_cast<CompileUnitDesc *>(SPD->getFile());
|
||||
CompileUnit *File = FindCompileUnit(FileDesc);
|
||||
unsigned FileID = File->getID();
|
||||
DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy);
|
||||
unsigned Line = SPD->getLine();
|
||||
unsigned IsExternal = SPD->isStatic() ? 0 : 1;
|
||||
|
||||
DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
|
||||
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);
|
||||
SubprogramDie->AddUInt (DW_AT_external, DW_FORM_flag, IsExternal);
|
||||
|
||||
// Add to map.
|
||||
Slot = SubprogramDie;
|
||||
|
@ -270,16 +270,12 @@ public:
|
||||
Elements.push_back(ConstantBool::get(Field));
|
||||
}
|
||||
virtual void Apply(std::string &Field) {
|
||||
if (Field.empty()) {
|
||||
Elements.push_back(NULL);
|
||||
} else {
|
||||
Elements.push_back(SR.getString(Field));
|
||||
}
|
||||
}
|
||||
virtual void Apply(DebugInfoDesc *&Field) {
|
||||
GlobalVariable *GV = NULL;
|
||||
|
||||
// If non-NULL the convert to global.
|
||||
// If non-NULL then convert to global.
|
||||
if (Field) GV = SR.Serialize(Field);
|
||||
|
||||
// FIXME - At some point should use specific type.
|
||||
@ -473,19 +469,21 @@ DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) {
|
||||
case DW_TAG_compile_unit: return new CompileUnitDesc();
|
||||
case DW_TAG_variable: return new GlobalVariableDesc();
|
||||
case DW_TAG_subprogram: return new SubprogramDesc();
|
||||
case DW_TAG_lexical_block: return new BlockDesc();
|
||||
case DW_TAG_base_type: return new BasicTypeDesc();
|
||||
case DW_TAG_typedef:
|
||||
case DW_TAG_pointer_type:
|
||||
case DW_TAG_pointer_type:
|
||||
case DW_TAG_reference_type:
|
||||
case DW_TAG_const_type:
|
||||
case DW_TAG_volatile_type:
|
||||
case DW_TAG_restrict_type: return new DerivedTypeDesc(Tag);
|
||||
case DW_TAG_volatile_type:
|
||||
case DW_TAG_restrict_type:
|
||||
case DW_TAG_formal_parameter:
|
||||
case DW_TAG_member: return new DerivedTypeDesc(Tag);
|
||||
case DW_TAG_array_type:
|
||||
case DW_TAG_structure_type:
|
||||
case DW_TAG_union_type:
|
||||
case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
|
||||
case DW_TAG_subrange_type: return new SubrangeDesc();
|
||||
case DW_TAG_member: return new DerivedTypeDesc(DW_TAG_member);
|
||||
case DW_TAG_enumerator: return new EnumeratorDesc();
|
||||
default: break;
|
||||
}
|
||||
@ -761,6 +759,7 @@ bool DerivedTypeDesc::classof(const DebugInfoDesc *D) {
|
||||
case DW_TAG_const_type:
|
||||
case DW_TAG_volatile_type:
|
||||
case DW_TAG_restrict_type:
|
||||
case DW_TAG_formal_parameter:
|
||||
case DW_TAG_member:
|
||||
return true;
|
||||
default: break;
|
||||
@ -948,6 +947,8 @@ GlobalDesc::GlobalDesc(unsigned T)
|
||||
: AnchoredDesc(T)
|
||||
, Context(0)
|
||||
, Name("")
|
||||
, File(NULL)
|
||||
, Line(0)
|
||||
, TyDesc(NULL)
|
||||
, IsStatic(false)
|
||||
, IsDefinition(false)
|
||||
@ -960,6 +961,8 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) {
|
||||
|
||||
Visitor->Apply(Context);
|
||||
Visitor->Apply(Name);
|
||||
Visitor->Apply((DebugInfoDesc *&)File);
|
||||
Visitor->Apply(Line);
|
||||
Visitor->Apply((DebugInfoDesc *&)TyDesc);
|
||||
Visitor->Apply(IsStatic);
|
||||
Visitor->Apply(IsDefinition);
|
||||
@ -983,7 +986,6 @@ void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) {
|
||||
GlobalDesc::ApplyToFields(Visitor);
|
||||
|
||||
Visitor->Apply(Global);
|
||||
Visitor->Apply(Line);
|
||||
}
|
||||
|
||||
/// getDescString - Return a string used to compose global names and labels.
|
||||
@ -1011,11 +1013,12 @@ void GlobalVariableDesc::dump() {
|
||||
<< "Tag(" << getTag() << "), "
|
||||
<< "Anchor(" << getAnchor() << "), "
|
||||
<< "Name(\"" << getName() << "\"), "
|
||||
<< "File(" << getFile() << "),"
|
||||
<< "Line(" << getLine() << "),"
|
||||
<< "Type(\"" << getTypeDesc() << "\"), "
|
||||
<< "IsStatic(" << (isStatic() ? "true" : "false") << "), "
|
||||
<< "IsDefinition(" << (isDefinition() ? "true" : "false") << "), "
|
||||
<< "Global(" << Global << "), "
|
||||
<< "Line(" << Line << ")\n";
|
||||
<< "Global(" << Global << ")\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1034,6 +1037,8 @@ bool SubprogramDesc::classof(const DebugInfoDesc *D) {
|
||||
/// SubprogramDesc.
|
||||
void SubprogramDesc::ApplyToFields(DIVisitor *Visitor) {
|
||||
GlobalDesc::ApplyToFields(Visitor);
|
||||
|
||||
Visitor->Apply(Elements);
|
||||
}
|
||||
|
||||
/// getDescString - Return a string used to compose global names and labels.
|
||||
@ -1061,6 +1066,8 @@ void SubprogramDesc::dump() {
|
||||
<< "Tag(" << getTag() << "), "
|
||||
<< "Anchor(" << getAnchor() << "), "
|
||||
<< "Name(\"" << getName() << "\"), "
|
||||
<< "File(" << getFile() << "),"
|
||||
<< "Line(" << getLine() << "),"
|
||||
<< "Type(\"" << getTypeDesc() << "\"), "
|
||||
<< "IsStatic(" << (isStatic() ? "true" : "false") << "), "
|
||||
<< "IsDefinition(" << (isDefinition() ? "true" : "false") << ")\n";
|
||||
@ -1069,6 +1076,44 @@ void SubprogramDesc::dump() {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
BlockDesc::BlockDesc()
|
||||
: DebugInfoDesc(DW_TAG_lexical_block)
|
||||
{}
|
||||
|
||||
// Implement isa/cast/dyncast.
|
||||
bool BlockDesc::classof(const DebugInfoDesc *D) {
|
||||
return D->getTag() == DW_TAG_lexical_block;
|
||||
}
|
||||
|
||||
/// ApplyToFields - Target the visitor to the fields of the BlockDesc.
|
||||
///
|
||||
void BlockDesc::ApplyToFields(DIVisitor *Visitor) {
|
||||
DebugInfoDesc::ApplyToFields(Visitor);
|
||||
|
||||
Visitor->Apply(Elements);
|
||||
}
|
||||
|
||||
/// getDescString - Return a string used to compose global names and labels.
|
||||
///
|
||||
const char *BlockDesc::getDescString() const {
|
||||
return "llvm.dbg.block";
|
||||
}
|
||||
|
||||
/// getTypeString - Return a string used to label this descriptors type.
|
||||
///
|
||||
const char *BlockDesc::getTypeString() const {
|
||||
return "llvm.dbg.block.type";
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void BlockDesc::dump() {
|
||||
std::cerr << getDescString() << " "
|
||||
<< "Tag(" << getTag() << ")\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
DebugInfoDesc *DIDeserializer::Deserialize(Value *V) {
|
||||
return Deserialize(getGlobalVariable(V));
|
||||
}
|
||||
@ -1159,17 +1204,22 @@ const StructType *DISerializer::getTagType(DebugInfoDesc *DD) {
|
||||
Constant *DISerializer::getString(const std::string &String) {
|
||||
// Check string cache for previous edition.
|
||||
Constant *&Slot = StringCache[String];
|
||||
// return Constant if previously defined.
|
||||
// Return Constant if previously defined.
|
||||
if (Slot) return Slot;
|
||||
// Construct string as an llvm constant.
|
||||
Constant *ConstStr = ConstantArray::get(String);
|
||||
// Otherwise create and return a new string global.
|
||||
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
|
||||
GlobalVariable::InternalLinkage,
|
||||
ConstStr, "str", M);
|
||||
StrGV->setSection("llvm.metadata");
|
||||
// Convert to generic string pointer.
|
||||
Slot = ConstantExpr::getCast(StrGV, getStrPtrType());
|
||||
// If empty string then use a sbyte* null instead.
|
||||
if (String.empty()) {
|
||||
Slot = ConstantPointerNull::get(getStrPtrType());
|
||||
} else {
|
||||
// Construct string as an llvm constant.
|
||||
Constant *ConstStr = ConstantArray::get(String);
|
||||
// Otherwise create and return a new string global.
|
||||
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
|
||||
GlobalVariable::InternalLinkage,
|
||||
ConstStr, "str", M);
|
||||
StrGV->setSection("llvm.metadata");
|
||||
// Convert to generic string pointer.
|
||||
Slot = ConstantExpr::getCast(StrGV, getStrPtrType());
|
||||
}
|
||||
return Slot;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user