[LLVMdev] Next round of DWARF issues/questions

Talin viridia at gmail.com
Tue Nov 9 00:07:43 PST 2010


On Mon, Nov 8, 2010 at 9:56 AM, Devang Patel <dpatel at apple.com> wrote:

>
> On Nov 6, 2010, at 7:35 PM, Talin wrote:
>
> 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.
>
> 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.
>
> #1) Class sizes coming out as zero.
>
> In my frontend, I call DebugFactory::CreateCompositeTypeEx as follows:
>
>   DICompositeType di = dbgFactory_.CreateCompositeTypeEx(
>       type->typeClass() == Type::Class ? dwarf::DW_TAG_class_type :
> dwarf::DW_TAG_structure_type,
>       dbgCompileUnit_,
>       type->typeDefn()->linkageName().c_str(),
>       genDIFile(type->typeDefn()),
>       getSourceLineNumber(type->typeDefn()->location()),
>       getSizeOfInBits(type->irType()),
>       getAlignOfInBits(type->irType()),
>       getInt64Val(0), 0,
>       DIType(),
>       dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>
> 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):
>
>    !15 = metadata !{i32 589826, metadata !2, metadata !"tart.core.Object",
> metadata !12, i32 9,
>       i64 mul (i64 ptrtoint (%tart.core.Object* getelementptr
> (%tart.core.Object* null, i32 1) to i64), i64 8),
>
>
>
> 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.
>
>       i6 4 mul (i64 ptrtoint (%tart.core.Object* getelementptr ({ i1,
> %tart.core.Object }* null, i64 0, i32 1) to i64), i64 8),
>       i64 0, i32 0, null, metadata !16, i32 0, null} ; [ DW_TAG_class_type
> ]
>
> However, when I print out the debugging information via dwarfdump, you can
> see that the size of the object is zero:
>
> <1>< 2233>      DW_TAG_class_type
>                 DW_AT_sibling               <2295>
>                 DW_AT_name                  tart.core.Object
> *                DW_AT_byte_size             0*
>                 DW_AT_decl_file             65
>                 DW_AT_decl_line             9
> <2>< 2258>      DW_TAG_member
>                 DW_AT_name                  __tib
>                 DW_AT_type                  <2228>
>                 DW_AT_decl_file             65
>                 DW_AT_decl_line             10
>                 DW_AT_data_member_location  DW_OP_plus_uconst 0
> <2>< 2274>      DW_TAG_member
>                 DW_AT_name                  __gcstate
>                 DW_AT_type                  <156>
>                 DW_AT_decl_file             65
>                 DW_AT_decl_line             11
>                 DW_AT_data_member_location  DW_OP_plus_uconst 0
>
> In addition, it appears that all of the field offsets are zero as well -
> see the DIEs immediately following the class definition.
>
> #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:
>
> define {} @ReflectionTest.testModuleReflection(%ReflectionTest* %self) gc
> "tart-gc" {
> prologue:
>   %m = alloca %tart.reflect.Module*
>   call void @llvm.dbg.value(metadata !{%ReflectionTest* %self}, i64 0,
> metadata !1176)
>   call void @llvm.dbg.declare(metadata !{%tart.reflect.Module** %m},
> metadata !1177)
>   %0 = bitcast %tart.reflect.Module** %m to i8**, !dbg !1178
>   call void @llvm.gcroot(i8** %0, i8* null), !dbg !1178
>
>
> 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.'
>
>
> Are using -O0? You do not have line number info with dbg.declare intrinsic.
> FWIW, following works ...
>
> define void @foo() nounwind ssp {
> entry:
>   %i = alloca i32, align 4
>   call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !5), !dbg !8
>   store i32 2, i32* %i, align 4, !dbg !9
>   ret void, !dbg !10
> }
>

Hmm, well I modified the front-end to add the line number on the
dbg.declare, and I still have the same problem - the debugger can see the
function parameter 'self' but not the local variable 'm'. Here's what the IR
looks like for me:

define {} @ReflectionTest.testModuleReflection(%ReflectionTest* %self) gc
"tart-gc" {
prologue:
  %m = alloca %tart.reflect.Module*, !dbg !1410
  call void @llvm.dbg.value(metadata !{%ReflectionTest* %self}, i64 0,
metadata !1411)
  call void @llvm.dbg.declare(metadata !{%tart.reflect.Module** %m},
metadata !1412)
  %0 = bitcast %tart.reflect.Module** %m to i8**, !dbg !1413
  call void @llvm.gcroot(i8** %0, i8* null), !dbg !1413
  %gc_root = alloca %"tart.reflect.Type[]"*, !dbg !1414
  %1 = bitcast %"tart.reflect.Type[]"** %gc_root to i8**, !dbg !1414
  call void @llvm.gcroot(i8** %1, i8* null), !dbg !1414
  %gc_root25 = alloca %"tart.reflect.Method[]"*, !dbg !1416
  %2 = bitcast %"tart.reflect.Method[]"** %gc_root25 to i8**, !dbg !1416
  call void @llvm.gcroot(i8** %2, i8* null), !dbg !1416
  %gc_root29 = alloca %"tart.reflect.Method[]"*, !dbg !1418
  %3 = bitcast %"tart.reflect.Method[]"** %gc_root29 to i8**, !dbg !1418
  call void @llvm.gcroot(i8** %3, i8* null), !dbg !1418
  %gc_root33 = alloca %"tart.reflect.Type[]"*, !dbg !1419
  %4 = bitcast %"tart.reflect.Type[]"** %gc_root33 to i8**, !dbg !1419
  call void @llvm.gcroot(i8** %4, i8* null), !dbg !1419
  %gc_root36 = alloca %1*, !dbg !1420
  %5 = bitcast %1** %gc_root36 to i8**, !dbg !1420
  call void @llvm.gcroot(i8** %5, i8* null), !dbg !1420
  %gc_root40 = alloca %1*, !dbg !1420
  %6 = bitcast %1** %gc_root40 to i8**, !dbg !1420
  call void @llvm.gcroot(i8** %6, i8* null), !dbg !1420
  %gc_root43 = alloca %1*, !dbg !1422
  %7 = bitcast %1** %gc_root43 to i8**, !dbg !1422
  call void @llvm.gcroot(i8** %7, i8* null), !dbg !1422
  %gc_root47 = alloca %1*, !dbg !1422
  %8 = bitcast %1** %gc_root47 to i8**, !dbg !1422
  call void @llvm.gcroot(i8** %8, i8* null), !dbg !1422
  %gc_root50 = alloca %1*, !dbg !1424
  %9 = bitcast %1** %gc_root50 to i8**, !dbg !1424
  call void @llvm.gcroot(i8** %9, i8* null), !dbg !1424
  %gc_root54 = alloca %1*, !dbg !1424
  %10 = bitcast %1** %gc_root54 to i8**, !dbg !1424
  call void @llvm.gcroot(i8** %10, i8* null), !dbg !1424
  br label %entry, !dbg !725




> -
> Devang
>
>
>


-- 
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101109/635c92f9/attachment.html>


More information about the llvm-dev mailing list