Make Systrace work with 4.1.2 device on Mac
Asked Answered
M

1

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).

Mohsen answered 13/2, 2014 at 7:17 Comment(1)
It looks like systrace is not enabled on your device. Some OEMs ship devices this way. Same errors as stackoverflow.com/questions/17887754 .Whalebone
C
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.

Couch answered 27/3, 2014 at 1:46 Comment(3)
/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. =)Mohsen
@Mohsen 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.Couch
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 2Tumblebug

© 2022 - 2024 — McMap. All rights reserved.