This is the AMP version of this page.
If you want to load the real page instead, click this text.

Tutorial How to connect GDB to your rooted Android device

G-Bo ッ

Administrator
Original poster
Staff member
Administrator
Mar 22, 2017
8,743
341,785
2,350
Behind you.
platinmods.com
Note: This is for testing. Gcore and watchpoint may work or not work. gdbserver won't work with emulators because they are emulating network that a computer can't access it directly.

I will make a tutorial about compiling GDB for all platforms for peoples who want to try fixing gcore.

Tested on Android 4.4.4 and 5.1.1 and it works

Requirements:
A rooted device
Android 4.x.x-6.x.x (marshmallow is untested)
Terminal app

Downloads:
GDB server by Google (Android NDK 11c March 2016)

Check your device's Kernel architecture before adding gdbserver!
You can check it using GPU-Z and go to "SYSTEM" tab to see your kernel architecture
CPU-Z - Android Apps on Google Play

android-arm gdbserver
android-arm64 gdbserver
android-mips gdbserver
android-mips64 gdbserver
android-x86 gdbserver
android-x86_64 gdbserver

GDB v7.11 by Google (Android NDK 11c March 2016)
windows-x86_64 gdb
linux-x86_64 gdb
darwin-x86_64 gdb (Mac OS X)

GDB v7.11 by iAndroHacker (target: arm-linux-androideabi)
windows-x86_64 gdb (gcore: have "g" packet error)
darwin-x86_64 (Mac OS X) (gcore: working but slow to save)
linux-x86_64 (coming)

Other
GDB 7.4.1 by SysProgs (stable)

How to download the file?



On your Android device, open Xplore, open confuguration and enable root access





Copy the file gdbserver to /system/bin



Open the Terminal app, input:
Code:
su
and hit enter. input

Code:
dumpsys meminfo
and hit enter to show all the processes.



pick one of the process you want to attach and input

Code:
gdbserver :<port> --attach <pid>
Replacing <pid> with the PID number and <port> with the port number. you can put any ports from range 0-65536 but make sure that the port you input is not in use



Hit enter and the gdbserver will attach the process and listen to the port



Open Wi-Fi settings and check your local IP



On Linux/Mac OS X, open the "gdb" file

On Windows, open the "gdb.exe" file

input:

Code:
target remote 192.168.1.25:1234
to connect to your device



That's all. Now you can use GDB remotely



Credit:
iAndroHacker