In the emulator of the Android system, there are two methods for GDB debugging: GDB debugging and gdbserver debugging.
1. Use GDB server for debugging:
A. Download the gdb server for Android from the following link
Http://www.billrocks.org/android_libs/bin/
B. Install the downloaded GDB server to your emulator.
1) Start emulator
2) download the gdb server to your emulator
Open a terminal and run:
$ ADB Shell
# CD Data
# Mkdir Bin
Run in another terminal:
$ ADB push gdbserver/data/bin
In this way, the gdbserver is downloaded to the emulator through the android ADB.
C. Run gdbserver:
#/Data/bin/gdbserver 10.0.2.2: 1234 [ARGs...]
D. Return to another terminal and map the Port:
$ Telnet local host 5554
Telnet to emulator and run the following command:
Redir add TCP: 1234: 1234
E. Run GDB on the third terminal:
$ GDB Test
Test is the program you want to debug, and then run it on the gdb command line:
(GDB) target remote localhost: 1234
Then you can debug the program as you did with GDB.
2. Use local GDB for debugging.
A. Download the android debugging package from the following link. It is a binary file compiled using the android toolchain:
Http://ortegaalfredo.googlepages.com/android-debug.tbz
B. decompress the debugging package and download GDB to your emulator. If you have a real mobile phone, you can debug it as follows:
$ ADB push GDB/data/bin
C. Use ADB to connect to emulator
$ ADB Shell
When running GDB, the following information is displayed:
#/Data/bin/GDB
Dlopen failed on 'libthread _ dB. so.1 '-libthread_db.so.1: cannot open shared object file: no such file or directory
GDB will not be able to debug pthreads.
Gnu gdb 6.7
Copyright (c) 2007 Free Software Foundation, Inc.
License gplv3 +: gnu gpl Version 3 or later This is free software: You are free to change and redistribute it.
There is no warranty, to the extent permitted by law. Type "show copying"
And "show warranty" for details.
This GDB was configured as "-- Host = arm-None-Linux-gnueabi -- target = ".
(GDB)
D. Then you can debug the program as you did with GDB.