Debugging ATIRE in Xcode 4
The instructions talks about how to use Xcode 4 to debug external binaries.
Since there is no easy way to creat a project in Xcode based on existing files, we have to create a empty project first. Let's say your source directory is under your home directory "~/atire".
- Now create a empty project in Xcode using "Other -> Empty" options in the popup window.
- Specify the product name as "atire".
- A file chooser windows pops up and choose any directory other than you home directory. (The problem here is that Xcode tries to create a directory called "atire" and this directory already exists under the home directory.)
- In the file choose window, make sure the option is ticked for "Create local git repository for this project" if your working copy is managed by git. Otherwise ignore this option.
- Click the "Create" buttion to create the project.
We need to copy the created project directory "atire.xcodeproj" to the working code directory "~/atire".
- First quit Xcode.
- Copy the generated project directory "atire.xcodeproj" into "~/atire".
- start Xcode to locate the project again in "~/atire".
Create a new schema in order to run the binary compiled externally. The example shows how to run the "atire" binary. Same procedures applies to other binaries.
- From menu choose "Product -> New Schema...".
- Type "atire" in the name text box.
- On the left panel, click "Run" and configure the "info" section. In the "executable", choose "Other" to locate the "atire" binary on disk. and change to use either "GDB" or "LLDB". (Don't forget to compile the binaries with the debugging options enabled.)
- Parameters can be specified in the "Arguments" section.
- The working directory can be specified in the "options" section.
- click "OK" to finish configuring the new schema.
In order to add breakpoints and trace line by line into the source files, we have to tell where these files are.
- From menu, choose "File -> Add Files to Atire..." to add all the files.
Now, we are ready to debug.
- Open a file and put a breakpoint on the line where you want the debugger to stop.
- From the menu, choose "Product -> Debug -> Activate breakpoints".
- Click the run button located on the top left.
- enjoy Xcode.