Re: Debugging a lanuchd daemon
Re: Debugging a lanuchd daemon
- Subject: Re: Debugging a lanuchd daemon
- From: Jim Ingham <email@hidden>
- Date: Tue, 30 Oct 2007 14:00:58 -0700
WaitForDebugger was present on Tiger but attaching to processes
stopped through this mechanism didn't actually work on Tiger (it was a
kernel bug.) So you won't be able to use the launchd plist to stop
your processes, and will have to resort to some other mechanism, like
putting in a spinloop in your deamon's main or something like that.
That bug was fixed for Leopard, however. So except for possible bugs
with Xcode attaching that Dustin was reporting in another thread, this
should work.
Note, on the Leopard gdb we also added a "-waitfor" parameter to the
attach command, so you can do:
(gdb) attach -waitfor ProcessName
and gdb will periodically sample the process list till a process
matching the name you gave it shows up, and then attaches to that.
There isn't UI for that in Xcode yet. This will also be in 2.5, so
you can use that method to catch daemons on Tiger with the Salt gdb.
Jim
On Oct 30, 2007, at 12:52 PM, Steve Sisak wrote:
Hi Dustin,
Thanks for the hint, WaitForDebugger does not appear to be in the
man page (I also tried Debug, which is present). For reference, I'm
using Xcode 2.4.1 on Mac OS X 10.4.10.
I can launch manually and things are working -- trying to figure out
how to attach from Xcode.
Thanks,
-Steve
At 10:54 AM -0400 10/30/07, Dustin Norman wrote:
Steve,
You can add a boolean value to your launchd plist file called
WaitForDebugger that should pause the process before main has been
called. See man launchd.plist for more information.
One word of caution, if you are using Xcode 3.0 this may not work.
At least I haven't been able to get it to work. Xcode attaches but
there are errors and it's not possible to debug. Attaching with
gdb from the command-line does work but it obviously isn't the best
debugging environment.
I have not tried this on Tiger so I don't know if this problem
exists with Xcode 2.4.
HTH,
Dustin
On Oct 30, 2007, at 10:39 AM, Steve Sisak wrote:
I'm in the process of converting a StartupItem (which I could just
run to debug) to a launch-on-demand daemon that will be
automatically launched when a Unix-domain socket it registers is
accessed.
I'd like to debug the launch code when it's launched by launchctl,
but obviously can't attach to the process because it isn't running
yet.
Is there a way to get Xcode to debug a process upon launch or
other practical techinique to use here?
(I can always put the process in an infinite loop and attach to it)
Also, the daemon will normally be run as root (although I'm pretty
sure I can test it in user space for the time being).
How would one debug a priviledged daemon with Xcode? (2-machine
debugging?)
Suggestions and best practice welcome.
Thanks,
-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden