| # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Chromium OS debug daemon" |
| author "chromium-os-dev@chromium.org" |
| |
| start on started ui |
| stop on stopping ui or starting halt or starting reboot |
| respawn |
| |
| pre-start script |
| TRACING_FILES="buffer_size_kb set_event trace trace_clock \ |
| trace_marker tracing_on" |
| # Extra tracing files, required by Android in dev mode |
| DEV_TRACING_FILES="options/overwrite options/print-tgid \ |
| events/cpufreq_interactive/enable \ |
| events/power/cpu_frequency/enable \ |
| events/power/cpu_idle/enable \ |
| events/power/clock_set_rate/enable \ |
| events/sched/sched_switch/enable \ |
| events/sched/sched_wakeup/enable" |
| TRACING=/sys/kernel/debug/tracing |
| # NB: check for tracing dir in case the kernel config changes |
| if [ -d "${TRACING}" ]; then |
| # Make sure all users can access tracing directory. Adding "/." is necessary |
| # to trigger kernel's automount (otherwise, we would change permission on |
| # the mount point). |
| chmod a+rx ${TRACING}/. |
| |
| # enable debugfs-access write access for systrace helper |
| for file in $TRACING_FILES; do |
| chgrp debugfs-access ${TRACING}/${file} && chmod g+w ${TRACING}/${file} |
| done |
| |
| if [ "$(crossystem cros_debug)" = "1" ]; then |
| for file in $DEV_TRACING_FILES; do |
| chgrp debugfs-access ${TRACING}/${file} && |
| chmod g+w ${TRACING}/${file} |
| done |
| |
| # All users can add tracing markers (required by Android) |
| chmod a+w ${TRACING}/trace_marker |
| fi |
| fi |
| # NB: only on exynos5 |
| MALI_HWC_ENABLE=/sys/class/misc/mali0/device/hwc_enable |
| if [ -f "${MALI_HWC_ENABLE}" ]; then |
| chgrp debugd ${MALI_HWC_ENABLE} && chmod g+w ${MALI_HWC_ENABLE} |
| fi |
| # NB: copy logs of stateful (re)creation / powerwash |
| cp -aP --remove-destination \ |
| /mnt/stateful_partition/unencrypted/clobber.log \ |
| /mnt/stateful_partition/unencrypted/clobber-state.log \ |
| /mnt/stateful_partition/unencrypted/preserve/powerwash_count \ |
| /var/log/ || true |
| end script |
| |
| exec /sbin/debugd |
| |