Date: Tue, 15 May 2018 00:00:44 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r333617 - in stable/11: . cddl/lib/libdtrace cddl/usr.sbin cddl/usr.sbin/dwatch cddl/usr.sbin/dwatch/libexec etc/mtree share/dtrace Message-ID: <201805150000.w4F00imB051812@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Tue May 15 00:00:44 2018 New Revision: 333617 URL: https://svnweb.freebsd.org/changeset/base/333617 Log: MFC SVN r329188,329334,329353,329914,329995-329996: DTrace Enhancements r329188: Use tabs in io.d, fix alignment issues, remove extra newlines r329334: Add errno definitions to /usr/lib/dtrace/errno.d r329353: Add inline to errno.d for translating int to string r329914: Updates and enhancements to io.d to aid DTrace scripting r329995: Updates and enhancements to signal.d to aid DTrace scripting r329996: Consistent casing for fallback SIGCHLD (s/Unknown/unknown/) MFC SVN r330559-330560,330672,332865-332867,333513-333519: dwatch(1) r330559: Introduce dwatch(1) as a tool for making DTrace more useful r330560: Bump dwatch(1) internal version from 1.0-beta-91 to 1.0 r330672: Fix display of wrong pid from dtrace_sched(4) r332865: Add `-dev' option to aid debugging of profiles r332866: Add profile for send(2)/recv(2) syscalls r332867: Remove the line used to demonstrate `-dev' option r333513: Bugfix, usage displayed with `-1Q' r333514: Separate default values so `-[BK] num' don't affect usage r333515: Simplify info message test r333516: Export ARGV to profiles loaded via load_profile() r333517: Allow `-E code' to override profile EVENT_DETAILS r333518: Expose process for ip/tcp/udp r333519: Refactor sendrecv profile Reviewed by: markj, gnn, bdrewery (head; earlier version) Approved by: re (gjb) Relnotes: yes Sponsored by: Smule, Inc. Differential Revision: https://reviews.freebsd.org/D15418 Added: stable/11/cddl/usr.sbin/dwatch/ - copied from r330559, head/cddl/usr.sbin/dwatch/ stable/11/cddl/usr.sbin/dwatch/libexec/sendrecv (contents, props changed) - copied, changed from r332866, head/cddl/usr.sbin/dwatch/libexec/sendrecv Deleted: stable/11/share/dtrace/watch_execve stable/11/share/dtrace/watch_kill stable/11/share/dtrace/watch_vop_remove Modified: stable/11/ObsoleteFiles.inc stable/11/cddl/lib/libdtrace/errno.d stable/11/cddl/lib/libdtrace/io.d stable/11/cddl/lib/libdtrace/ip.d stable/11/cddl/lib/libdtrace/libproc_compat.h stable/11/cddl/lib/libdtrace/psinfo.d stable/11/cddl/lib/libdtrace/regs_x86.d stable/11/cddl/lib/libdtrace/sched.d stable/11/cddl/lib/libdtrace/signal.d stable/11/cddl/lib/libdtrace/tcp.d stable/11/cddl/lib/libdtrace/udp.d stable/11/cddl/usr.sbin/Makefile stable/11/cddl/usr.sbin/dwatch/dwatch stable/11/cddl/usr.sbin/dwatch/libexec/Makefile stable/11/cddl/usr.sbin/dwatch/libexec/chmod stable/11/cddl/usr.sbin/dwatch/libexec/errno stable/11/cddl/usr.sbin/dwatch/libexec/io stable/11/cddl/usr.sbin/dwatch/libexec/ip stable/11/cddl/usr.sbin/dwatch/libexec/kill stable/11/cddl/usr.sbin/dwatch/libexec/nanosleep stable/11/cddl/usr.sbin/dwatch/libexec/open stable/11/cddl/usr.sbin/dwatch/libexec/proc stable/11/cddl/usr.sbin/dwatch/libexec/rw stable/11/cddl/usr.sbin/dwatch/libexec/sched stable/11/cddl/usr.sbin/dwatch/libexec/tcp stable/11/cddl/usr.sbin/dwatch/libexec/udp stable/11/cddl/usr.sbin/dwatch/libexec/vop_create stable/11/cddl/usr.sbin/dwatch/libexec/vop_readdir stable/11/cddl/usr.sbin/dwatch/libexec/vop_rename stable/11/cddl/usr.sbin/dwatch/libexec/vop_symlink stable/11/etc/mtree/BSD.usr.dist stable/11/share/dtrace/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/ObsoleteFiles.inc ============================================================================== --- stable/11/ObsoleteFiles.inc Mon May 14 23:12:30 2018 (r333616) +++ stable/11/ObsoleteFiles.inc Tue May 15 00:00:44 2018 (r333617) @@ -38,6 +38,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20180513: remove DTrace scripts made obsolete by dwatch(1) +OLD_FILES+=usr/share/dtrace/watch_execve +OLD_FILES+=usr/share/dtrace/watch_kill +OLD_FILES+=usr/share/dtrace/watch_vop_remove # 20180331: new clang import which bumps version from 5.0.1 to 6.0.0. OLD_FILES+=usr/lib/clang/5.0.1/include/sanitizer/allocator_interface.h OLD_FILES+=usr/lib/clang/5.0.1/include/sanitizer/asan_interface.h Modified: stable/11/cddl/lib/libdtrace/errno.d ============================================================================== --- stable/11/cddl/lib/libdtrace/errno.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/errno.d Tue May 15 00:00:44 2018 (r333617) @@ -20,6 +20,7 @@ * CDDL HEADER END * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org + * Portions Copyright 2018 Devin Teske dteske@freebsd.org * * $FreeBSD$ */ @@ -216,7 +217,15 @@ inline int ENOLINK = 91; #pragma D binding "1.0" ENOLINK inline int EPROTO = 92; #pragma D binding "1.0" EPROTO -inline int ELAST = 92; +inline int ENOTCAPABLE = 93; +#pragma D binding "1.13" ENOTCAPABLE +inline int ECAPMODE = 94; +#pragma D binding "1.13" ECAPMODE +inline int ENOTRECOVERABLE = 95; +#pragma D binding "1.13" ENOTRECOVERABLE +inline int EOWNERDEAD = 96; +#pragma D binding "1.13" EOWNERDEAD +inline int ELAST = 96; #pragma D binding "1.0" ELAST inline int ERESTART = -1; #pragma D binding "1.0" ERESTART @@ -226,3 +235,114 @@ inline int ENOIOCTL = -3; #pragma D binding "1.0" ENOIOCTL inline int EDIRIOCTL = -4; #pragma D binding "1.0" EDIRIOCTL +inline int ERELOOKUP = -5; +#pragma D binding "1.13" ERELOOKUP + +/* + * Error strings from <sys/errno.h> + */ +#pragma D binding "1.13" strerror +inline string strerror[int errno] = + errno == 0 ? "Success" : + errno == EPERM ? "Operation not permitted" : + errno == ENOENT ? "No such file or directory" : + errno == ESRCH ? "No such process" : + errno == EINTR ? "Interrupted system call" : + errno == EIO ? "Input/output error" : + errno == ENXIO ? "Device not configured" : + errno == E2BIG ? "Argument list too long" : + errno == ENOEXEC ? "Exec format error" : + errno == EBADF ? "Bad file descriptor" : + errno == ECHILD ? "No child processes" : + errno == EDEADLK ? "Resource deadlock avoided" : + errno == ENOMEM ? "Cannot allocate memory" : + errno == EACCES ? "Permission denied" : + errno == EFAULT ? "Bad address" : + errno == ENOTBLK ? "Block device required" : + errno == EBUSY ? "Device busy" : + errno == EEXIST ? "File exists" : + errno == EXDEV ? "Cross-device link" : + errno == ENODEV ? "Operation not supported by device" : + errno == ENOTDIR ? "Not a directory" : + errno == EISDIR ? "Is a directory" : + errno == EINVAL ? "Invalid argument" : + errno == ENFILE ? "Too many open files in system" : + errno == EMFILE ? "Too many open files" : + errno == ENOTTY ? "Inappropriate ioctl for device" : + errno == ETXTBSY ? "Text file busy" : + errno == EFBIG ? "File too large" : + errno == ENOSPC ? "No space left on device" : + errno == ESPIPE ? "Illegal seek" : + errno == EROFS ? "Read-only filesystem" : + errno == EMLINK ? "Too many links" : + errno == EPIPE ? "Broken pipe" : + errno == EDOM ? "Numerical argument out of domain" : + errno == ERANGE ? "Result too large" : + errno == EAGAIN ? "Resource temporarily unavailable" : + errno == EINPROGRESS ? "Operation now in progress" : + errno == EALREADY ? "Operation already in progress" : + errno == ENOTSOCK ? "Socket operation on non-socket" : + errno == EDESTADDRREQ ? "Destination address required" : + errno == EMSGSIZE ? "Message too long" : + errno == EPROTOTYPE ? "Protocol wrong type for socket" : + errno == ENOPROTOOPT ? "Protocol not available" : + errno == EPROTONOSUPPORT ? "Protocol not supported" : + errno == ESOCKTNOSUPPORT ? "Socket type not supported" : + errno == EOPNOTSUPP ? "Operation not supported" : + errno == EPFNOSUPPORT ? "Protocol family not supported" : + errno == EAFNOSUPPORT ? "Address family not supported by protocol family" : + errno == EADDRINUSE ? "Address already in use" : + errno == EADDRNOTAVAIL ? "Can't assign requested address" : + errno == ENETDOWN ? "Network is down" : + errno == ENETUNREACH ? "Network is unreachable" : + errno == ENETRESET ? "Network dropped connection on reset" : + errno == ECONNABORTED ? "Software caused connection abort" : + errno == ECONNRESET ? "Connection reset by peer" : + errno == ENOBUFS ? "No buffer space available" : + errno == EISCONN ? "Socket is already connected" : + errno == ENOTCONN ? "Socket is not connected" : + errno == ESHUTDOWN ? "Can't send after socket shutdown" : + errno == ETOOMANYREFS ? "Too many references: can't splice" : + errno == ETIMEDOUT ? "Operation timed out" : + errno == ECONNREFUSED ? "Connection refused" : + errno == ELOOP ? "Too many levels of symbolic links" : + errno == ENAMETOOLONG ? "File name too long" : + errno == EHOSTDOWN ? "Host is down" : + errno == EHOSTUNREACH ? "No route to host" : + errno == ENOTEMPTY ? "Directory not empty" : + errno == EPROCLIM ? "Too many processes" : + errno == EUSERS ? "Too many users" : + errno == EDQUOT ? "Disc quota exceeded" : + errno == ESTALE ? "Stale NFS file handle" : + errno == EREMOTE ? "Too many levels of remote in path" : + errno == EBADRPC ? "RPC struct is bad" : + errno == ERPCMISMATCH ? "RPC version wrong" : + errno == EPROGUNAVAIL ? "RPC prog. not avail" : + errno == EPROGMISMATCH ? "Program version wrong" : + errno == EPROCUNAVAIL ? "Bad procedure for program" : + errno == ENOLCK ? "No locks available" : + errno == ENOSYS ? "Function not implemented" : + errno == EFTYPE ? "Inappropriate file type or format" : + errno == EAUTH ? "Authentication error" : + errno == ENEEDAUTH ? "Need authenticator" : + errno == EIDRM ? "Identifier removed" : + errno == ENOMSG ? "No message of desired type" : + errno == EOVERFLOW ? "Value too large to be stored in data type" : + errno == ECANCELED ? "Operation canceled" : + errno == EILSEQ ? "Illegal byte sequence" : + errno == ENOATTR ? "Attribute not found" : + errno == EDOOFUS ? "Programming error" : + errno == EBADMSG ? "Bad message" : + errno == EMULTIHOP ? "Multihop attempted" : + errno == ENOLINK ? "Link has been severed" : + errno == EPROTO ? "Protocol error" : + errno == ENOTCAPABLE ? "Capabilities insufficient" : + errno == ECAPMODE ? "Not permitted in capability mode" : + errno == ENOTRECOVERABLE ? "State not recoverable" : + errno == EOWNERDEAD ? "Previous owner died" : + errno == ERESTART ? "restart syscall" : + errno == EJUSTRETURN ? "don't modify regs, just return" : + errno == ENOIOCTL ? "ioctl not handled by this layer" : + errno == EDIRIOCTL ? "do direct ioctl in GEOM" : + errno == ERELOOKUP ? "retry the directory lookup" : + "Unknown error"; Modified: stable/11/cddl/lib/libdtrace/io.d ============================================================================== --- stable/11/cddl/lib/libdtrace/io.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/io.d Tue May 15 00:00:44 2018 (r333617) @@ -18,6 +18,8 @@ * * CDDL HEADER END * + * Portions Copyright 2018 Devin Teske dteske@freebsd.org + * * $FreeBSD$ */ /* @@ -29,47 +31,51 @@ #pragma D depends_on provider io typedef struct devinfo { - int dev_major; /* major number */ - int dev_minor; /* minor number */ - int dev_instance; /* instance number */ - string dev_name; /* name of device */ - string dev_statname; /* name of device + instance/minor */ - string dev_pathname; /* pathname of device */ + int dev_major; /* major number */ + int dev_minor; /* minor number */ + int dev_instance; /* instance number */ + int dev_type; /* type of device */ + string dev_name; /* name of device */ + string dev_statname; /* name of device + instance/minor */ + string dev_pathname; /* pathname of device */ } devinfo_t; #pragma D binding "1.0" translator translator devinfo_t < struct devstat *D > { - dev_major = D->device_number; - dev_minor = D->unit_number; - dev_instance = 0; - dev_name = stringof(D->device_name); - dev_statname = stringof(D->device_name); - dev_pathname = stringof(D->device_name); + dev_major = D->device_number; + dev_minor = D->unit_number; + dev_instance = 0; + dev_type = D->device_type; + dev_name = stringof(D->device_name); + dev_statname = stringof(D->device_name); + dev_pathname = stringof(D->device_name); }; typedef struct bufinfo { - int b_flags; /* flags */ - long b_bcount; /* number of bytes */ - caddr_t b_addr; /* buffer address */ - uint64_t b_blkno; /* expanded block # on device */ - uint64_t b_lblkno; /* block # on device */ - size_t b_resid; /* # of bytes not transferred */ - size_t b_bufsize; /* size of allocated buffer */ -/* caddr_t b_iodone; I/O completion routine */ - int b_error; /* expanded error field */ -/* dev_t b_edev; extended device */ + int b_cmd; /* I/O operation */ + int b_flags; /* flags */ + long b_bcount; /* number of bytes */ + caddr_t b_addr; /* buffer address */ + uint64_t b_blkno; /* expanded block # on device */ + uint64_t b_lblkno; /* block # on device */ + size_t b_resid; /* # of bytes not transferred */ + size_t b_bufsize; /* size of allocated buffer */ +/* caddr_t b_iodone; I/O completion routine */ + int b_error; /* expanded error field */ +/* dev_t b_edev; extended device */ } bufinfo_t; #pragma D binding "1.0" translator translator bufinfo_t < struct bio *B > { - b_flags = B->bio_flags; - b_bcount = B->bio_bcount; - b_addr = B->bio_data; - b_blkno = 0; - b_lblkno = 0; - b_resid = B->bio_resid; - b_bufsize = 0; /* XXX gnn */ - b_error = B->bio_error; + b_cmd = B->bio_cmd; + b_flags = B->bio_flags; + b_bcount = B->bio_bcount; + b_addr = B->bio_data; + b_blkno = 0; + b_lblkno = 0; + b_resid = B->bio_resid; + b_bufsize = 0; /* XXX gnn */ + b_error = B->bio_error; }; /* @@ -106,4 +112,150 @@ inline int O_SYNC = 0x0080; inline int O_TRUNC = 0x0400; #pragma D binding "1.1" O_TRUNC +/* + * The following inline constants can be used to examine bio_cmd of struct bio + * or a translated bufinfo_t. + */ +inline int BIO_READ = 0x01; +#pragma D binding "1.13" BIO_READ +inline int BIO_WRITE = 0x02; +#pragma D binding "1.13" BIO_WRITE +inline int BIO_DELETE = 0x03; +#pragma D binding "1.13" BIO_DELETE +inline int BIO_GETATTR = 0x04; +#pragma D binding "1.13" BIO_GETATTR +inline int BIO_FLUSH = 0x05; +#pragma D binding "1.13" BIO_FLUSH +inline int BIO_CMD0 = 0x06; +#pragma D binding "1.13" BIO_CMD0 +inline int BIO_CMD1 = 0x07; +#pragma D binding "1.13" BIO_CMD1 +inline int BIO_CMD2 = 0x08; +#pragma D binding "1.13" BIO_CMD2 +inline int BIO_ZONE = 0x09; +#pragma D binding "1.13" BIO_ZONE +/* + * The following inline constants can be used to examine bio_flags of struct + * bio or a translated bufinfo_t. + */ +inline int BIO_ERROR = 0x01; +#pragma D binding "1.13" BIO_ERROR +inline int BIO_DONE = 0x02; +#pragma D binding "1.13" BIO_DONE +inline int BIO_ONQUEUE = 0x04; +#pragma D binding "1.13" BIO_ONQUEUE +inline int BIO_ORDERED = 0x08; +#pragma D binding "1.13" BIO_ORDERED +inline int BIO_UNMAPPED = 0x10; +#pragma D binding "1.13" BIO_UNMAPPED +inline int BIO_TRANSIENT_MAPPING = 0x20; +#pragma D binding "1.13" BIO_TRANSIENT_MAPPING +inline int BIO_VLIST = 0x40; +#pragma D binding "1.13" BIO_VLIST + +/* + * The following inline constants can be used to examine device_type of struct + * devstat or a translated devinfo_t. + */ +inline int DEVSTAT_TYPE_DIRECT = 0x000; +#pragma D binding "1.13" DEVSTAT_TYPE_DIRECT +inline int DEVSTAT_TYPE_SEQUENTIAL = 0x001; +#pragma D binding "1.13" DEVSTAT_TYPE_SEQUENTIAL +inline int DEVSTAT_TYPE_PRINTER = 0x002; +#pragma D binding "1.13" DEVSTAT_TYPE_PRINTER +inline int DEVSTAT_TYPE_PROCESSOR = 0x003; +#pragma D binding "1.13" DEVSTAT_TYPE_PROCESSOR +inline int DEVSTAT_TYPE_WORM = 0x004; +#pragma D binding "1.13" DEVSTAT_TYPE_WORM +inline int DEVSTAT_TYPE_CDROM = 0x005; +#pragma D binding "1.13" DEVSTAT_TYPE_CDROM +inline int DEVSTAT_TYPE_SCANNER = 0x006; +#pragma D binding "1.13" DEVSTAT_TYPE_SCANNER +inline int DEVSTAT_TYPE_OPTICAL = 0x007; +#pragma D binding "1.13" DEVSTAT_TYPE_OPTICAL +inline int DEVSTAT_TYPE_CHANGER = 0x008; +#pragma D binding "1.13" DEVSTAT_TYPE_CHANGER +inline int DEVSTAT_TYPE_COMM = 0x009; +#pragma D binding "1.13" DEVSTAT_TYPE_COMM +inline int DEVSTAT_TYPE_ASC0 = 0x00a; +#pragma D binding "1.13" DEVSTAT_TYPE_ASC0 +inline int DEVSTAT_TYPE_ASC1 = 0x00b; +#pragma D binding "1.13" DEVSTAT_TYPE_ASC1 +inline int DEVSTAT_TYPE_STORARRAY = 0x00c; +#pragma D binding "1.13" DEVSTAT_TYPE_STORARRAY +inline int DEVSTAT_TYPE_ENCLOSURE = 0x00d; +#pragma D binding "1.13" DEVSTAT_TYPE_ENCLOSURE +inline int DEVSTAT_TYPE_FLOPPY = 0x00e; +#pragma D binding "1.13" DEVSTAT_TYPE_FLOPPY +inline int DEVSTAT_TYPE_MASK = 0x00f; +#pragma D binding "1.13" DEVSTAT_TYPE_MASK +inline int DEVSTAT_TYPE_IF_SCSI = 0x010; +#pragma D binding "1.13" DEVSTAT_TYPE_IF_SCSI +inline int DEVSTAT_TYPE_IF_IDE = 0x020; +#pragma D binding "1.13" DEVSTAT_TYPE_IF_IDE +inline int DEVSTAT_TYPE_IF_OTHER = 0x030; +#pragma D binding "1.13" DEVSTAT_TYPE_IF_OTHER +inline int DEVSTAT_TYPE_IF_MASK = 0x0f0; +#pragma D binding "1.13" DEVSTAT_TYPE_IF_MASK +inline int DEVSTAT_TYPE_PASS = 0x100; +#pragma D binding "1.13" DEVSTAT_TYPE_PASS + +#pragma D binding "1.13" device_type_string +inline string device_type_string[int type] = + type == DEVSTAT_TYPE_DIRECT ? "DIRECT" : + type == DEVSTAT_TYPE_SEQUENTIAL ? "SEQUENTIAL" : + type == DEVSTAT_TYPE_PRINTER ? "PRINTER" : + type == DEVSTAT_TYPE_PROCESSOR ? "PROCESSOR" : + type == DEVSTAT_TYPE_WORM ? "WORM" : + type == DEVSTAT_TYPE_CDROM ? "CDROM" : + type == DEVSTAT_TYPE_SCANNER ? "SCANNER" : + type == DEVSTAT_TYPE_OPTICAL ? "OPTICAL" : + type == DEVSTAT_TYPE_CHANGER ? "CHANGER" : + type == DEVSTAT_TYPE_COMM ? "COMM" : + type == DEVSTAT_TYPE_ASC0 ? "ASC0" : + type == DEVSTAT_TYPE_ASC1 ? "ASC1" : + type == DEVSTAT_TYPE_STORARRAY ? "STORARRAY" : + type == DEVSTAT_TYPE_ENCLOSURE ? "ENCLOSURE" : + type == DEVSTAT_TYPE_FLOPPY ? "FLOPPY" : + strjoin("UNKNOWN(", strjoin(lltostr(type), ")")); + +#pragma D binding "1.13" device_type +inline string device_type[int type] = + device_type_string[type & DEVSTAT_TYPE_MASK]; + +#pragma D binding "1.13" device_if_string +inline string device_if_string[int type] = + type == 0 ? "ACCESS" : + type == DEVSTAT_TYPE_IF_SCSI ? "SCSI" : + type == DEVSTAT_TYPE_IF_IDE ? "IDE" : + type == DEVSTAT_TYPE_IF_OTHER ? "OTHER" : + strjoin("UNKNOWN(", strjoin(lltostr(type), ")")); + +#pragma D binding "1.13" device_if +inline string device_if[int type] = + device_if_string[type & DEVSTAT_TYPE_IF_MASK]; + +#pragma D binding "1.13" bio_cmd_string +inline string bio_cmd_string[int cmd] = + cmd == BIO_READ ? "READ" : + cmd == BIO_WRITE ? "WRITE" : + cmd == BIO_DELETE ? "DELETE" : + cmd == BIO_GETATTR ? "GETATTR" : + cmd == BIO_FLUSH ? "FLUSH" : + cmd == BIO_CMD0 ? "CMD0" : + cmd == BIO_CMD1 ? "CMD1" : + cmd == BIO_CMD2 ? "CMD2" : + cmd == BIO_ZONE ? "ZONE" : + strjoin("UNKNOWN(", strjoin(lltostr(cmd), ")")); + +#pragma D binding "1.13" bio_flag_string +inline string bio_flag_string[int flag] = + flag == BIO_ERROR ? "ERROR" : + flag == BIO_DONE ? "DONE" : + flag == BIO_ONQUEUE ? "ONQUEUE" : + flag == BIO_ORDERED ? "ORDERED" : + flag == BIO_UNMAPPED ? "UNMAPPED" : + flag == BIO_TRANSIENT_MAPPING ? "TRANSIENT_MAPPING" : + flag == BIO_VLIST ? "VLIST" : + ""; Modified: stable/11/cddl/lib/libdtrace/ip.d ============================================================================== --- stable/11/cddl/lib/libdtrace/ip.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/ip.d Tue May 15 00:00:44 2018 (r333617) @@ -215,10 +215,10 @@ translator csinfo_t < void *p > { #pragma D binding "1.6.3" translator translator csinfo_t < struct inpcb *p > { - cs_addr = NULL; - cs_cid = (uint64_t)p; - cs_pid = 0; /* XXX */ - cs_zoneid = 0; + cs_addr = NULL; + cs_cid = (uint64_t)p; + cs_pid = 0; /* XXX */ + cs_zoneid = 0; }; #pragma D binding "1.5" translator Modified: stable/11/cddl/lib/libdtrace/libproc_compat.h ============================================================================== --- stable/11/cddl/lib/libdtrace/libproc_compat.h Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/libproc_compat.h Tue May 15 00:00:44 2018 (r333617) @@ -4,7 +4,7 @@ * * This software was developed by Rui Paulo under sponsorship from the * FreeBSD Foundation. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: Modified: stable/11/cddl/lib/libdtrace/psinfo.d ============================================================================== --- stable/11/cddl/lib/libdtrace/psinfo.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/psinfo.d Tue May 15 00:00:44 2018 (r333617) @@ -97,4 +97,3 @@ inline psinfo_t *curpsinfo = xlate <psinfo_t *> (curth inline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread); #pragma D attributes Stable/Stable/Common curlwpsinfo #pragma D binding "1.0" curlwpsinfo - Modified: stable/11/cddl/lib/libdtrace/regs_x86.d ============================================================================== --- stable/11/cddl/lib/libdtrace/regs_x86.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/regs_x86.d Tue May 15 00:00:44 2018 (r333617) @@ -1,4 +1,4 @@ -/* +/* * CDDL HEADER START * * The contents of this file are subject to the terms of the @@ -116,4 +116,3 @@ inline int R_R14 = 18 + 1 + 1; #pragma D binding "1.0" R_R14 inline int R_R15 = 18 + 1 + 0; #pragma D binding "1.0" R_R15 - Modified: stable/11/cddl/lib/libdtrace/sched.d ============================================================================== --- stable/11/cddl/lib/libdtrace/sched.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/sched.d Tue May 15 00:00:44 2018 (r333617) @@ -81,4 +81,3 @@ inline chipid_t chip = curcpu->cpu_chip; inline lgrp_id_t lgrp = curcpu->cpu_lgrp; #pragma D attributes Stable/Stable/Common lgrp #pragma D binding "1.0" lgrp - Modified: stable/11/cddl/lib/libdtrace/signal.d ============================================================================== --- stable/11/cddl/lib/libdtrace/signal.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/signal.d Tue May 15 00:00:44 2018 (r333617) @@ -20,6 +20,7 @@ * CDDL HEADER END * * Portions Copyright 2008 John Birrell jb@freebsd.org + * Portions Copyright 2018 Devin Teske dteske@freebsd.org * * $FreeBSD$ */ @@ -86,7 +87,48 @@ inline int SIGUSR1 = 30; #pragma D binding "1.0" SIGUSR1 inline int SIGUSR2 = 31; #pragma D binding "1.0" SIGUSR2 +inline int SIGTHR = 32; +#pragma D binding "1.13" SIGTHR +inline int SIGLIBRT = 33; +#pragma D binding "1.13" SIGLIBRT +#pragma D binding "1.13" signal_string +inline string signal_string[int signal] = + signal == SIGHUP ? "SIGHUP" : + signal == SIGINT ? "SIGINT" : + signal == SIGQUIT ? "SIGQUIT" : + signal == SIGILL ? "SIGILL": + signal == SIGTRAP ? "SIGTRAP" : + signal == SIGABRT ? "SIGABRT" : + signal == SIGEMT ? "SIGEMT" : + signal == SIGFPE ? "SIGFPE" : + signal == SIGKILL ? "SIGKILL" : + signal == SIGBUS ? "SIGBUS" : + signal == SIGSEGV ? "SIGSEGV" : + signal == SIGSYS ? "SIGSYS" : + signal == SIGPIPE ? "SIGPIPE" : + signal == SIGALRM ? "SIGALRM" : + signal == SIGTERM ? "SIGTERM" : + signal == SIGURG ? "SIGURG" : + signal == SIGSTOP ? "SIGSTOP" : + signal == SIGTSTP ? "SIGTSTP" : + signal == SIGCONT ? "SIGCONT" : + signal == SIGCHLD ? "SIGCHLD" : + signal == SIGTTIN ? "SIGTTIN" : + signal == SIGTTOU ? "SIGTTOU" : + signal == SIGIO ? "SIGIO" : + signal == SIGXCPU ? "SIGXCPU" : + signal == SIGXFSZ ? "SIGXFSZ" : + signal == SIGVTALRM ? "SIGVTALRM" : + signal == SIGPROF ? "SIGPROF" : + signal == SIGWINCH ? "SIGWINCH" : + signal == SIGINFO ? "SIGINFO" : + signal == SIGUSR1 ? "SIGUSR1" : + signal == SIGUSR2 ? "SIGUSR2" : + signal == SIGTHR ? "SIGTHR" : + signal == SIGLIBRT ? "SIGLIBRT" : + "UNKNOWN"; + inline int CLD_EXITED = 1; #pragma D binding "1.0" CLD_EXITED inline int CLD_KILLED = 2; @@ -99,3 +141,13 @@ inline int CLD_STOPPED = 5; #pragma D binding "1.0" CLD_STOPPED inline int CLD_CONTINUED = 6; #pragma D binding "1.0" CLD_CONTINUED + +#pragma D binding "1.13" child_signal_string +inline string child_signal_string[int child_signal] = + child_signal == CLD_EXITED ? "child exited" : + child_signal == CLD_KILLED ? "child terminated abnormally" : + child_signal == CLD_DUMPED ? "child core dumped" : + child_signal == CLD_TRAPPED ? "traced child trapped" : + child_signal == CLD_STOPPED ? "child stopped" : + child_signal == CLD_CONTINUED ? "stopped child continued" : + strjoin("unknown SIGCHLD code (", strjoin(lltostr(child_signal), ")")); Modified: stable/11/cddl/lib/libdtrace/tcp.d ============================================================================== --- stable/11/cddl/lib/libdtrace/tcp.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/tcp.d Tue May 15 00:00:44 2018 (r333617) @@ -118,18 +118,18 @@ typedef struct tcpsinfo { int32_t tcps_rcv_ws; /* receive window scaling */ u_long tcps_cwnd; /* congestion window */ u_long tcps_cwnd_ssthresh; /* threshold for congestion avoidance */ - uint32_t tcps_srecover; /* for use in NewReno Fast Recovery */ + uint32_t tcps_srecover; /* for use in NewReno Fast Recovery */ uint32_t tcps_sack_fack; /* SACK sequence # we have acked */ uint32_t tcps_sack_snxt; /* next SACK seq # for retransmission */ uint32_t tcps_rto; /* round-trip timeout, msec */ uint32_t tcps_mss; /* max segment size */ int tcps_retransmit; /* retransmit send event, boolean */ int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ - int tcps_debug; /* socket has SO_DEBUG set */ - int tcps_cookie; /* expose the socket's SO_USER_COOKIE */ - int32_t tcps_dupacks; /* consecutive dup acks received */ - uint32_t tcps_rtttime; /* RTT measurement start time */ - uint32_t tcps_rtseq; /* sequence # being timed */ + int tcps_debug; /* socket has SO_DEBUG set */ + int tcps_cookie; /* expose the socket's SO_USER_COOKIE */ + int32_t tcps_dupacks; /* consecutive dup acks received */ + uint32_t tcps_rtttime; /* RTT measurement start time */ + uint32_t tcps_rtseq; /* sequence # being timed */ uint32_t tcps_ts_recent; /* timestamp echo data */ } tcpsinfo_t; @@ -206,31 +206,31 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_snxt = p == NULL ? 0 : p->snd_nxt; tcps_rack = p == NULL ? 0 : p->last_ack_sent; tcps_rnxt = p == NULL ? 0 : p->rcv_nxt; - tcps_swnd = p == NULL ? -1 : p->snd_wnd; - tcps_snd_ws = p == NULL ? -1 : p->snd_scale; - tcps_swl1 = p == NULL ? -1 : p->snd_wl1; - tcps_swl2 = p == NULL ? -1 : p->snd_wl2; - tcps_radv = p == NULL ? -1 : p->rcv_adv; - tcps_rwnd = p == NULL ? -1 : p->rcv_wnd; - tcps_rup = p == NULL ? -1 : p->rcv_up; - tcps_rcv_ws = p == NULL ? -1 : p->rcv_scale; - tcps_cwnd = p == NULL ? -1 : p->snd_cwnd; - tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh; - tcps_srecover = p == NULL ? -1 : p->snd_recover; + tcps_swnd = p == NULL ? -1 : p->snd_wnd; + tcps_snd_ws = p == NULL ? -1 : p->snd_scale; + tcps_swl1 = p == NULL ? -1 : p->snd_wl1; + tcps_swl2 = p == NULL ? -1 : p->snd_wl2; + tcps_radv = p == NULL ? -1 : p->rcv_adv; + tcps_rwnd = p == NULL ? -1 : p->rcv_wnd; + tcps_rup = p == NULL ? -1 : p->rcv_up; + tcps_rcv_ws = p == NULL ? -1 : p->rcv_scale; + tcps_cwnd = p == NULL ? -1 : p->snd_cwnd; + tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh; + tcps_srecover = p == NULL ? -1 : p->snd_recover; tcps_sack_fack = p == NULL ? 0 : p->snd_fack; tcps_sack_snxt = p == NULL ? 0 : p->sack_newdata; tcps_rto = p == NULL ? -1 : (p->t_rxtcur * 1000) / `hz; - tcps_mss = p == NULL ? -1 : p->t_maxseg; + tcps_mss = p == NULL ? -1 : p->t_maxseg; tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; - tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ + tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ tcps_debug = p == NULL ? 0 : p->t_inpcb->inp_socket->so_options & 1; tcps_cookie = p == NULL ? -1 : p->t_inpcb->inp_socket->so_user_cookie; - tcps_dupacks = p == NULL ? -1 : p->t_dupacks; - tcps_rtttime = p == NULL ? -1 : p->t_rtttime; - tcps_rtseq = p == NULL ? -1 : p->t_rtseq; - tcps_ts_recent = p == NULL ? -1 : p->ts_recent; + tcps_dupacks = p == NULL ? -1 : p->t_dupacks; + tcps_rtttime = p == NULL ? -1 : p->t_rtttime; + tcps_rtseq = p == NULL ? -1 : p->t_rtseq; + tcps_ts_recent = p == NULL ? -1 : p->ts_recent; }; #pragma D binding "1.6.3" translator @@ -319,74 +319,74 @@ inline int PRU_LISTEN = 3; #pragma D binding "1.12.1" PRU_CONNECT inline int PRU_CONNECT = 4; #pragma D binding "1.12.1" PRU_ACCEPT -inline int PRU_ACCEPT = 5 ; +inline int PRU_ACCEPT = 5 ; #pragma D binding "1.12.1" PRU_DISCONNECT -inline int PRU_DISCONNECT= 6; +inline int PRU_DISCONNECT = 6; #pragma D binding "1.12.1" PRU_SHUTDOWN -inline int PRU_SHUTDOWN = 7; +inline int PRU_SHUTDOWN = 7; #pragma D binding "1.12.1" PRU_RCVD -inline int PRU_RCVD = 8; +inline int PRU_RCVD = 8; #pragma D binding "1.12.1" PRU_SEND -inline int PRU_SEND = 9; +inline int PRU_SEND = 9; #pragma D binding "1.12.1" PRU_ABORT -inline int PRU_ABORT = 10; +inline int PRU_ABORT = 10; #pragma D binding "1.12.1" PRU_CONTROL -inline int PRU_CONTROL = 11; +inline int PRU_CONTROL = 11; #pragma D binding "1.12.1" PRU_SENSE -inline int PRU_SENSE = 12; +inline int PRU_SENSE = 12; #pragma D binding "1.12.1" PRU_RCVOOB -inline int PRU_RCVOOB = 13; +inline int PRU_RCVOOB = 13; #pragma D binding "1.12.1" PRU_SENDOOB -inline int PRU_SENDOOB = 14; +inline int PRU_SENDOOB = 14; #pragma D binding "1.12.1" PRU_SOCKADDR -inline int PRU_SOCKADDR = 15; +inline int PRU_SOCKADDR = 15; #pragma D binding "1.12.1" PRU_PEERADDR -inline int PRU_PEERADDR = 16; +inline int PRU_PEERADDR = 16; #pragma D binding "1.12.1" PRU_CONNECT2 -inline int PRU_CONNECT2 = 17; +inline int PRU_CONNECT2 = 17; #pragma D binding "1.12.1" PRU_FASTTIMO -inline int PRU_FASTTIMO = 18; +inline int PRU_FASTTIMO = 18; #pragma D binding "1.12.1" PRU_SLOWTIMO -inline int PRU_SLOWTIMO = 19; +inline int PRU_SLOWTIMO = 19; #pragma D binding "1.12.1" PRU_PROTORCV -inline int PRU_PROTORCV = 20; +inline int PRU_PROTORCV = 20; #pragma D binding "1.12.1" PRU_PROTOSEND -inline int PRU_PROTOSEND = 21; +inline int PRU_PROTOSEND = 21; #pragma D binding "1.12.1" PRU_SEND_EOF -inline int PRU_SEND_EOF = 22; +inline int PRU_SEND_EOF = 22; #pragma D binding "1.12.1" PRU_SOSETLABEL -inline int PRU_SOSETLABEL = 23; +inline int PRU_SOSETLABEL = 23; #pragma D binding "1.12.1" PRU_CLOSE -inline int PRU_CLOSE = 24; +inline int PRU_CLOSE = 24; #pragma D binding "1.12.1" PRU_FLUSH -inline int PRU_FLUSH = 25; +inline int PRU_FLUSH = 25; #pragma D binding "1.12.1" prureq_string inline string prureq_string[uint8_t req] = - req == PRU_ATTACH ? "ATTACH" : - req == PRU_DETACH ? "DETACH" : - req == PRU_BIND ? "BIND" : - req == PRU_LISTEN ? "LISTEN" : - req == PRU_CONNECT ? "CONNECT" : - req == PRU_ACCEPT ? "ACCEPT" : - req == PRU_DISCONNECT ? "DISCONNECT" : - req == PRU_SHUTDOWN ? "SHUTDOWN" : - req == PRU_RCVD ? "RCVD" : - req == PRU_SEND ? "SEND" : - req == PRU_ABORT ? "ABORT" : - req == PRU_CONTROL ? "CONTROL" : - req == PRU_SENSE ? "SENSE" : - req == PRU_RCVOOB ? "RCVOOB" : - req == PRU_SENDOOB ? "SENDOOB" : - req == PRU_SOCKADDR ? "SOCKADDR" : - req == PRU_PEERADDR ? "PEERADDR" : - req == PRU_CONNECT2 ? "CONNECT2" : - req == PRU_FASTTIMO ? "FASTTIMO" : - req == PRU_SLOWTIMO ? "SLOWTIMO" : - req == PRU_PROTORCV ? "PROTORCV" : - req == PRU_PROTOSEND ? "PROTOSEND" : - req == PRU_SEND ? "SEND_EOF" : - req == PRU_SOSETLABEL ? "SOSETLABEL" : - req == PRU_CLOSE ? "CLOSE" : - req == PRU_FLUSH ? "FLUSE" : + req == PRU_ATTACH ? "ATTACH" : + req == PRU_DETACH ? "DETACH" : + req == PRU_BIND ? "BIND" : + req == PRU_LISTEN ? "LISTEN" : + req == PRU_CONNECT ? "CONNECT" : + req == PRU_ACCEPT ? "ACCEPT" : + req == PRU_DISCONNECT ? "DISCONNECT" : + req == PRU_SHUTDOWN ? "SHUTDOWN" : + req == PRU_RCVD ? "RCVD" : + req == PRU_SEND ? "SEND" : + req == PRU_ABORT ? "ABORT" : + req == PRU_CONTROL ? "CONTROL" : + req == PRU_SENSE ? "SENSE" : + req == PRU_RCVOOB ? "RCVOOB" : + req == PRU_SENDOOB ? "SENDOOB" : + req == PRU_SOCKADDR ? "SOCKADDR" : + req == PRU_PEERADDR ? "PEERADDR" : + req == PRU_CONNECT2 ? "CONNECT2" : + req == PRU_FASTTIMO ? "FASTTIMO" : + req == PRU_SLOWTIMO ? "SLOWTIMO" : + req == PRU_PROTORCV ? "PROTORCV" : + req == PRU_PROTOSEND ? "PROTOSEND" : + req == PRU_SEND ? "SEND_EOF" : + req == PRU_SOSETLABEL ? "SOSETLABEL" : + req == PRU_CLOSE ? "CLOSE" : + req == PRU_FLUSH ? "FLUSE" : "unknown" ; Modified: stable/11/cddl/lib/libdtrace/udp.d ============================================================================== --- stable/11/cddl/lib/libdtrace/udp.d Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/lib/libdtrace/udp.d Tue May 15 00:00:44 2018 (r333617) @@ -47,7 +47,7 @@ typedef struct udpinfo { uint16_t udp_sport; /* source port */ uint16_t udp_dport; /* destination port */ uint16_t udp_length; /* total length */ - uint16_t udp_checksum; /* headers + data checksum */ + uint16_t udp_checksum; /* headers + data checksum */ struct udphdr *udp_hdr; /* raw UDP header */ } udpinfo_t; Modified: stable/11/cddl/usr.sbin/Makefile ============================================================================== --- stable/11/cddl/usr.sbin/Makefile Mon May 14 23:12:30 2018 (r333616) +++ stable/11/cddl/usr.sbin/Makefile Tue May 15 00:00:44 2018 (r333617) @@ -3,6 +3,7 @@ .include <src.opts.mk> SUBDIR= ${_dtrace} \ + ${_dwatch} \ ${_lockstat} \ ${_plockstat} \ ${_tests} \ @@ -26,6 +27,7 @@ _zfsd= zfsd .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" _dtrace= dtrace +_dwatch= dwatch _lockstat= lockstat _plockstat= plockstat .endif @@ -33,15 +35,18 @@ _plockstat= plockstat .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \ ${MACHINE_CPUARCH} == "riscv" _dtrace= dtrace +_dwatch= dwatch _lockstat= lockstat .endif .if ${MACHINE_CPUARCH} == "mips" _dtrace= dtrace +_dwatch= dwatch .endif .if ${MACHINE_CPUARCH} == "powerpc" _dtrace= dtrace +_dwatch= dwatch _lockstat= lockstat .endif Modified: stable/11/cddl/usr.sbin/dwatch/dwatch ============================================================================== --- head/cddl/usr.sbin/dwatch/dwatch Tue Mar 6 23:44:19 2018 (r330559) +++ stable/11/cddl/usr.sbin/dwatch/dwatch Tue May 15 00:00:44 2018 (r333617) @@ -47,7 +47,7 @@ DTRACE_PRAGMA=" ############################################################ GLOBALS -VERSION='$Version: 1.0-beta-91 $' # -V +VERSION='$Version: 1.2 $' # -V pgm="${0##*/}" # Program basename @@ -57,6 +57,12 @@ pgm="${0##*/}" # Program basename PROBE_ARG= # +# Command-line defaults +# +_MAX_ARGS=64 # -B num +_MAX_DEPTH=64 # -K num + +# # Command-line options # CONSOLE= # -y @@ -67,6 +73,7 @@ CUSTOM_DETAILS= # -E code CUSTOM_TEST= # -t test DEBUG= # -d DESTRUCTIVE_ACTIONS= # -w +DEVELOPER= # -dev EXECNAME= # -k name EXECREGEX= # -z regex EXIT_AFTER_COMPILE= # -e @@ -76,8 +83,8 @@ GROUP= # -g group JID= # -j jail LIST= # -l LIST_PROFILES= # -Q -MAX_ARGS=64 # -B num -MAX_DEPTH=64 # -K num +MAX_ARGS=$_MAX_ARGS # -B num +MAX_DEPTH=$_MAX_DEPTH # -K num ONELINE= # -1 OUTPUT= # -o file OUTPUT_CMD= # -O cmd @@ -143,7 +150,7 @@ usage() printf "$optfmt" "-1" \ "Print one line per process/profile (Default; disables \`-R')." printf "$optfmt" "-B num" \ - "Maximum process arguments to display (Default $MAX_ARGS)." + "Maximum process arguments to display (Default $_MAX_ARGS)." printf "$optfmt" "-d" \ "Debug. Send dtrace(1) script to stdout instead of executing." printf "$optfmt" "-e" \ @@ -161,7 +168,7 @@ usage() printf "$optfmt" "-k name" \ "Only show processes matching name." printf "$optfmt" "-K num" \ - "Maximum directory depth to display (Default $MAX_DEPTH)." + "Maximum directory depth to display (Default $_MAX_DEPTH)." printf "$optfmt" "-l" \ "List available probes on standard output and exit." printf "$optfmt" "-m" \ @@ -489,8 +496,7 @@ list_profiles() function ans(s) { return cons ? "\033[" s "m" : "" } gsub(filter, ans("31;1") "&" ans("39;22")) ' # END-QUOTE - return $SUCCESS - # NOTREACHED + exit $SUCCESS fi [ "$quiet" ] || echo PROFILES: @@ -531,6 +537,11 @@ list_profiles() exit $SUCCESS } +shell_escape() +{ + echo "$*" | awk 'gsub(/'\''/, "&\\\\&&")||1' +} + load_profile() { local profile="$1" @@ -540,7 +551,45 @@ load_profile() local oldIFS="$IFS" local dir found= + local ARGV= + [ $COUNT -gt 0 ] && ARGV="$ARGV -N $COUNT" + [ "$DEBUG" ] && ARGV="$ARGV -d" + [ "$DESTRUCTIVE_ACTIONS" ] && ARGV="$ARGV -w" + [ "$EXIT_AFTER_COMPILE" ] && ARGV="$ARGV -e" + [ "$GROUP" ] && ARGV="$ARGV -g $GROUP" + [ "$JID" ] && ARGV="$ARGV -j $JID" + [ $MAX_ARGS -ne $_MAX_ARGS ] && ARGV="$ARGV -B $MAX_ARGS" + [ $MAX_DEPTH -ne $_MAX_DEPTH ] && ARGV="$ARGV -K $MAX_DEPTH" + [ "$ONELINE" ] && ARGV="$ARGV -1" + [ "$PID" ] && ARGV="$ARGV -p $PID" + [ "$PSTREE" ] && ARGV="$ARGV -R" + [ "$QUIET" ] && ARGV="$ARGV -q" + [ "$TIMEOUT" ] && ARGV="$ARGV -T $TIMEOUT" + [ "$TRACE" ] && ARGV="$ARGV -x" + [ "$USER" ] && ARGV="$ARGV -u $USER" + [ "$VERBOSE" ] && ARGV="$ARGV -v" + + [ "$FILTER" ] && + ARGV="$ARGV -r '$( shell_escape "$FILTER" )'" + [ "$EXECREGEX" ] && + ARGV="$ARGV -z '$( shell_escape "$EXECREGEX" )'" + [ "$CUSTOM_DETAILS" ] && + ARGV="$ARGV -E '$( shell_escape "$EVENT_DETAILS" )'" + [ "$EVENT_TEST" ] && + ARGV="$ARGV -t '$( shell_escape "$EVENT_TEST" )'" + [ "$OUTPUT" ] && + ARGV="$ARGV -o '$( shell_escape "$OUTPUT" )'" + [ "$OUTPUT_CMD" ] && + ARGV="$ARGV -O '$( shell_escape "$OUTPUT_CMD" )'" + + case "$PROBE_TYPE" in + provider) ARGV="$ARGV -P" ;; + module) ARGV="$ARGV -m" ;; + function) ARGV="$ARGV -f" ;; + name) ARGV="$ARGV -n" ;; + esac + IFS=: for dir in $DWATCH_PROFILES_PATH; do [ -d "$dir" ] || continue @@ -835,6 +884,11 @@ if [ "$PROBE_ARG" ]; then fi # +# Developer switch +# +[ "$DEBUG" -a "$EXIT_AFTER_COMPILE" -a "$VERBOSE" ] && DEVELOPER=1 DEBUG= + +# # Set default event details if `-E code' was not given # [ "$CUSTOM_DETAILS" ] || EVENT_DETAILS=$( pproc_dump 0 ) @@ -848,7 +902,7 @@ fi # # Show the user what's being watched # -[ "$DEBUG$QUIET$EXIT_AFTER_COMPILE" ] || info "Watching '$PROBE' ..." +[ "$DEBUG$EXIT_AFTER_COMPILE" ] || info "Watching '$PROBE' ..." # # Header for watched probe entry @@ -966,6 +1020,61 @@ PSARGS_ACTION=$( cat <&9 ) exec 3>&1 console_stdout=3 + # + # Developer debugging aide + # + if [ "$DEVELOPER" ]; then + # + # Run, capture the error line, and focus it + # + # Example error text to capture line number from: + # dtrace: failed to compile script /dev/stdin: line 669: ... + # + errline= + stdin_buf=$( cat ) + stderr_buf=$( echo "$stdin_buf" | + dtrace_cmd -t -es /dev/stdin "$@" 2>&1 > /dev/null ) + status=$? + if [ "$stderr_buf" ]; then + errline=$( echo "$stderr_buf" | awk ' + BEGIN { + ti = "\033[31m" + te = "\033[39m" + } + { line = $0 } + sub(/.*: line /, "") && sub(/:.*/, "") { + print # to errline + sub("line " $0, ti "&" te, line) + } + { print line > "/dev/stderr" } + ' 2>&3 ) + fi + if [ "$errline" ]; then + echo "$stdin_buf" | awk -v line="${errline%%[^0-9]*}" ' + BEGIN { + start = line < 10 ? 1 : line - 10 + end = line + 10 + slen = length(sprintf("%u", start)) + elen = length(sprintf("%u", end)) + N = elen > slen ? elen : slen + for (i = start; i <= end; i++) { + ti[i] = "\033[2m" + te[i] = "\033[22m" + } + ti[line] = "\033[31m" + te[line] = "\033[39m" + fmt = "%s%*u %s%s\n" + } + NR < start { next } + NR == start, NR == end { + printf(fmt, ti[NR], N, NR, $0, te[NR]) + } + NR > end { exit } + ' # END-QUOTE + fi + exit $status + fi + if [ $COUNT -eq 0 -a ! "$EXECREGEX$FILTER$GROUP$OUTPUT_CMD$PID$USER" ] then case "$OUTPUT" in @@ -1285,6 +1394,7 @@ $( pproc_dump -v 3 )} } EOF +# NOTREACHED ################################################################################ # END Modified: stable/11/cddl/usr.sbin/dwatch/libexec/Makefile ============================================================================== --- head/cddl/usr.sbin/dwatch/libexec/Makefile Tue Mar 6 23:44:19 2018 (r330559) +++ stable/11/cddl/usr.sbin/dwatch/libexec/Makefile Tue May 15 00:00:44 2018 (r333617) @@ -11,6 +11,7 @@ FILES= chmod \ proc \ rw \ sched \ + sendrecv \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805150000.w4F00imB051812>