mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 13:40:30 +00:00
Change versioning to per debug info descriptor (merged with tag.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28782 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
014f98c7e5
commit
ed4e566dda
@ -90,23 +90,35 @@ public:
|
|||||||
///
|
///
|
||||||
class DebugInfoDesc {
|
class DebugInfoDesc {
|
||||||
private:
|
private:
|
||||||
|
enum {
|
||||||
|
tag_mask = 0x0000ffff,
|
||||||
|
version_shift = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
unsigned Tag; // Content indicator. Dwarf values are
|
unsigned Tag; // Content indicator. Dwarf values are
|
||||||
// used but that does not limit use to
|
// used but that does not limit use to
|
||||||
// Dwarf writers.
|
// Dwarf writers.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DebugInfoDesc(unsigned T) : Tag(T) {}
|
DebugInfoDesc(unsigned T) : Tag(T | (LLVMDebugVersion << version_shift)) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DebugInfoDesc() {}
|
virtual ~DebugInfoDesc() {}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
unsigned getTag() const { return Tag; }
|
unsigned getTag() const { return Tag & tag_mask; }
|
||||||
|
unsigned getVersion() const { return Tag >> version_shift; }
|
||||||
|
|
||||||
/// TagFromGlobal - Returns the Tag number from a debug info descriptor
|
/// TagFromGlobal - Returns the tag number from a debug info descriptor
|
||||||
/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
|
/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
|
||||||
static unsigned TagFromGlobal(GlobalVariable *GV);
|
static unsigned TagFromGlobal(GlobalVariable *GV);
|
||||||
|
|
||||||
|
/// VersionFromGlobal - Returns the version number from a debug info
|
||||||
|
/// descriptor GlobalVariable. Return DIIValid if operand is not an unsigned
|
||||||
|
/// int.
|
||||||
|
static unsigned VersionFromGlobal(GlobalVariable *GV);
|
||||||
|
|
||||||
/// DescFactory - Create an instance of debug info descriptor based on Tag.
|
/// DescFactory - Create an instance of debug info descriptor based on Tag.
|
||||||
/// Return NULL if not a recognized Tag.
|
/// Return NULL if not a recognized Tag.
|
||||||
static DebugInfoDesc *DescFactory(unsigned Tag);
|
static DebugInfoDesc *DescFactory(unsigned Tag);
|
||||||
@ -216,7 +228,6 @@ public:
|
|||||||
/// source/header file.
|
/// source/header file.
|
||||||
class CompileUnitDesc : public AnchoredDesc {
|
class CompileUnitDesc : public AnchoredDesc {
|
||||||
private:
|
private:
|
||||||
unsigned DebugVersion; // LLVM debug version when produced.
|
|
||||||
unsigned Language; // Language number (ex. DW_LANG_C89.)
|
unsigned Language; // Language number (ex. DW_LANG_C89.)
|
||||||
std::string FileName; // Source file name.
|
std::string FileName; // Source file name.
|
||||||
std::string Directory; // Source file directory.
|
std::string Directory; // Source file directory.
|
||||||
@ -227,7 +238,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
unsigned getDebugVersion() const { return DebugVersion; }
|
|
||||||
unsigned getLanguage() const { return Language; }
|
unsigned getLanguage() const { return Language; }
|
||||||
const std::string &getFileName() const { return FileName; }
|
const std::string &getFileName() const { return FileName; }
|
||||||
const std::string &getDirectory() const { return Directory; }
|
const std::string &getDirectory() const { return Directory; }
|
||||||
@ -243,10 +253,6 @@ public:
|
|||||||
static bool classof(const CompileUnitDesc *) { return true; }
|
static bool classof(const CompileUnitDesc *) { return true; }
|
||||||
static bool classof(const DebugInfoDesc *D);
|
static bool classof(const DebugInfoDesc *D);
|
||||||
|
|
||||||
/// DebugVersionFromGlobal - Returns the version number from a compile unit
|
|
||||||
/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
|
|
||||||
static unsigned DebugVersionFromGlobal(GlobalVariable *GV);
|
|
||||||
|
|
||||||
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
|
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
|
||||||
///
|
///
|
||||||
virtual void ApplyToFields(DIVisitor *Visitor);
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
||||||
@ -702,17 +708,13 @@ public:
|
|||||||
/// into DebugInfoDesc objects.
|
/// into DebugInfoDesc objects.
|
||||||
class DIDeserializer {
|
class DIDeserializer {
|
||||||
private:
|
private:
|
||||||
unsigned DebugVersion; // Version of debug information in use.
|
|
||||||
std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs;
|
std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs;
|
||||||
// Previously defined gloabls.
|
// Previously defined gloabls.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIDeserializer() : DebugVersion(LLVMDebugVersion) {}
|
DIDeserializer() {}
|
||||||
~DIDeserializer() {}
|
~DIDeserializer() {}
|
||||||
|
|
||||||
// Accessors
|
|
||||||
unsigned getDebugVersion() const { return DebugVersion; }
|
|
||||||
|
|
||||||
/// Deserialize - Reconstitute a GlobalVariable into it's component
|
/// Deserialize - Reconstitute a GlobalVariable into it's component
|
||||||
/// DebugInfoDesc objects.
|
/// DebugInfoDesc objects.
|
||||||
DebugInfoDesc *Deserialize(Value *V);
|
DebugInfoDesc *Deserialize(Value *V);
|
||||||
@ -780,14 +782,12 @@ private:
|
|||||||
Invalid,
|
Invalid,
|
||||||
Valid
|
Valid
|
||||||
};
|
};
|
||||||
unsigned DebugVersion; // Version of debug information in use.
|
|
||||||
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results.
|
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results.
|
||||||
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
|
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIVerifier()
|
DIVerifier()
|
||||||
: DebugVersion(LLVMDebugVersion)
|
: Validity()
|
||||||
, Validity()
|
|
||||||
, Counts()
|
, Counts()
|
||||||
{}
|
{}
|
||||||
~DIVerifier() {}
|
~DIVerifier() {}
|
||||||
@ -1039,15 +1039,10 @@ public:
|
|||||||
std::vector<T *> AnchoredDescs;
|
std::vector<T *> AnchoredDescs;
|
||||||
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
||||||
GlobalVariable *GV = Globals[i];
|
GlobalVariable *GV = Globals[i];
|
||||||
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
|
|
||||||
|
|
||||||
if (isa<CompileUnitDesc>(&Desc)) {
|
// FIXME - In the short term, changes are too drastic to continue.
|
||||||
unsigned DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
|
if (DebugInfoDesc::TagFromGlobal(GV) == Desc.getTag() &&
|
||||||
// FIXME - In the short term, changes are too drastic to continue.
|
DebugInfoDesc::VersionFromGlobal(GV) == LLVMDebugVersion) {
|
||||||
if (DebugVersion != LLVMDebugVersion) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tag == Desc.getTag()) {
|
|
||||||
AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
|
AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,11 +455,20 @@ public:
|
|||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// TagFromGlobal - Returns the Tag number from a debug info descriptor
|
/// TagFromGlobal - Returns the tag number from a debug info descriptor
|
||||||
/// GlobalVariable.
|
/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
|
||||||
unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
|
unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
|
||||||
ConstantUInt *C = getUIntOperand(GV, 0);
|
ConstantUInt *C = getUIntOperand(GV, 0);
|
||||||
return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
|
return C ? ((unsigned)C->getValue() & tag_mask) : (unsigned)DW_TAG_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// VersionFromGlobal - Returns the version number from a debug info
|
||||||
|
/// descriptor GlobalVariable. Return DIIValid if operand is not an unsigned
|
||||||
|
/// int.
|
||||||
|
unsigned DebugInfoDesc::VersionFromGlobal(GlobalVariable *GV) {
|
||||||
|
ConstantUInt *C = getUIntOperand(GV, 0);
|
||||||
|
return C ? ((unsigned)C->getValue() >> version_shift) :
|
||||||
|
(unsigned)DW_TAG_invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DescFactory - Create an instance of debug info descriptor based on Tag.
|
/// DescFactory - Create an instance of debug info descriptor based on Tag.
|
||||||
@ -563,6 +572,7 @@ const char *AnchorDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void AnchorDesc::dump() {
|
void AnchorDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "AnchorTag(" << AnchorTag << ")\n";
|
<< "AnchorTag(" << AnchorTag << ")\n";
|
||||||
}
|
}
|
||||||
@ -589,7 +599,6 @@ void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) {
|
|||||||
|
|
||||||
CompileUnitDesc::CompileUnitDesc()
|
CompileUnitDesc::CompileUnitDesc()
|
||||||
: AnchoredDesc(DW_TAG_compile_unit)
|
: AnchoredDesc(DW_TAG_compile_unit)
|
||||||
, DebugVersion(LLVMDebugVersion)
|
|
||||||
, Language(0)
|
, Language(0)
|
||||||
, FileName("")
|
, FileName("")
|
||||||
, Directory("")
|
, Directory("")
|
||||||
@ -601,19 +610,11 @@ bool CompileUnitDesc::classof(const DebugInfoDesc *D) {
|
|||||||
return D->getTag() == DW_TAG_compile_unit;
|
return D->getTag() == DW_TAG_compile_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DebugVersionFromGlobal - Returns the version number from a compile unit
|
|
||||||
/// GlobalVariable.
|
|
||||||
unsigned CompileUnitDesc::DebugVersionFromGlobal(GlobalVariable *GV) {
|
|
||||||
ConstantUInt *C = getUIntOperand(GV, 2);
|
|
||||||
return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
|
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
|
||||||
///
|
///
|
||||||
void CompileUnitDesc::ApplyToFields(DIVisitor *Visitor) {
|
void CompileUnitDesc::ApplyToFields(DIVisitor *Visitor) {
|
||||||
AnchoredDesc::ApplyToFields(Visitor);
|
AnchoredDesc::ApplyToFields(Visitor);
|
||||||
|
|
||||||
Visitor->Apply(DebugVersion);
|
|
||||||
Visitor->Apply(Language);
|
Visitor->Apply(Language);
|
||||||
Visitor->Apply(FileName);
|
Visitor->Apply(FileName);
|
||||||
Visitor->Apply(Directory);
|
Visitor->Apply(Directory);
|
||||||
@ -642,9 +643,9 @@ const char *CompileUnitDesc::getAnchorString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void CompileUnitDesc::dump() {
|
void CompileUnitDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Anchor(" << getAnchor() << "), "
|
<< "Anchor(" << getAnchor() << "), "
|
||||||
<< "DebugVersion(" << DebugVersion << "), "
|
|
||||||
<< "Language(" << Language << "), "
|
<< "Language(" << Language << "), "
|
||||||
<< "FileName(\"" << FileName << "\"), "
|
<< "FileName(\"" << FileName << "\"), "
|
||||||
<< "Directory(\"" << Directory << "\"), "
|
<< "Directory(\"" << Directory << "\"), "
|
||||||
@ -696,6 +697,7 @@ const char *TypeDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void TypeDesc::dump() {
|
void TypeDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Context(" << Context << "), "
|
<< "Context(" << Context << "), "
|
||||||
<< "Name(\"" << Name << "\"), "
|
<< "Name(\"" << Name << "\"), "
|
||||||
@ -742,6 +744,7 @@ const char *BasicTypeDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void BasicTypeDesc::dump() {
|
void BasicTypeDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Context(" << getContext() << "), "
|
<< "Context(" << getContext() << "), "
|
||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
@ -799,6 +802,7 @@ const char *DerivedTypeDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DerivedTypeDesc::dump() {
|
void DerivedTypeDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Context(" << getContext() << "), "
|
<< "Context(" << getContext() << "), "
|
||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
@ -853,6 +857,7 @@ const char *CompositeTypeDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void CompositeTypeDesc::dump() {
|
void CompositeTypeDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Context(" << getContext() << "), "
|
<< "Context(" << getContext() << "), "
|
||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
@ -901,6 +906,7 @@ const char *SubrangeDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void SubrangeDesc::dump() {
|
void SubrangeDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Lo(" << Lo << "), "
|
<< "Lo(" << Lo << "), "
|
||||||
<< "Hi(" << Hi << ")\n";
|
<< "Hi(" << Hi << ")\n";
|
||||||
@ -944,6 +950,7 @@ const char *EnumeratorDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void EnumeratorDesc::dump() {
|
void EnumeratorDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Name(" << Name << "), "
|
<< "Name(" << Name << "), "
|
||||||
<< "Value(" << Value << ")\n";
|
<< "Value(" << Value << ")\n";
|
||||||
@ -1005,6 +1012,7 @@ const char *VariableDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void VariableDesc::dump() {
|
void VariableDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Context(" << Context << "), "
|
<< "Context(" << Context << "), "
|
||||||
<< "Name(\"" << Name << "\"), "
|
<< "Name(\"" << Name << "\"), "
|
||||||
@ -1087,6 +1095,7 @@ const char *GlobalVariableDesc::getAnchorString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void GlobalVariableDesc::dump() {
|
void GlobalVariableDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Anchor(" << getAnchor() << "), "
|
<< "Anchor(" << getAnchor() << "), "
|
||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
@ -1138,6 +1147,7 @@ const char *SubprogramDesc::getAnchorString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void SubprogramDesc::dump() {
|
void SubprogramDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "), "
|
<< "Tag(" << getTag() << "), "
|
||||||
<< "Anchor(" << getAnchor() << "), "
|
<< "Anchor(" << getAnchor() << "), "
|
||||||
<< "Name(\"" << getName() << "\"), "
|
<< "Name(\"" << getName() << "\"), "
|
||||||
@ -1184,6 +1194,7 @@ const char *BlockDesc::getTypeString() const {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void BlockDesc::dump() {
|
void BlockDesc::dump() {
|
||||||
std::cerr << getDescString() << " "
|
std::cerr << getDescString() << " "
|
||||||
|
<< "Version(" << getVersion() << "), "
|
||||||
<< "Tag(" << getTag() << "),"
|
<< "Tag(" << getTag() << "),"
|
||||||
<< "Context(" << Context << ")\n";
|
<< "Context(" << Context << ")\n";
|
||||||
}
|
}
|
||||||
@ -1205,11 +1216,6 @@ DebugInfoDesc *DIDeserializer::Deserialize(GlobalVariable *GV) {
|
|||||||
// Get the Tag from the global.
|
// Get the Tag from the global.
|
||||||
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
|
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
|
||||||
|
|
||||||
// Get the debug version if a compile unit.
|
|
||||||
if (Tag == DW_TAG_compile_unit) {
|
|
||||||
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an empty instance of the correct sort.
|
// Create an empty instance of the correct sort.
|
||||||
Slot = DebugInfoDesc::DescFactory(Tag);
|
Slot = DebugInfoDesc::DescFactory(Tag);
|
||||||
|
|
||||||
@ -1366,16 +1372,6 @@ bool DIVerifier::Verify(GlobalVariable *GV) {
|
|||||||
// Check for user defined descriptors.
|
// Check for user defined descriptors.
|
||||||
if (Tag == DW_TAG_invalid) return true;
|
if (Tag == DW_TAG_invalid) return true;
|
||||||
|
|
||||||
// If a compile unit we need the debug version.
|
|
||||||
if (Tag == DW_TAG_compile_unit) {
|
|
||||||
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
|
|
||||||
// FIXME - In the short term, changes are too drastic to continue.
|
|
||||||
if (DebugVersion != LLVMDebugVersion) {
|
|
||||||
ValiditySlot = Invalid;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct an empty DebugInfoDesc.
|
// Construct an empty DebugInfoDesc.
|
||||||
DebugInfoDesc *DD = DebugInfoDesc::DescFactory(Tag);
|
DebugInfoDesc *DD = DebugInfoDesc::DescFactory(Tag);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user