summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2022-08-03 15:28:52 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2022-08-09 10:34:31 +0200
commit5cbd8e4cd5aef5476d6fb06ac68b4917bbfcb055 (patch)
tree6f506621c32144dbce9ff24bf0aeae048b0a329b
parent6e4a0fb4460090491976d86b4ea1f3fab4632d9a (diff)
downloadstrace-5cbd8e4cd5aef5476d6fb06ac68b4917bbfcb055.tar.gz
printsiginfo: print si_fd for SIGIO signals
* src/printsiginfo.c (print_si_code, print_si_info): Use SIGIO instead of the SIGPOLL synonym in switch cases as that is what strace prints out. (print_si_info) <case SIGIO>: Print si_fd field. * tests/.gitignore: Add ptrace-y, ptrace-y-Xabbrev, ptrace-y-Xraw, and ptrace-y-Xverbose. * tests/pure_executables.list: Likewise. * tests/gen_tests.in (ptrace-y, ptrace-y-Xabbrev, ptrace-y-Xraw, ptrace-y-Xverbose): New tests. * tests/ptrace-y.c: New file. * tests/ptrace-y-Xabbrev.c: Likewise. * tests/ptrace-y-Xraw.c: Likewise. * tests/ptrace-y-Xverbose.c: Likewise. * tests/ptrace.c: Include <fcntl.h>. (NULL_FD, NULL_STR, NULL_FD_STR): New macros. (null_path): New constant variable. (main): Open null_path at NULL_FD fd, update expected SIGIO check output.
-rw-r--r--src/printsiginfo.c6
-rw-r--r--tests/.gitignore4
-rw-r--r--tests/gen_tests.in4
-rw-r--r--tests/ptrace-y-Xabbrev.c2
-rw-r--r--tests/ptrace-y-Xraw.c2
-rw-r--r--tests/ptrace-y-Xverbose.c2
-rw-r--r--tests/ptrace-y.c2
-rw-r--r--tests/ptrace.c28
-rwxr-xr-xtests/pure_executables.list4
9 files changed, 49 insertions, 5 deletions
diff --git a/src/printsiginfo.c b/src/printsiginfo.c
index 2cbe669f9..e912fcfd3 100644
--- a/src/printsiginfo.c
+++ b/src/printsiginfo.c
@@ -90,7 +90,7 @@ print_si_code(const unsigned int si_code, const int si_signo)
case SIGCHLD:
code = xlookup(sigchld_codes, si_code);
break;
- case SIGPOLL:
+ case SIGIO: /* SIGPOLL */
code = xlookup(sigpoll_codes, si_code);
break;
case SIGPROF:
@@ -239,11 +239,13 @@ print_si_info(struct tcb *tcp, const siginfo_t *sip)
}
#endif /* ALPHA || HAVE_SIGINFO_T_SI_PERF_DATA */
break;
- case SIGPOLL:
+ case SIGIO: /* SIGPOLL */
switch (sip->si_code) {
case POLL_IN: case POLL_OUT: case POLL_MSG:
tprint_struct_next();
PRINT_FIELD_D(*sip, si_band);
+ tprint_struct_next();
+ PRINT_FIELD_FD(*sip, si_fd, tcp);
break;
}
break;
diff --git a/tests/.gitignore b/tests/.gitignore
index e80d504f1..5659f6056 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -780,6 +780,10 @@ ptrace
ptrace-Xabbrev
ptrace-Xraw
ptrace-Xverbose
+ptrace-y
+ptrace-y-Xabbrev
+ptrace-y-Xraw
+ptrace-y-Xverbose
ptrace_syscall_info
ptrace_syscall_info-Xabbrev
ptrace_syscall_info-Xraw
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index e0ff9b139..03a217ad7 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -777,6 +777,10 @@ ptrace -a23 -s64 -e signal=none
ptrace-Xabbrev -a23 -s64 -e signal=none -e trace=ptrace -Xabbrev
ptrace-Xraw -a10 -s64 -e signal=none -e trace=ptrace -Xraw
ptrace-Xverbose -a23 -s64 -e signal=none -e trace=ptrace -Xverbose
+ptrace-y -a23 -s64 -y -e signal=none -e trace=ptrace
+ptrace-y-Xabbrev -a23 -s64 -y -e signal=none -e trace=ptrace -Xabbrev
+ptrace-y-Xraw -a10 -s64 -y -e signal=none -e trace=ptrace -Xraw
+ptrace-y-Xverbose -a23 -s64 -y -e signal=none -e trace=ptrace -Xverbose
ptrace_syscall_info -a35 -e signal=none -e trace=ptrace
ptrace_syscall_info-Xabbrev -a35 -e signal=none -e trace=ptrace -Xabbrev
ptrace_syscall_info-Xraw -a26 -e signal=none -e trace=ptrace -Xraw
diff --git a/tests/ptrace-y-Xabbrev.c b/tests/ptrace-y-Xabbrev.c
new file mode 100644
index 000000000..ee8384074
--- /dev/null
+++ b/tests/ptrace-y-Xabbrev.c
@@ -0,0 +1,2 @@
+#define XLAT_ABBREV 1
+#include "ptrace-y.c"
diff --git a/tests/ptrace-y-Xraw.c b/tests/ptrace-y-Xraw.c
new file mode 100644
index 000000000..0c85f6e69
--- /dev/null
+++ b/tests/ptrace-y-Xraw.c
@@ -0,0 +1,2 @@
+#define XLAT_RAW 1
+#include "ptrace-y.c"
diff --git a/tests/ptrace-y-Xverbose.c b/tests/ptrace-y-Xverbose.c
new file mode 100644
index 000000000..6b05b8e22
--- /dev/null
+++ b/tests/ptrace-y-Xverbose.c
@@ -0,0 +1,2 @@
+#define XLAT_VERBOSE 1
+#include "ptrace-y.c"
diff --git a/tests/ptrace-y.c b/tests/ptrace-y.c
new file mode 100644
index 000000000..ce23e101b
--- /dev/null
+++ b/tests/ptrace-y.c
@@ -0,0 +1,2 @@
+#define NULL_FD_STR "<" NULL_STR ">"
+#include "ptrace.c"
diff --git a/tests/ptrace.c b/tests/ptrace.c
index 5164525b5..a3d58fe58 100644
--- a/tests/ptrace.c
+++ b/tests/ptrace.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include "ptrace.h"
#include <inttypes.h>
+#include <fcntl.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
@@ -33,6 +34,15 @@
#undef XLAT_MACROS_ONLY
#include "xlat/audit_arch.h"
+#define NULL_FD 23
+#define NULL_STR "/dev/null"
+
+#ifndef NULL_FD_STR
+# define NULL_FD_STR ""
+#endif
+
+static const char null_path[] = "/dev/null";
+
#if SIZEOF_LONG > 4
# define UP64BIT(a_) a_
#else
@@ -1684,6 +1694,15 @@ main(void)
(unsigned long) 0xdeadcafefffff00dULL;
const int pid = getpid();
+ int null_fd = open(null_path, O_RDONLY);
+ if (null_fd < 0)
+ perror_msg_and_fail("open(\"%s\")", null_path);
+ if (null_fd != NULL_FD) {
+ if (dup2(null_fd, NULL_FD) < 0)
+ perror_msg_and_fail("dup2(%d, NULL_FD)", null_fd);
+ close(null_fd);
+ }
+
TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, filter_off);
const unsigned int sigset_size = get_sigset_size();
@@ -1782,18 +1801,21 @@ main(void)
XLAT_ARGS(PTRACE_GETEVENTMSG),
pid, bad_request, bad_data, errstr);
+ /* SIGIO */
memset(sip, -1, sizeof(*sip));
sip->si_signo = SIGIO;
sip->si_code = 1;
sip->si_errno = ENOENT;
sip->si_band = -2;
+ sip->si_fd = NULL_FD;
do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
printf("ptrace(" XLAT_FMT ", %d, %#lx, {si_signo=" XLAT_FMT_U
- ", si_code=" XLAT_FMT ", si_errno=" XLAT_FMT_U ", si_band=-2}"
- ") = %s\n",
+ ", si_code=" XLAT_FMT ", si_errno=" XLAT_FMT_U ", si_band=-2"
+ ", si_fd=%d%s}) = %s\n",
XLAT_ARGS(PTRACE_SETSIGINFO), pid, bad_request, XLAT_ARGS(SIGIO),
- XLAT_ARGS(POLL_IN), XLAT_ARGS(ENOENT), errstr);
+ XLAT_ARGS(POLL_IN), XLAT_ARGS(ENOENT), NULL_FD, NULL_FD_STR,
+ errstr);
/* SIGTRAP */
struct valstraux trap_codes[] = {
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 511ea336b..56acf3856 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -557,6 +557,10 @@ ptrace
ptrace-Xabbrev
ptrace-Xraw
ptrace-Xverbose
+ptrace-y
+ptrace-y-Xabbrev
+ptrace-y-Xraw
+ptrace-y-Xverbose
ptrace_syscall_info
ptrace_syscall_info-Xabbrev
ptrace_syscall_info-Xraw