macoswaitsystem-callsdtracedarwin

Interpret dtruss output like “psynch_cvwait(...) = -1 Err#316”


dtruss appears to be a useful tool to analyze the (mis-)behaviour of applications on OS X. The closes thing I found to my beloved strace on linux. But interpreting its output requires an understanding of the syscalls it refers to, and sometimes the error conditions they might generate. Take for example the line

psynch_cvwait(0x6BE38D54, 0x100000100, 0x0)      = -1 Err#316

I'm interested in a source of documentation which would allow me to find out what this syscall is intended to do, what its parameters signify, and what this error code stands for. Pretty much like I'd expect from a libc function manpage. I'm asking for a reference which describes the above and similar syscalls, with the above and similar errors. So just take the line as an example for the kind of output I'd like to be able to understand.

What is the appropriate reference document to learn about OS X syscalls like this one?

The more syscalls your reference covers, the better.


Solution

  • The only documentation I've found on this is in the code itself.

    It's the kernel side of pthread_cond_wait() and pthread_cond_timedwait().

    In this case, it's the latter since the error code is #316. psync_cvcontinue sets two bits in the error code to indicate whether the wait timed out (0x100) or there were no waiters (0x200). Error #316 (0x13C) is the timed out bit bitwise OR'd with ETIMEDOUT (60).

    https://github.com/apple/darwin-libpthread/blob/master/kern/kern_synch.c#L1216 https://github.com/apple/darwin-xnu/blob/master/bsd/sys/errno.h#L179