android trace 介绍

一 通过debuggerd导出native进程trace信息

android中自带debuggerd工具打印native进程的trace信息,具体使用方法

$debuggerd -b 410
----- pid 410 at 2018-08-20 18:55:54 -----
Cmd line: /system/bin/mediadrmserver
ABI: 'arm'

"mediadrmserver" sysTid=410
  #00 pc 000541fc  /system/lib/libc.so (__ioctl+8)
  #01 pc 00021b93  /system/lib/libc.so (ioctl+38)
  #02 pc 0003d583  /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206)
  #03 pc 0003d6d3  /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10)
  #04 pc 0003dc5b  /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38)
  #05 pc 000022cf  /system/bin/mediadrmserver (main+90)
  #06 pc 0008c69d  /system/lib/libc.so (__libc_init+48)
  #07 pc 00002035  /system/bin/mediadrmserver (_start_main+40)
  #08 pc 00000306  

"Binder:410_1" sysTid=490
  #00 pc 000541fc  /system/lib/libc.so (__ioctl+8)
  #01 pc 00021b93  /system/lib/libc.so (ioctl+38)
  #02 pc 0003d583  /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206)
  #03 pc 0003d6d3  /system/lib/libbinder.so (android::IPCThreadState::getAndExeuteCommand()+10)
  #04 pc 0003dc5b  /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38)
  #05 pc 000547cd  /system/lib/libbinder.so (android::PoolThread::threadLoop()+12)
  #06 pc 0000c0bf  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170)
  #07 pc 00064343  /system/lib/libc.so (__pthread_start(void*)+22)
  #08 pc 0001dfad  /system/lib/libc.so (__start_thread+32)

"Binder:410_2" sysTid=12285
  #00 pc 000541fc  /system/lib/libc.so (__ioctl+8)
  #01 pc 00021b93  /system/lib/libc.so (ioctl+38)
  #02 pc 0003d583  /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+206)
  #03 pc 0003d6d3  /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+10)
  #04 pc 0003dc5b  /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+38)
  #05 pc 000547cd  /system/lib/libbinder.so (android::PoolThread::threadLoop()+12)
  #06 pc 0000c0bf  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+170)
  #07 pc 00064343  /system/lib/libc.so (__pthread_start(void*)+22)
  #08 pc 0001dfad  /system/lib/libc.so (__start_thread+32)

----- end 410 -----

二 在代码处打印trace信息

但是有的时候有些临界状态不容易被抓到,那么可能需要在代码处添加dump信息,便于查找调用栈,从而定位问题。

#include 
void tryToGetStack()
{
        CallStack stack;
        stack.update();
        stack.dump(2, 4, "dump:");
}


三 art虚拟机java调用栈

具体使用方法 kill -3 1906
ART虚拟在/data/anr/处生成trace_XX文件,如下:

/data/anr # ls
trace_00 trace_01 trace_02

你可能感兴趣的:(android trace 介绍)