Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First and foremost, open <code>~/.gdbinit</code> (that's the file called <code>.gdbinit</code> in your home directory - yes, starts with a dot) and put this in it:</p> <pre><code>fb -[NSException raise] fb objc_exception_throw fb malloc_error_break </code></pre> <p>That'll initialize GDB with three default breakpoints, when they occur, GDB will halt your application and show you the stack trace. This is very well integrated with Xcode so you'll be able to nicely walk through your code by clicking stack trace elements as soon as an exception occurs somewhere or a malloc fails.</p> <p>Then, open the <code>Get Info</code> panel on your project (or select your project (top item in the <code>Groups &amp; Files</code>) and hit <code>cmd-i</code>), go to the <code>Build</code> tab and set your project's <code>Base SDK</code> to <code>Device - iPhone OS [someversion]</code>. Scroll all the way to the bottom and find the <code>GCC 4.0 - Warnings</code> section. There; turn on as many warnings as you feel comfortable with, but make sure to turn on <code>Treat Warnings as Errors</code> (this is the equivalent of <code>GCC_TREAT_WARNINGS_AS_ERRORS</code>). Personally, I have it set to this:</p> <p><a href="http://lhunath.lyndir.com/stuff/gcc_warnings.png" rel="noreferrer">GCC Warning Build Settings http://lhunath.lyndir.com/stuff/gcc_warnings.png</a></p> <p>You should now be getting compiler warnings for most things you can do wrong in code and the compiler won't let you run the code until you fix them. When things do get past the compiler's nose, you should be able to find the problem easily with GDB breaking at a convenient spot.</p> <p>You should also look into <code>NSZombie*</code>. These are environment variables that are very handy for early breaking on bad memory allocation or access situations. For instance; wih <code>NSZombieEnabled</code> nothing will truly be released; on dealloc it'll get overwritten with <code>_NSZombie</code> and should you try to access this dealloced memory again (dereferencing a dealloced pointer) you'll get something to break on in GDB, instead of the call going through like normal, only being issued on random data (which, of course, isn't what you wanted). For more info on this, see <a href="http://www.cocoadev.com/index.pl?NSZombieEnabled" rel="noreferrer"><a href="http://www.cocoadev.com/index.pl?NSZombieEnabled" rel="noreferrer">http://www.cocoadev.com/index.pl?NSZombieEnabled</a></a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload