Deleted Added
sdiff udiff text old ( 211608 ) new ( 219561 )
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: head/sys/cddl/dev/systrace/systrace.c 219561 2011-03-12 09:09:25Z avg $
24 *
25 */
26
27/*
28 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
30 */
31

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

54#include <sys/sysent.h>
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#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
75extern struct sysent linux_sysent[];
76#define MODNAME "linux32"
77#define MAXSYSCALL LINUX_SYS_MAXSYSCALL
78#define SYSCALLNAMES linux_syscallnames
79#define SYSENT linux_sysent
80#elif defined(FREEBSD32_SYSTRACE)
81/*
82 * The syscall arguments are processed into a DTrace argument array
83 * using a generated function. See sys/kern/makesyscalls.sh.
84 */
85#include <compat/freebsd32/freebsd32_proto.h>
86#include <compat/freebsd32/freebsd32_util.h>
87#include <compat/freebsd32/freebsd32_syscall.h>
88#include <compat/freebsd32/freebsd32_systrace_args.c>
89extern const char *freebsd32_syscallnames[];
90#define MODNAME "freebsd32"
91#define MAXSYSCALL FREEBSD32_SYS_MAXSYSCALL
92#define SYSCALLNAMES freebsd32_syscallnames
93#define SYSENT freebsd32_sysent
94#else
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 <sys/syscall.h>
100#include <kern/systrace_args.c>
101#define MODNAME "freebsd"
102#define MAXSYSCALL SYS_MAXSYSCALL
103#define SYSCALLNAMES syscallnames
104#define SYSENT sysent
105#endif
106
107#define PROVNAME "syscall"
108#define DEVNAME "dtrace/systrace/" MODNAME
109
110#define SYSTRACE_ARTIFICIAL_FRAMES 1
111
112#define SYSTRACE_SHIFT 16
113#define SYSTRACE_ISENTRY(x) ((int)(x) >> SYSTRACE_SHIFT)
114#define SYSTRACE_SYSNUM(x) ((int)(x) & ((1 << SYSTRACE_SHIFT) - 1))
115#define SYSTRACE_ENTRY(id) ((1 << SYSTRACE_SHIFT) | (id))
116#define SYSTRACE_RETURN(id) (id)
117

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

232systrace_provide(void *arg, dtrace_probedesc_t *desc)
233{
234 int i;
235
236 if (desc != NULL)
237 return;
238
239 for (i = 0; i < MAXSYSCALL; i++) {
240 if (dtrace_probe_lookup(systrace_id, MODNAME,
241 uglyhack.pp_syscallnames[i], "entry") != 0)
242 continue;
243
244 (void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i],
245 "entry", SYSTRACE_ARTIFICIAL_FRAMES,
246 (void *)((uintptr_t)SYSTRACE_ENTRY(i)));
247 (void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i],
248 "return", SYSTRACE_ARTIFICIAL_FRAMES,
249 (void *)((uintptr_t)SYSTRACE_RETURN(i)));
250 }
251}
252
253static void
254systrace_destroy(void *arg, dtrace_id_t id, void *parg)
255{

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

353{
354 return (0);
355}
356
357SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL);
358SYSUNINIT(systrace_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_unload, NULL);
359
360#ifdef LINUX_SYSTRACE
361DEV_MODULE(systrace_linux32, systrace_modevent, NULL);
362MODULE_VERSION(systrace_linux32, 1);
363MODULE_DEPEND(systrace_linux32, linux, 1, 1, 1);
364MODULE_DEPEND(systrace_linux32, dtrace, 1, 1, 1);
365MODULE_DEPEND(systrace_linux32, opensolaris, 1, 1, 1);
366#elif defined(FREEBSD32_SYSTRACE)
367DEV_MODULE(systrace_freebsd32, systrace_modevent, NULL);
368MODULE_VERSION(systrace_freebsd32, 1);
369MODULE_DEPEND(systrace_freebsd32, dtrace, 1, 1, 1);
370MODULE_DEPEND(systrace_freebsd32, opensolaris, 1, 1, 1);
371#else
372DEV_MODULE(systrace, systrace_modevent, NULL);
373MODULE_VERSION(systrace, 1);
374MODULE_DEPEND(systrace, dtrace, 1, 1, 1);
375MODULE_DEPEND(systrace, opensolaris, 1, 1, 1);
376#endif