Remote debugging and dumping using gdbserver

This tutorial is for advanced users only!

As Google fixed gcore for Windows, we can finally dump core remotely using gdbserver. I tested GDB on macOS 2 years ago and was working, should still work today and for Linux too. I don't have device running macOS and Linux at the moment

A good internet connection is required for better debugging experience. 5GHz Wi-Fi and Ethernet is highly recommended.
Root is required.
Samsung devices with KNOX and/or other phones with security may prevent GDB from working. Use custom rom or custom kernel that doesn't have such security system. Or just buy old devices or buy crappy chinese devices that doesn't have any super security. That's the reason I use Denver tablets all time XD.
Some emulators does not support core file generation but Bluestacks support it.

Download the correct file for your device CPU architecture. You can check your CPU architecture using CPU-Z app

GDB server:
Android arm64: Link 1 | Link 2
Android armv7: Link 1 | Link 2
Android x86: Link 1 | Link 2
Android x86-64: Link 1 | Link 2

GDB client:
Windows x86 (32-bit): Link 1 | Link 2
Windows x86-64: Link 1 | Link 2
macOS (Darwin) x86-64: Link 1 | Link 2
Linux x86-64: Link 1 | Link 2

On PC, extract the folder into your desired folder.

On Android device, add the gdbserver file to /system/bin and give gdbserver file permission 755. If you are using X-plore, make sure you enable superuser + writeable in confuguration.

Attach the process and start the server:
Open up the Terminal, grand superuser/root access

Show all process list
dumpsys meminfo

Or search text
dumpsys meminfo | grep (string of package name, com.*, whatever…)

Find a pid number of process you want to attach

Running gdbserver and attaching to a running process:
Run gdbserver on the target system with TCP connection and attach to the pid number of process. Just give port 1234
gdbserver :<port> --attach <pid>

gdbserver will listen on port and waiting for you to connect.
Attached: pid = <pid>
Listening on port <port>

Connecting to gdbserver:
Execute the gdb file located in /bin/ (gdb.exe Windows)
Target your device's IP:Port. You can find your device's IP on Wifi settings (Kitkat and below) or Status (Lollipop and above)

target remote <ip>:<port>

That's all, now you can use GDB for debugging and dumping remotely.

I'll look into GDB game hacking later. For now, you can read iOS GDB hacking tutorials

To dump use
gcore <path to your hard drive>
Please note that dumping core to your PC may take 2-5 minutes depending on performance and network speed

Targeting emulator:

Forward TCP
adb forward tcp:<port> tcp:<port>

Then in GDB, you can target your emulator.
target remote :<port>

Some emulators required you to enable USB debugging and connect adb manually. For example Nox Player, do this to connect to localhost.

nox_adb.exe connect

Then forward TCP
nox_adb.exe forward tcp:1234 tcp:1234

Google (GDB)
iAndroHacker (Tutorial)