How to remotely debug process of Android by gdb via usb

Let take RIL daemon as an example.

On Android

Get process id

# ps | grep rild

Start gdb server and attach it to the process

# gdbserver :5039 --attach pid_of_rild

On host

Forward port over USB connection

adb forward tcp:5039 tcp:5039

Download NDK

NDK Downloads

Start gdb from NDK

$ gdb -q
(gdb) target remote :5039

Get stack

(gdb) bt

How to debug Android-x86 application running in virtual machine

How to remotely debug process of Android-x86 by gdb

Continue reading

How to upload files to Android device via adb

Connect the tablet to PC via USB cable.

Download and install drivers for adb from http://adbdriver.com/downloads/

Open terminal and run

adb usb

Remount device file system as writeable. Open terminal and run

adb root
adb remount

Push new file into target file system

adb push local_file remote_file

Open device shell and work with file as usual

adb shell

ADB commands for reference

Push and Pull Files Using ADB Commands

Android device isn’t shown in adb list

How to start the Android command line shell (adb)

How to get logs from Android-x86 virtual machine

Step 1

Turn on network interface and get IP-address of the virtual machine.

Getting IP-adress of virtual machine running Android-x86
Getting IP-adress of virtual machine running Android-x86.

Step 2

Start adb on Windows with IP-address of the virtual machine passed as parameter.

Starting adb on Windows with given IP-address of the virtual machine
Starting adb on Windows with given IP-address of the virtual machine.

Step 3

Get logs

$ adb logcat
Getting logs from adb
Getting logs from adb.

Clean radio logs

$ adb logcat -b radio -c

Clean all logs

$ adb logcat -b all -c

How to remotely debug process of Android-x86 by gdb

VM Android-x86 should have bridge network connection.

Let take RIL daemon as an example.

On VM

Get VM IP address

# ifconfig

Get process id

# ps | grep rild

Start gdb server

# gdbserver64 :5039 --attach pid_of_rild

On host

Start gdb

$ gdb -q
(gdb) target remote ip_address_of_vm:5039

Get stack

(gdb) bt

How to debug Android-x86 application running in virtual machine

Remote debugging with GDB

How to Debug Using GDB

gdbserver man

How to debug Android-x86 application running in virtual machine

Step 1

Turn on network interface and get IP-address of the virtual machine.

Getting IP-adress of virtual machine running Android-x86
Getting IP-adress of virtual machine running Android-x86.

Step 2

Start adb on Windows with IP-address of the virtual machine passed as parameter.

Starting adb on Windows with given IP-address of the virtual machine
Starting adb on Windows with given IP-address of the virtual machine.

Step 3

Start Android Studio (it connects to adb automatically) and attach it to process you want to debug.

Selecting application for debugging in Android Studio
Selecting application for debugging in Android Studio.

Unfortunately this set up allows to debug only Java-processes not native.

If you want just to get logs from Android stop Android Studio and type in Windows console

$ adb logcat
$ adb logcat -b radio
Getting logs from adb
Getting logs from adb.

Shell access

$ adb shell

VirtualBox bridged adapter gets only IPv6 address

How to remotely debug process of Android-x86 by gdb

Debug Howto