<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 6, 2010, at 7:35 PM, Talin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">After to speaking to Devang and a number of other people at the developer's conference, I was able to make some forward progress on getting debugging to work. I'm now able to actually single-step through my program and set breakpoints, and examine function parameters.<div>

<br></div><div>However, I'm also seeing a lot of new problems which weren't exposed before. After spending the better part of two days working on them, I'd like to describe them here and get some advice on what I might be doing wrong.</div>

<div><br></div><div>#1) Class sizes coming out as zero.</div><div><br></div><div>In my frontend, I call DebugFactory::CreateCompositeTypeEx as follows:</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">  DICompositeType di = dbgFactory_.CreateCompositeTypeEx(</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">      type->typeClass() == Type::Class ? dwarf::DW_TAG_class_type : dwarf::DW_TAG_structure_type,</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      dbgCompileUnit_,</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">      type->typeDefn()->linkageName().c_str(),</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      genDIFile(type->typeDefn()),</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">      getSourceLineNumber(type->typeDefn()->location()),</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      getSizeOfInBits(type->irType()),</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">      getAlignOfInBits(type->irType()),</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      getInt64Val(0), 0,</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">      DIType(),</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      dbgFactory_.GetOrCreateArray(members.data(), members.size()));</font></div>

<div> <br clear="all">The 'getSizeOfInBits()' function and the others like it basically call llvm::ConstantExpr::getSizeOf() and then multiple the result by 8. Looking at the generated IR, I can see that the expressions look correct to me (I've added some line breaks for clarity):</div>

<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">   !15 = metadata !{i32 589826, metadata !2, metadata !"tart.core.Object", metadata !12, i32 9,</font></div><div><font class="Apple-style-span" face="'courier new', monospace">      i64 mul (i64 ptrtoint (%tart.core.Object* getelementptr (%tart.core.Object* null, i32 1) to i64), i64 8),</font></div></div></blockquote><div><br></div><div><br></div>This does not work. The DebugInfo accessors uses getSizeInBits() to get an integer for the size. You will have to modify it to get the value.</div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font><blockquote type="cite"><div>

<div><font class="Apple-style-span" face="'courier new', monospace">      i6 4 mul (i64 ptrtoint (%tart.core.Object* getelementptr ({ i1, %tart.core.Object }* null, i64 0, i32 1) to i64), i64 8),</font></div><div>

<font class="Apple-style-span" face="'courier new', monospace">      i64 0, i32 0, null, metadata !16, i32 0, null} ; [ DW_TAG_class_type ]</font></div></div><div><br></div><div>However, when I print out the debugging information via dwarfdump, you can see that the size of the object is zero:</div>

<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><1>< 2233>      DW_TAG_class_type</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_sibling               <2295></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_name                  tart.core.Object</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><b>                DW_AT_byte_size             0</b></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_file             65</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_line             9</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><2>< 2258>      DW_TAG_member</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_name                  __tib</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_type                  <2228></font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_file             65</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_line             10</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_data_member_location  DW_OP_plus_uconst 0</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><2>< 2274>      DW_TAG_member</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_name                  __gcstate</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_type                  <156></font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_file             65</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_decl_line             11</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                DW_AT_data_member_location  DW_OP_plus_uconst 0</font></div>

</div><div><br></div><div>In addition, it appears that all of the field offsets are zero as well - see the DIEs immediately following the class definition.</div><div><br></div><div>#2) I can't seem to get llvm.dbg.declare() to work for local variables, although it appears to work fine for function parameters. For example, look at the following snippet of IR:</div>

<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace">define {} @ReflectionTest.testModuleReflection(%ReflectionTest* %self) gc "tart-gc" {</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">prologue:</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  %m = alloca %tart.reflect.Module*</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  call void @llvm.dbg.value(metadata !{%ReflectionTest* %self}, i64 0, metadata !1176)</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  call void @llvm.dbg.declare(metadata !{%tart.reflect.Module** %m}, metadata !1177)</font></div>

</div><div><div><font class="Apple-style-span" face="'courier new', monospace">  %0 = bitcast %tart.reflect.Module** %m to i8**, !dbg !1178</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  call void @llvm.gcroot(i8** %0, i8* null), !dbg !1178</font></div>

</div></blockquote><div><br></div><div>In the debugger, I can examine the value of 'self', however when I attempt to print the value of 'm', gdb reports 'No symbol "m" in current context.'</div></blockquote><div><br></div><div>Are using -O0? You do not have line number info with dbg.declare intrinsic. FWIW, following works ...</div><div><br></div><div><div>define void @foo() nounwind ssp {</div><div>entry:</div><div>  %i = alloca i32, align 4</div><div>  call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !5), !dbg !8</div><div>  store i32 2, i32* %i, align 4, !dbg !9</div><div>  ret void, !dbg !10</div><div>}</div></div><div><br></div><div>-</div><div>Devang</div><br></div><br></body></html>