Android
代码调试工具 traceview
和 dmtracedump 的波折演绎
✿
Android 程序调试工具
Google 为我们提供的代码调试工具的亮点:
traceview
和
dmtracedump
。有了这两个工
具,我们调试程序分析 bug 就非常得心应手了。traceview 帮助我们分析程序性能,
dmtracedump 生成函数调用图。遗憾的是,google 提供的 dmtracedump 是个失败的工具,
并不能绘图,本文会详细介绍解决方案,实现绘图。
✿生成
.trace 文件
android.os.Debug 类,其中重要的两个方法 Debug.startMethodTracing()和
Debug.stopMethodTracing()。这两个方法用来创建.trace 文件,将从
Debug.startMethodTracing()开始,到 Debug.stopMethodTracing()结束,期间所有的调用过程
保存在.trace 文件中,包括调用的函数名称和执行的时间等信息。
把下面代码分别在加在调试起始代码的位置,和终止位置。
1
Debug.startMethodTracing(“test”)
;
2
Debug.stopMethodTracing()
;
其中参数 test 是要创建的 trace 文件的名称,test.trace。默认路径是/sdcard/test.trace,也可以
自己制定/data/log/test,表示文件在/data/log/test.trace。
✿
traceview
在 SDK
中执行 :
./traceview test.trace
我们可以得到
1.程序中每个线程调用方法的启动和停止时间
找软件资料,就到一览软件文库