Getting the current stack trace on Mac OS X

后端 未结 1 601
囚心锁ツ
囚心锁ツ 2021-02-09 14:49

I\'m trying to work out how to store and then print the current stack in my C++ apps on Mac OS X. The main problem seems to be getting dladdr to return the right symbol when giv

相关标签:
1条回答
  • 2021-02-09 15:24

    What releases of OS X are you targetting. If you are running on Mac OS X 10.5 and higher you can just use the backtrace() and backtrace_symbols() libraray calls. They are defined in execinfo.h, and there is a manpage with some sample code.

    Edit:

    You mentioned in the comments that you need to run on Tiger. You can probably just include the implementation from Libc in your app. The source is available from Apple's opensource site. Here is a link to the relevent file.

    0 讨论(0)
提交回复
热议问题