Showing posts with label gdb android gdbserver remote debugging malformed packet. Show all posts
Showing posts with label gdb android gdbserver remote debugging malformed packet. Show all posts

Wednesday, January 18, 2012

using gdbserver on android emulator

1. Make your library debugable (add -g options in makefile)
modify your Android.mk add below command "LOCAL_CPPFLAGS += -g" for C++ files and "LOCAL_CFLAGS += -G" FOR C files.
rebuild your library and system image(if necessary)

2. in your local system redirect the debug port
$ telnet localhost 5554
redir add tcp:1234:1234
exit

3.you can start emulator by below command with debug port redirected.
./emulator -avd avdname -qemu -redir udp:1234::1234

4. push gdbserver to emulator
adb push ./out/target/product/generic/obj/EXECUTABLES/gdbserver_intermediates/gdbserver /system/bin/

5. run # gdbserver :1234 --attach your-desired-pid or gdbserver :1234 desired_process

6. run ./prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gdb ./out/target/product/generic/symbols/system/bin/app_process

7. in gdb-terminal
gdb>set solib-search-path out/target/product/generic/symbols/system/lib
In case there are multiple library paths to be searched, use ':' to concatenate the paths
gdb>target remote localhost:1234

8. Now you can see the Errors .... Happy remote Debugging!!!!

Common Error:

Malformed packet(b) (missing colon): re:0;
Packet: 'T050b:00000000;0d:c03ecebe;0f:b0070040;thread:4ab;core:0;'

This means the gdbserver and gdb in localhost are not compatible!!