mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
Work on debug
This commit is contained in:
parent
6d22dd7999
commit
c3ea7b27c6
6 changed files with 46 additions and 15 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
|
@ -350,6 +351,9 @@ struct VarDeclaration : Declaration
|
||||||
|
|
||||||
/// This var is used by a naked function.
|
/// This var is used by a naked function.
|
||||||
bool nakedUse;
|
bool nakedUse;
|
||||||
|
|
||||||
|
// debug description
|
||||||
|
llvm::DIVariable debugVariable;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
|
@ -347,6 +348,9 @@ struct VarDeclaration : Declaration
|
||||||
|
|
||||||
/// This var is used by a naked function.
|
/// This var is used by a naked function.
|
||||||
bool nakedUse;
|
bool nakedUse;
|
||||||
|
|
||||||
|
// debug description
|
||||||
|
llvm::DIVariable debugVariable;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -470,6 +470,13 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
||||||
}
|
}
|
||||||
gIR->ir->CreateStore(r, l);
|
gIR->ir->CreateStore(r, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DISABLE_DEBUG_INFO
|
||||||
|
DVarValue *var = lhs->isVar();
|
||||||
|
VarDeclaration *varDecl = var ? var->var : 0;
|
||||||
|
if (global.params.symdebug && varDecl && varDecl->debugVariable)
|
||||||
|
DtoDwarfValue(rhs->getRVal(), lhs->isVar()->var);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
|
@ -114,7 +114,7 @@ static llvm::DIDerivedType dwarfDerivedType(Type* type, llvm::DICompileUnit comp
|
||||||
return gIR->difactory.CreateDerivedType(
|
return gIR->difactory.CreateDerivedType(
|
||||||
DW_TAG_pointer_type, // tag
|
DW_TAG_pointer_type, // tag
|
||||||
compileUnit, // context
|
compileUnit, // context
|
||||||
"", // name
|
type->toChars(), // name
|
||||||
DtoDwarfFile(Loc(gIR->dmodule, 0), DtoDwarfCompileUnit(gIR->dmodule)), // file
|
DtoDwarfFile(Loc(gIR->dmodule, 0), DtoDwarfCompileUnit(gIR->dmodule)), // file
|
||||||
0, // line number
|
0, // line number
|
||||||
getTypeBitSize(T), // size (bits)
|
getTypeBitSize(T), // size (bits)
|
||||||
|
@ -350,11 +350,12 @@ static llvm::DIVariable dwarfVariable(VarDeclaration* vd, llvm::DIType type)
|
||||||
|
|
||||||
return gIR->difactory.CreateVariable(
|
return gIR->difactory.CreateVariable(
|
||||||
tag, // tag
|
tag, // tag
|
||||||
gIR->func()->diSubprogram, // context
|
gIR->func()->diLexicalBlock, // context
|
||||||
vd->toChars(), // name
|
vd->toChars(), // name
|
||||||
DtoDwarfFile(vd->loc, DtoDwarfCompileUnit(getDefinedModule(vd))), // file
|
DtoDwarfFile(vd->loc, DtoDwarfCompileUnit(getDefinedModule(vd))), // file
|
||||||
vd->loc.linnum, // line num
|
vd->loc.linnum, // line num
|
||||||
type // type
|
type, // type
|
||||||
|
true // preserve
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,10 +409,10 @@ void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd)
|
||||||
return; // unsupported
|
return; // unsupported
|
||||||
|
|
||||||
// get variable description
|
// get variable description
|
||||||
llvm::DIVariable VD = dwarfVariable(vd, TD);
|
vd->debugVariable = dwarfVariable(vd, TD);
|
||||||
|
|
||||||
// declare
|
// declare
|
||||||
dwarfDeclare(ll, VD);
|
dwarfDeclare(ll, vd->debugVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -447,7 +448,6 @@ llvm::DICompileUnit DtoDwarfCompileUnit(Module* m)
|
||||||
m->srcfile->name->toChars(),
|
m->srcfile->name->toChars(),
|
||||||
srcpath,
|
srcpath,
|
||||||
"LDC (http://www.dsource.org/projects/ldc)",
|
"LDC (http://www.dsource.org/projects/ldc)",
|
||||||
//FIXME: What do these two mean?
|
|
||||||
gIR->dmodule == m, // isMain,
|
gIR->dmodule == m, // isMain,
|
||||||
false // isOptimized
|
false // isOptimized
|
||||||
);
|
);
|
||||||
|
@ -464,6 +464,7 @@ llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd)
|
||||||
|
|
||||||
llvm::DICompileUnit context = DtoDwarfCompileUnit(gIR->dmodule);
|
llvm::DICompileUnit context = DtoDwarfCompileUnit(gIR->dmodule);
|
||||||
llvm::DIFile file = DtoDwarfFile(fd->loc, DtoDwarfCompileUnit(getDefinedModule(fd)));
|
llvm::DIFile file = DtoDwarfFile(fd->loc, DtoDwarfCompileUnit(getDefinedModule(fd)));
|
||||||
|
Type *retType = ((TypeFunction*)fd->type)->next;
|
||||||
|
|
||||||
// FIXME: duplicates ?
|
// FIXME: duplicates ?
|
||||||
return gIR->difactory.CreateSubprogram(
|
return gIR->difactory.CreateSubprogram(
|
||||||
|
@ -473,10 +474,14 @@ llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd)
|
||||||
fd->mangle(), // linkage name
|
fd->mangle(), // linkage name
|
||||||
file, // file
|
file, // file
|
||||||
fd->loc.linnum, // line no
|
fd->loc.linnum, // line no
|
||||||
//FIXME: what's this type for?
|
dwarfTypeDescription(retType, context, NULL), // type
|
||||||
llvm::DIType(NULL), // type
|
|
||||||
fd->protection == PROTprivate, // is local to unit
|
fd->protection == PROTprivate, // is local to unit
|
||||||
gIR->dmodule == getDefinedModule(fd) // isdefinition
|
gIR->dmodule == getDefinedModule(fd), // isdefinition
|
||||||
|
0, 0, // VK, Index
|
||||||
|
llvm::DIType(),
|
||||||
|
false, // isArtificial
|
||||||
|
false, // isOptimized
|
||||||
|
fd->ir.irFunc->func
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +502,7 @@ llvm::DISubprogram DtoDwarfSubProgramInternal(const char* prettyname, const char
|
||||||
mangledname, // linkage name
|
mangledname, // linkage name
|
||||||
DtoDwarfFile(Loc(gIR->dmodule, 0), context), // compile unit
|
DtoDwarfFile(Loc(gIR->dmodule, 0), context), // compile unit
|
||||||
0, // line no
|
0, // line no
|
||||||
//FIXME: what's this type for?
|
llvm::DIType(NULL), // return type. TODO: fill it up
|
||||||
llvm::DIType(NULL), // type
|
|
||||||
true, // is local to unit
|
true, // is local to unit
|
||||||
true // isdefinition
|
true // isdefinition
|
||||||
);
|
);
|
||||||
|
@ -523,8 +527,11 @@ void DtoDwarfFuncStart(FuncDeclaration* fd)
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0);
|
assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0);
|
||||||
//TODO:
|
fd->ir.irFunc->diLexicalBlock = gIR->difactory.CreateLexicalBlock(
|
||||||
//gIR->difactory.InsertSubprogramStart(fd->ir.irFunc->diSubprogram, gIR->scopebb());
|
fd->ir.irFunc->diSubprogram, // context
|
||||||
|
DtoDwarfFile(fd->loc, DtoDwarfCompileUnit(getDefinedModule(fd))), // file
|
||||||
|
fd->loc.linnum
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -535,8 +542,6 @@ void DtoDwarfFuncEnd(FuncDeclaration* fd)
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0);
|
assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0);
|
||||||
//TODO:
|
|
||||||
//gIR->difactory.InsertRegionEnd(fd->ir.irFunc->diSubprogram, gIR->scopebb());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -549,4 +554,11 @@ void DtoDwarfStopPoint(unsigned ln)
|
||||||
gIR->ir->SetCurrentDebugLocation(loc);
|
gIR->ir->SetCurrentDebugLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DtoDwarfValue(LLValue* var, VarDeclaration* vd)
|
||||||
|
{
|
||||||
|
gIR->difactory.InsertDbgValueIntrinsic(var, 0, vd->debugVariable, gIR->scopebb());
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,6 +32,8 @@ void DtoDwarfFuncEnd(FuncDeclaration* fd);
|
||||||
|
|
||||||
void DtoDwarfStopPoint(unsigned ln);
|
void DtoDwarfStopPoint(unsigned ln);
|
||||||
|
|
||||||
|
void DtoDwarfValue(LLValue* var, VarDeclaration* vd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits all things necessary for making debug info for a local variable vd.
|
* Emits all things necessary for making debug info for a local variable vd.
|
||||||
* @param ll LLVM Value of the variable.
|
* @param ll LLVM Value of the variable.
|
||||||
|
@ -47,6 +49,7 @@ void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd);
|
||||||
*/
|
*/
|
||||||
llvm::DIGlobalVariable DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd);
|
llvm::DIGlobalVariable DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd);
|
||||||
|
|
||||||
|
|
||||||
#endif // DISABLE_DEBUG_INFO
|
#endif // DISABLE_DEBUG_INFO
|
||||||
|
|
||||||
#endif // LDC_GEN_TODEBUG_H
|
#endif // LDC_GEN_TODEBUG_H
|
||||||
|
|
|
@ -98,6 +98,7 @@ struct IrFunction : IrBase
|
||||||
llvm::Value* _argptr;
|
llvm::Value* _argptr;
|
||||||
|
|
||||||
llvm::DISubprogram diSubprogram;
|
llvm::DISubprogram diSubprogram;
|
||||||
|
llvm::DILexicalBlock diLexicalBlock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue