From 89aeb05042b2fe6a86b48372edde90ccadf3789c Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Fri, 14 Jan 2011 14:38:38 +0100 Subject: [PATCH] apply fixed debug info fix, see #452; thanks to sokol --- gen/todebug.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 393197a6..d290a70f 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -205,10 +205,10 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit // dynamic array if (t->ty == Tarray) { + file = DtoDwarfFile(Loc(gIR->dmodule, 0), DtoDwarfCompileUnit(gIR->dmodule)); tag = DW_TAG_structure_type; elems.push_back(dwarfMemberType(0, Type::tsize_t, compileUnit, file, "length", 0)); elems.push_back(dwarfMemberType(0, t->nextOf()->pointerTo(), compileUnit, file, "ptr", global.params.is64bit?8:4)); - file = DtoDwarfFile(Loc(gIR->dmodule, 0), DtoDwarfCompileUnit(gIR->dmodule)); } // struct/class @@ -350,7 +350,7 @@ static llvm::DIVariable dwarfVariable(VarDeclaration* vd, llvm::DIType type) return gIR->difactory.CreateVariable( tag, // tag - gIR->func()->diLexicalBlock, // context + gIR->func()->diSubprogram, // context vd->toChars(), // name DtoDwarfFile(vd->loc, DtoDwarfCompileUnit(getDefinedModule(vd))), // file vd->loc.linnum, // line num @@ -363,7 +363,8 @@ static llvm::DIVariable dwarfVariable(VarDeclaration* vd, llvm::DIType type) static void dwarfDeclare(LLValue* var, llvm::DIVariable divar) { - gIR->difactory.InsertDeclare(var, divar, gIR->scopebb()); + llvm::Instruction *instr = gIR->difactory.InsertDeclare(var, divar, gIR->scopebb()); + instr->setDebugLoc(gIR->ir->getCurrentDebugLocation()); } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -532,11 +533,12 @@ void DtoDwarfFuncStart(FuncDeclaration* fd) LOG_SCOPE; assert((llvm::MDNode*)fd->ir.irFunc->diSubprogram != 0); - fd->ir.irFunc->diLexicalBlock = gIR->difactory.CreateLexicalBlock( + DtoDwarfStopPoint(fd->loc.linnum); + /* fd->ir.irFunc->diLexicalBlock = gIR->difactory.CreateLexicalBlock( fd->ir.irFunc->diSubprogram, // context DtoDwarfFile(fd->loc, DtoDwarfCompileUnit(getDefinedModule(fd))), // file fd->loc.linnum - ); + );*/ } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -563,7 +565,11 @@ void DtoDwarfStopPoint(unsigned ln) void DtoDwarfValue(LLValue* var, VarDeclaration* vd) { - gIR->difactory.InsertDbgValueIntrinsic(var, 0, vd->debugVariable, gIR->scopebb()); + if (llvm::isa(vd->ir.irLocal->value) == 0) + return; + + llvm::Instruction *instr = gIR->difactory.InsertDbgValueIntrinsic(vd->ir.irLocal->value, 0, vd->debugVariable, gIR->scopebb()); + instr->setDebugLoc(gIR->ir->getCurrentDebugLocation()); } #endif