The xcode (v2.4) doc on attaching to a running process does not
adequately describe what I need to do in order to attach to a running process.?
My goal is to use xcode for visual debugging of an executable compiled outside
of the xcode environment,?using gcc with the -g option (to make it
debuggable).? I do not have the luxury of launching this directly, but have to
attach it once the process receives a request (the process is
launched/controlled by another process).? ?Moreover, the project was not built
via xcode, but through gcc/make.? The program was started via the terminal (shell).??
According to the doc below, all I have to do is select
Debug...Attach... and then either select the program, if it appears, or select
Process ID... and specify the pid.? ?I fire up xcode and do not open anything,
and go straight to the attach operation.
The problem is, when selecting debug... nothing in the attach submenu
is selectable (i.e. it's all dimmed out) - so I can't specify ?the Process ID.
?In another case, I was able to specify the pid, but xcode didn't successfully
attach.
I know that in gdb, when doing command line mode attach operations, I
have to specify symbol-file <executable> in order to associate the pid
with a particular executable file - this works fine, I am able to set
breakponts, walk through code, display variables, etc.
But I cannot do the equivalent in xcode.? ?Any help would be much
appreciated, I have been pulling my hair out looking at the simplistic
documentation below and can't find anything more on the web.
Regards, Eric
Attaching to a Running Process
You can use Xcode to attach to, and debug, a
program that is already running. You can attach to a program running under
Xcode or to any process running on the current computer for which you have a
process ID. To attach the debugger to a running process perform one of the
following operations:
- Choose
a program from the Debug > Attach menu. This menu lists currently
running programs launched from Xcode, identified by the program name and
the name of the corresponding Xcode project. (This menu also lists other
programs running on the system.) To attach to one of these programs,
choose it from the menu.
- To attach to any other running process, choose Debug >
Attach > Process ID. Enter the process ID of the process you want to
attach to in the dialog that Xcode displays and press Return.
- Click
the Attach toolbar item in the Run Log window to attach to a program
already running in Xcode. Xcode automatically displays this window when
you launch a program in Xcode.
When you launch a program from Xcode, you can also
have Xcode automatically attempt to attach the debugger to the process when the
program crashes. To do so, select the executable for the program, open an
inspector, and select the ?Auto-attach debugger on crash? option in the
Debugging pane.