Android调试跟踪不包含特定于应用程序的方法调用 [英] Android debug traces do not contain application specific method calls

查看:132
本文介绍了Android调试跟踪不包含特定于应用程序的方法调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据以下文档



这是应该如何工作的,即只是显示android调用而不是应用程序方法调用,还是我遗漏了一些东西?



请注意,我对检索方法执行的排他和包含时间最为感兴趣。

解决方案

可能是因为(默认情况下)traceview的-t选项设置为20%。来自 AndroidStudio dmtracedump


-t:在图中包括子节点的最小阈值(子项包含时间与父项包含时间的百分比)。如果不使用
,则默认阈值为20%。


如果使用traceview打开跟踪文件,会看到您的图形类似于:




  • 图形的第一个节点是第一个方法调用

  • 图形的第二个是traceview中第一个调用的第一个孩子

  • 图形的第二个是第一个方法调用中的第一个孩子

  • 依此类推...



使用-t 0(如下所示)运行dmtracedump,您应该查看所有方法。

  dmtracedump -t 0 debugtest.trace -g tree.png 


I am trying to generate trace files for applications using the Debug.startMethodTracing (on the activity onCreate) and Debug.stopMethodTracing (on the activity onDestroy) according to the following documentation http://developer.android.com/tools/debugging/debugging-tracing.html#creatingtracefiles.

I run the application on a physical device and it successfully creates the trace file. Later I run dmtracedump on them to generate a call-stack diagram, but it does not contain any of my application method calls.

To test this, I created a simple Android application, added debbuggable to the manifest:

 <application
    ... 
    android:debuggable="true">

Created two test classes A and B. Class A has two methods b() and c():

public class A {

private int _i;

public A(){_i=0;}

public void b(){c();}
public void c(){for(int k=0;k<20;k++)_i++;}}

Class B has a single method c():

public class B {

public void c(){
    (new A()).b();
    A d = new A();
    d.c();
}}

Finally in the main activity on the onCreate and onDestroy methods I started the tracing:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Debug.startMethodTracing("debugtest");

    A a;
    for (int i = 0; i < 20; i++) {
        a = new A();
        a.b();
        a.c();
    }

    (new B()).c();
}

@Override
public void onDestroy() {
    super.onDestroy();
    Debug.stopMethodTracing();
}

I was hoping to get at least A.b() and A.c() method calls in the call stack diagram but after running:

adb pull sdcard/debugtest.trace . ; dmtracedump debugtest.trace -g tree.png

The generated call graph is as follows:

Is this how it is supposed to work, i.e. just show android calls and not application method calls, or am I missing something?

Please note that i am mostly interested in retrieving the exclusive and inclusive times of method execution.

解决方案

It might be because (by default) the -t option of traceview is set to 20%. From AndroidStudio dmtracedump

-t : Minimum threshold for including child nodes in the graph (child's inclusive time as a percentage of parent inclusive time). If this option is not used, the default threshold is 20%.

If you open your trace file with traceview you'll see that your graph is something like:

  • the first node of your graph is the first method call
  • the second of your graph is the first child of the first call in traceview
  • the third of your graph is the first child of the child of the first method call
  • and so on...

Run dmtracedump with -t 0 (as follows) and you should see all the methods.

dmtracedump -t 0 debugtest.trace -g tree.png

这篇关于Android调试跟踪不包含特定于应用程序的方法调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆