clang is finally debuggable with gdb
It was a pain to debug clang -faddress-sanitizer instrumented executables, because variable values were not visible, though they should be. It was caused by wrong stack realignment, triggered by -faddress-sanitizer, but it really was a clang bug.
This is now fixed in clang svn, since r160248. See http://llvm.org/bugs/show_bug.cgi?id=11468. http://llvm.org/bugs/show_bug.cgi?id=11818 is also fixed now.
With a llvm from svn go into build and do a make update. I'm running with r160959 successfully now.
Update: Sorry, it is not (yet) Nov 2012.
But I got it somehow working with the LLVM debugger, lldb.
E.g. a current problem in blead, debugged in darwin, built with perlall build bleadd-nt-asan
and a recent llvm 3.2.svn
$ lldb /usr/local/bin/perl5.17.6d-nt-asan@5ca74088 cpan/Socket/t/sockaddr.t
Current executable set to '/usr/local/bin/perl5.17.6d-nt-asan@5ca74088' (x86_64).
(lldb) b __asan_report_error
breakpoint set --name '__asan_report_error'
Breakpoint created: 1: name = '__asan_report_error', locations = 1
(lldb) r
Process 89832 launched: '/usr/local/bin/perl5.17.6d-nt-asan@5ca74088' (x86_64)
1..33
ok 1 - inet_aton returns packed bytes
ok 2 - inet_ntoa from v-string
ok 3 - inet_aton->inet_ntoa roundtrip
ok 4 - inet_ntoa warns about wide characters
ok 5 - inet_pton AF_INET returns packed bytes
Process 89832 stopped
* thread #1: tid = 0x1c03, 0x000000010000b210 perl5.17.6d-nt-asan@5ca74088`__asan_report_error, stop reason = breakpoint 1.1
frame #0: 0x000000010000b210 perl5.17.6d-nt-asan@5ca74088`__asan_report_error
perl5.17.6d-nt-asan@5ca74088`__asan_report_error:
-> 0x10000b210: pushq %rbp
0x10000b211: pushq %r15
0x10000b213: pushq %r14
0x10000b215: pushq %r13
(lldb) up 2
frame select -r 2
frame #2: 0x0000000102f8d8ce Socket.bundle`XS_Socket_inet_ntop + 2462 at Socket.xs:938
935 "Socket::inet_ntop", af);
936 }
937
-> 938 Copy(ip_address, &addr, sizeof addr, char);
939 inet_ntop(af, &addr, str, sizeof str);
940
941 ST(0) = sv_2mortal(newSVpvn(str, strlen(str)));
(lldb) frame variable
(CV *) cv = <variable not available>
(SV **) sp = <variable not available>
(SV **) mark = <variable not available>
(I32) ax = <variable not available>
(SV *) ip_address_sv = <variable not available>
(int) af = 2
(lldb) register read
General Purpose Registers:
rbx = 0x0000000102844060 libperl.dylib`PL_stack_base
rbp = 0x00007fff5fbff370
rsp = 0x00007fff5fbff200
r12 = 0x0000000000000001
r13 = 0x00001000207a7911
r14 = 0x0000000102844060 libperl.dylib`PL_stack_base
r15 = 0x00001fffebf7fe44
rip = 0x0000000102f8d8ce Socket.bundle`XS_Socket_inet_ntop + 2462 at Socket.xs:941
13 registers were unavailable.
See http://lldb.llvm.org/tutorial.html
$ clang --version
clang version 3.2 (trunk 167678)
Target: x86_64-apple-darwin12.2.0
Thread model: posix