3 ms·
> If you'd like to know why an exception was thrown, you have to print the value of the proper CPU register. On x86-64 it's $rax. As far as I know this is an or
by saagarjha 8y ago
> If you'd like to know why an exception was thrown, you have to print the value of the proper CPU register. On x86-64 it's $rax. As far as I know this is an oral tradition, passed down from senior developer to junior developer.
This varies based on the calling convention and signature of the the method that the exception handler puts a breakpoint on. With objc_exception_throw on x86_64 the value should be in $rdi ($arg1) in LLDB.
> If you want a daemon to survive the user logging out and logging in, you have to use a barely-documented function (bootstrap_parent) which is only mentioned in a now-archived tech note.
It's also mentioned in Mac OS X Internals: A Systems Approach, FWIW.
- aaronbrethorst 8y agoIt’s always a good sign when the document that explains a piece of functionality no longer bears the same name as the operating system it purports to document.
- tinus_hn 8y agoThat’s kind of hard to avoid if it’s a physical book and the subject changes names.
- oblio 8y agoI think his point is that it should be documented online, in an ever-green knowledge base...
- userbinator 8y agoThis comment nicely sums up one of the things that's wrong with the Apple ecosystem --- apparently, whatever backwards-compatibility Apple does manage to have gets dismissed by developers because "it's old". ...and then they wonder why they can't find the old docs that actually have what they need. Apple thinks the developers don't care, and vice-versa. It's a cycle of negative feedback. On most other platforms, the assumption is that things will not change between versions, and changes are explicitly mentioned and documented when they do occur, but Apple and its developers seem to have the exact opposite mentality.
- aaronbrethorst 8y agoI hope you didn’t imply that I’m what’s wrong with the Apple developer ecosystem. Old is fine, as long as it is still accurate. I have spent more time than you could imagine digging through ancient cocoadev mailing list posts and WebKit Trac bugs in order to debug problems with my apps. There is nothing more frustrating than having the only available reference be out of date, and having to synthesize the gaps.
- jonhendry18 8y agoIt's a third party technical book, not an Apple document. No reason to expect it to be reissued because of a later Apple marketing decision.
- gnachman 8y ago> It's also mentioned in Mac OS X Internals: A Systems Approach, FWIW. It's funny you should mention this. After someone sent me an amazing pull request using this call, I thought "hm, this should be in Mac OS X Internals: A Systems Approach. Why didn't I see it?" So I looked it up, and yes, it's there, but there's nowhere near enough context or description for it to be of use to anyone but (at most) the author. Here's what it says: The /usr/libexec/StartupItemContext program can be used to run an executable in the startup context—that is, the context in which the Mac OS X startup items run. It works by calling bootstrap_parent() repeatedly until it has reached the startup (root) context. It then sets the port as its own bootstrap port, after which it can execute the requested program. The automatic relaunching of servers by the Bootstrap Server is useful for creating crash-resistant servers. However, it is neither necessary not advisable to create production servers by directly using the Bootstrap Server interface. Beginning with MacOS X 10.4, the launch API, as exported through <launch.h>, should be used. With this caveat, let us look at two examples of using the Bootstrap Server interface. [an example that shows how to list all known services] [a rather complex example that creates a bootstrap service and maybe uses bootstrap_parent somewhere] There are bits of wisdom in this wonderfully written (and of course now obsolete) tech note: https://developer.apple.com/library/archive/technotes/tn2083/_index.html https://developer.apple.com/library/archive/technotes/tn2083... But of course, most people just copy-paste from the code Apple has (I would guess grudgingly) made open-source and we hope for the best.