Skip to contentSkip to conversation

linux-user: report signals being taken in strace output

PATCH New Peter Maydell 1 participant 1 message Jul 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: report signals being taken in strace output

Native strace reports when the process being traced takes a signal:
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---

Report something similar when QEMU is doing its internal strace of the guest process and is about to deliver it a signal.

---
A new feature, really, but handy for debugging...

 linux-user/qemu.h   |  10 +++++
 linux-user/signal.c |   4 ++
 linux-user/strace.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+)
linux-user/qemu.h +10 -0
index cdf23a7..18cb200 100644
@@ -362,6 +362,16 @@ void print_syscall(int num,
                    abi_long arg1, abi_long arg2, abi_long arg3,
                    abi_long arg4, abi_long arg5, abi_long arg6);
 void print_syscall_ret(int num, abi_long arg1);
+/**
+ * print_taken_signal:
+ * @target_signum: target signal being taken
+ * @tinfo: target_siginfo_t which will be passed to the guest for the signal
+ *
+ * Print strace output indicating that this signal is being taken by the guest,
+ * in a format similar to:
+ * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
+ */
+void print_taken_signal(int target_signum, const target_siginfo_t *tinfo);
 extern int do_strace;
 
 /* signal.c */
linux-user/signal.c +4 -0
index 9a4d894..85976da 100644
@@ -5849,6 +5849,10 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,
         handler = sa->_sa_handler;
     }
 
+    if (do_strace) {
+        print_taken_signal(sig, &k->info);
+    }
+
     if (handler == TARGET_SIG_DFL) {
         /* default handler : ignore some signal. The other are job control or fatal */
         if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) {
linux-user/strace.c +106 -0

115 lines not on this page · raw message

Signature · 1 line
1.9.1