当前位置:首页 > 开发 > 移动开发 > 正文

【Android ndk-stack tool】用ndk-stack分析应用native程序异常crash掉

发表于: 2013-09-22   作者:aigo   来源:转载   浏览次数:
摘要: Android ndk-stack tool ----------------------   Introduction: -------------   This document describes the 'ndk-stack' tool that is distributed with the Android NDK, since release r6.

Android ndk-stack tool

----------------------

 

Introduction:

-------------

 

This document describes the 'ndk-stack' tool that is distributed with

the Android NDK, since release r6.

 

Overview:

---------

 

'ndk-stack' is a simple tool that allows you to filter stack traces as they

appear in the output of 'adb logcat' and replace any address inside a shared

library with the corresponding <source-file>

:

<line-number>

 values.

 

In a nutshell, it will translate something like:

 

    I/DEBUG   (   31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    I/DEBUG   (   31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'

    I/DEBUG   (   31): pid: 351, tid: 351  %gt;%gt;%gt; /data/local/ndk-tests/crasher <<<

    I/DEBUG   (   31): signal 11 (SIGSEGV), fault addr 0d9f00d8

    I/DEBUG   (   31):  r0 0000af88  r1 0000a008  r2 baadf00d  r3 0d9f00d8

    I/DEBUG   (   31):  r4 00000004  r5 0000a008  r6 0000af88  r7 00013c44

    I/DEBUG   (   31):  r8 00000000  r9 00000000  10 00000000  fp 00000000

    I/DEBUG   (   31):  ip 0000959c  sp be956cc8  lr 00008403  pc 0000841e  cpsr 60000030

    I/DEBUG   (   31):          #00  pc 0000841e  /data/local/ndk-tests/crasher

    I/DEBUG   (   31):          #01  pc 000083fe  /data/local/ndk-tests/crasher

    I/DEBUG   (   31):          #02  pc 000083f6  /data/local/ndk-tests/crasher

    I/DEBUG   (   31):          #03  pc 000191ac  /system/lib/libc.so

    I/DEBUG   (   31):          #04  pc 000083ea  /data/local/ndk-tests/crasher

    I/DEBUG   (   31):          #05  pc 00008458  /data/local/ndk-tests/crasher

    I/DEBUG   (   31):          #06  pc 0000d362  /system/lib/libc.so

    I/DEBUG   (   31):

 

Into the more readable output:

 

    ********** Crash dump: **********

    Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'

    pid: 351, tid: 351  >>> /data/local/ndk-tests/crasher <<<

    signal 11 (SIGSEGV), fault addr 0d9f00d8

    Stack frame #00  pc 0000841e  /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13

    Stack frame #01  pc 000083fe  /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5

    Stack frame #02  pc 000083f6  /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9

    Stack frame #03  pc 000191ac  /system/lib/libc.so

    Stack frame #04  pc 000083ea  /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14

    Stack frame #05  pc 00008458  /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19

    Stack frame #06  pc 0000d362  /system/lib/libc.so

 

Usage:

------

 

To do this, you will first need a directory containing symbolic versions of your

application's shared libraries. If you use the NDK build system (i.e. ndk-build),

then these are always located under $PROJECT_PATH/obj/local/<ab>, where

<ab> stands for your device's ABI (i.e. 'armeabi' by default).

 

You can feed the logcat text either as direct input to the program, e.g.:

 

   adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi

 

Or you can use the -dump option to specify the logcat as an input file, e.g.:

 

   adb logcat > /tmp/foo.txt

   $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi -dump foo.txt

 

 

** IMPORTANT **:

 

  The tool looks for the initial line containing starts in the logcat output,

  i.e. something that looks like:

 

    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

 

  When copy/pasting traces, don't forget this line from the traces, or

  ndk-stack won't work correctly.

 

TODO:

-----

 

A future version of 'ndk-stack' will try to launch 'adb logcat' and select the

library path automatically. For now, you'll have to do these steps manually.

 

As of now, ndk-stack doesn't handle libraries that don't have debug information

in them. It may be useful to try to detect the nearest function entry point to

a given PC address (e.g. as in the libc.so example above).

【Android ndk-stack tool】用ndk-stack分析应用native程序异常crash掉

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
转载请注明来源:http://blog.csdn.net/singwhatiwanna/article/details/17289479 前言 大家都知道
本文将分析Android native memory的使用状况及通过一些手段来定位到native memory leak代码。 在Eng
Outline 如何获得crash日志 如何解析crash日志 如何分析crash日志 1. iOS策略相关 2. 常见错误标识
Outline 如何获得crash日志 如何解析crash日志 如何分析crash日志 1. iOS策略相关 2. 常见错误标识
iOS应用的crash日志的分析基础 Outline 如何获得crash日志 如何解析crash日志 如何分析crash日志 1.
APK是Android PacKage的缩写,即Android安装包。将APK文件直接传到Android模拟器或Android手机中执
APK是Android PacKage的缩写,即Android安装包。将APK文件直接传到Android模拟器或Android手机中执
ilocker:关注 Android 安全(新入行,0基础) QQ: 2597294287 先看一张原理图: 我是 Linux 和 And
当我们要在IIS PRD环境下分析异常,并且对问题毫无头绪,又没有权限直接上打Log的代码。这个时候就
转载自:http://linux.cn/article-3475-1.html 在工作中经常会遇到一些内核crash的情况,本文就是根
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号