1 # -*- tab-width: 4 -*- ;; Emacs
2 # vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3 ############################################################ IDENT(1)
5 # $Title: dwatch(8) module for read(2), write(2), or similar entry $
6 # $Copyright: 2014-2018 Devin Teske. All rights reserved. $
9 ############################################################ DESCRIPTION
11 # Display data sent/received when read(2)/write(2) occurs
13 ############################################################ PROBE
16 rw) : ${PROBE:=syscall::read:entry, syscall::write:entry} ;;
17 *) : ${PROBE:=syscall::$PROFILE:entry}
20 ############################################################ ACTIONS
29 $PROBE /* probe ID $ID */
36 this->flow = probefunc == "read" ? "<-" : "->";
37 this->buf = (void *)arg1;
38 this->nbytes = (size_t)arg2;
41 * Allocate temporary memory for, copy, and NUL-terminate the data
43 this->data = alloca(this->nbytes + 1);
44 copyinto((uintptr_t)this->buf, this->nbytes, this->data);
45 bcopy("\0", (void *)((uintptr_t)this->data + this->nbytes), 1);
48 * Extract string from temporary memory
50 this->bufstr = stringof(this->data);
56 ############################################################ EVENT DETAILS
58 if [ ! "$CUSTOM_DETAILS" ]; then
61 * Print read/write details
63 printf("%s \"%s\" %d byte%s",
67 this->nbytes == 1 ? "" : "s");
69 EVENT_DETAILS=$( cat <&9 )
72 ################################################################################
74 ################################################################################