用 jdb 追踪 Android
You may have debug Android in eclipse, Have you ever used jdb tracing Android. Since Dalvikvm support jdwp, we can use jdb to debug the program. there are 2 ways
Android as debug hostSteps1) update libandroid_runtime
change below
frameworks/base/core/jni/AndroidRuntime.cpp 620 opt.optionString = 621 "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";asopt.optionString = "-agentlib:jdwp=transport=dt_socket,address=localhost:8011,server=n,suspend=y";
if you won't run jdb on the same host, change "localhost" to other host/ip
2) change system/root/default.prop on your running envchange "ro.debuggable=0" to "ro.debuggable=1"
3) use jdb to listen the portjdb -listen 8011
4) Start Android or APPs
when your Dalvik VM start, it will connect 8011
The good advantages of "Jdb as Host" is that when you need to debug, you let jdb listen; if you won't listen, Android will run as normal.
For example, when I want to debug the App, I run "jdb -listen 8011", then I click the App icon on the Launcher and start to debug.
Attention:
The Apps have launch timeout limits or It will be terminated by AM, when you enter jdb console, you need to quickly set breakpoint, and enter "cont" to run