From 3ba0098d6764df4a7b2c885f0cf5263b4062c357 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Wed, 23 Jan 2019 19:04:43 -0800 Subject: crosvm: add debug labels to devices for improved SIGCHLD logs Each device (Bus, Pci, Proxy, etc), gets a debug label associated with it. When a child is spawned, the debug label for it is stored in a map with the child's pid as the key. If a SIGCHLD is handled, this map is used to print a more helpful message about exactly which child died. BUG=None TEST=run with sandboxing and a faulty child device check logs for message about child died the child should have a debug label Change-Id: I61fbbee0a8e701249533a7a3a6a1ad48840f12e5 Reviewed-on: https://chromium-review.googlesource.com/1432835 Commit-Ready: Chih-Yang Hsia Tested-by: kokoro Tested-by: Zach Reizner Reviewed-by: Daniel Verkamp --- src/linux.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/linux.rs') diff --git a/src/linux.rs b/src/linux.rs index 1dcedbe..4b684ca 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -1023,12 +1023,14 @@ fn run_control( Token::ChildSignal => { // Print all available siginfo structs, then exit the loop. while let Some(siginfo) = sigchld_fd.read().map_err(Error::SignalFd)? { + let pid = siginfo.ssi_pid; + let pid_label = match linux.pid_debug_label_map.get(&pid) { + Some(label) => format!("{} (pid {})", label, pid), + None => format!("pid {}", pid), + }; error!( "child {} died: signo {}, status {}, code {}", - siginfo.ssi_pid, - siginfo.ssi_signo, - siginfo.ssi_status, - siginfo.ssi_code + pid_label, siginfo.ssi_signo, siginfo.ssi_status, siginfo.ssi_code ); } break 'poll; -- cgit 1.4.1