Notice: this project is no longer maintained As an alternative, see: termux

Goal

Run a program under gdb

Download/install gdb

Run the commands at an adb command line. This will require a working busybox (tar, wget) in your path. Running under a terminal will require adjusting your paths.

Run a program under gdb

Here, I created a small program that crashes and put it in /data/local/tmp

Below is a sample session, typed commands are in bold

Reading symbols from /data/local/tmp/crash...done.
(gdb) run
Starting program: /data/local/tmp/crash
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

Program received signal SIGSEGV, Segmentation fault.
0x0000859c in main ()
(gdb) info regi
r0             0x1      1
r1             0xbecc6b34       -1093899468
r2             0x0      0
r3             0x0      0
r4             0x8580   34176
r5             0xbecc6b34       -1093899468
r6             0x1      1
r7             0xbecc6b3c       -1093899460
r8             0x0      0
r9             0x0      0
r10            0x0      0
r11            0xbecc6b14       -1093899500
r12            0x400d200c       1074601996
sp             0xbecc6b08       0xbecc6b08
lr             0x4012d169       1074975081
pc             0x859c   0x859c <main+28>
cpsr           0x60070010       1611071504
(gdb) x/i $pc
=> 0x859c <main+28>:    str     r2, [r3]

You can see that this program is trying to store the value in r2 (0x0) in the address pointed to by r3 (0x0), which resulted in the segmentation fault.