gdb on iPhone
来源:互联网 发布:淘宝给差评被电话骚扰 编辑:程序博客网 时间:2024/05/17 21:46
General
- Break on szone_error not working [permalink]
Sometimes when you have memory corruption issues, the malloc library happily informs you:Borkdoku(11062,0xcec0600) malloc: *** error for object 0xd109010: incorrect checksum for freed object - object was probably modified after being freed, break at szone_error to debug
Which is fine and dandy, but it lies. I've never gottenszone_error
to actually do anything. Try breaking onmalloc_printf
instead. - Breaking on exceptions [permalink]
It can be annoying tracking down the cause of thrown exceptions in Cocoa. you get a notice like2007-05-05 17:18:00.702 QueenStitcher[2804:117] *** Assertion failure in -[NSColorWell setColor:], NSColorWell.m:497, u suk l0s3r
, and then the runloop happily runs again, giving you no clue where the problem is. I tellgdb
to always break on Cocoa exceptions:fb -[NSException raise]fb objc_exception_throw()
For maximal enjoyment, add these two lines to your~/.gdbinit
file, so they'll get set no matter how you invokegdb
(no need to add these to every single project, for instance).I've been told VoiceOver uses exceptions heavily, so if you're doing VoiceOver development, these breaks may cause you pain.
- Displaying four-character ints [permalink]
Old-school Mac programming (and Quicktime, and other places) use four-character ints, things like'bork'
. You can have gdb print them out if you need to look at one or two of them:(gdb) print/T 1936746868$4 = 'spit'
(thanks to Daniel Jalkut for the print/T trick) - Finding 'self' on Intel [permalink]
(gdb) po *(int*)($ebp+8)
- Ignoring signals [permalink]
(gdb) handle SIGTRAP nostop
The signal still goes to your program. Another handy option is 'ignore' to prevent it coming to the program. Also there is 'print' to print a message go on.
- Printing method arguments [permalink]
If you've hit a breakpoint on a method that doesn't have debug symbols, you can sometimes get useful information by looking in the processor registers. Arguments start in$r3
and go up from there. For Objective-C method sends,$r3
has 'self', and$r4
has the name of the method. Subsequent arguments are in$5
and so on.(gdb) print (char*) $r4$5 = 0x90874160 "drawRect:"(gdb) po $r5<BWStitchView: 0x1a6670>
- Printing object retain count in gdb [permalink]
In the gdb console:(gdb) print (int)[theObject retainCount]
If you're expecting to have an excessively high number of retains, you can use
(unsigned int)
in the cast. I find(int)
a skootch faster to type. - Printing wide character strings [permalink]
gdb won't by default let you print wide character strings. Here is a little bit of gdb code that'll let you print them. In case that page moves, here is the relevant stuff. Paste this into your.gdbinit
and then you can usewchar_print
:define wchar_print echo " set $i = 0 while (1 == 1) set $c = (char)(($arg0)[$i++]) if ($c == '/0') loop_break end printf "%c", $c end echo "enddocument wchar_printwchar_print <wstr>Print ASCII part of <wstr>, which is a wide character string of type wchar_t*.end
- Seeing functions and selectors [permalink]
info selectors
will show you all of the selectors in the application's symbol table.info functions
will show you all of the functions. You can supply regular expressions to limit the output. - Using libgmalloc in gdb [permalink]
libgmalloc
puts guard pages at the end of malloc'd blocks of memory, letting you catch buffer overruns. (This will hugely inflate your program's working set, and may lead to swapping) To turn onlibgmalloc
in gdb, do this:(gdb) set env DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib
- calling objective-C methods in gdb [permalink]
To call an Objective-C method in the gdb console, you have to cast the return type (since gdb doesn't really know what the return value is):(gdb) call (void)[textField setStringValue: @"Bork"]
Hacks
- Loading a bundle into a running program [permalink]
Sometimes it's handy to load a bundle into a running app to do some poseAsClass: for doing some debugging or reverse engineering. Make a Cocoa bundle which has the code you want to load, then do:(gdb) call (id) objc_getClass("NSBundle")$1 = (struct objc_object *) 0xa0a051d8gdb) call (id)[$1 bundleWithPath:@"/blah/blah/PoseAsClassBundle.bundle"]$2 = (struct objc_object *) 0x51467e0(gdb) call (BOOL)[$2 load]Reading symbols for shared libraries . done
一个挺好的网站:http://www.borkware.com/quickies/
- gdb on iPhone
- iphone逆向--gdb常用命令
- GDB on Android
- Setting Gdb on Windows
- GDB来调试IPHONE步骤
- IDA on iPhone
- Irrlicht On IPhone
- Using OpenCV on iPhone
- OpenVPN on iPhone
- Memory on the iPhone
- base64 on iphone-sdk
- WebKit on the iPhone
- OpenGL ES on iPhone OS
- OpenGL ES on iPhone OS
- openAL sound on the iPhone
- Android Pattern Lock on iPhone
- FreeType on OpenGL ES (iPhone)
- iphone gdb program received signal 0
- Java中的同一性和等同性
- Hocate Ajax 框架介绍
- 实现端口复用与端口劫持
- 我的CSDN正式开张
- js关闭页面不弹出确认框
- gdb on iPhone
- c# 全接触
- jspSmartUpload上传下载组件
- 使用代码处理页面中不可预知的错误
- 在C++中使用Apache的Log4cxx记录日志
- (转)Hibernate jar包详解
- 用php人工使网页过期
- 以假乱真的日用品,大家小心了。
- 以假乱真的日用品,大家小心了。