From d454dac0dcc605f4eecd8175c94e9fd91a154e72 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Mon, 28 Nov 2016 22:02:52 +0300 Subject: [PATCH] signal: fix omission of field names in sigaction printers * signal.c (decode_old_sigaction, decode_new_sigaction): Add printing of the field names. * tests/sigaction.awk: Update expected output. Co-authored-by: Elvira Khabirova --- signal.c | 16 ++++++------ tests/sigaction.awk | 59 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/signal.c b/signal.c index b483ce08..9f51440b 100644 --- a/signal.c +++ b/signal.c @@ -335,19 +335,19 @@ decode_old_sigaction(struct tcb *tcp, long addr) * be manipulated by strace. In order to prevent the * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ - tprints("{"); + tprints("{sa_handler="); print_sa_handler((unsigned long) sa.__sa_handler); - tprints(", "); + tprints(", sa_mask="); #ifdef MIPS tprintsigmask_addr("", sa.sa_mask); #else tprintsigmask_val("", sa.sa_mask); #endif - tprints(", "); + tprints(", sa_flags="); printflags(sigact_flags, sa.sa_flags, "SA_???"); #if HAVE_SA_RESTORER && defined SA_RESTORER if (sa.sa_flags & SA_RESTORER) - tprintf(", %p", sa.sa_restorer); + tprintf(", sa_restorer=%p", sa.sa_restorer); #endif tprints("}"); } @@ -540,9 +540,9 @@ decode_new_sigaction(struct tcb *tcp, long addr) * be manipulated by strace. In order to prevent the * compiler from generating code to manipulate * __sa_handler we cast the function pointers to long. */ - tprints("{"); + tprints("{sa_handler="); print_sa_handler((unsigned long) sa.__sa_handler); - tprints(", "); + tprints(", sa_mask="); /* * Sigset size is in tcp->u_arg[4] (SPARC) * or in tcp->u_arg[3] (all other), @@ -551,12 +551,12 @@ decode_new_sigaction(struct tcb *tcp, long addr) * We just fetch the right size, which is NSIG / 8. */ tprintsigmask_val("", sa.sa_mask); - tprints(", "); + tprints(", sa_flags="); printflags(sigact_flags, sa.sa_flags, "SA_???"); #if HAVE_SA_RESTORER && defined SA_RESTORER if (sa.sa_flags & SA_RESTORER) - tprintf(", %p", sa.sa_restorer); + tprintf(", sa_restorer=%p", sa.sa_restorer); #endif tprints("}"); } diff --git a/tests/sigaction.awk b/tests/sigaction.awk index 5c6b6d09..9c3a9ed3 100644 --- a/tests/sigaction.awk +++ b/tests/sigaction.awk @@ -1,6 +1,7 @@ #!/bin/gawk # # Copyright (c) 2014-2015 Dmitry V. Levin +# Copyright (c) 2016 Elvira Khabirova # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -26,23 +27,44 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. BEGIN { - n1[1] = "SIG_IGN, \\[HUP INT\\], SA_RESTORER\\|SA_RESTART, 0x[0-9a-f]+" - n2[1] = "SIG_IGN, \\[HUP INT\\], SA_RESTART" + n1[1][1] = n2[1][1] = "SIG_IGN" + n1[1][2] = n2[1][2] = "\\[HUP INT\\]" + n1[1][3] = "SA_RESTORER\\|SA_RESTART" + n2[1][3] = "SA_RESTART" + n1[1][4] = ", sa_restorer=0x[0-9a-f]+" + n2[1][4] = "" - n1[2] = "0x[0-9a-f]+, \\[QUIT TERM\\], SA_RESTORER\\|SA_SIGINFO, 0x[0-9a-f]+" - n2[2] = "0x[0-9a-f]+, \\[QUIT TERM\\], SA_SIGINFO" + n1[2][1] = n2[2][1] = "0x[0-9a-f]+" + n1[2][2] = n2[2][2] = "\\[QUIT TERM\\]" + n1[2][3] = "SA_RESTORER\\|SA_SIGINFO" + n2[2][3] = "SA_SIGINFO" + n1[2][4] = ", sa_restorer=0x[0-9a-f]+" + n2[2][4] = "" - n1[3] = "SIG_DFL, \\[\\], SA_RESTORER, 0x[0-9a-f]+" - n2[3] = "SIG_DFL, \\[\\], 0" + n1[3][1] = n2[3][1] = "SIG_DFL" + n1[3][2] = n2[3][2] = "\\[\\]" + n1[3][3] = "SA_RESTORER" + n2[3][3] = "0" + n1[3][4] = ", sa_restorer=0x[0-9a-f]+" + n2[3][4] = "" - n1[4] = "SIG_DFL, ~\\[HUP( ((RT|SIGRT)[^] ]+|[3-9][0-9]|1[0-9][0-9]))*\\], SA_RESTORER, 0x[0-9a-f]+" - n2[4] = "SIG_DFL, ~\\[HUP( ((RT|SIGRT)[^] ]+|[3-9][0-9]|1[0-9][0-9]))*\\], 0" + n1[4][1] = n2[4][1] = "SIG_DFL" + n1[4][2] = n2[4][2] = "~\\[HUP( ((RT|SIGRT)[^] ]+|[3-9][0-9]|1[0-9][0-9]))*\\]" + n1[4][3] = "SA_RESTORER" + n2[4][3] = "0" + n1[4][4] = ", sa_restorer=0x[0-9a-f]+" + n2[4][4] = "" - o1[1] = o2[1] = "SIG_DFL, \\[\\], 0" + o1[1][1] = o2[1][1] = "SIG_DFL" + o1[1][2] = o2[1][2] = "\\[\\]" + o1[1][3] = o2[1][3] = "0" + o1[1][4] = o2[1][4] = "" for (i = 2; i < 5; i++) { - o1[i] = n1[i - 1] - o2[i] = n2[i - 1] + for (j = 1; j < 5; j++) { + o1[i][j] = n1[i - 1][j] + o2[i][j] = n2[i - 1][j] + } } a1 = "(0x[0-9a-f]+, )?(4|8|16)" @@ -51,9 +73,18 @@ BEGIN { for (i = 1; i < 5; i++) { r[i] = "^rt_sigaction\\(SIGUSR2, (" \ - "\\{" n1[i] "\\}, \\{" o1[i] "\\}, " a1 "|" \ - "\\{" n2[i] "\\}, \\{" o2[i] "\\}, " a2 "|" \ - "\\{" n2[i] "\\}, \\{" o2[i] "\\}, " a3 ")\\) = 0$" + "\\{sa_handler=" n1[i][1] ", sa_mask=" n1[i][2] \ + ", sa_flags=" n1[i][3] n1[i][4] "\\}, \\{sa_handler=" \ + o1[i][1] ", sa_mask=" o1[i][2] ", sa_flags=" o1[i][3] \ + o1[i][4] "\\}, " a1 "|" \ + "\\{sa_handler=" n2[i][1] ", sa_mask=" n2[i][2] \ + ", sa_flags=" n2[i][3] n2[i][4] "\\}, \\{sa_handler=" \ + o2[i][1] ", sa_mask=" o2[i][2] ", sa_flags=" o2[i][3] \ + o2[i][4] "\\}, " a2 "|" \ + "\\{sa_handler=" n2[i][1] ", sa_mask=" n2[i][2] \ + ", sa_flags=" n2[i][3] n2[i][4] "\\}, \\{sa_handler=" \ + o2[i][1] ", sa_mask=" o2[i][2] ", sa_flags=" o2[i][3] \ + o2[i][4] "\\}, " a3 ")\\) = 0$" } s[5] = "+++ exited with 0 +++" -- 2.40.0