From 7ff121c0a5ac6e30cf8ccc2be2b6976a9ec360f4 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Mon, 14 Nov 2022 18:13:23 +0900 Subject: [PATCH] Print backtrace of microdroid_manager to kmsg To track any possible bugs on microdroid_manager. Bug: 258760809 Test: intentionally crash microdroid_manager and see console Change-Id: I2359e59270a1c6c5efab2a6cb1e0727bb3c5743e --- microdroid_manager/microdroid_manager.rc | 3 +++ microdroid_manager/src/main.rs | 6 ++++++ 2 files changed, 9 insertions(+) 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") {