summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2019-01-28 14:05:23 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-07 03:02:13 -0800
commitb3fa5c95af68c66835a5c5670552eea84ad346ce (patch)
tree136472ca3ae046c6816c2009d3b8f1ebf412988a /src/main.rs
parentbae43dd4c98182736ea601b313e03620a72ccf83 (diff)
downloadcrosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar.gz
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar.bz2
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar.lz
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar.xz
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.tar.zst
crosvm-b3fa5c95af68c66835a5c5670552eea84ad346ce.zip
main: add panic hook that redirects to syslog
The default panic hook prints panic information and a backtrace to
stderr, where it gets dropped into /dev/null in the typical crostini
context.

This change adds a panic hook that will call the default panic hook
with stderr redirected to a pipe, which will then get forwarded to
syslog.

The new hook also forces an abort at the end to ensure the crash
reporter sees the panicked crosvm process, which will generate a
minidump for later debugging.

TEST=manually add panic!() observe /var/log/messages
BUG=None

Change-Id: I4e76afe811943e55cec91761447e03b949a674a4
Reviewed-on: https://chromium-review.googlesource.com/1440881
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 8a4fce0..16dcf10 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,6 +39,7 @@ extern crate vm_control;
 
 pub mod argument;
 pub mod linux;
+pub mod panic_hook;
 #[cfg(feature = "plugin")]
 pub mod plugin;
 
@@ -925,6 +926,8 @@ fn crosvm_main() -> std::result::Result<(), ()> {
         return Err(());
     }
 
+    panic_hook::set_panic_hook();
+
     let mut args = std::env::args();
     if args.next().is_none() {
         error!("expected executable name");