Updated Description: This article is described comprehensively later.
Http://blog.csdn.net/ch_soft/article/details/6740000
Article reproduced in: http://www.ethangao.com /? P = 273. Thank you for sharing it.
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 = {
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 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]