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
If you open your trace file with traceview you'll see that your graph is something like:
Run dmtracedump with -t 0 (as follows) and you should see all the methods.