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 269272 2014-07-29 22:26:41Z markj $
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 <amd64/linux32/linux.h>
64#include <amd64/linux32/linux32_proto.h>
65#include <amd64/linux32/linux32_syscalls.c>
66#include <amd64/linux32/linux32_systrace_args.c>
67#define MODNAME "linux32"
68#elif defined(__i386__)
69#include <i386/linux/linux.h>
70#include <i386/linux/linux_proto.h>
71#include <i386/linux/linux_syscalls.c>
72#include <i386/linux/linux_systrace_args.c>
73#define MODNAME "linux"
74#else
75#error Only i386 and amd64 are supported.
76#endif
77extern struct sysent linux_sysent[];
78#define MAXSYSCALL LINUX_SYS_MAXSYSCALL
79#define SYSCALLNAMES linux_syscallnames
80#define SYSENT linux_sysent
81#elif defined(FREEBSD32_SYSTRACE)
82/*
83 * The syscall arguments are processed into a DTrace argument array
84 * using a generated function. See sys/kern/makesyscalls.sh.
85 */
86#include <compat/freebsd32/freebsd32_proto.h>
87#include <compat/freebsd32/freebsd32_util.h>
88#include <compat/freebsd32/freebsd32_syscall.h>

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

98 * using a generated function. See sys/kern/makesyscalls.sh.
99 */
100#include <sys/syscall.h>
101#include <kern/systrace_args.c>
102#define MODNAME "freebsd"
103#define MAXSYSCALL SYS_MAXSYSCALL
104#define SYSCALLNAMES syscallnames
105#define SYSENT sysent
106#endif
107
108#define PROVNAME "syscall"
109#define DEVNAME "dtrace/systrace/" MODNAME
110
111#define SYSTRACE_ARTIFICIAL_FRAMES 1
112
113#define SYSTRACE_SHIFT 16

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

127static void systrace_destroy(void *, dtrace_id_t, void *);
128static void systrace_enable(void *, dtrace_id_t, void *);
129static void systrace_disable(void *, dtrace_id_t, void *);
130static void systrace_load(void *);
131
132static struct cdevsw systrace_cdevsw = {
133 .d_version = D_VERSION,
134 .d_open = systrace_open,
135#ifdef LINUX_SYSTRACE
136 .d_name = "systrace_" MODNAME,
137#else
138 .d_name = "systrace",
139#endif
140};
141
142static union {
143 const char **p_constnames;

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

166};
167
168static struct cdev *systrace_cdev;
169static dtrace_provider_id_t systrace_id;
170
171typedef void (*systrace_dtrace_probe_t)(dtrace_id_t, uintptr_t, uintptr_t,
172 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
173
174#if !defined(LINUX_SYSTRACE)
175/*
176 * Probe callback function.
177 *
178 * Note: This function is called for _all_ syscalls, regardless of which sysent
179 * array the syscall comes from. It could be a standard syscall or a
180 * compat syscall from something like Linux.
181 */
182static void

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

309 /* Create the /dev/dtrace/systrace entry. */
310 systrace_cdev = make_dev(&systrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
311 DEVNAME);
312
313 if (dtrace_register(PROVNAME, &systrace_attr, DTRACE_PRIV_USER,
314 NULL, &systrace_pops, NULL, &systrace_id) != 0)
315 return;
316
317#if !defined(LINUX_SYSTRACE)
318 systrace_probe_func = systrace_probe;
319#endif
320}
321
322
323static int
324systrace_unload()
325{
326 int error = 0;
327
328 if ((error = dtrace_unregister(systrace_id)) != 0)
329 return (error);
330
331#if !defined(LINUX_SYSTRACE)
332 systrace_probe_func = NULL;
333#endif
334
335 destroy_dev(systrace_cdev);
336
337 return (error);
338}
339

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

365{
366 return (0);
367}
368
369SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL);
370SYSUNINIT(systrace_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_unload, NULL);
371
372#ifdef LINUX_SYSTRACE
373DEV_MODULE(systrace_linux32, systrace_modevent, NULL);
374MODULE_VERSION(systrace_linux32, 1);
375MODULE_DEPEND(systrace_linux32, linux, 1, 1, 1);
376MODULE_DEPEND(systrace_linux32, dtrace, 1, 1, 1);
377MODULE_DEPEND(systrace_linux32, opensolaris, 1, 1, 1);
378#elif defined(FREEBSD32_SYSTRACE)
379DEV_MODULE(systrace_freebsd32, systrace_modevent, NULL);
380MODULE_VERSION(systrace_freebsd32, 1);
381MODULE_DEPEND(systrace_freebsd32, dtrace, 1, 1, 1);
382MODULE_DEPEND(systrace_freebsd32, opensolaris, 1, 1, 1);
383#else
384DEV_MODULE(systrace, systrace_modevent, NULL);
385MODULE_VERSION(systrace, 1);
386MODULE_DEPEND(systrace, dtrace, 1, 1, 1);
387MODULE_DEPEND(systrace, opensolaris, 1, 1, 1);
388#endif