///
class DebugInfoDesc {
private:
+ enum {
+ tag_mask = 0x0000ffff,
+ version_shift = 16
+ };
+
+
unsigned Tag; // Content indicator. Dwarf values are
// used but that does not limit use to
// Dwarf writers.
protected:
- DebugInfoDesc(unsigned T) : Tag(T) {}
+ DebugInfoDesc(unsigned T) : Tag(T | (LLVMDebugVersion << version_shift)) {}
public:
virtual ~DebugInfoDesc() {}
// 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
- /// GlobalVariable. Return DIIValid if operand is not an unsigned int.
+ /// TagFromGlobal - Returns the tag number from a debug info descriptor
+ /// GlobalVariable. Return DIIValid if operand is not an unsigned int.
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.
/// Return NULL if not a recognized Tag.
static DebugInfoDesc *DescFactory(unsigned Tag);
/// source/header file.
class CompileUnitDesc : public AnchoredDesc {
private:
- unsigned DebugVersion; // LLVM debug version when produced.
unsigned Language; // Language number (ex. DW_LANG_C89.)
std::string FileName; // Source file name.
std::string Directory; // Source file directory.
// Accessors
- unsigned getDebugVersion() const { return DebugVersion; }
unsigned getLanguage() const { return Language; }
const std::string &getFileName() const { return FileName; }
const std::string &getDirectory() const { return Directory; }
static bool classof(const CompileUnitDesc *) { return true; }
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.
///
virtual void ApplyToFields(DIVisitor *Visitor);
/// into DebugInfoDesc objects.
class DIDeserializer {
private:
- unsigned DebugVersion; // Version of debug information in use.
std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs;
// Previously defined gloabls.
public:
- DIDeserializer() : DebugVersion(LLVMDebugVersion) {}
+ DIDeserializer() {}
~DIDeserializer() {}
- // Accessors
- unsigned getDebugVersion() const { return DebugVersion; }
-
/// Deserialize - Reconstitute a GlobalVariable into it's component
/// DebugInfoDesc objects.
DebugInfoDesc *Deserialize(Value *V);
Invalid,
Valid
};
- unsigned DebugVersion; // Version of debug information in use.
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results.
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
public:
DIVerifier()
- : DebugVersion(LLVMDebugVersion)
- , Validity()
+ : Validity()
, Counts()
{}
~DIVerifier() {}
std::vector<T *> AnchoredDescs;
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
GlobalVariable *GV = Globals[i];
- unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
-
- if (isa<CompileUnitDesc>(&Desc)) {
- unsigned DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
- // FIXME - In the short term, changes are too drastic to continue.
- if (DebugVersion != LLVMDebugVersion) break;
- }
- if (Tag == Desc.getTag()) {
+ // FIXME - In the short term, changes are too drastic to continue.
+ if (DebugInfoDesc::TagFromGlobal(GV) == Desc.getTag() &&
+ DebugInfoDesc::VersionFromGlobal(GV) == LLVMDebugVersion) {
AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
}
}
//===----------------------------------------------------------------------===//
-/// TagFromGlobal - Returns the Tag number from a debug info descriptor
-/// GlobalVariable.
+/// TagFromGlobal - Returns the tag number from a debug info descriptor
+/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
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.
#ifndef NDEBUG
void AnchorDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "AnchorTag(" << AnchorTag << ")\n";
}
CompileUnitDesc::CompileUnitDesc()
: AnchoredDesc(DW_TAG_compile_unit)
-, DebugVersion(LLVMDebugVersion)
, Language(0)
, FileName("")
, Directory("")
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.
///
void CompileUnitDesc::ApplyToFields(DIVisitor *Visitor) {
AnchoredDesc::ApplyToFields(Visitor);
- Visitor->Apply(DebugVersion);
Visitor->Apply(Language);
Visitor->Apply(FileName);
Visitor->Apply(Directory);
#ifndef NDEBUG
void CompileUnitDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Anchor(" << getAnchor() << "), "
- << "DebugVersion(" << DebugVersion << "), "
<< "Language(" << Language << "), "
<< "FileName(\"" << FileName << "\"), "
<< "Directory(\"" << Directory << "\"), "
#ifndef NDEBUG
void TypeDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Context(" << Context << "), "
<< "Name(\"" << Name << "\"), "
#ifndef NDEBUG
void BasicTypeDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Context(" << getContext() << "), "
<< "Name(\"" << getName() << "\"), "
#ifndef NDEBUG
void DerivedTypeDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Context(" << getContext() << "), "
<< "Name(\"" << getName() << "\"), "
#ifndef NDEBUG
void CompositeTypeDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Context(" << getContext() << "), "
<< "Name(\"" << getName() << "\"), "
#ifndef NDEBUG
void SubrangeDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Lo(" << Lo << "), "
<< "Hi(" << Hi << ")\n";
#ifndef NDEBUG
void EnumeratorDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Name(" << Name << "), "
<< "Value(" << Value << ")\n";
#ifndef NDEBUG
void VariableDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Context(" << Context << "), "
<< "Name(\"" << Name << "\"), "
#ifndef NDEBUG
void GlobalVariableDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Anchor(" << getAnchor() << "), "
<< "Name(\"" << getName() << "\"), "
#ifndef NDEBUG
void SubprogramDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "), "
<< "Anchor(" << getAnchor() << "), "
<< "Name(\"" << getName() << "\"), "
#ifndef NDEBUG
void BlockDesc::dump() {
std::cerr << getDescString() << " "
+ << "Version(" << getVersion() << "), "
<< "Tag(" << getTag() << "),"
<< "Context(" << Context << ")\n";
}
// Get the Tag from the global.
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.
Slot = DebugInfoDesc::DescFactory(Tag);
// Check for user defined descriptors.
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.
DebugInfoDesc *DD = DebugInfoDesc::DescFactory(Tag);