[lldb-dev] breakpoint command

Michael Sartain mikesart at valvesoftware.com
Wed Jun 19 14:49:09 PDT 2013


On Tue, Jun 18, 2013 at 6:58 PM, <jingham at apple.com> wrote:

> I don't know what more recent gcc's do, but they used to omit the
> prologue_end marker, and instead use the convention that the first line
> table entry for the function is the beginning of the function, and the
> second is the end of the prologue.  gdb has relied on that for a long long
> time (in absence of the prologue_end and back to the stabs days when there
> was no such thing.)
>

I think Jim is absolutely right here with his very useful reply. It looks
like gdb ignores the prologue end stuff entirely (which makes sense since
it doesn't look like gcc outputs it), and it sets the breakpoint on the
second line table entry. But in this case:

0x00400764  [   6, 0] NS uri: "/home/mikesart/data/src/blah2/blah.cpp"
> 0x00400796  [   6, 0] NS
> 0x004007bd  [  10, 0] NS
> 0x004007ea  [  11, 0] NS


gdb is treating 0x004007bd as the second line table entry, and lldb is
treating 0x00400796 as the second. This is pretty clear with the
disassembly output down below.

The problem in this case is that second block with the sse movaps
instructions isn't run, so the breakpoint is never hit.

So I think the change would be in how lldb handles what the second line
table entry is? Ie, skip duplicate entries.
 -Mike

(lldb) disassemble -n myprintf -m
blah`myprintf(char const*, ...) at blah.cpp:6
   5    myprintf (const char *format, ...)
   6    {
   7      va_list arg;
blah[0x400764]:  pushq  %rbp
blah[0x400765]:  movq   %rsp, %rbp
blah[0x400768]:  subq   $224, %rsp
blah[0x40076f]:  movq   %rsi, -168(%rbp)
blah[0x400776]:  movq   %rdx, -160(%rbp)
blah[0x40077d]:  movq   %rcx, -152(%rbp)
blah[0x400784]:  movq   %r8, -144(%rbp)
blah[0x40078b]:  movq   %r9, -136(%rbp)
blah[0x400792]:  testb  %al, %al
blah[0x400794]:  je     0x4007b6                  ; myprintf(char const*,
...) + 82 at blah.cpp:6
blah`myprintf(char const*, ...) + 50 at blah.cpp:6
   5    myprintf (const char *format, ...)
   6    {
   7      va_list arg;
blah[0x400796]:  movaps %xmm0, -128(%rbp)
blah[0x40079a]:  movaps %xmm1, -112(%rbp)
blah[0x40079e]:  movaps %xmm2, -96(%rbp)
blah[0x4007a2]:  movaps %xmm3, -80(%rbp)
blah[0x4007a6]:  movaps %xmm4, -64(%rbp)
blah[0x4007aa]:  movaps %xmm5, -48(%rbp)
blah[0x4007ae]:  movaps %xmm6, -32(%rbp)
blah[0x4007b2]:  movaps %xmm7, -16(%rbp)
blah[0x4007b6]:  movq   %rdi, -216(%rbp)
blah`myprintf(char const*, ...) + 89 at blah.cpp:10
   9
   10     va_start (arg, format);
   11     done = vfprintf (stdout, format, arg);
blah[0x4007bd]:  movl   $8, -208(%rbp)
blah[0x4007c7]:  movl   $48, -204(%rbp)
blah[0x4007d1]:  leaq   16(%rbp), %rax
blah[0x4007d5]:  movq   %rax, -200(%rbp)
blah[0x4007dc]:  leaq   -176(%rbp), %rax
blah[0x4007e3]:  movq   %rax, -192(%rbp)
blah`myprintf(char const*, ...) + 134 at blah.cpp:11


(gdb) disassemble /m myprintf
Dump of assembler code for function myprintf(char const*, ...):
6       {
   0x0000000000400764 <+0>:     push   rbp
   0x0000000000400765 <+1>:     mov    rbp,rsp
   0x0000000000400768:  sub    rsp,0xe0
   0x000000000040076f:  mov    QWORD PTR [rbp-0xa8],rsi
   0x0000000000400776:  mov    QWORD PTR [rbp-0xa0],rdx
   0x000000000040077d:  mov    QWORD PTR [rbp-0x98],rcx
   0x0000000000400784:  mov    QWORD PTR [rbp-0x90],r8
   0x000000000040078b:  mov    QWORD PTR [rbp-0x88],r9
   0x0000000000400792:  test   al,al
   0x0000000000400794:  je     0x4007b6
   0x0000000000400796:  movaps XMMWORD PTR [rbp-0x80],xmm0
   0x000000000040079a:  movaps XMMWORD PTR [rbp-0x70],xmm1
   0x000000000040079e:  movaps XMMWORD PTR [rbp-0x60],xmm2
   0x00000000004007a2:  movaps XMMWORD PTR [rbp-0x50],xmm3
   0x00000000004007a6:  movaps XMMWORD PTR [rbp-0x40],xmm4
   0x00000000004007aa:  movaps XMMWORD PTR [rbp-0x30],xmm5
   0x00000000004007ae:  movaps XMMWORD PTR [rbp-0x20],xmm6
   0x00000000004007b2:  movaps XMMWORD PTR [rbp-0x10],xmm7
   0x00000000004007b6:  mov    QWORD PTR [rbp-0xd8],rdi
7         va_list arg;
8         int done;
9
10        va_start (arg, format);
   0x00000000004007bd:  mov    DWORD PTR [rbp-0xd0],0x8
   0x00000000004007c7:  mov    DWORD PTR [rbp-0xcc],0x30
   0x00000000004007d1:  lea    rax,[rbp+0x10]
   0x00000000004007d5:  mov    QWORD PTR [rbp-0xc8],rax
   0x00000000004007dc:  lea    rax,[rbp-0xb0]
   0x00000000004007e3:  mov    QWORD PTR [rbp-0xc0],rax
11        done = vfprintf (stdout, format, arg);
   0x00000000004007ea:  mov    rax,QWORD PTR [rip+0x20082f]        #
0x601020 <stdout@@GLIBC_2.2.5>
   0x00000000004007f1:  lea    rdx,[rbp-0xd0]
   0x00000000004007f8:  mov    rcx,QWORD PTR [rbp-0xd8]
   0x00000000004007ff:  mov    rsi,rcx
   0x0000000000400802:  mov    rdi,rax
   0x0000000000400805:  call   0x400670 <vfprintf at plt>
   0x000000000040080a:  mov    DWORD PTR [rbp-0xb4],eax
12        va_end (arg);
13
14        return done;
   0x0000000000400810:  mov    eax,DWORD PTR [rbp-0xb4]
15      }
   0x0000000000400816:  leave
   0x0000000000400817:  ret
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130619/1096af5a/attachment.html>


More information about the lldb-dev mailing list