diff --git a/microdroid_manager/microdroid_manager.rc b/microdroid_manager/microdroid_manager.rc index cfa70bda..c41ee38b 100644 --- a/microdroid_manager/microdroid_manager.rc +++ b/microdroid_manager/microdroid_manager.rc @@ -1,6 +1,9 @@ service microdroid_manager /system/bin/microdroid_manager disabled + # print android log to kmsg file /dev/kmsg w + # redirect stdout/stderr to kmsg_debug + stdio_to_kmsg setenv RUST_LOG info # TODO(jooyung) remove this when microdroid_manager becomes a daemon oneshot diff --git a/microdroid_manager/src/main.rs b/microdroid_manager/src/main.rs index 4b4f996d..51cecbd4 100644 --- a/microdroid_manager/src/main.rs +++ b/microdroid_manager/src/main.rs @@ -47,6 +47,7 @@ use rustutils::system_properties; use rustutils::system_properties::PropertyWatcher; use std::borrow::Cow::{Borrowed, Owned}; use std::convert::TryInto; +use std::env; use std::fs::{self, create_dir, File, OpenOptions}; use std::io::Write; use std::os::unix::io::{FromRawFd, IntoRawFd}; @@ -152,6 +153,11 @@ fn get_vms_rpc_binder() -> Result> { } fn main() -> Result<()> { + // If debuggable, print full backtrace to console log with stdio_to_kmsg + if system_properties::read_bool(APP_DEBUGGABLE_PROP, true)? { + env::set_var("RUST_BACKTRACE", "full"); + } + scopeguard::defer! { info!("Shutting down..."); if let Err(e) = system_properties::write("sys.powerctl", "shutdown") {