# HG changeset patch # User Tomas Lindquist Olsen # Date 1242575753 -7200 # Node ID 5a54b39af6d66074f21661b00d0368c1c0bfc8c0 # Parent 5855958073a92a29b088fb08e354e95a8fbae75f Add debug info for all class fields, including those from super classes... diff -r 5855958073a9 -r 5a54b39af6d6 gen/todebug.cpp --- a/gen/todebug.cpp Sun May 17 17:10:26 2009 +0200 +++ b/gen/todebug.cpp Sun May 17 17:55:53 2009 +0200 @@ -215,6 +215,28 @@ ////////////////////////////////////////////////////////////////////////////////////////////////// +static void add_base_fields( + ClassDeclaration* sd, + llvm::DICompileUnit compileUnit, + llvm::DICompileUnit definedCU, + std::vector& elems) +{ + if (sd->baseClass) + { + add_base_fields(sd->baseClass, compileUnit, definedCU, elems); + } + + ArrayIter it(sd->fields); + size_t narr = sd->fields.dim; + elems.reserve(narr); + for (; !it.done(); it.next()) + { + VarDeclaration* vd = it.get(); + LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV(); + elems.push_back(DBG_CAST(ptr)); + } +} + //FIXME: This does not use llvm's DIFactory as it can't // handle recursive types properly. static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit compileUnit) @@ -301,14 +323,21 @@ std::vector elems; if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one { - ArrayIter it(sd->fields); - size_t narr = sd->fields.dim; - elems.reserve(narr); - for (; !it.done(); it.next()) + if (t->ty == Tstruct) { - VarDeclaration* vd = it.get(); - LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV(); - elems.push_back(DBG_CAST(ptr)); + ArrayIter it(sd->fields); + size_t narr = sd->fields.dim; + elems.reserve(narr); + for (; !it.done(); it.next()) + { + VarDeclaration* vd = it.get(); + LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV(); + elems.push_back(DBG_CAST(ptr)); + } + } + else + { + add_base_fields(ir->aggrdecl->isClassDeclaration(), compileUnit, definedCU, elems); } }