Search code examples
cxcode

How to use Xcode as a debugger for my C executable


I want to basically use Xcode as a nice integrated frontend to lldb and debug my code with it. I've compiled my C program with debug info; I have both the executable and a .dSYM folder. On Xcode, I used the Debug Executable menu to debug it, and it shows the output of my executable but nothing else; I can't step though it or view any associated files. How can I use Xcode as a debugger with proper integration?


Solution

  • Once you have used Debug > Debug Executable… to set the executable, select Debug > Breakpoints > Create Symbolic Breakpoint… and enter main in the Symbol field. Then you can click the run triangle at the top of the window (right side of left column), and the program will start running and then stop at the start of main.

    Then you can use the Debug menu for further actions or enter commands at the (lldb) prompt in the bottom-right pane.