ANR分析

2018-04-24  本文已影响9人  Res2013

ANR日志分析

获取日志

adb pull /data/anr/trace.txt

trace文件解析

trace文件例子

关注主线程调用栈,断点调试若干次就可搞定了。

All threads:
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289] DALVIK THREADS (63):
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289] "main" prio=5 tid=1 Native
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x740a5700 self=0xb8e7b300
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   | sysTid=15674 nice=-8 cgrp=default sched=0/0 handle=0xb6fbcbec
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   | state=S schedstat=( 4619443227 537650589 5766 ) utm=346 stm=115 core=1 HZ=100
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   | stack=0xbe5e7000-0xbe5e9000 stackSize=8MB
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   | held mutexes=
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #00 pc 0003d414  /system/lib/libc.so (__epoll_pwait+20)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #01 pc 00014761  /system/lib/libc.so (epoll_pwait+26)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #02 pc 0001476f  /system/lib/libc.so (epoll_wait+6)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #03 pc 000124df  /system/lib/libutils.so (android::Looper::pollInner(int)+98)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #04 pc 00012709  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #05 pc 00081a29  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   native: #06 pc 000b34c3  /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+102)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at android.os.MessageQueue.nativePollOnce(Native method)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at android.os.MessageQueue.next(MessageQueue.java:143)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at android.os.Looper.loop(Looper.java:122)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at android.app.ActivityThread.main(ActivityThread.java:5280)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at java.lang.reflect.Method.invoke!(Native method)
01-17 15:59:16.556 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at java.lang.reflect.Method.invoke(Method.java:372)
01-17 15:59:16.557 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
01-17 15:59:16.557 15674-15935/com.cloudream.shoppingguide A/art: art/runtime/runtime.cc:289]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)

基本概念

"main":主线程,prio:线程的优先级,tid:线程id,Native:线程状态

线程状态

ThreadStatus

/*
 * Current status; these map to JDWP constants, so don't rearrange them.
 * (If you do alter this, update the strings in dvmDumpThread and the
 * conversion table in VMThread.java.)
 *
 * Note that "suspended" is orthogonal to these values (so says JDWP).
 */
typedef enum ThreadStatus {
    /* these match up with JDWP values */
    THREAD_ZOMBIE       = 0,        /* TERMINATED */
    THREAD_RUNNING      = 1,        /* RUNNABLE or running now */
    THREAD_TIMED_WAIT   = 2,        /* TIMED_WAITING in Object.wait() */
    THREAD_MONITOR      = 3,        /* BLOCKED on a monitor */
    THREAD_WAIT         = 4,        /* WAITING in Object.wait() */
    /* non-JDWP states */
    THREAD_INITIALIZING = 5,        /* allocated, not yet running */
    THREAD_STARTING     = 6,        /* started, not yet on thread list */
    THREAD_NATIVE       = 7,        /* off in a JNI native method */
    THREAD_VMWAIT       = 8,        /* waiting on a VM resource */
} ThreadStatus;
上一篇下一篇

猜你喜欢

热点阅读