Xcode console Debugging commands (small experience)

Source: Internet
Author: User

Address: http://blog.csdn.net/likendsl/article/details/7576549

After xcode4.0, the compiler is replacedLlvm compiler 2.0

More powerful than before:
1. llvm compiler is a next-region open source compilation technology. It fully supports C, objective-C, and C ++.
2. llvm is twice faster than GCC, and the established program runs faster because it makes better use of the modern Chip structure.
3. llvm and xcode 4 are fully integrated. including keyword highlighting and code integrity are all analyzed by llvm syntax analyzer. in this way, you can understand your code well during editing.

 

After the compiler evolved, the console debugging command prefix was changed from the original GDB to lldb, so when you see that the Console does not have GDB and lldb appears, don't worry, because we can still use the following common Debugging commands:

Prerequisites:

1. For Debugging commands, select debug mode for program mode.

2. In debug mode, if your program crashes during running (crash), congratulations, the chance to use lldb for debugging is coming. (Another way is to open the breakpoint program and enter the debugging status. You can enter some commands on the command line)

After the preceding two conditions are met, the console (that is, the log output window all output) will automatically generate a (lldb) command. Enter Bt and press Enter.

Congratulations, xcode will automatically output the last call stack. As follows:

 

 

 

In fact, to be honest, this is really difficult to find. I searched Baidu for xcode command line commands for a long time, but none of them were the results I wanted. Today I suddenly saw a blog about it, after reading the command, I also typed the command in the command line. It is really useful! However, there are still many more powerful functions that I have not studied yet ~~

 

There are also some other commands: (common to gdb commands)
  1. Command explanation
  2. Break num sets a breakpoint on the specified row.
  3. BT displays all call stack frames. This command can be used to display the call sequence of a function.
  4. Clear deletes a breakpoint set on a specific source file or line. The usage is clear filename: num.
  5. Continue continues to execute the program being debugged. This command is used when the program stops running because of processing signals or breakpoints.
  6. Display expr: The expression value is displayed after each program is stopped. An expression is composed of variables defined by the program.
  7. File file to load the specified executable file for debugging.
  8. Help name: displays the help information of a specified command.
  9. Info break displays the current breakpoint list, including the number of times the breakpoint is reached.
  10. Info files: displays detailed information about the file to be debugged.
  11. Info func shows all function names.
  12. Info local shows the local variable information in the function.
  13. Info prog displays the execution status of the program to be debugged.
  14. Info var displays all global and static variable names.
  15. Kill the program being debugged.
  16. List shows source code segments.
  17. Make runs the make tool without exiting GDB.
  18. Next executes a source code line forward without entering other functions.
  19. Print expr: the value of the expression expr.
  20. Print-object: print an object
  21. Print (INT) Name print a type
  22. Print-object [artist description] calls a function.
  23. Set artist = @ "test" to set the variable value
  24. Whatis: view the variant Data Type

 

 

If you are proficient in this application, your level will rise to another level. One way to solve the exc_bad_access error is to use nszombieenabled together, it is really convenient to find the crash tool of crash !!

 

 

Finally, we recommend several websites

  1. Cocoadev: I personally think it is one of the websites with very professional cocoa technology. The following link details the principles of nszombieenable. Http://www.cocoadev.com/index.pl? Nszombieenabled
  2. Apple's official Mac OS X debugging magic, detailed about the most advanced Apple programmers should have debugging skills http://developer.apple.com/library/mac/#technotes/tn2004/tn2124.html
  3. In fact, you can also enable the nszombie option in instruments, so that you can directly view the callstack crash in instruments: http://www.markj.net/iphone-memory-debug-nszombie/

 

Xcode console Debugging commands (small experience)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.