IOS development ---- common basic GDB commands

Source: Internet
Author: User

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 typeinformation available.

To call this function anyway, you can cast the return typeexplicitly (e.g. 'print (float) fabs (3.0 )')

(Gdb) p (CGSize) [[self view] size]

$1 = {

Length = 320,

Height = 411

}

(Gdb) print (CGSize) [[self view] size]

$2 = {

Length = 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 typeinformation available.

To call this function anyway, you can cast the return typeexplicitly (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 typeinformation available.

To call this function anyway, you can cast the return typeexplicitly (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.

 

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.