IOS development-common basic GDB commands, ios-gdb

Source: Internet
Author: User

IOS development-common basic GDB commands, ios-gdb

Gdb is not omnipotent, but it is absolutely impossible without gdb. Here is a brief introduction to the most basic gdb commands in iOS development.

Po

Po is short for print-object and can be used to print all NSObject objects. Example:

(gdb) po self<LauncherViewController: 0x552c570>(gdb) po [self view]<UIView: 0x544eb80; frame = (0 0; 320 411); autoresize = W+H; layer = <CALayer: 0x544ebb0>>(gdb) print-object [self view]<UIView: 0x544eb80; frame = (0 0; 320 411); autoresize = W+H; layer = <CALayer: 0x544ebb0>>

 

P

P is short for print and can be used to print all simple types, such as int, float, and struct. Example:

(gdb) p self$1 = (LauncherViewController *) 0x552c570(gdb) p [[self view] size]Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)(gdb) p (CGSize)[[self view] size]$1 = {width = 320,height = 411}(gdb) print (CGSize)[[self view] size]$2 = {width = 320,height = 411}

 

Call

Call is called. In fact, the above po and p also have the calling function. Therefore, call is generally used only when no output is displayed or the method does not return a value. Example:

(gdb) call [[self view]sizeToFit]Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)(gdb) call (void)[[self view]sizeToFit](gdb) call [[self view] size]Unable to call function “objc_msgSend” at 0x1e7e08c: no return type information available.To call this function anyway, you can cast the return type explicitly (e.g. ‘print (float) fabs (3.0)’)(gdb) call (void)[[self view] size]

 

**************************************** **************************************** ******************************

 

The Xcode debugger provides you with a GDB interface, which is an open-source debugger of GNU. You can do anything in the visual interface of Xcode. However, if you need it, you can use the GDB command in the command line.


Enter the GDB command line in a debugging task:

Click Console Drawer in the toolbar to open the Console.
You can view the commands that the Xcode debugger sends to GDB in the console, or you can directly enter the GDB command in the console. In the console window, click and enter the command at the gdb prompt.

 

Break NUM Set a breakpoint on the specified row.
Bt Display All call stack frames. This command can be used to display the call sequence of a function.
Clear Delete a breakpoint set on a specific source file or line. The usage is clear FILENAME: NUM.
Continue Continue to execute the program being debugged. This command is used when the program stops running because of processing signals or breakpoints.
Display EXPR The expression value is displayed after each program stops. An expression is composed of variables defined by the program.
File FILE Load the specified executable file for debugging.
Help NAME Displays the help information of a specified command.
Info break Display the current breakpoint list, including the number of times the breakpoint is reached.
Info files Displays detailed information about the file to be debugged.
Info func Show all function names.
Info local Displays information about local variables in a function.
Info prog Displays the execution status of the program to be debugged.
Info var Display all global and static variable names.
Kill Terminate the program being debugged.
List Shows the source code segment.
Make Run make without exiting gdb.
Next Execute a source code line forward without entering other functions.
Print EXPR Displays the value of the expression EXPR.
Print-object Print an object
Print (int) name Print a type
Print-object [artist description] Call a function
Set artist = @ "test" Set variable value
Whatis View the modified data type

Related Article

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.