Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Debugger: Why is it only showing me assembler?

I'm just starting out with Cocoa development in Xcode, doing the hello world example. I'm up to step 6 of the section "runtime debugging", which is

Using the Step Over button in the debugger toolbar, begin stepping through the code. As each line of code executes, you can examine the program’s state. The value of a variable is sometimes drawn in red to indicate that the value was modified in the last step. Notice that the debugger pauses before executing the indicated line. After each pause, you can add additional breakpoints or choose Debug > Restart to terminate the application and start a new debugging session.

now what I've been pulling my hair out for over the last hour is the fact that this debugger will only show me assembly code. I can manually select my source code file, but as soon as I click "Step over" I'm right back in assembler view. I can't for the life of me figure out how to turn the assembler off, and make it show me my source code!

like image 398
Breton Avatar asked Sep 14 '09 11:09

Breton


People also ask

How do I show debugger in Xcode?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

Why breakpoint is not working in Xcode?

You might be pushing "Run" instead of "Debug" in which case your program is not running with the help of gdb, in which case you cannot expect breakpoints to work! In Xcode 6.4, there is now only a Run button and whether it runs a debug configuration or not depends on the currently selected scheme settings.

What is assembly debugger?

The debugger automatically displays the contents of memory locations and registers as they are accessed and displays the address of the program counter. This display makes assembly debugging a valuable tool that you can use together with source debugging.

What is debugging executable in Xcode?

The “Debug executable” checkbox specifies whether or not you want to run with the debugger enabled. Once running, you can use Debug > Attach to Process on a process that has been launched with debugging disabled if needed. It seems like all this does is start your app with the debugger attached.


2 Answers

I know this article is a hundred years old, but in case anyone is wondering how to address this issue in more recent Xcode versions (as opposed to Xcode 3), you'll find the appropriate setting labeled Always Show Disassembly under Debug>Debug Workflow in Xcode 6 and up. Ensure the option is NOT checked.

In Xcode 5, the option was labeled Show Disassembly When Debugging under Debug>Debug Workflow. Ensure that "Show Disassembly When Debugging" is unchecked.

Back in Xcode 4, the Show Disassembly When Debugging setting was found under Product>Debug Workflow. Again, ensure that the option remains unchecked.

This was driving me crazy, too.

NOTE: The information above is still valid for Xcode 13+. I've applied updates to this answer as new versions of Xcode have been released. Fortunately, the option has remained unchanged since Xcode 6 (so far).

like image 96
Mike Fahy Avatar answered Sep 20 '22 16:09

Mike Fahy


There are two other things to make sure of:

  1. That you're looking at one of your own functions/methods. If the stack frame you're looking at is a function or method from one of the frameworks, you're going to see assembly no matter how you have Xcode configured.
  2. That you are running a Debug build. Strip debug symbols (as in a Release build), and you'll be looking at assembly even for your own code, no matter what.
like image 25
Peter Hosey Avatar answered Sep 16 '22 16:09

Peter Hosey