LLDB, a new debugger on Mac OS X

The LLVM team is working on a new debugger called lldb.

It compiles cleanly so you can give it a try if you have the devtools (including SVN client) installed on your machine.

Running it


You need to run the lldb-tool with the firewall disabled and as the superuser because it uses task_for_pid and in 10.6 this requires superuser privileges or code signing on the binary. Since the binary is not signed, you need to run it with superuser privileges, otherwise you will get an error like: "failed to send the qLaunchSuccess packet".

I run it this way:
sudo DYLD_FRAMEWORK_PATH=/Users/diciu/Programming/external/lldb/build/BuildAndIntegration/ ./build/BuildAndIntegration/lldb /tmp/a.out



LLDB vs GDB





LLDBGDB

(lldb) breakpoint set -n main
Breakpoint created: 1 Breakpoint by name: 'main' with 1 location;
(lldb) r
Launching '/private/tmp/a.out' (x86_64)
(lldb) Process 50271 Stopped
* thread #1: tid = 0x2c03, pc = 0x0000000100000edb, where = a.out`main + 11 at /private/tmp/test.c:14, stop reason = breakpoint 1.1, queue = com.apple.main-thread
11
12 int main()
13 {
14 -> struct i10 v = fun();
15 }

(gdb) b main
Breakpoint 1 at 0x100000edb: file test.c, line 14.
(gdb) r
Starting program: /private/tmp/a.out
Reading symbols for shared libraries +. done

Breakpoint 1, main () at test.c:14
14 struct i10 v = fun();
(lldb) disass
0x100000ed0: pushq %rbp
0x100000ed1: movq %rsp, %rbp
0x100000ed4: subq $131072, %rsp
0x100000edb: leaq -131072(%rbp), %rdi
0x100000ee2: movl $0, %eax
0x100000ee7: callq 0x100000ea0 ; fun at /private/tmp/test.c:7
0x100000eec: leave
0x100000eed: ret



(gdb) disass main
Dump of assembler code for function main:
0x0000000100000ed0 : push %rbp
0x0000000100000ed1 : mov %rsp,%rbp
0x0000000100000ed4 : sub $0x20000,%rsp
0x0000000100000edb : lea -0x20000(%rbp),%rdi
0x0000000100000ee2 : mov $0x0,%eax
0x0000000100000ee7 : callq 0x100000ea0
0x0000000100000eec : leaveq
0x0000000100000eed : retq
End of assembler dump.