How to get gdb working on Apple iOS 4.3.x
► Step 1: Download and install gdb
1) Download gdb at http://apt.saurik.com/debs/gdb_1518-11_iphoneos-arm.deb2) Transfer the file to the iDevice (e.g. via SSH)
3) Install the package with the following command
iPhone:~ root# dpkg -i gdb_1518-11_iphoneos-arm.deb
This version of gdb will work on iOS 4.3.x with ASLR but it has a problem displaying the register values. To solve this issue I wrote a little gdb script.
► Step 2: Download and use my gdb script
1) Download the gdb script at http://www.trapkit.de/pub/registers.gdb2) Transfer the file to the iDevice (e.g. via SSH)
3) Start gdb and load the script with the following command:
(gdb) source registers.gdb
The script implements a new gdb command called 'ir' ([i]nfo[r]egisters) that lists the registers and their contents. Example output:
(gdb) ir r0 0x10004005 268451845 r1 0x07000006 117440518 r2 0x00000000 0 r3 0x00000c00 3072 r4 0x00001a03 6659 r5 0xffffffff -1 r6 0x00000000 0 r7 0x2feb5dbc 803954108 r8 0x00000000 0 r9 0x3f45afb4 1061531572 r10 0x00000000 0 r11 0xffffffff -1 sp 0x2feb5d84 803954052 lr 0x35cd575f 902649695 pc 0x35cd5c00 902650880
Alternatively, rename the file to '.gdbinit' and put it in the home directory of the user that will run gdb.