git: b983d4f63cb5 - stable/14 - kdump: decode pollfd struct arrays coming from poll(2)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Mar 2024 15:53:20 UTC
The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=b983d4f63cb5f8bd3955c092b4d166c4d0bd972d commit b983d4f63cb5f8bd3955c092b4d166c4d0bd972d Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2024-03-05 04:14:06 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2024-03-18 15:52:58 +0000 kdump: decode pollfd struct arrays coming from poll(2) We'll handle these just as we do kevents, one per line with subsequent lines indented sufficiently to distinguish them from the upcoming return value. Sample, with indentation stripped and revents changed to '...' in the first one to keep the line length down: CALL poll(0x820610560,0x3,0) STRU struct pollfd[] = { { fd=0, events=0x1<POLLIN>, revents=0x11<...> { fd=1, events=0x4<POLLOUT>, revents=0x4<POLLOUT>} { fd=-1, events=0x4<POLLOUT>, revents=0} } RET poll 2 Reviewed by: bapt, jhb (cherry picked from commit 02c57f7b48772c5ec4e3a0a3405273b387b9bb08) --- usr.bin/kdump/kdump.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 078b8a364db8..d69c019bd6be 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -58,6 +58,7 @@ static char sccsid[] = "@(#)kdump.c 8.1 (Berkeley) 6/6/93"; #include <sys/ktrace.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <sys/poll.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/sysent.h> @@ -122,6 +123,7 @@ void ktrcapfail(struct ktr_cap_fail *); void ktrfault(struct ktr_fault *); void ktrfaultend(struct ktr_faultend *); void ktrkevent(struct kevent *); +void ktrpollfd(struct pollfd *); void ktrstructarray(struct ktr_struct_array *, size_t); void ktrbitset(char *, struct bitset *, size_t); void ktrsyscall_freebsd(struct ktr_syscall *ktr, register_t **resip, @@ -2221,10 +2223,23 @@ ktrkevent(struct kevent *kev) printf(", data=%#jx, udata=%p }", (uintmax_t)kev->data, kev->udata); } +void +ktrpollfd(struct pollfd *pfd) +{ + + printf("{ fd=%d", pfd->fd); + printf(", events="); + print_mask_arg0(sysdecode_pollfd_events, pfd->events); + printf(", revents="); + print_mask_arg0(sysdecode_pollfd_events, pfd->revents); + printf("}"); +} + void ktrstructarray(struct ktr_struct_array *ksa, size_t buflen) { struct kevent kev; + struct pollfd pfd; char *name, *data; size_t namelen, datalen; int i; @@ -2306,6 +2321,11 @@ ktrstructarray(struct ktr_struct_array *ksa, size_t buflen) kev.udata = (void *)(uintptr_t)kev32.udata; ktrkevent(&kev); #endif + } else if (strcmp(name, "pollfd") == 0) { + if (ksa->struct_size != sizeof(pfd)) + goto bad_size; + memcpy(&pfd, data, sizeof(pfd)); + ktrpollfd(&pfd); } else { printf("<unknown structure> }\n"); return;