<div dir="ltr">I'm trying to diagnose a problem with the IRInterpreter, but this is all very foreign to me so I think I should ask here.<div><br></div><div>Before I go into the details though, a simple question which I don't want to get lost in the shuffle: Why doesn't LLDB use LLI instead of creating its own interpreter?<br>
<div><br></div><div>Anyway, on to the problem. First of all, this is only on Windows. This all just works on Linux and presumably Mac, although I don't have a Mac to test. The scenario is this: I run the following two commands:</div>
<div><br></div><div>(lldb) expr const unsigned int $foo = 5</div><div>(lldb) expr &$foo</div><div><br></div><div>And this results in an error. Printing the value of $foo works fine, it just can't get the address. </div>
</div><div><br></div><div>I turn on logging and I see this:</div><div><br></div><div><div>Module as passed in to IRInterpreter::Interpret: </div><div>"; ModuleID = '$__lldb_module'</div><div>target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"</div>
<div>target triple = "i686-pc-windows-msvc"</div><div><br></div><div><b>@"\01?$S1@?0??$__lldb_expr@@YAXPAX@Z@4IA" = internal global i32 0</b></div><div><br></div><div>; Function Attrs: nounwind</div><div>
define void @"\01?$__lldb_expr@@YAXPAX@Z"(i8* %"$__lldb_arg") #0 {</div><div> %1 = getelementptr i8* %"$__lldb_arg", i32 8</div><div> %2 = bitcast i8* %1 to i32**</div><div> %3 = getelementptr i8* %"$__lldb_arg", i32 0</div>
<div> %4 = bitcast i8* %3 to i32***</div><div> %5 = load i32*** %4</div><div> %6 = alloca i8*, align 4, !clang.decl.ptr !8</div><div> store i8* %"$__lldb_arg", i8** %6, align 4</div><div><b> %7 = load i32* @"\01?$S1@?0??$__lldb_expr@@YAXPAX@Z@4IA"</b></div>
<div> %8 = and i32 %7, 1</div><div> %9 = icmp ne i32 %8, 0</div><div> br i1 %9, label %13, label %10</div><div><br></div><div>; <label>:10 ; preds = %0</div><div> %11 = or i32 %7, 1</div>
<div> store i32 %11, i32* @"\01?$S1@?0??$__lldb_expr@@YAXPAX@Z@4IA"</div><div> %12 = load i32** %2, align 4</div><div> store i32* %12, i32** %5, align 4</div><div> br label %13</div><div><br></div><div>; <label>:13 ; preds = %10, %0</div>
<div> ret void</div><div>}</div><div><br></div><div>attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="0" "unsafe-fp-math"="false" "use-soft-float"="false" }</div>
<div><br></div><div>!clang.global.decl.ptrs = !{!0, !1, !2, !0, !0}</div><div>!llvm.module.flags = !{!3, !4, !5, !6}</div><div>!llvm.ident = !{!7}</div><div><br></div><div>!0 = metadata !{null, i64 7787680}</div><div>!1 = metadata !{null, i64 7787504}</div>
<div>!2 = metadata !{void (i8*)* @"\01?$__lldb_expr@@YAXPAX@Z", i64 7787328}</div><div>!3 = metadata !{i32 1, metadata !"Objective-C Version", i32 2}</div><div>!4 = metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}</div>
<div>!5 = metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__DATA, __objc_imageinfo, regular, no_dead_strip"}</div><div>!6 = metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 0}</div>
<div>!7 = metadata !{metadata !"clang version 3.5.0 "}</div><div>!8 = metadata !{i64 7787200}</div><div>"</div><div>IRMemoryMap::WriteMemory (0x81ffc, 0x124db54, 0x4) went to [0x2000..0x82000)</div><div>Made an allocation for argument i8* %"$__lldb_arg"</div>
<div> Data region : 1000</div><div> Ref region : 81ffc</div><div>Interpreting %1 = getelementptr i8* %"$__lldb_arg", i32 8</div><div>IRMemoryMap::WriteMemory (0x81ff8, 0x702b00, 0x4) went to [0x2000..0x82000)</div>
<div>Interpreted a GetElementPtrInst</div><div> P : i8* %"$__lldb_arg" 0x81ffc</div><div> Poffset : %1 = getelementptr i8* %"$__lldb_arg", i32 8 0x81ff8</div><div>Interpreting %2 = bitcast i8* %1 to i32**</div>
<div>IRMemoryMap::WriteMemory (0x81ff4, 0x702b00, 0x4) went to [0x2000..0x82000)</div><div>Interpreting %3 = getelementptr i8* %"$__lldb_arg", i32 0</div><div>IRMemoryMap::WriteMemory (0x81ff0, 0x702b00, 0x4) went to [0x2000..0x82000)</div>
<div>Interpreted a GetElementPtrInst</div><div> P : i8* %"$__lldb_arg" 0x81ffc</div><div> Poffset : %3 = getelementptr i8* %"$__lldb_arg", i32 0 0x81ff0</div><div>Interpreting %4 = bitcast i8* %3 to i32***</div>
<div>IRMemoryMap::WriteMemory (0x81fec, 0x702b00, 0x4) went to [0x2000..0x82000)</div><div>Interpreting %5 = load i32*** %4</div><div>IRMemoryMap::ReadMemory (0x81fec, 0x702b00, 0x4) came from [0x2000..0x82000)</div><div>
IRMemoryMap::ReadMemory (0x1000, 0x702b00, 0x4) came from [0x1000..0x1010)</div><div>IRMemoryMap::WriteMemory (0x81fe8, 0x702b00, 0x4) went to [0x2000..0x82000)</div><div>Interpreted a LoadInst</div><div> P : 0x81fec</div>
<div> R : 0x1000</div><div> D : 0x81fe8</div><div>Interpreting %6 = alloca i8*, align 4, !clang.decl.ptr !8</div><div>IRMemoryMap::WriteMemory (0x81fe0, 0x124dc00, 0x4) went to [0x2000..0x82000)</div><div>Interpreted an AllocaInst</div>
<div> R : 0x81fe4</div><div> P : 0x81fe0</div><div>Interpreting store i8* %"$__lldb_arg", i8** %6, align 4</div><div>IRMemoryMap::ReadMemory (0x81fe0, 0x702b00, 0x4) came from [0x2000..0x82000)</div><div>IRMemoryMap::ReadMemory (0x81ffc, 0x702b00, 0x4) came from [0x2000..0x82000)</div>
<div>IRMemoryMap::WriteMemory (0x81fe4, 0x702b00, 0x4) went to [0x2000..0x82000)</div><div>Interpreted a StoreInst</div><div> D : 0x81ffc</div><div> P : 0x81fe0</div><div> R : 0x81fe4</div><div><b>Interpreting %7 = load i32* @"\01?$S1@?0??$__lldb_expr@@YAXPAX@Z@4IA"</b></div>
<div><b>LoadInst's pointer doesn't resolve to anything</b></div></div><div><b><br></b></div><div>I've bolded a few of the relevant lines. I'm not really sure what's going on here, or even how to diagnose it. Can anyone offer some advice?<b><br>
</b></div><div><br></div><div>Thanks</div><div><br></div></div>