Attach lldb debugger to the compiled program's executable when the main executable is not the compiled program

I am building an MPI C project in Xcode. In order to do run it, I had to:

  1. Specify /path/to/mpiexec in Edit Scheme -> Run -> Info -> Executable, instead of the "default" one, say myprogram if my target is called myprogram.
  2. Specify the following arguments in Edit Scheme -> Run -> Arguments -> Arguments Passed On Launch: -np 4, ${BUILT_PRODUCTS_DIR}/${EXECUTABLE_NAME}

This is clearly analogous to a mpiexec -np 4 a.out command launched on terminal.

The problem is, when I want to debug my application, the execution doesn't "stop" on the breakpoints.
I instantly thought that it is because of the check box Debug Executable in Edit Scheme -> Run -> Info -> Executable. Indeed (as I have just said), the Executable specified in there is mpiexec and not myprogram.

Thus, is there an option or some command I could set in Xcode to attach the lldb to myprogram?

It’s hard to answer this without knowing how mpiexec does what it’s doing. Do you have insight into that?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It’s better if you reply as a reply; if you reply in the comments, I might not see it. See Quinn’s Top Ten DevForums Tips for this and other titbits.

Can you go a little deeper with your question?

I’m presuming that mpiexec runs your executabel as a child process. What API does it use for that? fork/exec{ve}? posix_spawn? Something else? And does it do anything special to ‘detach’ the child from itself?

Also, am I right in assuming that -np 4 means that it’ll run 4 child processes? If so, are you expecting to get 4 instances of the debugger, each one attached to a different child?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Attach lldb debugger to the compiled program's executable when the main executable is not the compiled program
 
 
Q