Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174749635
D4537.id11179.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D4537.id11179.diff
View Options
Index: contrib/mdocml/lib.in
===================================================================
--- contrib/mdocml/lib.in
+++ contrib/mdocml/lib.in
@@ -110,6 +110,7 @@
LINE("libssp", "Buffer Overflow Protection Library (libssp, \\-lssp)")
LINE("libstdthreads", "C11 Threads Library (libstdthreads, \\-lstdthreads)")
LINE("libSystem", "System Library (libSystem, \\-lSystem)")
+LINE("libsysdcode", "System Argument Decoding Library (libsysdecode, \\-lsysdecode)")
LINE("libtacplus", "TACACS+ Client Library (libtacplus, \\-ltacplus)")
LINE("libtcplay", "TrueCrypt-compatible API library (libtcplay, \\-ltcplay)")
LINE("libtermcap", "Termcap Access Library (libtermcap, \\-ltermcap)")
Index: lib/Makefile
===================================================================
--- lib/Makefile
+++ lib/Makefile
@@ -98,6 +98,7 @@
libstand \
libstdbuf \
libstdthreads \
+ libsysdecode \
libtacplus \
${_libtelnet} \
${_libthr} \
Index: lib/libc/sys/utrace.2
===================================================================
--- lib/libc/sys/utrace.2
+++ lib/libc/sys/utrace.2
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 5, 2015
+.Dd December 11, 2015
.Dt UTRACE 2
.Os
.Sh NAME
@@ -71,7 +71,8 @@
.Xr kdump 1 ,
.Xr ktrace 1 ,
.Xr ktrace 2 ,
-.Xr truss 1
+.Xr truss 1 ,
+.Xr sysdecode_utrace 3
.Sh HISTORY
The
.Fn utrace
Index: lib/libsysdecode/Makefile
===================================================================
--- /dev/null
+++ lib/libsysdecode/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+LIB= sysdecode
+
+SRCS= utrace.c
+INCS= sysdecode.h
+
+MAN+= sysdecode.3 \
+# sysdecode_utrace.3
+
+.include <bsd.lib.mk>
Index: lib/libsysdecode/sysdecode.h
===================================================================
--- /dev/null
+++ lib/libsysdecode/sysdecode.h
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2015 John H. Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * 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 AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __SYSDECODE_H__
+#define __SYSDECODE_H__
+
+int sysdecode_utrace(FILE *_fp, void *_buf, size_t _len);
+
+#endif /* !__SYSDECODE_H__ */
Index: lib/libsysdecode/sysdecode.3
===================================================================
--- /dev/null
+++ lib/libsysdecode/sysdecode.3
@@ -0,0 +1,47 @@
+.\"
+.\" Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" 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 AUTHOR 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 AUTHOR 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 10, 2015
+.Dt SYSDECODE 3
+.Os
+.Sh NAME
+.Nm sysdecode
+.Nd system argument decoding library
+.Sh LIBRARY
+.Lb libsysdecode
+.Sh DESCRIPTION
+The
+.Nm
+library includes several functions that provide descriptive names of
+values associated with system calls.
+.Sh SEE ALSO
+.Xr sysdecode_utrace 3
+.Sh HISTORY
+The
+.Nm
+library first appeared in
+.Fx 11.0 .
Index: lib/libsysdecode/sysdecode_utrace.3
===================================================================
--- /dev/null
+++ lib/libsysdecode/sysdecode_utrace.3
@@ -0,0 +1,73 @@
+.\"
+.\" Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" 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 AUTHOR 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 AUTHOR 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 11, 2015
+.Dt sysdecode_utrace 3
+.Os
+.Sh NAME
+.Nm sysdecode_utrace
+.Nd produce text description of a utrace record
+.Sh LIBRARY
+.Lb libsysdecode
+.Sh SYNOPSIS
+.Ft int
+.Fn sysdecode_utrace "FILE *fp" "void *buf" "size_t len" "int decimal"
+.Sh DESCRIPTION
+The
+.Fn sysdecode_utrace
+function outputs a textual representation of a
+.Xr utrace 2
+record identified by
+.Fa buf
+and
+.Fa len
+to the output stream
+.Fa fp .
+.Pp
+The function only outputs a representation for certain types of records.
+If a record is recognized,
+the function outputs the description and returns a non-zero value.
+If the record is not recognized,
+the function does not output anything and returns zero.
+The
+.Fn sysdecode_utrace
+function currently recognizes
+.Xr utrace 2
+records generated by
+.Xr malloc 3
+and
+.Xr rtld 1 .
+.Sh RETURN VALUES
+The
+.Fn sysdecode_utrace
+function returns a non-zero value if it recognizes a
+.Xr utrace 2
+record;
+otherwise it returns zero.
+.Sh SEE ALSO
+.Xr utrace 2 ,
+.Xr sysdecode 3
Index: lib/libsysdecode/utrace.c
===================================================================
--- lib/libsysdecode/utrace.c
+++ lib/libsysdecode/utrace.c
@@ -34,8 +34,7 @@
#include <dlfcn.h>
#include <stdio.h>
#include <strings.h>
-
-int kdump_print_utrace(FILE *, void *, size_t, int);
+#include <sysdecode.h>
#define UTRACE_DLOPEN_START 1
#define UTRACE_DLOPEN_STOP 2
@@ -60,11 +59,10 @@
char name[MAXPATHLEN];
};
-static void
-print_utrace_rtld(FILE *fp, void *p, size_t len, int decimal)
+static int
+print_utrace_rtld(FILE *fp, void *p)
{
struct utrace_rtld *ut = p;
- unsigned char *cp;
void *parent;
int mode;
@@ -136,16 +134,9 @@
ut->name);
break;
default:
- cp = p;
- cp += 4;
- len -= 4;
- fprintf(fp, "RTLD: %zu ", len);
- while (len--)
- if (decimal)
- fprintf(fp, " %d", *cp++);
- else
- fprintf(fp, " %02x", *cp++);
+ return (0);
}
+ return (1);
}
struct utrace_malloc {
@@ -170,12 +161,11 @@
}
int
-kdump_print_utrace(FILE *fp, void *p, size_t len, int decimal)
+sysdecode_utrace(FILE *fp, void *p, size_t len)
{
- if (len >= 8 && bcmp(p, "RTLD", 4) == 0) {
- print_utrace_rtld(fp, p, len, decimal);
- return (1);
+ if (len == sizeof(struct utrace_rtld) && bcmp(p, "RTLD", 4) == 0) {
+ return (print_utrace_rtld(fp, p));
}
if (len == sizeof(struct utrace_malloc)) {
Index: share/mk/bsd.libnames.mk
===================================================================
--- share/mk/bsd.libnames.mk
+++ share/mk/bsd.libnames.mk
@@ -134,6 +134,7 @@
LIBSTAND?= ${DESTDIR}${LIBDIR}/libstand.a
LIBSTDCPLUSPLUS?= ${DESTDIR}${LIBDIR}/libstdc++.a
LIBSTDTHREADS?= ${DESTDIR}${LIBDIR}/libstdthreads.a
+LIBSYSDECODE?= ${DESTDIR}${LIBDIR}/libsysdecode.a
LIBTACPLUS?= ${DESTDIR}${LIBDIR}/libtacplus.a
LIBTERMCAP?= ${DESTDIR}${LIBDIR}/libtermcap.a
LIBTERMCAPW?= ${DESTDIR}${LIBDIR}/libtermcapw.a
Index: share/mk/src.libnames.mk
===================================================================
--- share/mk/src.libnames.mk
+++ share/mk/src.libnames.mk
@@ -148,6 +148,7 @@
ssp_nonshared \
stdthreads \
supcplusplus \
+ sysdecode \
tacplus \
termcapw \
ufs \
Index: usr.bin/kdump/Makefile
===================================================================
--- usr.bin/kdump/Makefile
+++ usr.bin/kdump/Makefile
@@ -6,11 +6,12 @@
.PATH: ${.CURDIR}/../ktrace
PROG= kdump
-SRCS= kdump_subr.c kdump_subr.h kdump.c ioctl.c subr.c utrace.c
+SRCS= kdump_subr.c kdump_subr.h kdump.c ioctl.c subr.c
CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
+LIBADD= sysdecode
.if ${MK_CASPER} != "no"
-LIBADD= capsicum
+LIBADD+= capsicum
CFLAGS+=-DHAVE_LIBCAPSICUM
.endif
Index: usr.bin/kdump/kdump.c
===================================================================
--- usr.bin/kdump/kdump.c
+++ usr.bin/kdump/kdump.c
@@ -83,6 +83,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysdecode.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
@@ -116,7 +117,6 @@
void limitfd(int fd);
void usage(void);
void ioctlname(unsigned long, int);
-int kdump_print_utrace(FILE *, void *, size_t, int);
#define TIMESTAMP_NONE 0x0
#define TIMESTAMP_ABSOLUTE 0x1
@@ -1541,7 +1541,7 @@
{
unsigned char *cp;
- if (kdump_print_utrace(stdout, p, len, decimal)) {
+ if (sysdecode_utrace(stdout, p, len)) {
printf("\n");
return;
}
Index: usr.bin/truss/Makefile
===================================================================
--- usr.bin/truss/Makefile
+++ usr.bin/truss/Makefile
@@ -4,8 +4,7 @@
PROG= truss
SRCS= cloudabi.c ioctl.c main.c setup.c syscalls.c
-.PATH: ${.CURDIR:H}/kdump
-SRCS+= utrace.c
+LIBADD= sysdecode
CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys
CLEANFILES= ioctl.c
Index: usr.bin/truss/syscalls.c
===================================================================
--- usr.bin/truss/syscalls.c
+++ usr.bin/truss/syscalls.c
@@ -65,6 +65,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysdecode.h>
#include <time.h>
#include <unistd.h>
#include <vis.h>
@@ -75,9 +76,6 @@
#include "extern.h"
#include "syscall.h"
-/* usr.bin/kdump/utrace.c */
-int kdump_print_utrace(FILE *, void *, size_t, int);
-
/* 64-bit alignment on 32-bit platforms. */
#if !defined(__LP64__) && defined(__powerpc__)
#define QUAD_ALIGN 1
@@ -1108,7 +1106,7 @@
unsigned char *utrace_buffer;
fprintf(fp, "{ ");
- if (kdump_print_utrace(fp, utrace_addr, len, 0)) {
+ if (sysdecode_utrace(fp, utrace_addr, len)) {
fprintf(fp, " }");
return;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 6, 5:44 PM (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40308177
Default Alt Text
D4537.id11179.diff (12 KB)
Attached To
Mode
D4537: Move shared utrace code from kdump and truss to a new libsysdecode library.
Attached
Detach File
Event Timeline
Log In to Comment