First of all, this article may be flawed, because I do not have the conditions to test the dynamic library debugging. (mainly because it is their own mobile phones do not want to put all kinds of so)
So I can only say that if I have time, I will go to the test, this is the first.
1. Test Code GDB-TEST.C
#include <stdio.h>
int main () {
printf ("This is the GDB test!!! \ n ");
}
2, Android.mk
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_cflags: =-G
Local_strip_module: = flase #禁止对最终生成的gdb-test for STRIP processing
Local_moule_tags: = Optional
Local_src_files: = gdb-test.c
Local_module: = Gdb-test
Include $ (build_executable)
3, copy gdb-test gdbserver to device Data directory (here just for simplicity)
4. Enter in the shell
# adb Shell
into the shell in device
# CD Data
#./gdbserver:2000./gdb-test (Note: Gdb-test can be sent here)
The port we used for Gdbserver was 2000.
If you succeed, you will see
# Listening on Port 2000
Description successfully opened the service
5, on the PC to perform
ADB forward tcp:2000 tcp:2000
6, in the running of the GDB on the PC, the specific path is
#arm-linux-androideabi-gdb./gdb-test
Note that the position of the gdb-test here is very important because you can see that there is a gdb-test under Libs, also under OBJ, in order to ensure that the symbol table
Can be successfully loaded, this must be used in the gdb-test under OBJ, because Libs is always generated by removing the symbol table, only the OBJS in the real can be debugged.
After successful entry into GDB, enter
# (GDB) Target remote:2000
Use Gdbserver to debug C programs in Android