当前位置: 首页 > article >正文

Android上使用tombstone定位问题的示例

菜谱

1)tombstone文件
2)对应的带symbol的可执行文件或者库文件
3)stack脚本

生成tombstone文件

如果恰好手头上没有现成的tombstone文件,可以手动创建一个。
1)在native代码中写一个空指针错误,直接崩掉就会生成tombstone文件。
2)对已有的进程发送一个signal 11(SIGSEGV)
3)tombstone文件保存在/data/tombstones/目录下。

例如:可以给system_server发一个信号,为它生成一个tombstone纪念一下。
鉴于system_server的重要性和复杂性,他的tombstone内容很丰富…
找个简单点的native程序,生成的tombstone也会简单一些。


symbol文件

在AOSP源码中,对应的目录在:

	out/target/product/${prod_name}/symbols/

${prod_name}根据你的工程信息填写。

stack脚本

stack是一个python脚本,在AOSP源码和Android NDK中都可以找到。
在AOSP中的位置:

	prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
# stack 脚本的用法
$ stack -h
usage: stack [-h] [--arch ARCH] [--syms SYMS] [FILE]
Parse and symbolize crashes
positional arguments:FILE                  should contain a stack trace in it somewhere the toolwill find that and re-print it with source files andline numbers. If you don't pass FILE, or if file is -,it reads from stdin.
optional arguments:-h, --help            show this help message and exit--arch ARCH           the target architecture--syms SYMS, --symdir SYMSthe symbols directory

解析tombstone文件

把symbol文件目录和对应的tombstone文件传给stack脚本,就会帮着解析出错误对应的方法名称。

$ stack --syms ${aosp_dir}/out/target/product/${prod_name}/symbols/ ~/temp/tombstones/tombstone_25
Searching for native crashes in /home/user/temp/tombstones/tombstone_25
Reading symbols from symbols/
Revision: '0'
pid: 19272, tid: 19272, name: logcat  >>> logcat <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8x0  000000563dd67f1d  x1  0000007ffc1de546  x2  0000007ffc1db608  x3  0000000000000030x4  0000000000000010  x5  b4000077403c0061  x6  2d20315b203a3231  x7  5d3237323931203ex8  0000000000000000  x9  0000000000000070  x10 6d75642065726f63  x11 0000000000000008x12 0000000000000000  x13 0a2e64656c6c6163  x14 0000007860504d22  x15 00000000fffffffex16 0000007860501d80  x17 0000007861a92934  x18 00000078618b6000  x19 0000007ffc1dd990x20 0000007861b547f0  x21 0000007ffc1de546  x22 0000000000000054  x23 b4000076103b41c0x24 0000007ffc1dbee0  x25 00000078608fb000  x26 0000000000000000  x27 b4000076103b48b0x28 0000007ffc1dc4f0  x29 0000007ffc1dbe40sp  0000007ffc1db990  pc  000000563dd6edfc
Using arm64 toolchain from: /home/user/code/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/Stack Trace:RELADDR           FUNCTION                             FILE:LINEv-------------->  getLastLine(char const*)             system/core/logcat/logcat.cpp:270v-------------->  getLastLogTimeString(char const*)    system/core/logcat/logcat.cpp:306000000000000edfc  Logcat::RotateLogs2()+192            system/core/logcat/logcat.cpp:497000000000000fd74  Logcat::ProcessBuffer(log_msg*)+628  system/core/logcat/logcat.cpp:6370000000000012d34  Logcat::Run(int, char**)+11676       system/core/logcat/logcat.cpp:160000000000000134a4  main+268                             system/core/logcat/logcat.cpp:164700000000000499fc  __libc_init+108                      bionic/libc/bionic/libc_init_dynamic.cpp:151

手动查看tombstone文件

有文本编辑器(vi、vs code)等直接打开tombstone文件,也可以看到很多基本的有用信息,对于自己编写的代码,很多时候打开一看就能帮助定位到问题原因。

http://www.lryc.cn/news/2416997.html

相关文章:

  • Longhorn,企业级云原生容器分布式存储 - 定制默认设置
  • 关于Https中的headers的理解
  • 数据备份与数据容灾全解析
  • C# 读写ini文件
  • SSH服务远程访问及控制
  • ij工具的基础操作
  • DecimalFormat用法
  • GCC下载地址(linux/windows\安装)或从minGW中取得gcc
  • JSF 原理简要介绍
  • 802.11ac/ax (wifi6)中的Beamforming技术介绍
  • ERP系统之sap入门操作--sap的基本的了解入门
  • 港片怀旧:《鹰爪铁布衫》(1)
  • Linux环境如何下载文件
  • VRP基础
  • DNS是什么,有什么用(详细介绍版)
  • 【数模】多元线性回归分析
  • 单片机和sbit和sfr
  • 常用软件过程——RUP
  • TreeSet的使用方法总结、实现原理、使用示例
  • 语法制导的翻译总结
  • Aircrack-ng组件详解
  • 安卓屏幕分辨率及UI尺寸详解
  • 服务器配置篇 ━━ iis7配置php出现fastcgi的500错误,LocalSystem/LocalService/NetworkService/ApplicationPoolIdentity
  • 【UEFI实战】FSP简介
  • 并发——ScheduledThreadPoolExecutor 详解
  • 逻辑回归(Logistic)
  • 学习Qss--Qss的特性
  • 高并发下System.currentTimeMillis()性能问题及优化方案
  • 串口(SerialPort)的使用
  • 常用正交表(正交法编写测试用例)