05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In the upper left, GDB shows the stack. Every time a method or function is called, it is<br />

pushed onto the stack. Each item on the stack is called a stack frame. The top stack frame is the<br />

current method. The next frame in the stack is the method that called it, and so on down the line.<br />

If the stack frame contains any variables, they appear to the right. This includes automatic variables,<br />

global variables, instance variables, and so on. Each variable’s current value is listed beside<br />

its name.<br />

Below the stack and variable views is an editor window with the current line of code highlighted.<br />

If the code is yours, you will just see a standard editor view. If the code is not yours, GDB<br />

will decompile it and show you the assembly.<br />

You can continue executing the code, or you can step over it a line at a time, observing its<br />

effects. If the code is yours, you can edit it, but the edits will not take effect until the next build,<br />

and if you add or remove lines, the editor’s display will no longer match the current line of execution,<br />

making its display inaccurate.<br />

Beneath the editor is the GDB console. The console can be revealed by dragging the separator<br />

from the bottom of the screen, or by clicking its icon in the toolbar. The console will display<br />

any information being logged from the application or your breakpoints. Any errors or other<br />

feedback will also show up here.<br />

More than just a message board, the GDB console is fully interactive. You can execute any<br />

GDB command. My personal favorite is print object, or po for short. The po command will take<br />

any expression and print the return value. In resolving an expression in Objective-C, GDB will<br />

send messages to objects. That means you can interact with your objects, change their values, or<br />

get information about them. While there are certain limitations to this, it’s not unlike the interactive<br />

runtime environments enjoyed by users of noncompiled languages like LISP, JavaScript,<br />

Ruby, and Python.<br />

Inline Debugging<br />

Xcode’s traditional debugging interface is very powerful, but it suffers from the same problem as<br />

the old build results system. That is, it interrupts the programming flow by taking you out of the<br />

editor and thrusting you into a different environment. Sometimes you don’t need quite as much<br />

power as the full interface provides. For times like these, Xcode provides a new inline debugging<br />

interface, as shown in Figure 25-19.<br />

Figure 25-19. Xcode’s new inline debugging environment<br />

CHAPTER 25 MAC <strong>OS</strong> X DEVELOPMENT: THE TOOLS 471

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!