crash-reporter: Include powerd logs with crashes.

Attach relevant power manager logs to crash reports for
powerd, powerd_setuid_helper, and power_supply_info.

BUG=chromium:405727
TEST=induced crashes in powerd, powerd_setuid_helper, and
     power_supply_info, then forced crash reporting with
     "FORCE_OFFICIAL=1 crash_sender" and checked that the
     following crash reports had the expected data attached
     in the "Files" section:
     2f710954e30472b1 (powerd)
     e7d985b7dbd9d158 (powerd_setuid_helper)
     2213b0413fc9e408 (power_supply_info)

Change-Id: Icddb7d0b99eb19b95c656f8c06d8766733eaae28
Reviewed-on: https://chromium-review.googlesource.com/216020
Tested-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
diff --git a/crash_reporter/crash_reporter_logs.conf b/crash_reporter/crash_reporter_logs.conf
index 9c1a531..e4ad207 100644
--- a/crash_reporter/crash_reporter_logs.conf
+++ b/crash_reporter/crash_reporter_logs.conf
@@ -41,6 +41,19 @@
 crash_reporter-udev-collection---TouchNoise:cat /var/log/touch_noise.log
 # Periodically collect touch event log for debugging (crosbug.com/p/17244)
 crash_reporter-udev-collection---TouchEvent:cat /var/log/touch_event.log
+
+# Dump the last 50 lines of the last two powerd log files -- if the job has
+# already restarted, we want to see the end of the previous instance's logs.
+powerd:for f in $(ls -1tr /var/log/power_manager/powerd.[0-9]* | tail -2); do echo "===$(basename $f) (tail)==="; tail -50 $f; echo EOF; done
+# If power_supply_info aborts (due to e.g. a bad battery), its failure message
+# could end up in various places depending on which process was running it.
+# Attach the end of powerd's log since it might've also logged the underlying
+# problem.
+power_supply_info:echo "===powerd.LATEST (tail)==="; tail -50 /var/log/power_manager/powerd.LATEST; echo EOF
+# powerd_setuid_helper gets run by powerd, so its stdout/stderr will be mixed in
+# with powerd's stdout/stderr.
+powerd_setuid_helper:echo "===powerd.OUT (tail)==="; tail -50 /var/log/powerd.out; echo EOF
+
 # The following rules are only for testing purposes.
 crash_log_test:echo hello world
 crash_log_recursion_test:sleep 1 && /usr/local/autotest/tests/crash_log_recursion_test