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 host
Steps
1) update libandroid_runtime
change below
[java]
frameworks/base/core/jni/AndroidRuntime.cpp
620 opt.optionString =
621 "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";
as
opt.optionString = "-agentlib:jdwp=transport=dt_socket,address=8011,server=y,suspend=y";
frameworks/base/core/jni/AndroidRuntime.cpp
620 opt.optionString =
621 "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";
as
opt.optionString = "-agentlib:jdwp=transport=dt_socket,address=8011,server=y,suspend=y";
use "mmm frameworks/base/core/jni" to re-generate system/lib/libandroid_runtime.so, then copy to your runing env (system/lib)
2) change system/root/default.prop on your running env
change "ro.debuggable=0" to "ro.debuggable=1"
if you won not do it, you can specify AndroidManifest.xml
Or the App can not be debugged
3) start the app
check stop you will see below
[java]
I/Zygote ( 6843/6843): Accepting command socket connections
I/jdwp ( 7385/7385): JDWP will wait for debugger on port 8011
I/Zygote ( 6843/6843): Accepting command socket connections
I/jdwp ( 7385/7385): JDWP will wait for debugger on port 8011
4) use jdb to attach the port
jdb -attach localhost:8011
--- you will see ---
[java]
Initializing jdb ...
>
VM Started: "thread=<1> main", dalvik.system.Zygote.nativeForkSystemServer(), line=-1 bci=-1
<1> main[1]
Initializing jdb ...
>
VM Started: "thread=<1> main", dalvik.system.Zygote.nativeForkSystemServer(), line=-1 bci=-1
<1> main[1]
5) include source dirs by "use" command, you will see source code
<1> main[1] use /home/user/jb/frameworks/base/core/java:/home/user/jb/frameworks/base/packages/SettingsProvider/src/:/home/user/jb/frameworks/base/services/java
6) set break and trace
[java]
Use commands: stop in, cont, list, next, you will able to trace your code
<1> main[1] stop in com.android.server.InputMethodManagerService.getEnabledInputMethodSubtypeList
Deferring breakpoint com.android.server.InputMethodManagerService.getEnabledInputMethodSubtypeList.
<1> main[1] cont
> Ignoring cmd 268435570/199/1 from the VM
Set deferred breakpoint com.android.server.InputMethodManagerService.getEnabledInputMethodSubtypeList
Breakpoint hit: "thread=<12> android.server.ServerThread", com.android.server.InputMethodManagerService.getEnabledInputMethodSubtypeList(), line=845 bci=0
845 synchronized (mMethodMap) {
<12> android.server.ServerThread[1] list
841
842 @Override
843 public List
844 boolean allowsImplicitlySelectedSubtypes) {
845 => synchronized (mMethodMap) {
846 return getEnabledInputMethodSubtypeListLocked(imi, allowsImplicitlySelectedSubtypes);
847 }
848 }
849
850 @Override
<12> android.server.ServerThread[1] next
Step completed: "thread=<12> android.server.ServerThread", com.android.server.InputMethodManagerService.getEnabledInputMethodSubtypeList(), line=846 bci=3
846 return getEnabledInputMe