enum {
LLVMDebugVersion = 1, // Current version of debug information.
- DIInvalid = ~0U, // Invalid result indicator.
-
- // DebugInfoDesc type identifying tags.
- DI_TAG_anchor = 0,
- DI_TAG_compile_unit,
- DI_TAG_global_variable,
- DI_TAG_subprogram,
- DI_TAG_basictype,
- DI_TAG_typedef,
- DI_TAG_pointer,
- DI_TAG_reference,
- DI_TAG_array,
- DI_TAG_struct,
- DI_TAG_union,
- DI_TAG_enum,
- DI_TAG_subrange,
- DI_TAG_const,
- DI_TAG_volatile,
- DI_TAG_restrict
};
//===----------------------------------------------------------------------===//
std::string Name; // Anchor type string.
public:
- AnchorDesc()
- : DebugInfoDesc(DI_TAG_anchor)
- , Name("")
- {}
- AnchorDesc(const std::string &N)
- : DebugInfoDesc(DI_TAG_anchor)
- , Name(N)
- {}
+ AnchorDesc();
+ AnchorDesc(const std::string &N);
// Accessors
const std::string &getName() const { return Name; }
// Implement isa/cast/dyncast.
static bool classof(const AnchorDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_anchor;
- }
+ static bool classof(const DebugInfoDesc *D);
/// getLinkage - get linkage appropriate for this type of descriptor.
///
// Implement isa/cast/dyncast.
static bool classof(const CompileUnitDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_compile_unit;
- }
+ 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.
// Implement isa/cast/dyncast.
static bool classof(const BasicTypeDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_basictype;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc.
///
// Implement isa/cast/dyncast.
static bool classof(const DerivedTypeDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- unsigned T = D->getTag();
- switch (T) {
- case DI_TAG_typedef:
- case DI_TAG_pointer:
- case DI_TAG_reference:
- case DI_TAG_const:
- case DI_TAG_volatile:
- case DI_TAG_restrict:
- return true;
- default: break;
- }
- return false;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc.
///
// Implement isa/cast/dyncast.
static bool classof(const CompositeTypeDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- unsigned T = D->getTag();
- switch (T) {
- case DI_TAG_array:
- case DI_TAG_struct:
- case DI_TAG_union:
- case DI_TAG_enum:
- return true;
- default: break;
- }
- return false;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
///
// Implement isa/cast/dyncast.
static bool classof(const SubrangeDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_subrange;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
///
// Implement isa/cast/dyncast.
static bool classof(const GlobalVariableDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_global_variable;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the
/// GlobalVariableDesc.
// Implement isa/cast/dyncast.
static bool classof(const SubprogramDesc *) { return true; }
- static bool classof(const DebugInfoDesc *D) {
- return D->getTag() == DI_TAG_subprogram;
- }
+ static bool classof(const DebugInfoDesc *D);
/// ApplyToFields - Target the visitor to the fields of the SubprogramDesc.
///
getGlobalVariablesUsing(M, Desc.getAnchorString());
std::vector<T *> AnchoredDescs;
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
- AnchoredDescs.push_back(cast<T>(DR.Deserialize(Globals[i])));
+ GlobalVariable *GV = Globals[i];
+ // FIXME - Tag check only necessary for bring up (changed tag values.)
+ unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
+ if (Tag == Desc.getTag()) {
+ AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
+ }
}
return AnchoredDescs;
unsigned Encoding = BasicTy->getEncoding();
Ty->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding);
} else if (DerivedTypeDesc *DerivedTy = dyn_cast<DerivedTypeDesc>(TyDesc)) {
- // Determine which derived type.
- unsigned T = 0;
- switch (DerivedTy->getTag()) {
- case DI_TAG_typedef: T = DW_TAG_typedef; break;
- case DI_TAG_pointer: T = DW_TAG_pointer_type; break;
- case DI_TAG_reference: T = DW_TAG_reference_type; break;
- case DI_TAG_const: T = DW_TAG_const_type; break;
- case DI_TAG_volatile: T = DW_TAG_volatile_type; break;
- case DI_TAG_restrict: T = DW_TAG_restrict_type; break;
- default: assert( 0 && "Unknown tag on derived type");
- }
-
// Create specific DIE.
- Slot = Ty = new DIE(T);
+ Slot = Ty = new DIE(DerivedTy->getTag());
// Map to main type, void will not have a type.
if (TypeDesc *FromTy = DerivedTy->getFromType()) {
Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
}
} else if (CompositeTypeDesc *CompTy = dyn_cast<CompositeTypeDesc>(TyDesc)) {
- // Determine which composite type.
- unsigned T = 0;
- switch (CompTy->getTag()) {
- case DI_TAG_array: T = DW_TAG_array_type; break;
- case DI_TAG_struct: T = DW_TAG_structure_type; break;
- case DI_TAG_union: T = DW_TAG_union_type; break;
- case DI_TAG_enum: T = DW_TAG_enumeration_type; break;
- default: assert( 0 && "Unknown tag on composite type");
- }
-
// Create specific DIE.
- Slot = Ty = new DIE(T);
+ Slot = Ty = new DIE(CompTy->getTag());
std::vector<DebugInfoDesc *> &Elements = CompTy->getElements();
switch (CompTy->getTag()) {
- case DI_TAG_array: {
+ case DW_TAG_array_type: {
// Add element type.
if (TypeDesc *FromTy = CompTy->getFromType()) {
Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
break;
}
- case DI_TAG_struct: {
+ case DW_TAG_structure_type: {
break;
}
- case DI_TAG_union: {
+ case DW_TAG_union_type: {
break;
}
- case DI_TAG_enum: {
+ case DW_TAG_enumeration_type: {
break;
}
default: break;
#include <iostream>
using namespace llvm;
+using namespace llvm::dwarf;
// Handle the Pass registration stuff necessary to use TargetData's.
namespace {
/// GlobalVariable.
unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
ConstantUInt *C = getUIntOperand(GV, 0);
- return C ? (unsigned)C->getValue() : (unsigned)DIInvalid;
+ return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
}
/// DescFactory - Create an instance of debug info descriptor based on Tag.
/// Return NULL if not a recognized Tag.
DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) {
switch (Tag) {
- case DI_TAG_anchor: return new AnchorDesc();
- case DI_TAG_compile_unit: return new CompileUnitDesc();
- case DI_TAG_global_variable: return new GlobalVariableDesc();
- case DI_TAG_subprogram: return new SubprogramDesc();
- case DI_TAG_basictype: return new BasicTypeDesc();
- case DI_TAG_typedef:
- case DI_TAG_pointer:
- case DI_TAG_reference:
- case DI_TAG_const:
- case DI_TAG_volatile:
- case DI_TAG_restrict: return new DerivedTypeDesc(Tag);
- case DI_TAG_array:
- case DI_TAG_struct:
- case DI_TAG_union:
- case DI_TAG_enum: return new CompositeTypeDesc(Tag);
- case DI_TAG_subrange: return new SubrangeDesc();
+ case DW_TAG_anchor: return new AnchorDesc();
+ 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_base_type: return new BasicTypeDesc();
+ case DW_TAG_typedef:
+ 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_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();
default: break;
}
return NULL;
//===----------------------------------------------------------------------===//
+AnchorDesc::AnchorDesc()
+: DebugInfoDesc(DW_TAG_anchor)
+, Name("")
+{}
+AnchorDesc::AnchorDesc(const std::string &N)
+: DebugInfoDesc(DW_TAG_anchor)
+, Name(N)
+{}
+
+// Implement isa/cast/dyncast.
+bool AnchorDesc::classof(const DebugInfoDesc *D) {
+ return D->getTag() == DW_TAG_anchor;
+}
+
/// getLinkage - get linkage appropriate for this type of descriptor.
///
GlobalValue::LinkageTypes AnchorDesc::getLinkage() const {
//===----------------------------------------------------------------------===//
CompileUnitDesc::CompileUnitDesc()
-: AnchoredDesc(DI_TAG_compile_unit)
+: AnchoredDesc(DW_TAG_compile_unit)
, DebugVersion(LLVMDebugVersion)
, Language(0)
, FileName("")
, Producer("")
{}
+// Implement isa/cast/dyncast.
+bool CompileUnitDesc::classof(const DebugInfoDesc *D) {
+ 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)DIInvalid;
+ return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
}
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
//===----------------------------------------------------------------------===//
BasicTypeDesc::BasicTypeDesc()
-: TypeDesc(DI_TAG_basictype)
+: TypeDesc(DW_TAG_base_type)
, Encoding(0)
{}
+// Implement isa/cast/dyncast.
+bool BasicTypeDesc::classof(const DebugInfoDesc *D) {
+ return D->getTag() == DW_TAG_base_type;
+}
+
/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc.
///
void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) {
, FromType(NULL)
{}
+// Implement isa/cast/dyncast.
+bool DerivedTypeDesc::classof(const DebugInfoDesc *D) {
+ unsigned T = D->getTag();
+ switch (T) {
+ case DW_TAG_typedef:
+ 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 true;
+ default: break;
+ }
+ return false;
+}
+
/// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc.
///
void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) {
, Elements()
{}
+// Implement isa/cast/dyncast.
+bool CompositeTypeDesc::classof(const DebugInfoDesc *D) {
+ unsigned T = D->getTag();
+ switch (T) {
+ case DW_TAG_array_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_enumeration_type:
+ return true;
+ default: break;
+ }
+ return false;
+}
+
/// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
///
void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
//===----------------------------------------------------------------------===//
SubrangeDesc::SubrangeDesc()
-: DebugInfoDesc(DI_TAG_subrange)
+: DebugInfoDesc(DW_TAG_subrange_type)
, Lo(0)
, Hi(0)
{}
+// Implement isa/cast/dyncast.
+bool SubrangeDesc::classof(const DebugInfoDesc *D) {
+ return D->getTag() == DW_TAG_subrange_type;
+}
+
/// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
///
void SubrangeDesc::ApplyToFields(DIVisitor *Visitor) {
//===----------------------------------------------------------------------===//
GlobalVariableDesc::GlobalVariableDesc()
-: GlobalDesc(DI_TAG_global_variable)
+: GlobalDesc(DW_TAG_variable)
, Global(NULL)
{}
+// Implement isa/cast/dyncast.
+bool GlobalVariableDesc::classof(const DebugInfoDesc *D) {
+ return D->getTag() == DW_TAG_variable;
+}
+
/// ApplyToFields - Target the visitor to the fields of the GlobalVariableDesc.
///
void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) {
//===----------------------------------------------------------------------===//
SubprogramDesc::SubprogramDesc()
-: GlobalDesc(DI_TAG_subprogram)
+: GlobalDesc(DW_TAG_subprogram)
{}
+// Implement isa/cast/dyncast.
+bool SubprogramDesc::classof(const DebugInfoDesc *D) {
+ return D->getTag() == DW_TAG_subprogram;
+}
+
/// ApplyToFields - Target the visitor to the fields of the
/// SubprogramDesc.
void SubprogramDesc::ApplyToFields(DIVisitor *Visitor) {
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
// Get the debug version if a compile unit.
- if (Tag == DI_TAG_compile_unit) {
+ if (Tag == DW_TAG_compile_unit) {
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
}
// Get the Tag
unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
- if (Tag == DIInvalid) return false;
+ if (Tag == DW_TAG_invalid) return false;
// If a compile unit we need the debug version.
- if (Tag == DI_TAG_compile_unit) {
+ if (Tag == DW_TAG_compile_unit) {
DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
- if (DebugVersion == DIInvalid) return false;
+ if (DebugVersion == DW_TAG_invalid) return false;
}
// Construct an empty DebugInfoDesc.