Debugging in Xcode as Root

Debugging in XCode as root

Update: For Xcode 4.5 and later, see this answer instead.


The only way I'm aware of to do what you're asking is to run Xcode as root.

>> sudo /Developer/Applications/Xcode.app/Contents/MacOS/Xcode

Once you're running as root, anything processes launched from Xcode will also run as root. Note, though, that if you create or edit any files, they will be owned by root, which means that you'll have to chown them before you can edit them as your normal user first.

I'd love a way for Xcode to say "Launch process as root", but as far as I know, no such functionality is available.

Note that you can also run the application within the command-line debugger gdb to debug your application. Run

>> sudo gdb /path/to/my/application

Then you could keep Xcode open, modify at will, and debug your program within gdb. This is what I generally do.

EDIT: Readers from the future: see the answer from Alexander Stavonin; it talks about how to do this. If you're okay with ssh keys and enabling the root user on your system, his answer is the way to go.

How to enable the options of Debug Process As in Xcode?

Debugging as root only makes sense if you are targetting OSX, not iOS, so that is why it's disabled.

Xcode - How to profile an application as root?

The solution is to run Instruments as root and attach to the process.

To run Instruments as root: sudo /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/MacOS/Ins‌​truments

Xcode debugger: cmd line application - start with sudo?

Have you tried starting Xcode with sudo?

The processes it spawns (gdb,...) should also run with superuser privileges:

sudo /Applications/Xcode.app/Contents/MacOS/Xcode

Xcode 4 debugging as root

There's currently no way to do this in Xcode 4. I've filed bugs regarding that lack, and would encourage you to do the same.



Related Topics



Leave a reply



Submit