6

We're working in extending the systrace tool to add customized information for our devices. We're specifically interested in knowing how does android support TRACE generation. What is the architecture and mechanisms that are involved in tracing events, zigote, finders, jvm starting, android starting, linux calls, hardware calls, etc.

Can anybody please help us with some links or manuals about this information ?

We will specially appreciate technical documentation for adb atrace tool and any other related module.

Information of trace file format is also of our interest, where can we find this trace files and how can we extend them to add more information ?

Detail :

In systrace.py line 81 we find:

atrace_args = ['adb', 'shell', 'atrace', '-z']

We know that this generates some tracing files in /sys/kernel/debug/tracing/

Our main interest is to know where, when and how are these files generated ?

Thank you very much !

Rodmar Conde
  • 956
  • 1
  • 12
  • 24

3 Answers3

5

I have done research in systrace, as you mentioned it uses the atrace. Atrace internally uses ftrace. So to understand kernel events read about ftrace. So understand Android framework tags, they manually added tags in the Android framework, where they felt it will be useful to trace.

You can refer these to get better clarity

http://androidxref.com/4.1.1/xref/system/extras/atrace/atrace.c

http://androidxref.com/4.1.1/xref/frameworks/native/libs/utils/Trace.cpp

Krishna
  • 66
  • 2
  • 2
    http://androidxref.com/4.1.1/xref/frameworks/native/include/utils/Trace.h http://androidxref.com/4.1.1/xref/frameworks/base/core/java/android/os/Trace.java – Krishna Nov 28 '12 at 06:33
  • 1
    http://www.kernel.org/doc/Documentation/trace/ftrace.txt https://www.osadl.org/fileadmin/dam/presentations/RTLWS11/rostedt-ftrace.pdf – Krishna Nov 28 '12 at 06:34
1

Grepcode is your friend. I think a good starting point is the debug class : http://www.grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/os/Debug.java?av=f

There is an interesting part that describes a list of debug properties :

1085            final String TAG = "DebugProperties";
1086            final String[] files = { "/system/debug.prop", "/debug.prop", "/data/debug.prop" };

Each property must be declared with a specific annotation :

android.os.Debug.DebugProperty

It seems to be available only to plateform developpers though.

Gomoku7
  • 1,362
  • 13
  • 31
  • Thanks ! Apparently that information is good for debugging but we're interested in making tracing. – Rodmar Conde Nov 22 '12 at 12:31
  • 1
    Ah, I was expecting this anwser. It's a bit tricky to understand it by just looking at the code it like that, but it seems that every property that is annotated "DebugProperty" is automatically "traced". And that is the elegancy of this trace mecanism. Look at the header : "Debug can create log files that give details about an application, such as a call stack and start/stop times for any running methods. See Traceview: A Graphical Log Viewer for information about reading trace files." – Gomoku7 Nov 23 '12 at 11:20
  • Now I understand, after many months of work. From Linux developers: "**Definition** : Tracing is similar to logging: it consists in recording events that happen in a system. However, it usually records much _lowerlevel_ events that occur much _more frequently_." – Rodmar Conde Apr 30 '13 at 07:39
1

I am working on similar task and use this. It helps me browse and understand the Java/c++/kernel level api and how it is implemented.

http://www.srcmap.org/p/1/857623b50f7e/Android_Jellybean_systrace__atrace__ftrace_code_study.html

Y_Yen
  • 189
  • 1
  • 6
  • 2
    You should summarize the contents of your links. This ensures that your answer will still be useful if the linked content changes or becomes unreachable. – skrrgwasme Sep 24 '14 at 17:04
  • It looks cool, however that didn't exist when I posted the question so I had to do it by hand. ;-) Regards, – Rodmar Conde Sep 24 '14 at 17:08