www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Stack tracing assert for linux/D2

reply BCS <none anon.com> writes:
I just created a module that generates stack traces on asserts (D2):

http://www.dsource.org/projects/scrapple/browser/trunk/backtrace_assert/debugging.d

Just compile and link it.

It does have some not exactly ideal bits:

-it won't work nicely unless you link with gcc and add the -rdynamic flag.
-accessing some of the posix stuff fubared my link (unresolved ModuleInfos) 
so I had to add the prototypes directly (yuck)
-it uses the c function dprintf that on some system does what I want (print 
to a low level file stream) and on some system does something totaly different.
-it has the expected executable name and the location of addr2line hard coded

(any ideas on how to fix these issues welcomed)

-- 
... <IXOYE><
Mar 04 2010
parent reply Jordi <jordi rovira.cat> writes:
BCS wrote:
 I just created a module that generates stack traces on asserts (D2):
 
 http://www.dsource.org/projects/scrapple/browser/trunk/backtrac
_assert/debugging.d 
 
 
 Just compile and link it.
 
 It does have some not exactly ideal bits:
 
 -it won't work nicely unless you link with gcc and add the -rdynamic flag.
 -accessing some of the posix stuff fubared my link (unresolved 
 ModuleInfos) so I had to add the prototypes directly (yuck)
 -it uses the c function dprintf that on some system does what I want 
 (print to a low level file stream) and on some system does something 
 totaly different.
 -it has the expected executable name and the location of addr2line hard 
 coded
 
 (any ideas on how to fix these issues welcomed)
 

that would be great if i manage to make it work.... for now i get: /usr/bin/ld: optind: TLS definition in [...]/crosa/xfbuild/debug/core-sys-posix-unistd.o section .tbss mismatches non-TLS definition in /lib/libc.so.6 section .data /lib/libc.so.6: could not read symbols: Bad value collect2: ld returned 1 exit status I am using xfbuild, so i have to pass -L-export-dynamic instead of "-rdynamic. I also have to use your hardcoded declarations, as some of them "backtrace..." seem not to be in the druntime source. But i am still fairly new with d, so i might have screwed anywhere else. j.
Mar 05 2010
parent BCS <none anon.com> writes:
Hello Jordi,

 BCS wrote:
 
 I just created a module that generates stack traces on asserts (D2):
 
 http://www.dsource.org/projects/scrapple/browser/trunk/backtrace_asse
 rt/debugging.d
 
 Just compile and link it.
 
 It does have some not exactly ideal bits:
 
 -it won't work nicely unless you link with gcc and add the -rdynamic
 flag.
 -accessing some of the posix stuff fubared my link (unresolved
 ModuleInfos) so I had to add the prototypes directly (yuck)
 -it uses the c function dprintf that on some system does what I want
 (print to a low level file stream) and on some system does something
 totaly different.
 -it has the expected executable name and the location of addr2line
 hard
 coded
 (any ideas on how to fix these issues welcomed)
 

/usr/bin/ld: optind: TLS definition in [...]/crosa/xfbuild/debug/core-sys-posix-unistd.o section .tbss mismatches non-TLS definition in /lib/libc.so.6 section .data /lib/libc.so.6: could not read symbols: Bad value collect2: ld returned 1 exit status

Taking a wild stab, try not linking in core-sys-posix-unistd.o (I got a different error trying to include it) either by mucking with the link command or by convincing your build that it's just prototypes for a library.
 I am using xfbuild, so i have to pass -L-export-dynamic instead of
 "-rdynamic.

I'm not sure backtrace is even officially part of posix and I don't think it's ever been part of phobos. It's the posix function/enum from core.sys.posix that were causing me problems. -- ... <IXOYE><
Mar 05 2010