Deleted Added
sdiff udiff text old ( 269272 ) new ( 294368 )
full compact
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 *
21 * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
22 *
23 * $FreeBSD: stable/10/sys/cddl/dev/systrace/systrace.c 294368 2016-01-20 01:09:53Z jhb $
24 *
25 */
26
27/*
28 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
30 */
31

--- 23 unchanged lines hidden (view full) ---

55#include <sys/uio.h>
56#include <sys/unistd.h>
57#include <machine/stdarg.h>
58
59#include <sys/dtrace.h>
60
61#ifdef LINUX_SYSTRACE
62#if defined(__amd64__)
63#include
64#include <amd64/linux/linux_proto.h>
65#include <amd64/linux/linux_syscalls.c>
66#include <amd64/linux/linux_systrace_args.c>
67#elif defined(__i386__)
68#include <i386/linux/linux.h>
69#include <i386/linux/linux_proto.h>
70#include <i386/linux/linux_syscalls.c>
71#include <i386/linux/linux_systrace_args.c>
72#else
73#error Only i386 and amd64 are supported.
74#endif
75#define MODNAME "linux"
76extern struct sysent linux_sysent[];
77#define MAXSYSCALL LINUX_SYS_MAXSYSCALL
78#define SYSCALLNAMES linux_syscallnames
79#define SYSENT linux_sysent
80#elif defined(LINUX32_SYSTRACE)
81#if defined(__amd64__)
82#include <amd64/linux32/linux.h>
83#include <amd64/linux32/linux32_proto.h>
84#include <amd64/linux32/linux32_syscalls.c>
85#include <amd64/linux32/linux32_systrace_args.c>
86#else
87#error Only amd64 is supported.
88#endif
89#define MODNAME "linux32"
90extern struct sysent linux32_sysent[];
91#define MAXSYSCALL LINUX32_SYS_MAXSYSCALL
92#define SYSCALLNAMES linux32_syscallnames
93#define SYSENT linux32_sysent
94#elif defined(FREEBSD32_SYSTRACE)
95/*
96 * The syscall arguments are processed into a DTrace argument array
97 * using a generated function. See sys/kern/makesyscalls.sh.
98 */
99#include <compat/freebsd32/freebsd32_proto.h>
100#include <compat/freebsd32/freebsd32_util.h>
101#include <compat/freebsd32/freebsd32_syscall.h>

--- 9 unchanged lines hidden (view full) ---

111 * using a generated function. See sys/kern/makesyscalls.sh.
112 */
113#include <sys/syscall.h>
114#include <kern/systrace_args.c>
115#define MODNAME "freebsd"
116#define MAXSYSCALL SYS_MAXSYSCALL
117#define SYSCALLNAMES syscallnames
118#define SYSENT sysent
119#define NATIVE_ABI
120#endif
121
122#define PROVNAME "syscall"
123#define DEVNAME "dtrace/systrace/" MODNAME
124
125#define SYSTRACE_ARTIFICIAL_FRAMES 1
126
127#define SYSTRACE_SHIFT 16

--- 13 unchanged lines hidden (view full) ---

141static void systrace_destroy(void *, dtrace_id_t, void *);
142static void systrace_enable(void *, dtrace_id_t, void *);
143static void systrace_disable(void *, dtrace_id_t, void *);
144static void systrace_load(void *);
145
146static struct cdevsw systrace_cdevsw = {
147 .d_version = D_VERSION,
148 .d_open = systrace_open,
149#ifndef NATIVE_ABI
150 .d_name = "systrace_" MODNAME,
151#else
152 .d_name = "systrace",
153#endif
154};
155
156static union {
157 const char **p_constnames;

--- 22 unchanged lines hidden (view full) ---

180};
181
182static struct cdev *systrace_cdev;
183static dtrace_provider_id_t systrace_id;
184
185typedef void (*systrace_dtrace_probe_t)(dtrace_id_t, uintptr_t, uintptr_t,
186 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
187
188#ifdef NATIVE_ABI
189/*
190 * Probe callback function.
191 *
192 * Note: This function is called for _all_ syscalls, regardless of which sysent
193 * array the syscall comes from. It could be a standard syscall or a
194 * compat syscall from something like Linux.
195 */
196static void

--- 126 unchanged lines hidden (view full) ---

323 /* Create the /dev/dtrace/systrace entry. */
324 systrace_cdev = make_dev(&systrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
325 DEVNAME);
326
327 if (dtrace_register(PROVNAME, &systrace_attr, DTRACE_PRIV_USER,
328 NULL, &systrace_pops, NULL, &systrace_id) != 0)
329 return;
330
331#ifdef NATIVE_ABI
332 systrace_probe_func = systrace_probe;
333#endif
334}
335
336
337static int
338systrace_unload()
339{
340 int error = 0;
341
342 if ((error = dtrace_unregister(systrace_id)) != 0)
343 return (error);
344
345#ifdef NATIVE_ABI
346 systrace_probe_func = NULL;
347#endif
348
349 destroy_dev(systrace_cdev);
350
351 return (error);
352}
353

--- 25 unchanged lines hidden (view full) ---

379{
380 return (0);
381}
382
383SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL);
384SYSUNINIT(systrace_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_unload, NULL);
385
386#ifdef LINUX_SYSTRACE
387DEV_MODULE(systrace_linux, systrace_modevent, NULL);
388MODULE_VERSION(systrace_linux, 1);
389#ifdef __amd64__
390MODULE_DEPEND(systrace_linux, linux64, 1, 1, 1);
391#else
392MODULE_DEPEND(systrace_linux, linux, 1, 1, 1);
393#endif
394MODULE_DEPEND(systrace_linux, dtrace, 1, 1, 1);
395MODULE_DEPEND(systrace_linux, opensolaris, 1, 1, 1);
396#elif defined(LINUX32_SYSTRACE)
397DEV_MODULE(systrace_linux32, systrace_modevent, NULL);
398MODULE_VERSION(systrace_linux32, 1);
399MODULE_DEPEND(systrace_linux32, linux, 1, 1, 1);
400MODULE_DEPEND(systrace_linux32, dtrace, 1, 1, 1);
401MODULE_DEPEND(systrace_linux32, opensolaris, 1, 1, 1);
402#elif defined(FREEBSD32_SYSTRACE)
403DEV_MODULE(systrace_freebsd32, systrace_modevent, NULL);
404MODULE_VERSION(systrace_freebsd32, 1);
405MODULE_DEPEND(systrace_freebsd32, dtrace, 1, 1, 1);
406MODULE_DEPEND(systrace_freebsd32, opensolaris, 1, 1, 1);
407#else
408DEV_MODULE(systrace, systrace_modevent, NULL);
409MODULE_VERSION(systrace, 1);
410MODULE_DEPEND(systrace, dtrace, 1, 1, 1);
411MODULE_DEPEND(systrace, opensolaris, 1, 1, 1);
412#endif