sdt.c revision b0f673c4626e4cb1db7785287eaeed2731dfefe8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#include <vm/seg_kmem.h>
#include <sys/sdt_impl.h>
static dev_info_t *sdt_devi;
int sdt_verbose = 0;
#define SDT_REG_G0 0
#define SDT_REG_O0 8
#define SDT_REG_O1 9
#define SDT_REG_O2 10
#define SDT_REG_O3 11
#define SDT_REG_O4 12
#define SDT_REG_O5 13
#define SDT_REG_I0 24
#define SDT_REG_I1 25
#define SDT_REG_I2 26
#define SDT_REG_I3 27
#define SDT_REG_I4 28
#define SDT_REG_I5 29
#define SDT_SIMM13_MASK 0x1fff
0x3fffffff))
#define SDT_RET 0x81c7e008
#define SDT_RESTORE 0x81e80000
#define SDT_OP_SETHI 0x1000000
#define SDT_OP_OR 0x80100000
#define SDT_FMT2_RD_SHIFT 25
#define SDT_IMM22_SHIFT 10
#define SDT_IMM22_MASK 0x3fffff
#define SDT_IMM10_MASK 0x3ff
#define SDT_FMT3_RD_SHIFT 25
#define SDT_FMT3_RS1_SHIFT 14
#define SDT_FMT3_RS2_SHIFT 0
static void
{
} else {
}
instr++;
*instr++ = SDT_RESTORE;
*trampoline = instr;
}
/*ARGSUSED*/
static void
{
int len;
/*
* One for all, and all for one: if we haven't yet registered all of
* our providers, we'll refuse to provide anything.
*/
return;
}
return;
/*
*/
sizeof (struct modctl)) == 0;
/*
* If there hasn't been an sdt table allocated, we'll do so now.
*/
nprobes++;
}
/*
* We could (should?) determine precisely the size of the
* table -- but a reasonable maximum will suffice.
*/
"for module %s", modname);
return;
}
}
int i, j;
break;
}
}
for (i = 0, j = 0; name[j] != '\0'; i++) {
nname[i] = '-';
j += 2;
} else {
}
}
nname[i] = '\0';
func = "<unknown>";
/*
* We have our provider. Now create the probe.
*/
} else {
mp->sdt_nprobes++;
}
sdpd->sdpd_offset);
}
}
/*ARGSUSED*/
static void
{
}
}
}
}
/*ARGSUSED*/
static int
{
ctl->mod_nenabled++;
/*
* If this module has disappeared since we discovered its probes,
* refuse to enable it.
*/
if (sdt_verbose) {
"(module %s unloaded)",
}
goto err;
}
/*
* Now check that our modctl has the expected load count. If it
* doesn't, this module must have been unloaded and reloaded -- and
* we're not going to touch it.
*/
if (sdt_verbose) {
"(module %s reloaded)",
}
goto err;
}
}
err:
return (0);
}
/*ARGSUSED*/
static void
{
ctl->mod_nenabled--;
goto err;
}
err:
;
}
static dtrace_pops_t sdt_pops = {
NULL,
NULL,
NULL,
NULL,
NULL,
};
static int
{
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
} else {
}
}
}
return (DDI_SUCCESS);
}
static int
{
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
}
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_SUCCESS;
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*ARGSUSED*/
static int
{
return (0);
}
static struct cb_ops sdt_cb_ops = {
sdt_open, /* open */
nodev, /* close */
nulldev, /* strategy */
nulldev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
sdt_info, /* get_dev_info */
nulldev, /* identify */
nulldev, /* probe */
sdt_attach, /* attach */
sdt_detach, /* detach */
nodev, /* reset */
&sdt_cb_ops, /* driver operations */
NULL, /* bus operations */
nodev, /* dev power */
ddi_quiesce_not_needed, /* quiesce */
};
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* module type (this is a pseudo driver) */
"Statically Defined Tracing", /* name of module */
&sdt_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
(void *)&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
{
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}