RandomDSdevel
RandomDSdevel

Reputation: 429

How Does OS X Implement backtrace()?

Does anyone know where I might find the code that implements OS X's version of backtrace()? I know it's probably somewhere inside libSystem.B.dylib, so I should probably get that module's source code from Apple's read-only open-source repository, but where inside it should I start looking?

Upvotes: 1

Views: 705

Answers (2)

Ken Thomases
Ken Thomases

Reputation: 90611

Actually, most of this stuff is in Libc. In particular, backtrace() is defined here. However, that's mostly just a thin wrapper around the internal function _thread_stack_pcs(), which is defined here.

The easiest way to find this sort of stuff is perhaps Google. For example, searching for "backtrace" site:opensource.apple.com leads you to an older version of Libc. Then, you can start from the top of http://opensource.apple.com to find the version that's used in a given version of the OS.

Upvotes: 6

Related Questions