From 38fe71563869086ab5f4bbc2e1bd1236ad804511 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sat, 8 Jan 2011 18:00:04 +0300 Subject: [PATCH] Work on debug --- gen/todebug.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 393197a6..03b15e29 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -206,9 +206,9 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit if (t->ty == Tarray) { tag = DW_TAG_structure_type; + file = DtoDwarfFile(Loc(gIR->dmodule, 0), DtoDwarfCompileUnit(gIR->dmodule)); 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,8 @@ void DtoDwarfStopPoint(unsigned ln) void DtoDwarfValue(LLValue* var, VarDeclaration* vd) { - gIR->difactory.InsertDbgValueIntrinsic(var, 0, vd->debugVariable, gIR->scopebb()); + llvm::Instruction *instr = gIR->difactory.InsertDbgValueIntrinsic(vd->ir.irLocal->value, 0, vd->debugVariable, gIR->scopebb()); + instr->setDebugLoc(gIR->ir->getCurrentDebugLocation()); } #endif