- Move some debug fields to coincide with how GCC emits them. No functionality

change.
- Reformatting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71118 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2009-05-06 21:21:34 +00:00
parent 69b20fd6f9
commit 3f500d9358

View File

@ -1145,8 +1145,29 @@ public:
virtual unsigned getLine() { assert ( 0 && "Unexpected scope!"); return 0; } virtual unsigned getLine() { assert ( 0 && "Unexpected scope!"); return 0; }
virtual unsigned getColumn() { assert ( 0 && "Unexpected scope!"); return 0; } virtual unsigned getColumn() { assert ( 0 && "Unexpected scope!"); return 0; }
virtual unsigned getFile() { assert ( 0 && "Unexpected scope!"); return 0; } virtual unsigned getFile() { assert ( 0 && "Unexpected scope!"); return 0; }
#ifndef NDEBUG
void dump() const;
#endif
}; };
#ifndef NDEBUG
void DbgScope::dump() const {
static unsigned IndentLevel = 0;
std::string Indent(IndentLevel, ' ');
cerr << Indent; Desc.dump();
cerr << " [" << StartLabelID << ", " << EndLabelID << "]\n";
IndentLevel += 2;
for (unsigned i = 0, e = Scopes.size(); i != e; ++i)
if (Scopes[i] != this)
Scopes[i]->dump();
IndentLevel -= 2;
}
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// DbgInlinedSubroutineScope - This class is used to track inlined subroutine /// DbgInlinedSubroutineScope - This class is used to track inlined subroutine
@ -1713,13 +1734,14 @@ private:
break; break;
case DW_TAG_subroutine_type: case DW_TAG_subroutine_type:
{ {
// Add prototype flag.
AddUInt(&Buffer, DW_AT_prototyped, DW_FORM_flag, 1);
DIArray Elements = CTy.getTypeArray();
// Add return type. // Add return type.
DIArray Elements = CTy.getTypeArray();
DIDescriptor RTy = Elements.getElement(0); DIDescriptor RTy = Elements.getElement(0);
AddType(DW_Unit, &Buffer, DIType(RTy.getGV())); AddType(DW_Unit, &Buffer, DIType(RTy.getGV()));
// Add prototype flag.
AddUInt(&Buffer, DW_AT_prototyped, DW_FORM_flag, 1);
// Add arguments. // Add arguments.
for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
DIE *Arg = new DIE(DW_TAG_formal_parameter); DIE *Arg = new DIE(DW_TAG_formal_parameter);
@ -1901,21 +1923,29 @@ private:
/// CreateSubprogramDIE - Create new DIE using SP. /// CreateSubprogramDIE - Create new DIE using SP.
DIE *CreateSubprogramDIE(CompileUnit *DW_Unit, DIE *CreateSubprogramDIE(CompileUnit *DW_Unit,
const DISubprogram &SP, const DISubprogram &SP,
bool IsConstructor = false) { bool IsConstructor = false) {
DIE *SPDie = new DIE(DW_TAG_subprogram); DIE *SPDie = new DIE(DW_TAG_subprogram);
std::string Name; std::string Name;
SP.getName(Name); SP.getName(Name);
AddString(SPDie, DW_AT_name, DW_FORM_string, Name); AddString(SPDie, DW_AT_name, DW_FORM_string, Name);
std::string LinkageName; std::string LinkageName;
SP.getLinkageName(LinkageName); SP.getLinkageName(LinkageName);
if (!LinkageName.empty()) if (!LinkageName.empty())
AddString(SPDie, DW_AT_MIPS_linkage_name, DW_FORM_string, AddString(SPDie, DW_AT_MIPS_linkage_name, DW_FORM_string, LinkageName);
LinkageName);
AddSourceLine(SPDie, &SP); AddSourceLine(SPDie, &SP);
DICompositeType SPTy = SP.getType(); DICompositeType SPTy = SP.getType();
DIArray Args = SPTy.getTypeArray(); DIArray Args = SPTy.getTypeArray();
// Add prototyped tag, if C or ObjC.
unsigned Lang = SP.getCompileUnit().getLanguage();
if (Lang == DW_LANG_C99 || Lang == DW_LANG_C89 || Lang == DW_LANG_ObjC)
AddUInt(SPDie, DW_AT_prototyped, DW_FORM_flag, 1);
// Add Return Type. // Add Return Type.
unsigned SPTag = SPTy.getTag(); unsigned SPTag = SPTy.getTag();
@ -1928,26 +1958,20 @@ private:
if (!SP.isDefinition()) { if (!SP.isDefinition()) {
AddUInt(SPDie, DW_AT_declaration, DW_FORM_flag, 1); AddUInt(SPDie, DW_AT_declaration, DW_FORM_flag, 1);
// Add arguments. // Add arguments. Do not add arguments for subprogram definition. They
// Do not add arguments for subprogram definition. They will be // will be handled through RecordVariable.
// handled through RecordVariable.
if (SPTag == DW_TAG_subroutine_type) if (SPTag == DW_TAG_subroutine_type)
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIE *Arg = new DIE(DW_TAG_formal_parameter); DIE *Arg = new DIE(DW_TAG_formal_parameter);
AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV())); AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
AddUInt(Arg, DW_AT_artificial, DW_FORM_flag, 1); // ??? AddUInt(Arg, DW_AT_artificial, DW_FORM_flag, 1); // ??
SPDie->AddChild(Arg); SPDie->AddChild(Arg);
} }
} }
unsigned Lang = SP.getCompileUnit().getLanguage();
if (Lang == DW_LANG_C99 || Lang == DW_LANG_C89
|| Lang == DW_LANG_ObjC)
AddUInt(SPDie, DW_AT_prototyped, DW_FORM_flag, 1);
if (!SP.isLocalToUnit()) if (!SP.isLocalToUnit())
AddUInt(SPDie, DW_AT_external, DW_FORM_flag, 1); AddUInt(SPDie, DW_AT_external, DW_FORM_flag, 1);
// DW_TAG_inlined_subroutine may refer to this DIE. // DW_TAG_inlined_subroutine may refer to this DIE.
DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getGV()); DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getGV());
Slot = SPDie; Slot = SPDie;
@ -2008,11 +2032,13 @@ private:
DbgScope *Parent = NULL; DbgScope *Parent = NULL;
DIBlock Block(V); DIBlock Block(V);
if (!Block.isNull()) { if (!Block.isNull()) {
DIDescriptor ParentDesc = Block.getContext(); DIDescriptor ParentDesc = Block.getContext();
Parent = Parent =
ParentDesc.isNull() ? NULL : getOrCreateScope(ParentDesc.getGV()); ParentDesc.isNull() ? NULL : getOrCreateScope(ParentDesc.getGV());
} }
Slot = new DbgScope(Parent, DIDescriptor(V)); Slot = new DbgScope(Parent, DIDescriptor(V));
if (Parent) if (Parent)
@ -3007,8 +3033,10 @@ private:
// Add to map. // Add to map.
Slot = VariableDie; Slot = VariableDie;
// Add to context owner. // Add to context owner.
DW_Unit->getDie()->AddChild(VariableDie); DW_Unit->getDie()->AddChild(VariableDie);
// Expose as global. FIXME - need to check external flag. // Expose as global. FIXME - need to check external flag.
std::string Name; std::string Name;
DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie); DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie);
@ -3033,10 +3061,9 @@ private:
for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end(); for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
UI != UE; ++UI) UI != UE; ++UI)
for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end(); for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
UUI != UUE; ++UUI) { UUI != UUE; ++UUI)
GlobalVariable *GV = cast<GlobalVariable>(*UUI); Result |= ConstructGlobalVariableDIE(cast<GlobalVariable>(*UUI));
Result |= ConstructGlobalVariableDIE(GV);
}
return Result; return Result;
} }
@ -3085,10 +3112,9 @@ private:
for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end(); for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
UI != UE; ++UI) UI != UE; ++UI)
for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end(); for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
UUI != UUE; ++UUI) { UUI != UUE; ++UUI)
GlobalVariable *GV = cast<GlobalVariable>(*UUI); Result |= ConstructSubprogram(cast<GlobalVariable>(*UUI));
Result |= ConstructSubprogram(GV);
}
return Result; return Result;
} }
@ -3441,6 +3467,7 @@ public:
} else { } else {
DenseMap<const MachineInstr *, DbgScope *>::iterator DenseMap<const MachineInstr *, DbgScope *>::iterator
SI = InlinedVariableScopes.find(MI); SI = InlinedVariableScopes.find(MI);
if (SI != InlinedVariableScopes.end()) { if (SI != InlinedVariableScopes.end()) {
// or GV is an inlined local variable. // or GV is an inlined local variable.
Scope = SI->second; Scope = SI->second;
@ -3506,6 +3533,7 @@ public:
GlobalVariable *GV = SP.getGV(); GlobalVariable *GV = SP.getGV();
DenseMap<GlobalVariable *, SmallVector<DbgScope *, 2> >::iterator DenseMap<GlobalVariable *, SmallVector<DbgScope *, 2> >::iterator
I = DbgInlinedScopeMap.find(GV); I = DbgInlinedScopeMap.find(GV);
if (I == DbgInlinedScopeMap.end()) { if (I == DbgInlinedScopeMap.end()) {
if (TimePassesIsEnabled) if (TimePassesIsEnabled)
DebugTimer->stopTimer(); DebugTimer->stopTimer();
@ -3517,6 +3545,7 @@ public:
assert(!Scopes.empty() && "We should have at least one debug scope!"); assert(!Scopes.empty() && "We should have at least one debug scope!");
DbgScope *Scope = Scopes.back(); Scopes.pop_back(); DbgScope *Scope = Scopes.back(); Scopes.pop_back();
unsigned ID = MMI->NextLabelID(); unsigned ID = MMI->NextLabelID();
MMI->RecordUsedDbgLabel(ID); MMI->RecordUsedDbgLabel(ID);
Scope->setEndLabelID(ID); Scope->setEndLabelID(ID);