android debug
2015-07-31 20:54
537 查看
android app 问题分析方法
Force close: 会在main log中有FATAL EXCEPTIONANR会有trace文件生成
tombstone一般是由Dalvik错误、状态监视调试器、C层代码以及libc的一些问题导致的
1. trace文件生成
命令:kill -3 pid
保存路径:/data/anr/traces.txt
包含的信息:包含所有的java和native线程的堆栈
作用:
怀疑会有线程卡死,比如ANR的时候,多打印几次trace,如果调用堆栈一直不变,证明有卡死。
分析binder调用线程,里面会有类似transact、onTransact、talkWithDriver的调用
2. kernel log
root@:/ # dmesg
root@:/ # cat /proc/kmsg
root@:/ # cat /proc/kmsg > /sdcard/kernel_log.txt &
root@:/ # cat /proc/sys/kernel/printk 7 4 1 7 (7=Current level, 4=Default level, 1=Minimum level, 7=Boot up level)
If you want to see all logs in the kernel log then echo “8” to the printk node.
To see only the super-critical messages echo “1”.
貌似日志级别不影响/proc/kmsg和dmesg
3. tombstone
内核在加载可执行映像时,会先执行/system/bin/linker(参考android linker相关的资料),在linker中设置进程的信号处理函数。信号如下:
sigaction(SIGABRT, &action, NULL); sigaction(SIGBUS, &action, NULL); sigaction(SIGFPE, &action, NULL); sigaction(SIGILL, &action, NULL); sigaction(SIGPIPE, &action, NULL); sigaction(SIGSEGV, &action, NULL); #if defined(SIGSTKFLT) sigaction(SIGSTKFLT, &action, NULL); #endif sigaction(SIGTRAP, &action, NULL);
时序图如下:
debuggerd,位置system/core/debuggerd/debuggerd.c
debuggerd收到某个进程的DEBUGGER_ACTION_CRASH请求,然后:
PTRACE_ATTACH到那个进程
发送SIGSTOP给那个进程,让它的所有线程都停止运行
打开tomestone文件,dump CRASH信息
如果这个property "ro.debuggable" 是置位的,则dump该进程的 system和main log
ptrace 参考 http://blog.csdn.net/myarrow/article/details/9617673
如何调试tomestone 参考 http://blog.csdn.net/lizzy115/article/details/13296979
http://blog.csdn.net/helldevil/article/details/6682211
相关文章推荐
- android之Broadcast
- Android子线程更新主界面
- android 开发 drawerlayout出现退不回去的情况
- Android之——判断当前应用程序是否是用户程序
- Android之——实现应用卸载功能
- 谈谈Android(Activity)的理解
- Android学习笔记之事件分发机制(二)
- android broadcast基础学习
- Android第四十五期 - QQ空间发说说功能
- Android第四十五期 - QQ空间发说说功能
- Android侧滑抽屉效果实现
- Android开发之远距离PC控制
- 【Android学习笔记】手机中data文件夹点不开怎么办?三步教你获取数据库文件
- [Android]可缩放性ImageView(可以放大缩小)
- Android 内存监测工具 DDMS --> Heap
- Android studio 安装中遇到一些问题的解决办法,分享一下
- Android 布局详解 -三表格布局(TableLayout)以及重要属性
- Android5.0 Framework框架源码剖析声明
- Android ViewPager多页面滑动切换以及动画效果
- android的问号?和@符号的含义