Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
564 views
in Technique[技术] by (71.8m points)

objective c - How can I examine assembly in Xcode 4?

I'm tuning some code that runs in a tight loop in my iPhone app and I'm curious to see the generated assembly code to see if anything looks out of the ordinary.

In Xcode 3.x, there was a Build > Show Assembly Code option in the menu, but I don't see anything in the menus or the documentation for Xcode 4.

Anyone know how to do this? I could do "gcc -S" but my understanding is that that won't be identical to how the entire project is compiled.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The "View Disassembly" option is gone, as far as I can tell.

Here's one workaround:

  1. Build your project
  2. Open the build log, and use the search window to find the compile command that was used to build the source file you're interested in. Copy the entire build command.
  3. Open a terminal window, and cd to your project directory.
  4. Paste the build command from the build log into the terminal, and append -save-temps. Hit enter.
  5. You now have two new files, yourFile.i and yourFile.s, which are the preprocessed source and generated assembly, respectively, built exactly as they are in your project.

Alternatively, you can disassemble the built binary (or the object file resulting from your source file) using otool -tvV /path/to/binaryOrDotOFile.

Finally, if this is a feature that you would like to have back, make sure to file a bug report!

Edit: This feature is back in Xcode 4.1. In the assistant editor pane, select "Generated Output -> YourFilename (Assembly)". Boom!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...