1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Switch back to using actual dwarf tags. Simplifies code without loss to other

debug forms.

llvm-svn: 26455
This commit is contained in:
Jim Laskey 2006-03-01 20:39:36 +00:00
parent 5544c94289
commit c73a56236e
4 changed files with 129 additions and 127 deletions

View File

@ -56,25 +56,6 @@ class StructType;
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
};
//===----------------------------------------------------------------------===//
@ -166,23 +147,15 @@ private:
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.
///
@ -259,9 +232,7 @@ public:
// 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.
@ -348,9 +319,7 @@ public:
// 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.
///
@ -386,20 +355,7 @@ public:
// 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.
///
@ -433,18 +389,7 @@ public:
// 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.
///
@ -482,9 +427,7 @@ public:
// 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.
///
@ -554,9 +497,7 @@ public:
// 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.
@ -594,9 +535,7 @@ public:
// 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.
///
@ -873,7 +812,12 @@ public:
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;

View File

@ -24,6 +24,16 @@ namespace dwarf {
// Dwarf constants as gleaned from the DWARF Debugging Information Format V.3
// reference manual http://dwarf.freestandards.org .
//
// Do not mix the following two enumerations sets. DW_TAG_invalid changes the
// enumeration base type.
enum llvm_dwarf_constants {
// llvm mock tags
DW_TAG_invalid = ~0U, // Tag for invalid results.
DW_TAG_anchor = 0, // Tag for descriptor anchors.
};
enum dwarf_constants {
DWARF_VERSION = 2,

View File

@ -1070,42 +1070,20 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc) {
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));
@ -1139,13 +1117,13 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc) {
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;

View File

@ -20,6 +20,7 @@
#include <iostream>
using namespace llvm;
using namespace llvm::dwarf;
// Handle the Pass registration stuff necessary to use TargetData's.
namespace {
@ -492,29 +493,29 @@ public:
/// 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;
@ -534,6 +535,20 @@ void DebugInfoDesc::ApplyToFields(DIVisitor *Visitor) {
//===----------------------------------------------------------------------===//
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 {
@ -586,7 +601,7 @@ void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) {
//===----------------------------------------------------------------------===//
CompileUnitDesc::CompileUnitDesc()
: AnchoredDesc(DI_TAG_compile_unit)
: AnchoredDesc(DW_TAG_compile_unit)
, DebugVersion(LLVMDebugVersion)
, Language(0)
, FileName("")
@ -594,11 +609,16 @@ CompileUnitDesc::CompileUnitDesc()
, 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.
@ -693,10 +713,15 @@ void TypeDesc::dump() {
//===----------------------------------------------------------------------===//
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) {
@ -735,6 +760,22 @@ DerivedTypeDesc::DerivedTypeDesc(unsigned T)
, 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) {
@ -775,6 +816,20 @@ CompositeTypeDesc::CompositeTypeDesc(unsigned T)
, 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) {
@ -812,11 +867,16 @@ void CompositeTypeDesc::dump() {
//===----------------------------------------------------------------------===//
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) {
@ -873,10 +933,15 @@ void GlobalDesc::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) {
@ -921,9 +986,14 @@ void GlobalVariableDesc::dump() {
//===----------------------------------------------------------------------===//
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) {
@ -977,7 +1047,7 @@ DebugInfoDesc *DIDeserializer::Deserialize(GlobalVariable *GV) {
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);
}
@ -1123,12 +1193,12 @@ bool DIVerifier::Verify(GlobalVariable *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.