Bah, I was hoping we could debug this with static analysis. Sadly, that doesn’t seem to be the case.
One thing that might help here is to set a symbolic breakpoint on INIT_Processes
. If you do that and then run your program, does it stop at the breakpoint? If so, what does the backtrace look like?
For example, here’s what I see when I start a standard app with that breakpoint:
% lldb Test777284.app/Contents/MacOS/Test777284
(lldb) target create "Test777284.app/Contents/MacOS/Test777284"
…
(lldb) br set -n INIT_Processes
Breakpoint 1: where = HIServices`INIT_Processes(), address = 0x0000000186fe371c
(lldb) r
…
Process 28979 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000018c45371c HIServices`INIT_Processes()
HIServices`INIT_Processes:
-> 0x18c45371c <+0>: pacibsp
0x18c453720 <+4>: stp x20, x19, [sp, #-0x20]!
0x18c453724 <+8>: stp x29, x30, [sp, #0x10]
0x18c453728 <+12>: add x29, sp, #0x10
Target 0: (Test777284) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000018c45371c HIServices`INIT_Processes()
frame #1: 0x000000018c4536e8 HIServices`GetCurrentProcess + 36
frame #2: 0x000000018a3d00ac AppKit`-[NSMenuBarPresentationInstance _getAggregateUIMode:withOptions:] + 148
…
frame #9: 0x00000001895e716c AppKit`NSApplicationMain + 384
frame #12: 0x0000000100001b08 Test777284`main at <compiler-generated>:0
frame #13: 0x0000000185542b4c dyld`start + 6000
Now, I’m going this from Terminal, which is fine in my case because I’m working with an app. You’re working with a daemon, which isn’t something you should run from Terminal in general. If your daemon won’t work from Terminal at all, you can do the following:
-
Modify your daemon so that it waits for the debugger at the start of main
. I usually do this by logging to the system log [1] and then calling pause
.
-
Start your daemon using sudo launchctl start JOB_LABEL
.
-
Check to see if it’s already visible in Activity Monitor. If it is, something before main
has connected to the window server, which makes things substantially harder )-: Lemme know in that case and I’ll think about this some more.
-
If not, attach with LLDB.
-
Then set the INIT_Processes
breakpoint.
-
And continue.
Oh, there’s one other bit of info I’d like from you. If you reproduce the problem normally — without any of the stuff I’ve talked about above — and then attach with LLDB and run image list
, what do you get back?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] See Your Friend the System Log.