1# Copyright (C) 2012 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# This file is parsed by chromeos::KeyValueStore. It has the format:
16#
17# <basename>=<shell command>\n
18#
19# Commands may be split across multiple lines using trailing backslashes.
20#
21# When an executable named <basename> crashes, the corresponding command is
22# executed and its standard output and standard error are attached to the crash
23# report.
24#
25# Use caution in modifying this file. Only run common Unix commands here, as
26# these commands will be run when a crash has recently occurred and we should
27# avoid running anything that might cause another crash. Similarly, these
28# commands block notification of the crash to parent processes, so commands
29# should execute quickly.
30
31update_engine=cat $(ls -1tr /var/log/update_engine | tail -5 | \
32  sed s.^./var/log/update_engine/.) | tail -c 50000
33
34# The cros_installer output is logged into the update engine log file,
35# so it is handled in the same way as update_engine.
36cros_installer=cat $(ls -1tr /var/log/update_engine | tail -5 | \
37  sed s.^./var/log/update_engine/.) | tail -c 50000
38
39# Dump the last 20 lines of the last two files in Chrome's system and user log
40# directories, along with the last 20 messages from the session manager.
41chrome=\
42  for f in $(ls -1rt /var/log/chrome/chrome_[0-9]* | tail -2) \
43    $(ls -1rt /home/chronos/u-*/log/chrome_[0-9]* 2>/dev/null | tail -2); do \
44    echo "===$f (tail)==="; \
45    tail -20 $f; \
46    echo EOF; \
47    echo; \
48  done; \
49  echo "===session_manager (tail)==="; \
50  awk '$3 ~ "^session_manager\[" { print }' /var/log/messages | tail -20; \
51  echo EOF
52
53# The following rule is used for generating additional diagnostics when
54# collection of user crashes fails.  This output should not be too large
55# as it is stored in memory.  The output format specified for 'ps' is the
56# same as with the "u" ("user-oriented") option, except it doesn't show
57# the commands' arguments (i.e. "comm" instead of "command").
58crash_reporter-user-collection=\
59  echo "===ps output==="; \
60  ps axw -o user,pid,%cpu,%mem,vsz,rss,tname,stat,start_time,bsdtime,comm | \
61    tail -c 25000; \
62  echo "===meminfo==="; \
63  cat /proc/meminfo
64
65# This rule is similar to the crash_reporter-user-collection rule, except it is
66# run for kernel errors reported through udev events.
67crash_reporter-udev-collection-change-card0-drm=\
68  for dri in /sys/kernel/debug/dri/*; do \
69    echo "===$dri/i915_error_state==="; \
70    cat $dri/i915_error_state; \
71  done
72
73# When trackpad driver cyapa detects some abnormal behavior, we collect
74# additional logs from kernel messages.
75crash_reporter-udev-collection-change--i2c-cyapa=\
76  /usr/sbin/kernel_log_collector.sh cyapa 30
77# When trackpad/touchscreen driver atmel_mxt_ts detects some abnormal behavior,
78# we collect additional logs from kernel messages.
79crash_reporter-udev-collection-change--i2c-atmel_mxt_ts=\
80  /usr/sbin/kernel_log_collector.sh atmel 30
81# When touch device noise are detected, we collect relevant logs.
82# (crosbug.com/p/16788)
83crash_reporter-udev-collection---TouchNoise=cat /var/log/touch_noise.log
84# Periodically collect touch event log for debugging (crosbug.com/p/17244)
85crash_reporter-udev-collection---TouchEvent=cat /var/log/touch_event.log
86
87# Collect the last 50 lines of /var/log/messages and /var/log/net.log for
88# intel wifi driver (iwlwifi) for debugging purpose.
89crash_reporter-udev-collection-devcoredump-iwlwifi=\
90  echo "===/var/log/messages==="; \
91  tail -n 50 /var/log/messages; \
92  echo "===/var/log/net.log==="; \
93  tail -n 50 /var/log/net.log; \
94  echo EOF
95
96# Dump the last 50 lines of the last two powerd log files -- if the job has
97# already restarted, we want to see the end of the previous instance's logs.
98powerd=\
99  for f in $(ls -1tr /var/log/power_manager/powerd.[0-9]* | tail -2); do \
100    echo "===$(basename $f) (tail)==="; \
101    tail -50 $f; \
102    echo EOF; \
103  done
104# If power_supply_info aborts (due to e.g. a bad battery), its failure message
105# could end up in various places depending on which process was running it.
106# Attach the end of powerd's log since it might've also logged the underlying
107# problem.
108power_supply_info=\
109  echo "===powerd.LATEST (tail)==="; \
110  tail -50 /var/log/power_manager/powerd.LATEST; \
111  echo EOF
112# powerd_setuid_helper gets run by powerd, so its stdout/stderr will be mixed in
113# with powerd's stdout/stderr.
114powerd_setuid_helper=\
115  echo "===powerd.OUT (tail)==="; \
116  tail -50 /var/log/powerd.out; \
117  echo EOF
118
119# The following rules are only for testing purposes.
120crash_log_test=echo hello world
121crash_log_recursion_test=sleep 1 && \
122  /usr/local/autotest/tests/crash_log_recursion_test
123