Fix abbreviated output of poll and ppoll decoders
* poll.c (decode_poll_entering, decode_poll_exiting): Fix corner cases of abbreviated output. * tests/ppoll-v.expected: Update. * tests/ppoll.expected: Update. * tests/ppoll.test: Update.
This commit is contained in:
parent
8ef9809b63
commit
9f612ffc49
56
poll.c
56
poll.c
@ -51,7 +51,8 @@ decode_poll_entering(struct tcb *tcp)
|
||||
const unsigned long size = sizeof(fds) * nfds;
|
||||
const unsigned long start = tcp->u_arg[0];
|
||||
const unsigned long end = start + size;
|
||||
unsigned long cur, abbrev_end;
|
||||
const unsigned long max_printed =
|
||||
abbrev(tcp) ? max_strlen : (unsigned int) -1;
|
||||
|
||||
if (!verbose(tcp) || !start || !nfds ||
|
||||
size / sizeof(fds) != nfds || end < start) {
|
||||
@ -60,32 +61,31 @@ decode_poll_entering(struct tcb *tcp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (abbrev(tcp)) {
|
||||
abbrev_end = start + max_strlen * sizeof(fds);
|
||||
if (abbrev_end < start)
|
||||
abbrev_end = end;
|
||||
} else {
|
||||
abbrev_end = end;
|
||||
}
|
||||
|
||||
if (start >= abbrev_end || umove(tcp, start, &fds) < 0) {
|
||||
if (umove(tcp, start, &fds) < 0) {
|
||||
printaddr(start);
|
||||
tprintf(", %u, ", nfds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tprints("[");
|
||||
print_pollfd(tcp, &fds);
|
||||
for (cur = start + sizeof(fds); cur < end; cur += sizeof(fds)) {
|
||||
tprints(", ");
|
||||
if (cur >= abbrev_end) {
|
||||
tprints("...");
|
||||
break;
|
||||
}
|
||||
if (umove_or_printaddr(tcp, cur, &fds))
|
||||
break;
|
||||
print_pollfd(tcp, &fds);
|
||||
if (max_printed) {
|
||||
unsigned long printed = 1;
|
||||
unsigned long cur = start + sizeof(fds);
|
||||
|
||||
print_pollfd(tcp, &fds);
|
||||
for (; cur < end; ++printed, cur += sizeof(fds)) {
|
||||
tprints(", ");
|
||||
if (printed >= max_printed) {
|
||||
tprints("...");
|
||||
break;
|
||||
}
|
||||
if (umove_or_printaddr(tcp, cur, &fds))
|
||||
break;
|
||||
print_pollfd(tcp, &fds);
|
||||
|
||||
}
|
||||
} else {
|
||||
tprints("...");
|
||||
}
|
||||
tprintf("], %u, ", nfds);
|
||||
|
||||
@ -100,7 +100,9 @@ decode_poll_exiting(struct tcb *tcp, const long pts)
|
||||
const unsigned long size = sizeof(fds) * nfds;
|
||||
const unsigned long start = tcp->u_arg[0];
|
||||
const unsigned long end = start + size;
|
||||
unsigned long cur, abbrev_end;
|
||||
const unsigned long max_printed =
|
||||
abbrev(tcp) ? max_strlen : (unsigned int) -1;
|
||||
unsigned long printed, cur;
|
||||
|
||||
static char outstr[1024];
|
||||
char *outptr;
|
||||
@ -116,17 +118,10 @@ decode_poll_exiting(struct tcb *tcp, const long pts)
|
||||
if (!verbose(tcp) || !start || !nfds ||
|
||||
size / sizeof(fds) != nfds || end < start)
|
||||
return 0;
|
||||
if (abbrev(tcp)) {
|
||||
abbrev_end = start + max_strlen * sizeof(fds);
|
||||
if (abbrev_end < start)
|
||||
abbrev_end = end;
|
||||
} else {
|
||||
abbrev_end = end;
|
||||
}
|
||||
|
||||
outptr = outstr;
|
||||
|
||||
for (cur = start; cur < end; cur += sizeof(fds)) {
|
||||
for (printed = 0, cur = start; cur < end; cur += sizeof(fds)) {
|
||||
if (umove(tcp, cur, &fds) < 0) {
|
||||
if (outptr == outstr)
|
||||
*outptr++ = '[';
|
||||
@ -141,7 +136,7 @@ decode_poll_exiting(struct tcb *tcp, const long pts)
|
||||
*outptr++ = '[';
|
||||
else
|
||||
outptr = stpcpy(outptr, ", ");
|
||||
if (cur >= abbrev_end) {
|
||||
if (printed >= max_printed) {
|
||||
outptr = stpcpy(outptr, "...");
|
||||
break;
|
||||
}
|
||||
@ -160,6 +155,7 @@ decode_poll_exiting(struct tcb *tcp, const long pts)
|
||||
outptr = stpcpy(outptr, fdstr);
|
||||
outptr = stpcpy(outptr, flagstr);
|
||||
*outptr++ = '}';
|
||||
++printed;
|
||||
}
|
||||
|
||||
if (outptr != outstr)
|
||||
|
@ -1,3 +1,3 @@
|
||||
ppoll\(\[\{fd=0, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=1, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}, \{fd=3, events=POLLIN\|POLLPRI\}, \{fd=4, events=POLLOUT\}\], 4, \{42, 999999999\}, \[(USR2 CHLD|CHLD USR2)\], (4|8|16)\) += 2 \(\[\{fd=1, revents=POLLOUT(\|POLLWRNORM)?\}, \{fd=4, revents=POLLOUT\}\], left \{42, 9[0-9]{8}\}\)
|
||||
ppoll\(\[\{fd=1, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=0, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}\], 2, \{0, 999\}, ~\[HUP KILL STOP[^]]*\], (4|8|16)\) += 0 \(Timeout\)
|
||||
ppoll\(NULL, 42, NULL, NULL, (4|8|16)\) += -1 EFAULT .*
|
||||
ppoll\(\[\{fd=0, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=1, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}, \{fd=3, events=POLLIN\|POLLPRI\}, \{fd=4, events=POLLOUT\}\], 4, \{42, 999999999\}, \[(USR2 CHLD|CHLD USR2)\], (4|8|16)\) = 2 \(\[\{fd=1, revents=POLLOUT(\|POLLWRNORM)?\}, \{fd=4, revents=POLLOUT\}\], left \{42, 9[0-9]{8}\}\)
|
||||
ppoll\(\[\{fd=1, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=0, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}\], 2, \{0, 999\}, ~\[HUP KILL STOP[^]]*\], (4|8|16)\) = 0 \(Timeout\)
|
||||
ppoll\(NULL, 42, NULL, NULL, (4|8|16)\) = -1 EFAULT .*
|
||||
|
@ -1,3 +1,3 @@
|
||||
ppoll\(\[\{fd=0, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=1, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}, \.\.\.\], 4, \{42, 999999999\}, \[(USR2 CHLD|CHLD USR2)\], (4|8|16)\) += 2 \(\[\{fd=1, revents=POLLOUT(\|POLLWRNORM)?\}, \.\.\.\], left \{42, 9[0-9]{8}\}\)
|
||||
ppoll\(\[\{fd=1, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=0, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}\], 2, \{0, 999\}, ~\[HUP KILL STOP[^]]*\], (4|8|16)\) += 0 \(Timeout\)
|
||||
ppoll\(NULL, 42, NULL, NULL, (4|8|16)\) += -1 EFAULT .*
|
||||
ppoll\(\[\{fd=0, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=1, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}, \.\.\.\], 4, \{42, 999999999\}, \[(USR2 CHLD|CHLD USR2)\], (4|8|16)\) = 2 \(\[\{fd=1, revents=POLLOUT(\|POLLWRNORM)?\}, \{fd=4, revents=POLLOUT\}\], left \{42, 9[0-9]{8}\}\)
|
||||
ppoll\(\[\{fd=1, events=POLLIN\|POLLPRI\|POLLRDNORM\|POLLRDBAND\}, \{fd=0, events=POLLOUT(\|POLLWRNORM)?\|POLLWRBAND\}\], 2, \{0, 999\}, ~\[HUP KILL STOP[^]]*\], (4|8|16)\) = 0 \(Timeout\)
|
||||
ppoll\(NULL, 42, NULL, NULL, (4|8|16)\) = -1 EFAULT .*
|
||||
|
@ -5,9 +5,9 @@
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
run_prog
|
||||
run_strace -s2 -e ppoll $args
|
||||
run_strace -a30 -s2 -e ppoll $args
|
||||
match_grep
|
||||
run_strace -v -s2 -e ppoll $args
|
||||
run_strace -a30 -v -s2 -e ppoll $args
|
||||
match_grep "$LOG" "$srcdir/${ME_%.test}-v.expected"
|
||||
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user