Debugging Programs with gdb
The GNU debugger is gdb
. It was written and is maintained by
the Free Software Foundation. gdb
is a powerful
tool for looking inside a running program and trying to figure out
why that program is not behaving as expected. Apple has modified
gdb
to be aware of Objective-C syntax and
objects, and to work together with the PB and Terminal applications.
The gdb
tool is located in the directory
/usr/bin
. If you
click the Computer icon in the Finder’s toolbar and
then select Macintosh HD, you will not see /usr
listed.
Mac
OS X and the Finder hide many system details from the user, including
Unix system directories such as /usr/bin
,
/bin
, and /etc
. You can
view these directories in the Finder using the Go to Folder sheet,
but you cannot see all directories in the Finder (e.g., the
.app
directories are hidden). You can, however,
see all the filesystem directories in a Terminal shell — your
vehicle for exploring the guts of Mac OS X.
Using gdb in Project Builder, Step by Step
The easiest way to use the gdb
debugger is in
PB. We’ll show you how to get started with that in
this section. First, we must have an application to work with, so
we’ll use a copy of the CircleView example
application that is bundled with the Mac OS X developer system.
When you debug a running program within PB, you can access some of
the most useful gdb
commands graphically. You
can set breakpoints by clicking the mouse next to a line of code (a
breakpoint is a place where a running ...
Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.