android小工具,通过读取trace文件,回溯整个整个程序执行调用树。

Overview

TraceReader

1.简述

Android 调试工具ddms的devices栏目存在一个功能叫做start method profiling,此按钮顾名思义是启动method profiling的,而Android的Method Profiling功能,是可以在一段时间内记录所有运行过的函数,最后生成一个xxx.trace文件。xxx.trace文件比较有趣,如果分析andorid源码可以知道,xxx.trace文件按线程和时间记录了method的enter和exit事件。也就是说,如果我们能够读取xxx.trace文件,那么我们就能够获取到某段时间,某个app运行过的java函数。

2.功能

 于是乎,便有个这个工具,目前更新到TraceReader v1.1,实现了如下功能:
1)支持拖拽解析xx.trace。
image
2)支持显示线程。
image
3)支持树形显示方法调用
image
4)支持按列显示运行方法
image
5)支持搜索
image
6)支持复制、重命名
image
image
7)支持显示调用时间
image
image

3.用法

 解析trace文件,用法如下:

  byte[] bytes=BytesHelper.toByteArray(fl.getPath());
  Trace trace=new Trace(bytes);		 
  trace.getThreadList();

3.原理

TODO….

You might also like...
Comments
  • 解析文件出错  java.lang.NumberFormatException: For input string:

    解析文件出错 java.lang.NumberFormatException: For input string: "882d5af0"

    解析文件出错

    java.lang.NumberFormatException: For input string: "882d5af0" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:583) at com.panda.trace.Trace.readFileFormat(Trace.java:156) at com.panda.trace.Trace.divideBytes(Trace.java:180) at com.panda.trace.Trace.(Trace.java:49) at com.panda.ui.TraceFrame$2.actionPerformed(TraceFrame.java:188) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6533) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6298) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) at java.awt.Container.dispatchEventImpl(Container.java:2280) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

    opened by liyungui 1
Owner
null