I'm trying to run bluedroid under valgrind on Android 5.1
I compiled and installed valgrind from "external/valgrind"
I'm running valgrind 3.11.0
I have selinux disabled
I'm successfully starting valgrind with logwrapper:
setprop wrap.com.android.bluetooth "logwrapper valgrind"
And it starts, but fails very shortly with:
Zygote setregid() failed. errno: 1
Zygote setreuid() failed. errno: 1
libc pthread_create sched_setscheduler call failed: Operation not permitted
libc pthread_create sched_setscheduler call failed: Operation not permitted
bt_osi_alarm bool timer_create_internal(clockid_t, void**) unable to create timer with clock 9: Operation not permitted
bt_osi_alarm The kernel might not have support for timer_create(CLOCK_BOOTTIME_ALARM): https://lwn.net/Articles/429925/
After changing clock type from CLOCK_BOOTTIME_ALARM to CLOCK_BOOTTIME, in alarm.cc, i'm able to successfully run bluedroid with valgring on Android.
My valgrind startup script: (vg.sh)
#!/system/bin/sh
PACKAGE="com.android.bluetooth"
VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=no --show-reachable=no --track-origins=yes'
export TMPDIR=/data/data/$PACKAGE
/system/bin/valgrind $VGPARAMS $*
I boot normally, setup logwrapper with:
adb shell setprop wrap.com.android.bluetooth "logwrapper /system/xbin/vg.sh"
And just kill the bluetooth process, it then restarts under valgrind.