comparison gen/todebug.cpp @ 1388:5a54b39af6d6

Add debug info for all class fields, including those from super classes...
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Sun, 17 May 2009 17:55:53 +0200
parents b8c2f3e05b52
children 855f188aab7a
comparison
equal deleted inserted replaced
1387:5855958073a9 1388:5a54b39af6d6
213 ); 213 );
214 } 214 }
215 215
216 ////////////////////////////////////////////////////////////////////////////////////////////////// 216 //////////////////////////////////////////////////////////////////////////////////////////////////
217 217
218 static void add_base_fields(
219 ClassDeclaration* sd,
220 llvm::DICompileUnit compileUnit,
221 llvm::DICompileUnit definedCU,
222 std::vector<LLConstant*>& elems)
223 {
224 if (sd->baseClass)
225 {
226 add_base_fields(sd->baseClass, compileUnit, definedCU, elems);
227 }
228
229 ArrayIter<VarDeclaration> it(sd->fields);
230 size_t narr = sd->fields.dim;
231 elems.reserve(narr);
232 for (; !it.done(); it.next())
233 {
234 VarDeclaration* vd = it.get();
235 LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV();
236 elems.push_back(DBG_CAST(ptr));
237 }
238 }
239
218 //FIXME: This does not use llvm's DIFactory as it can't 240 //FIXME: This does not use llvm's DIFactory as it can't
219 // handle recursive types properly. 241 // handle recursive types properly.
220 static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit compileUnit) 242 static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit compileUnit)
221 { 243 {
222 const LLType* T = DtoType(type); 244 const LLType* T = DtoType(type);
299 definedCU = DtoDwarfCompileUnit(getDefinedModule(sd)); 321 definedCU = DtoDwarfCompileUnit(getDefinedModule(sd));
300 322
301 std::vector<LLConstant*> elems; 323 std::vector<LLConstant*> elems;
302 if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one 324 if (!ir->aggrdecl->isInterfaceDeclaration()) // plain interfaces don't have one
303 { 325 {
304 ArrayIter<VarDeclaration> it(sd->fields); 326 if (t->ty == Tstruct)
305 size_t narr = sd->fields.dim;
306 elems.reserve(narr);
307 for (; !it.done(); it.next())
308 { 327 {
309 VarDeclaration* vd = it.get(); 328 ArrayIter<VarDeclaration> it(sd->fields);
310 LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV(); 329 size_t narr = sd->fields.dim;
311 elems.push_back(DBG_CAST(ptr)); 330 elems.reserve(narr);
331 for (; !it.done(); it.next())
332 {
333 VarDeclaration* vd = it.get();
334 LLGlobalVariable* ptr = dwarfMemberType(vd->loc.linnum, vd->type, compileUnit, definedCU, vd->toChars(), vd->offset).getGV();
335 elems.push_back(DBG_CAST(ptr));
336 }
337 }
338 else
339 {
340 add_base_fields(ir->aggrdecl->isClassDeclaration(), compileUnit, definedCU, elems);
312 } 341 }
313 } 342 }
314 343
315 const LLArrayType* at = LLArrayType::get(DBG_TYPE, elems.size()); 344 const LLArrayType* at = LLArrayType::get(DBG_TYPE, elems.size());
316 LLConstant* ca = LLConstantArray::get(at, elems); 345 LLConstant* ca = LLConstantArray::get(at, elems);