mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 23:25:06 +00:00
Debug info: Support variadic functions.
Variadic functions have an unspecified parameter tag after the last argument. In IR this is represented as an unspecified parameter in the subroutine type. Paired commit with CFE r202185. rdar://problem/13690847 This re-applies r202184 + a bugfix in DwarfDebug's argument handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202188 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -403,15 +403,21 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
|
||||
DIArray Args = SPTy.getTypeArray();
|
||||
uint16_t SPTag = SPTy.getTag();
|
||||
if (SPTag == dwarf::DW_TAG_subroutine_type)
|
||||
// FIXME: Use DwarfUnit::constructSubprogramArguments() here.
|
||||
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
|
||||
DIE *Arg =
|
||||
SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
|
||||
DIType ATy(Args.getElement(i));
|
||||
SPCU->addType(Arg, ATy);
|
||||
if (ATy.isArtificial())
|
||||
SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
|
||||
if (ATy.isObjectPointer())
|
||||
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
|
||||
if (ATy.isUnspecifiedParameter()) {
|
||||
assert(i == N-1 && "ellipsis must be the last argument");
|
||||
SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
|
||||
} else {
|
||||
DIE *Arg =
|
||||
SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
|
||||
SPCU->addType(Arg, ATy);
|
||||
if (ATy.isArtificial())
|
||||
SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
|
||||
if (ATy.isObjectPointer())
|
||||
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
|
||||
}
|
||||
}
|
||||
DIE *SPDeclDie = SPDie;
|
||||
SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
|
||||
@@ -582,7 +588,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
||||
DIE *ObjectPointer = NULL;
|
||||
|
||||
// Collect arguments for current function.
|
||||
if (LScopes.isCurrentFunctionScope(Scope))
|
||||
if (LScopes.isCurrentFunctionScope(Scope)) {
|
||||
for (unsigned i = 0, N = CurrentFnArguments.size(); i < N; ++i)
|
||||
if (DbgVariable *ArgDV = CurrentFnArguments[i])
|
||||
if (DIE *Arg =
|
||||
@@ -592,6 +598,16 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
|
||||
ObjectPointer = Arg;
|
||||
}
|
||||
|
||||
// Create the unspecified parameter that marks a function as variadic.
|
||||
DISubprogram SP(Scope->getScopeNode());
|
||||
assert(SP.Verify());
|
||||
DIArray FnArgs = SP.getType().getTypeArray();
|
||||
if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
|
||||
DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
|
||||
Children.push_back(Ellipsis);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect lexical scope children first.
|
||||
const SmallVectorImpl<DbgVariable *> &Variables =
|
||||
ScopeVariables.lookup(Scope);
|
||||
|
Reference in New Issue
Block a user