summaryrefslogtreecommitdiff
path: root/lib/libc/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-06-01 09:49:54 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-06-01 09:49:54 +0000
commita275d1d143573a3af196681dd301130c293de367 (patch)
tree56040e0e516d6f3b13a85043d3031df102cca766 /lib/libc/sys
parenteab181d9ad5afedec5a0231154a2c2f7b0298215 (diff)
Add utrace(2), a system call allowing for userland to send its own ktrace
records. From FreeBSD via otto@, with tweaks suggested by guenther@. Commite on behalf of otto@ who is not around, to ride the libc minor bump. Causes a librthread minor bump as well (new syscall).
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/Makefile.inc6
-rw-r--r--lib/libc/sys/ktrace.211
-rw-r--r--lib/libc/sys/utrace.288
3 files changed, 99 insertions, 6 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 57f76b8fb16..b26ccc211af 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.111 2013/04/29 17:06:20 matthew Exp $
+# $OpenBSD: Makefile.inc,v 1.112 2013/06/01 09:49:53 miod Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@@ -56,7 +56,7 @@ ASM= __get_tcb.o __getcwd.o __semctl.o __set_tcb.o __syscall.o \
shmget.o shutdown.o sigaction.o sigaltstack.o socket.o \
socketpair.o stat.o statfs.o swapctl.o symlink.o \
symlinkat.o sync.o sysarch.o umask.o unlink.o unlinkat.o \
- unmount.o utimensat.o utimes.o wait4.o write.o writev.o
+ unmount.o utimensat.o utimes.o utrace.o wait4.o write.o writev.o
# modules with specific implementations on some architectures, and the
# default implementation elsewhere:
@@ -195,7 +195,7 @@ MAN+= __get_tcb.2 __thrsigdivert.2 __thrsleep.2 _exit.2 accept.2 \
sigprocmask.2 sigreturn.2 sigsuspend.2 socket.2 \
socketpair.2 stat.2 statfs.2 swapctl.2 symlink.2 \
sync.2 sysarch.2 syscall.2 truncate.2 umask.2 unlink.2 \
- utimes.2 vfork.2 wait.2 write.2
+ utimes.2 utrace.2 vfork.2 wait.2 write.2
MLINKS+=__get_tcb.2 __set_tcb.2
MLINKS+=__thrsleep.2 __thrwakeup.2
diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2
index 594a3591334..dcf8dfad10f 100644
--- a/lib/libc/sys/ktrace.2
+++ b/lib/libc/sys/ktrace.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ktrace.2,v 1.22 2012/11/29 02:35:04 guenther Exp $
+.\" $OpenBSD: ktrace.2,v 1.23 2013/06/01 09:49:53 miod Exp $
.\" $NetBSD: ktrace.2,v 1.2 1995/02/27 12:33:58 cgd Exp $
.\"
.\" Copyright (c) 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd $Mdocdate: November 29 2012 $
+.Dd $Mdocdate: June 1 2013 $
.Dt KTRACE 2
.Os
.Sh NAME
@@ -110,6 +110,10 @@ Trace emulation changes.
Trace context switch points.
.It Dv KTRFAC_STRUCT
Trace various structs
+.It Dv KTRFAC_USER
+Trace user data coming from
+.Xr utrace 2
+calls.
.It Dv KTRFAC_INHERIT
Inherit tracing to future children.
.El
@@ -188,7 +192,8 @@ No process can be found corresponding to that specified by
.El
.Sh SEE ALSO
.Xr kdump 1 ,
-.Xr ktrace 1
+.Xr ktrace 1 ,
+.Xr utrace 2
.Sh HISTORY
A
.Fn ktrace
diff --git a/lib/libc/sys/utrace.2 b/lib/libc/sys/utrace.2
new file mode 100644
index 00000000000..a646f9f8500
--- /dev/null
+++ b/lib/libc/sys/utrace.2
@@ -0,0 +1,88 @@
+.\" $OpenBSD: utrace.2,v 1.1 2013/06/01 09:49:53 miod Exp $
+.\" $NetBSD: utrace.2,v 1.13 2008/05/02 18:38:32 martin Exp $
+.\"
+.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry <g.mcgarry@ieee.org>.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd $Mdocdate: June 1 2013 $
+.Dt UTRACE 2
+.Os
+.Sh NAME
+.Nm utrace
+.Nd insert user record in ktrace log
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/param.h
+.In sys/uio.h
+.In sys/ktrace.h
+.Ft int
+.Fn utrace "const char *label" "void *addr" "size_t len"
+.Sh DESCRIPTION
+Adds a record to the process trace with information supplied by the user.
+The record is identified by
+.Fa label
+and contains
+.Fa len
+bytes from memory pointed to by
+.Fa addr .
+This call only has an effect if the calling process is being traced.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er ENOSYS
+The currently running kernel was compiled without
+.Xr ktrace 2
+support (option KTRACE).
+.It Bq Er ENAMETOOLONG
+The length of the
+.Fa label
+string was longer than
+.Dv KTR_USER_MAXIDLEN\-1 .
+.It Bq Er EINVAL
+The specified data length
+.Fa len
+was bigger than
+.Dv KTR_USER_MAXLEN .
+.El
+.Sh SEE ALSO
+.Xr kdump 1 ,
+.Xr ktrace 1 ,
+.Xr ktrace 2 ,
+.Xr options 4
+.Sh HISTORY
+The
+.Fn utrace
+system call first appeared in
+.Fx 2.2 .
+It was added to
+.Ox
+in
+.Ox 5.4 .
+The
+.Fa label
+argument is an extension.