<div dir="ltr"><div>When I explicitly run the "disassemble -m -n printf" command I don't get source even though we've obviously got source and I'm stepping through it. Example is way down below.</div>
<div><br></div><div>I was hoping someone might be able to explain the the SourceManager class a bit. It looks like this function is being called to display the source:</div><div><br></div><div>// Disassembler::PrintInstructions()</div>
<div><div> 443+> debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.line_entry.file,</div><div> 444| sc.line_entry.line,</div>
<div> 445| num_mixed_context_lines,</div><div> 446| num_mixed_context_lines,</div>
<div> 447| ((inst_is_at_pc && (options & eOptionMarkPCSourceLine)) ? "->" : "")</div><div>
448| &strm);</div></div><div><br></div><div>SourceManager.cpp, SourceManager::File::File() is not resolving the filename because there is no target set:</div>
<div><br></div><div><div> if (!m_mod_time.IsValid())</div><div> {</div><div> if (target)</div><div> {</div><div> m_source_map_mod_id = target->GetSourcePathMap().GetModificationID();</div>
<div><br></div><div> if (!file_spec.GetDirectory() && file_spec.GetFilename())</div><div> {</div></div><div><br></div><div>The SourceManager class has two constructors, and the debugger one doesn't appear to set the target:</div>
<div><br></div><div><div>//----------------------------------------------------------------------</div><div>// SourceManager constructor</div><div>//----------------------------------------------------------------------</div>
<div>SourceManager::SourceManager(const TargetSP &target_sp) :</div><div> m_last_file_sp (),</div><div> m_last_line (0),</div><div> m_last_count (0),</div><div> m_default_set(false),</div><div> m_target_wp (target_sp),</div>
<div> m_debugger_wp(target_sp->GetDebugger().shared_from_this())</div><div>{</div><div>}</div><div><br></div><div>SourceManager::SourceManager(const DebuggerSP &debugger_sp) :</div><div> m_last_file_sp (),</div>
<div> m_last_line (0),</div><div> m_last_count (0),</div><div> m_default_set(false),</div><div> m_target_wp (),</div><div> m_debugger_wp (debugger_sp)</div><div>{</div><div>}</div></div><div><br></div><div>
Thoughts on how best to fix this?</div><div>Thanks.</div><div> -Mike</div><div><br></div><div>Example:</div><div><br></div><div>mikesart@mikesart-rad:~/data/src/blah2/build$ lldb -- blah</div><div>Current executable set to 'blah' (x86_64).</div>
<div>(lldb) b __printf</div><div>Breakpoint 1: no locations (pending).</div><div>WARNING: Unable to resolve breakpoint to any actual locations.</div><div>(lldb) r</div><div>Process 14039 launched: '/home/mikesart/data/src/blah2/build/blah' (x86_64)</div>
<div>1 location added to breakpoint 1</div><div>Process 14039 stopped</div><div>* thread #1: tid = 0x36d7, 0x00007fe484b5b89b libc.so.6`__printf(format=0x0000000000401fc6) + 91 at printf.c:34, stop reason = breakpoint 1.1</div>
<div> frame #0: 0x00007fe484b5b89b libc.so.6`__printf(format=0x0000000000401fc6) + 91 at printf.c:34</div><div> 31 va_list arg;</div><div> 32 int done;</div><div> 33 </div><div>-> 34 va_start (arg, format);</div>
<div> 35 done = vfprintf (stdout, format, arg);</div><div> 36 va_end (arg);</div><div> 37 </div><div>(lldb) n</div><div>Process 14039 stopped</div><div>* thread #1: tid = 0x36d7, 0x00007fe484b5b8a3 libc.so.6`__printf(format=0x0000000000401fc6) + 99 at printf.c:30, stop reason = step over</div>
<div> frame #0: 0x00007fe484b5b8a3 libc.so.6`__printf(format=0x0000000000401fc6) + 99 at printf.c:30</div><div> 27 /* VARARGS1 */</div><div> 28 int</div><div> 29 __printf (const char *format, ...)</div><div>
-> 30 {</div><div> 31 va_list arg;</div><div> 32 int done;</div><div> 33 </div><div>(lldb) disassemble -m</div><div>libc.so.6`__printf at printf.c:30</div><div> 0x7fe484b5b840: subq $216, %rsp</div>
<div> 0x7fe484b5b847: testb %al, %al</div><div> 0x7fe484b5b849: movq %rsi, 40(%rsp)</div><div> 0x7fe484b5b84e: movq %rdx, 48(%rsp)</div><div> 0x7fe484b5b853: movq %rcx, 56(%rsp)</div><div> 0x7fe484b5b858: movq %r8, 64(%rsp)</div>
<div> 0x7fe484b5b85d: movq %r9, 72(%rsp)</div><div> 0x7fe484b5b862: je 0x7fe484b5b89b ; __printf + 91 at printf.c:34</div><div>libc.so.6`__printf + 36 at printf.c:30</div><div> 0x7fe484b5b864: movaps %xmm0, 80(%rsp)</div>
<div> 0x7fe484b5b869: movaps %xmm1, 96(%rsp)</div><div> 0x7fe484b5b86e: movaps %xmm2, 112(%rsp)</div><div> 0x7fe484b5b873: movaps %xmm3, 128(%rsp)</div><div> 0x7fe484b5b87b: movaps %xmm4, 144(%rsp)</div><div>
0x7fe484b5b883: movaps %xmm5, 160(%rsp)</div>
<div> 0x7fe484b5b88b: movaps %xmm6, 176(%rsp)</div><div> 0x7fe484b5b893: movaps %xmm7, 192(%rsp)</div><div>libc.so.6`__printf + 91 at printf.c:34</div><div> 0x7fe484b5b89b: leaq 224(%rsp), %rax</div><div>libc.so.6`__printf + 99 at printf.c:30</div>
<div>-> 0x7fe484b5b8a3: movq %rdi, %rsi</div><div>libc.so.6`__printf + 102 at printf.c:35</div><div> 0x7fe484b5b8a6: leaq 8(%rsp), %rdx</div><div>libc.so.6`__printf + 107 at printf.c:34</div><div> 0x7fe484b5b8ab: movl $8, 8(%rsp)</div>
<div> 0x7fe484b5b8b3: movl $48, 12(%rsp)</div><div> 0x7fe484b5b8bb: movq %rax, 16(%rsp)</div><div> 0x7fe484b5b8c0: leaq 32(%rsp), %rax</div><div> 0x7fe484b5b8c5: movq %rax, 24(%rsp)</div><div>libc.so.6`__printf + 138 at printf.c:35</div>
<div> 0x7fe484b5b8ca: movq 3556935(%rip), %rax</div><div> 0x7fe484b5b8d1: movq (%rax), %rdi</div><div> 0x7fe484b5b8d4: callq 0x7fe484b509c0 ; _IO_vfprintf_internal at vfprintf.c:211</div><div>libc.so.6`__printf + 153 at printf.c:39</div>
<div> 0x7fe484b5b8d9: addq $216, %rsp</div><div> 0x7fe484b5b8e0: ret </div><div><br></div></div>