I am debugging C++ library for Android with GDB (gdbserver + gdb on host), and I've noticed that gdb output is very very slow.
E.g. application has about 15 threads, and when I type thread apply all bt
it takes 15-20 seconds to output all stacktraces to terminal/file. All output is about 200 lines of text, it should not be that slow!
Moreover, on my host machine (64-bit Ubuntu) the same thing takes no more than 0.1-0.2 seconds!
I suspected that terminal output on host may be the cause of slowdown, but it is not the case. Even with the following settings it takes the same amount of time:
set width 0
set height 0
set pagination 0
set logging redirect on
set logging overwrite on
set logging file prof.txt
set logging on
I am not completely sure what is the main cause of slowdown, it is either slow stack unwinding on Android or slow transfer of data via gdb<-->gdbserver connection. But I am suspecting the latter, because when gdb outputs data the adb
process consumes a lot of CPU time.
My question is: how do I make the gdb output to file faster?
Please help, if anyone knows how to achieve one of the following:
- Set some gdb/adb options to make the data transfer faster
- make gdbserver save data to local file (on Android device) instead of sending it to remote gdb client
- Build gdb client for target device and debug on the device
EDIT:
It worth mentioning that I am using adb forward
to establish tcp connection between gdb and gdbserver:
adb push $NDK_ROOT/prebuilt/android-arm/gdbserver/gdbserver /data/local/tmp
adb shell chmod 777 /data/local/tmp/gdbserver
adb shell /data/local/tmp/gdbserver :5039 --attach $1 &
adb forward tcp:5039 tcp:5039