Hi, Start tracing struct flock. I've been using this diff during lockf development.
Comments? OK? Index: sys/kern/kern_descrip.c =================================================================== RCS file: /cvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.182 diff -u -p -r1.182 kern_descrip.c --- sys/kern/kern_descrip.c 24 Aug 2018 12:45:27 -0000 1.182 +++ sys/kern/kern_descrip.c 5 Nov 2018 07:10:39 -0000 @@ -527,6 +527,10 @@ restart: sizeof (fl)); if (error) break; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) + ktrflock(p, &fl); +#endif if (fl.l_whence == SEEK_CUR) { if (fl.l_start == 0 && fl.l_len < 0) { /* lockf(3) compliance hack */ @@ -615,6 +619,10 @@ restart: error = VOP_ADVLOCK(vp, fdp, F_GETLK, &fl, F_POSIX); if (error) break; +#ifdef KTRACE + if (KTRPOINT(p, KTR_STRUCT)) + ktrflock(p, &fl); +#endif error = (copyout((caddr_t)&fl, (caddr_t)SCARG(uap, arg), sizeof (fl))); break; Index: sys/sys/ktrace.h =================================================================== RCS file: /cvs/src/sys/sys/ktrace.h,v retrieving revision 1.36 diff -u -p -r1.36 ktrace.h --- sys/sys/ktrace.h 28 Nov 2017 16:05:13 -0000 1.36 +++ sys/sys/ktrace.h 5 Nov 2018 07:10:39 -0000 @@ -248,5 +248,7 @@ void ktrstruct(struct proc *, const c ktrstruct(p, "pollfd", pfd, (count) * sizeof(struct pollfd)) #define ktrfds(p, fds, count) \ ktrstruct(p, "fds", fds, (count) * sizeof(int)) +#define ktrflock(p, fl) \ + ktrstruct(p, "flock", (fl), sizeof(struct flock)) #endif /* !_KERNEL */ Index: usr.bin/kdump/kdump_subr.h =================================================================== RCS file: /cvs/src/usr.bin/kdump/kdump_subr.h,v retrieving revision 1.21 diff -u -p -r1.21 kdump_subr.h --- usr.bin/kdump/kdump_subr.h 28 Apr 2017 13:53:05 -0000 1.21 +++ usr.bin/kdump/kdump_subr.h 5 Nov 2018 07:10:39 -0000 @@ -98,5 +98,6 @@ void evfflagsname(int, int); void pollfdeventname(int); void syslogflagname(int); void futexflagname(int); +void flocktypename(int); extern int decimal, fancy, basecol, arg1; Index: usr.bin/kdump/ktrstruct.c =================================================================== RCS file: /cvs/src/usr.bin/kdump/ktrstruct.c,v retrieving revision 1.25 diff -u -p -r1.25 ktrstruct.c --- usr.bin/kdump/ktrstruct.c 13 Jul 2018 09:25:23 -0000 1.25 +++ usr.bin/kdump/ktrstruct.c 5 Nov 2018 07:10:39 -0000 @@ -37,6 +37,7 @@ #include <sys/time.h> #include <sys/event.h> #include <sys/un.h> +#include <sys/fcntl.h> #include <ufs/ufs/quota.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -517,6 +518,17 @@ ktrcmsghdr(char *data, socklen_t len) printf("\n"); } +static void +ktrflock(const struct flock *fl) +{ + printf("struct flock { start=%lld, len=%lld, pid=%d, type=", + fl->l_start, fl->l_len, fl->l_pid); + flocktypename(fl->l_type); + printf(", whence="); + whencename(fl->l_whence); + printf(" } \n"); +} + void ktrstruct(char *buf, size_t buflen) { @@ -658,6 +670,13 @@ ktrstruct(char *buf, size_t buflen) printf("flags="); showbufc(basecol + sizeof("flags=") - 1, (unsigned char *)data, datalen, VIS_DQ | VIS_TAB | VIS_NL); + } else if (strcmp(name, "flock") == 0) { + struct flock fl; + + if (datalen != sizeof(fl)) + goto invalid; + memcpy(&fl, data, datalen); + ktrflock(&fl); } else { printf("unknown structure %s\n", name); } Index: usr.bin/kdump/mksubr =================================================================== RCS file: /cvs/src/usr.bin/kdump/mksubr,v retrieving revision 1.35 diff -u -p -r1.35 mksubr --- usr.bin/kdump/mksubr 14 Feb 2018 17:26:56 -0000 1.35 +++ usr.bin/kdump/mksubr 5 Nov 2018 07:10:39 -0000 @@ -365,6 +365,7 @@ auto_orz_type "pollfdeventname" "POLL[^_ auto_orz_type "evflagsname" "EV_[^S][A-Z]+[[:space:]]+0x" "sys/event.h" auto_orz_type "syslogflagname" "LOG_[A-Z]+[[:space:]]+0x0*[1248]0*[[:space:]]" "sys/syslog.h" auto_orz_type "futexflagname" "FUTEX_[A-Z_]+[[:space:]]+[0-9]+" "sys/futex.h" +auto_switch_type "flocktypename" "F_[A-Z]+LCK" "sys/fcntl.h" cat <<_EOF_ /*