mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-13 19:33:13 +01:00
[svn r264] Fixed debug info for global variables.
This commit is contained in:
@@ -111,6 +111,10 @@ static const llvm::StructType* getDwarfCompositeTypeType() {
|
||||
return isaStruct(gIR->module->getTypeByName("llvm.dbg.compositetype.type"));
|
||||
}
|
||||
|
||||
static const llvm::StructType* getDwarfGlobalVariableType() {
|
||||
return isaStruct(gIR->module->getTypeByName("llvm.dbg.global_variable.type"));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLGlobalVariable* DtoDwarfCompileUnit(Module* m)
|
||||
@@ -486,12 +490,47 @@ static LLGlobalVariable* dwarfCompositeType(Loc loc, Type* type, llvm::GlobalVar
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd)
|
||||
{
|
||||
assert(vd->isDataseg());
|
||||
llvm::GlobalVariable* compileUnit = DtoDwarfCompileUnit(gIR->dmodule);
|
||||
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.push_back(llvm::ConstantExpr::getAdd(
|
||||
DtoConstUint(DW_TAG_variable),
|
||||
DtoConstUint(llvm::LLVMDebugVersion)));
|
||||
vals.push_back(DBG_CAST(GetDwarfAnchor(DW_TAG_variable)));
|
||||
|
||||
vals.push_back(DBG_CAST(compileUnit));
|
||||
|
||||
vals.push_back(DtoConstStringPtr(vd->mangle(), "llvm.metadata"));
|
||||
vals.push_back(DtoConstStringPtr(vd->toPrettyChars(), "llvm.metadata"));
|
||||
vals.push_back(DtoConstStringPtr(vd->toChars(), "llvm.metadata"));
|
||||
|
||||
vals.push_back(DBG_CAST(DtoDwarfCompileUnit(vd->getModule())));
|
||||
vals.push_back(DtoConstUint(vd->loc.linnum));
|
||||
|
||||
LLGlobalVariable* TY = dwarfTypeDescription(vd->loc, vd->type, compileUnit, NULL);
|
||||
vals.push_back(TY ? DBG_CAST(TY) : DBG_NULL);
|
||||
vals.push_back(DtoConstBool(vd->protection == PROTprivate));
|
||||
vals.push_back(DtoConstBool(vd->getModule() == gIR->dmodule));
|
||||
|
||||
vals.push_back(DBG_CAST(ll));
|
||||
|
||||
LLConstant* c = llvm::ConstantStruct::get(getDwarfGlobalVariableType(), vals);
|
||||
llvm::GlobalVariable* gv = new llvm::GlobalVariable(c->getType(), true, llvm::GlobalValue::InternalLinkage, c, "llvm.dbg.global_variable", gIR->module);
|
||||
gv->setSection("llvm.metadata");
|
||||
return gv;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static LLGlobalVariable* dwarfVariable(VarDeclaration* vd, LLGlobalVariable* typeDescr)
|
||||
{
|
||||
unsigned tag;
|
||||
if (vd->isParameter())
|
||||
tag = DW_TAG_arg_variable;
|
||||
else if (vd->isCodeseg())
|
||||
else if (vd->isDataseg())
|
||||
assert(0 && "a static variable");
|
||||
else
|
||||
tag = DW_TAG_auto_variable;
|
||||
|
||||
@@ -18,6 +18,14 @@ void DtoDwarfStopPoint(unsigned ln);
|
||||
*/
|
||||
void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd);
|
||||
|
||||
/**
|
||||
* Emits all things necessary for making debug info for a global variable vd.
|
||||
* @param ll
|
||||
* @param vd
|
||||
* @return
|
||||
*/
|
||||
LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd);
|
||||
|
||||
#endif // LLVMDC_GEN_TODEBUG_H
|
||||
|
||||
|
||||
|
||||
@@ -574,6 +574,9 @@ void VarDeclaration::toObjFile()
|
||||
DtoConstInitGlobal(this);
|
||||
else
|
||||
gIR->constInitList.push_back(this);
|
||||
|
||||
if (global.params.symdebug)
|
||||
DtoDwarfGlobalVariable(gvar, this);
|
||||
}
|
||||
|
||||
// inside aggregate declaration. declare a field.
|
||||
|
||||
@@ -768,6 +768,7 @@ tangotests/debug3.d
|
||||
tangotests/debug4.d
|
||||
tangotests/debug5.d
|
||||
tangotests/debug6.d
|
||||
tangotests/debug7.d
|
||||
tangotests/e.d
|
||||
tangotests/f.d
|
||||
tangotests/files1.d
|
||||
|
||||
9
tangotests/debug7.d
Normal file
9
tangotests/debug7.d
Normal file
@@ -0,0 +1,9 @@
|
||||
module tangotests.debug7;
|
||||
|
||||
int gi;
|
||||
|
||||
void main()
|
||||
{
|
||||
int* fail;
|
||||
*fail = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user