[lldb-dev] disassemble w/ source

Michael Sartain mikesart at gmail.com
Fri Jul 5 15:54:39 PDT 2013


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.

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:

// Disassembler::PrintInstructions()
 443+>
 debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers
(sc.line_entry.file,
 444|
                             sc.line_entry.line,
 445|
                             num_mixed_context_lines,
 446|
                             num_mixed_context_lines,
 447|
                             ((inst_is_at_pc && (options &
eOptionMarkPCSourceLine)) ? "->" : "")
 448|
                             &strm);

SourceManager.cpp, SourceManager::File::File() is not resolving the
filename because there is no target set:

    if (!m_mod_time.IsValid())
    {
        if (target)
        {
            m_source_map_mod_id =
target->GetSourcePathMap().GetModificationID();

            if (!file_spec.GetDirectory() && file_spec.GetFilename())
            {

The SourceManager class has two constructors, and the debugger one doesn't
appear to set the target:

//----------------------------------------------------------------------
// SourceManager constructor
//----------------------------------------------------------------------
SourceManager::SourceManager(const TargetSP &target_sp) :
    m_last_file_sp (),
    m_last_line (0),
    m_last_count (0),
    m_default_set(false),
    m_target_wp (target_sp),
    m_debugger_wp(target_sp->GetDebugger().shared_from_this())
{
}

SourceManager::SourceManager(const DebuggerSP &debugger_sp) :
    m_last_file_sp (),
    m_last_line (0),
    m_last_count (0),
    m_default_set(false),
    m_target_wp (),
    m_debugger_wp (debugger_sp)
{
}

Thoughts on how best to fix this?
Thanks.
 -Mike

Example:

mikesart at mikesart-rad:~/data/src/blah2/build$ lldb -- blah
Current executable set to 'blah' (x86_64).
(lldb) b __printf
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 14039 launched: '/home/mikesart/data/src/blah2/build/blah' (x86_64)
1 location added to breakpoint 1
Process 14039 stopped
* thread #1: tid = 0x36d7, 0x00007fe484b5b89b
libc.so.6`__printf(format=0x0000000000401fc6) + 91 at printf.c:34, stop
reason = breakpoint 1.1
    frame #0: 0x00007fe484b5b89b
libc.so.6`__printf(format=0x0000000000401fc6) + 91 at printf.c:34
   31     va_list arg;
   32     int done;
   33
-> 34     va_start (arg, format);
   35     done = vfprintf (stdout, format, arg);
   36     va_end (arg);
   37
(lldb) n
Process 14039 stopped
* thread #1: tid = 0x36d7, 0x00007fe484b5b8a3
libc.so.6`__printf(format=0x0000000000401fc6) + 99 at printf.c:30, stop
reason = step over
    frame #0: 0x00007fe484b5b8a3
libc.so.6`__printf(format=0x0000000000401fc6) + 99 at printf.c:30
   27   /* VARARGS1 */
   28   int
   29   __printf (const char *format, ...)
-> 30   {
   31     va_list arg;
   32     int done;
   33
(lldb) disassemble -m
libc.so.6`__printf at printf.c:30
   0x7fe484b5b840:  subq   $216, %rsp
   0x7fe484b5b847:  testb  %al, %al
   0x7fe484b5b849:  movq   %rsi, 40(%rsp)
   0x7fe484b5b84e:  movq   %rdx, 48(%rsp)
   0x7fe484b5b853:  movq   %rcx, 56(%rsp)
   0x7fe484b5b858:  movq   %r8, 64(%rsp)
   0x7fe484b5b85d:  movq   %r9, 72(%rsp)
   0x7fe484b5b862:  je     0x7fe484b5b89b            ; __printf + 91 at
printf.c:34
libc.so.6`__printf + 36 at printf.c:30
   0x7fe484b5b864:  movaps %xmm0, 80(%rsp)
   0x7fe484b5b869:  movaps %xmm1, 96(%rsp)
   0x7fe484b5b86e:  movaps %xmm2, 112(%rsp)
   0x7fe484b5b873:  movaps %xmm3, 128(%rsp)
   0x7fe484b5b87b:  movaps %xmm4, 144(%rsp)
   0x7fe484b5b883:  movaps %xmm5, 160(%rsp)
   0x7fe484b5b88b:  movaps %xmm6, 176(%rsp)
   0x7fe484b5b893:  movaps %xmm7, 192(%rsp)
libc.so.6`__printf + 91 at printf.c:34
   0x7fe484b5b89b:  leaq   224(%rsp), %rax
libc.so.6`__printf + 99 at printf.c:30
-> 0x7fe484b5b8a3:  movq   %rdi, %rsi
libc.so.6`__printf + 102 at printf.c:35
   0x7fe484b5b8a6:  leaq   8(%rsp), %rdx
libc.so.6`__printf + 107 at printf.c:34
   0x7fe484b5b8ab:  movl   $8, 8(%rsp)
   0x7fe484b5b8b3:  movl   $48, 12(%rsp)
   0x7fe484b5b8bb:  movq   %rax, 16(%rsp)
   0x7fe484b5b8c0:  leaq   32(%rsp), %rax
   0x7fe484b5b8c5:  movq   %rax, 24(%rsp)
libc.so.6`__printf + 138 at printf.c:35
   0x7fe484b5b8ca:  movq   3556935(%rip), %rax
   0x7fe484b5b8d1:  movq   (%rax), %rdi
   0x7fe484b5b8d4:  callq  0x7fe484b509c0            ;
_IO_vfprintf_internal at vfprintf.c:211
libc.so.6`__printf + 153 at printf.c:39
   0x7fe484b5b8d9:  addq   $216, %rsp
   0x7fe484b5b8e0:  ret
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130705/63df75aa/attachment.html>


More information about the lldb-dev mailing list