3

I have been struggling a long time to just use systrace.

My device runs 4.1.2 (LT28i) and I'm on a Mac. I am bouncing SO questions with similar issues none of whom have a clear answer.

I want let's say to trace views and graphics

Method 1, eclipse:

enter image description here

error:

enter image description here

method 2, terminal:

$ python systrace.py --cpu-load --time=10 -o mytracefile.html
error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/sched/sched_switch/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/power/cpu_frequency/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/power/cpu_idle/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/cpufreq_interactive/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/buffer_size_kb: No such file or directory (2)
error opening /sys/kernel/debug/tracing/trace_clock: No such file or directory (2)
error opening /sys/kernel/debug/tracing/tracing_on: No such file or directory (2)
error: unable to start trace
error opening /sys/kernel/debug/tracing/tracing_on: No such file or directory (2)
error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/sched/sched_switch/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/events/power/cpu_frequency/enable: No such file or directory (2)
error opening /sys/kernel/debug/tracing/trace_clock: No such file or directory (2)
unable to start tracing
error opening /sys/kernel/debug/tracing/buffer_size_kb: No such file or directory (2)
An error occured while capturing the trace.  Output file was not written.
dionyses-lorentzoss-imac:systrace dionysis_lorentzos$ mount -o rw,remount -t debugfs none /sys/kernel/debug
mount: realpath /sys: No such file or directory

I also try the command below and get an error but according to the google docs root is needed only in some of the tracing.

$ adb root
adbd cannot run as root in production builds

How can I generate a simple systrace for views or graphics?

Debugging in phone is ofc enabled and also the "enable tracing" is (either by command line or via the phone itself).

Diolor
  • 13,181
  • 30
  • 111
  • 179
  • It looks like systrace is not enabled on your device. Some OEMs ship devices this way. Same errors as http://stackoverflow.com/questions/17887754/ . – fadden Feb 13 '14 at 15:47

1 Answers1

8

It looks like your cellphone is running a boot(kernel) image that does not support systrace.

"error opening /sys/kernel/debug/tracing/options/overwrite: No such file or directory (2)"

This error message means adb daemon (the adb module running on device side) could not find /sys/kernel/debug/tracing/options/overwrite on your device's file system. systrace works over adb and communicates with kernel though sysfs nodes under /sys/kernel/debug/tracing. If these nodes are not exposed on you phone for whatever reason, systrace just will not work.

So you should first get a shell on your device using:

adb shell

Then browse to confirm if /sys exists at all and if /sys/kernel/debug/tracing exists.

If they are there which is extremely unlikely, you have to debug systrace.py to figure out how come systrace think the nodes were not there. Otherwise, you need to flash a different boot image which has systrace support, because sysfs is controlled by kernel(mostly by configurations at compile time) and init.rc , both of which are part of boot image.

Flashing a different boot image might involve unlocking/rooting the device. You probably have to go to fan sites like xdadeveloper for information and image. Another option is to download the source of kernel for your device, compile kernel and make the boot image yourself. Linux is under GPL thus manufacturer of your device is obligated to release the source code of the specialized kernel they use.

xiay
  • 855
  • 8
  • 19
  • /sys/kernel/debug exists: `shell@android:/sys/kernel/debug $` What if I created a tracing folder inside it? But I guess there would be many missing files inside it as well. =) – Diolor Mar 27 '14 at 16:29
  • @Diolor It will not help if you create a tracing folder inside. Sysfs is a virtual file system or rather abstract file system to be distinguished from file systems used by virtual machine. "Files" inside sysfs are not regular files but rather linux kernel interface nodes presented in the form of a file. Userspace communicates with kernel by doing file operations like read/write/ioctl on these nodes. Hence sysfs nodes are useful only if it is created and backed by kernel. Replacing your boot image with one that has systrace enabled is probably your only choice. – xiay Mar 27 '14 at 20:36
  • Nice explanation. However I have all directories, as well as overwrite file, i can see it content from shell but can't generate html report file. This happens on Android M Preview 2 – Ewoks Jul 22 '15 at 16:55