在User模式下开启ftrace、adb root和traceview的方式

1.配置kernel,在config文件中删除下面的设定;
# CONFIG_PERF_EVENTS is not set
# CONFIG_HW_PERF_EVENTS is not set

# CONFIG_PROFILING is not set
# CONFIG_EVENT_TRACING is not set
# CONFIG_EVENT_POWER_TRACING_DEPRECATED is not set
# CONFIG_CONTEXT_SWITCH_TRACER is not set
# CONFIG_GENERIC_TRACER is not set
# CONFIG_TRACING is not set
# CONFIG_FTRACE is not set
# CONFIG_TRACEPOINTS is not set

# CONFIG_PERF_EVENTS is not set
# CONFIG_HW_PERF_EVENTS is not set

2. 挂载debugfs文件,可以有两种方式:
a、在system/core/init/init.c挂载debugfs
mount("debugfs", "/sys/kernel/debug", "debugfs", 0, NULL);
b、在init.rc里面挂载debugfs
mount("debugfs", "/sys/kernel/debug", "debugfs", 0, NULL)

3、修改system/core/adb/adb.c:
在should_drop_privileges()函数中,修改为如下:
#ifndef ALLOW_ADBD_ROOT
return 0; // 由1变成0,以便User有adb root权限

4. user load开启traceview权限:
在build/core/main.mk 中设置,搜索"ro.debuggable",在出现第二处,将ro.debuggable=0改ro.debuggable=1。

编译成User模式的image,烧写手机,在Settings->About Phone->Build number,连续点击7次后即可打开开发者选项,可以勾选相应的systrace选项,抓取systrace文件。

你可能感兴趣的:(在User模式下开启ftrace、adb root和traceview的方式)