CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   printStack implementation (https://www.cfd-online.com/Forums/openfoam-programming-development/152138-printstack-implementation.html)

alexeym April 24, 2015 10:13

printStack implementation
 
1 Attachment(s)
Dear all,

What is the reason behind rather fancy implementation of printStack function? I.e. it first converts stack trace addresses into strings using backtrace_symbols, and then parses results of the conversion to find out converted addresses (and on OS X it needs to account for stripped file names and different format of the strings)?

Internally backtrace_symbols both on Linux and Darwin uses dladdr for calculation of the contents of the strings array [1, 2]. Why not use the function directly?

Please find my attempt on rewrite of the printStack.C attached to the message.

File in Linux folder was tested using OpenFOAM 2.3.0 on SL 7. File in Darwin folder is adaptation of addr2Line4Mac.py idea to C (and it was born out of desire to get rid of additional Python call). It was tested on OS X 10.10.3 with clang compiler. As on Darwin atos and lldb are available, the utility used can be configured using -DUSE_ATOS or -DUSE_LLDB flags. In my tests lldb was better at address to line number conversion.

Cordialement

1. https://sourceware.org/git/?p=glibc....c61c4b;hb=HEAD
2. http://www.opensource.apple.com/sour...en/backtrace.c


All times are GMT -4. The time now is 09:50.