10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*191Sahl * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <stdlib.h> 300Sstevel@tonic-gate #include <strings.h> 310Sstevel@tonic-gate #include <errno.h> 320Sstevel@tonic-gate #include <unistd.h> 330Sstevel@tonic-gate #include <assert.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <dt_impl.h> 360Sstevel@tonic-gate #include <dt_printf.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate static int 390Sstevel@tonic-gate dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id) 400Sstevel@tonic-gate { 410Sstevel@tonic-gate dtrace_id_t max; 420Sstevel@tonic-gate int rval, i, maxformat; 430Sstevel@tonic-gate dtrace_eprobedesc_t *enabled, *nenabled; 440Sstevel@tonic-gate dtrace_probedesc_t *probe; 450Sstevel@tonic-gate 460Sstevel@tonic-gate while (id >= (max = dtp->dt_maxprobe) || dtp->dt_pdesc == NULL) { 470Sstevel@tonic-gate dtrace_id_t new_max = max ? (max << 1) : 1; 480Sstevel@tonic-gate size_t nsize = new_max * sizeof (void *); 490Sstevel@tonic-gate dtrace_probedesc_t **new_pdesc; 500Sstevel@tonic-gate dtrace_eprobedesc_t **new_edesc; 510Sstevel@tonic-gate 520Sstevel@tonic-gate if ((new_pdesc = malloc(nsize)) == NULL || 530Sstevel@tonic-gate (new_edesc = malloc(nsize)) == NULL) { 540Sstevel@tonic-gate free(new_pdesc); 550Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 560Sstevel@tonic-gate } 570Sstevel@tonic-gate 580Sstevel@tonic-gate bzero(new_pdesc, nsize); 590Sstevel@tonic-gate bzero(new_edesc, nsize); 600Sstevel@tonic-gate 610Sstevel@tonic-gate if (dtp->dt_pdesc != NULL) { 620Sstevel@tonic-gate size_t osize = max * sizeof (void *); 630Sstevel@tonic-gate 640Sstevel@tonic-gate bcopy(dtp->dt_pdesc, new_pdesc, osize); 650Sstevel@tonic-gate free(dtp->dt_pdesc); 660Sstevel@tonic-gate 670Sstevel@tonic-gate bcopy(dtp->dt_edesc, new_edesc, osize); 680Sstevel@tonic-gate free(dtp->dt_edesc); 690Sstevel@tonic-gate } 700Sstevel@tonic-gate 710Sstevel@tonic-gate dtp->dt_pdesc = new_pdesc; 720Sstevel@tonic-gate dtp->dt_edesc = new_edesc; 730Sstevel@tonic-gate dtp->dt_maxprobe = new_max; 740Sstevel@tonic-gate } 750Sstevel@tonic-gate 760Sstevel@tonic-gate if (dtp->dt_pdesc[id] != NULL) 770Sstevel@tonic-gate return (0); 780Sstevel@tonic-gate 790Sstevel@tonic-gate if ((enabled = malloc(sizeof (dtrace_eprobedesc_t))) == NULL) 800Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 810Sstevel@tonic-gate 820Sstevel@tonic-gate bzero(enabled, sizeof (dtrace_eprobedesc_t)); 830Sstevel@tonic-gate enabled->dtepd_epid = id; 840Sstevel@tonic-gate enabled->dtepd_nrecs = 1; 850Sstevel@tonic-gate 860Sstevel@tonic-gate if (dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled) == -1) { 870Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 880Sstevel@tonic-gate free(enabled); 890Sstevel@tonic-gate return (rval); 900Sstevel@tonic-gate } 910Sstevel@tonic-gate 920Sstevel@tonic-gate if (DTRACE_SIZEOF_EPROBEDESC(enabled) != sizeof (*enabled)) { 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * There must be more than one action. Allocate the 950Sstevel@tonic-gate * appropriate amount of space and try again. 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate if ((nenabled = 980Sstevel@tonic-gate malloc(DTRACE_SIZEOF_EPROBEDESC(enabled))) != NULL) 990Sstevel@tonic-gate bcopy(enabled, nenabled, sizeof (*enabled)); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate free(enabled); 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate if ((enabled = nenabled) == NULL) 1040Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled); 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate if (rval == -1) { 1090Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 1100Sstevel@tonic-gate free(enabled); 1110Sstevel@tonic-gate return (rval); 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate if ((probe = malloc(sizeof (dtrace_probedesc_t))) == NULL) { 1160Sstevel@tonic-gate free(enabled); 1170Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 1180Sstevel@tonic-gate } 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate probe->dtpd_id = enabled->dtepd_probeid; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate if (dt_ioctl(dtp, DTRACEIOC_PROBES, probe) == -1) { 1230Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 1240Sstevel@tonic-gate goto err; 1250Sstevel@tonic-gate } 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate for (i = 0; i < enabled->dtepd_nrecs; i++) { 1280Sstevel@tonic-gate dtrace_fmtdesc_t fmt; 1290Sstevel@tonic-gate dtrace_recdesc_t *rec = &enabled->dtepd_rec[i]; 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate if (!DTRACEACT_ISPRINTFLIKE(rec->dtrd_action)) 1320Sstevel@tonic-gate continue; 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate if (rec->dtrd_format == 0) 1350Sstevel@tonic-gate continue; 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate if (rec->dtrd_format <= dtp->dt_maxformat && 1380Sstevel@tonic-gate dtp->dt_formats[rec->dtrd_format - 1] != NULL) 1390Sstevel@tonic-gate continue; 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate bzero(&fmt, sizeof (fmt)); 1420Sstevel@tonic-gate fmt.dtfd_format = rec->dtrd_format; 1430Sstevel@tonic-gate fmt.dtfd_string = NULL; 1440Sstevel@tonic-gate fmt.dtfd_length = 0; 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { 1470Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 1480Sstevel@tonic-gate goto err; 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate if ((fmt.dtfd_string = malloc(fmt.dtfd_length)) == NULL) { 1520Sstevel@tonic-gate rval = dt_set_errno(dtp, EDT_NOMEM); 1530Sstevel@tonic-gate goto err; 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { 1570Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 1580Sstevel@tonic-gate free(fmt.dtfd_string); 1590Sstevel@tonic-gate goto err; 1600Sstevel@tonic-gate } 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate while (rec->dtrd_format > (maxformat = dtp->dt_maxformat)) { 1630Sstevel@tonic-gate int new_max = maxformat ? (maxformat << 1) : 1; 1640Sstevel@tonic-gate size_t nsize = new_max * sizeof (void *); 1650Sstevel@tonic-gate size_t osize = maxformat * sizeof (void *); 1660Sstevel@tonic-gate void **new_formats = malloc(nsize); 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate if (new_formats == NULL) { 1690Sstevel@tonic-gate rval = dt_set_errno(dtp, EDT_NOMEM); 1700Sstevel@tonic-gate free(fmt.dtfd_string); 1710Sstevel@tonic-gate goto err; 1720Sstevel@tonic-gate } 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate bzero(new_formats, nsize); 1750Sstevel@tonic-gate bcopy(dtp->dt_formats, new_formats, osize); 1760Sstevel@tonic-gate free(dtp->dt_formats); 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate dtp->dt_formats = new_formats; 1790Sstevel@tonic-gate dtp->dt_maxformat = new_max; 1800Sstevel@tonic-gate } 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate dtp->dt_formats[rec->dtrd_format - 1] = 1830Sstevel@tonic-gate rec->dtrd_action == DTRACEACT_PRINTA ? 1840Sstevel@tonic-gate dtrace_printa_create(dtp, fmt.dtfd_string) : 1850Sstevel@tonic-gate dtrace_printf_create(dtp, fmt.dtfd_string); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate free(fmt.dtfd_string); 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate if (dtp->dt_formats[rec->dtrd_format - 1] == NULL) { 1900Sstevel@tonic-gate rval = -1; /* dt_errno is set for us */ 1910Sstevel@tonic-gate goto err; 1920Sstevel@tonic-gate } 1930Sstevel@tonic-gate } 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate dtp->dt_pdesc[id] = probe; 1960Sstevel@tonic-gate dtp->dt_edesc[id] = enabled; 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate return (0); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate err: 2010Sstevel@tonic-gate /* 2020Sstevel@tonic-gate * If we failed, free our allocated probes. Note that if we failed 2030Sstevel@tonic-gate * while allocating formats, we aren't going to free formats that 2040Sstevel@tonic-gate * we have already allocated. This is okay; these formats are 2050Sstevel@tonic-gate * hanging off of dt_formats and will therefore not be leaked. 2060Sstevel@tonic-gate */ 2070Sstevel@tonic-gate free(enabled); 2080Sstevel@tonic-gate free(probe); 2090Sstevel@tonic-gate return (rval); 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate int 2130Sstevel@tonic-gate dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, 2140Sstevel@tonic-gate dtrace_eprobedesc_t **epdp, dtrace_probedesc_t **pdp) 2150Sstevel@tonic-gate { 2160Sstevel@tonic-gate int rval; 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate if (epid >= dtp->dt_maxprobe || dtp->dt_pdesc[epid] == NULL) { 2190Sstevel@tonic-gate if ((rval = dt_epid_add(dtp, epid)) != 0) 2200Sstevel@tonic-gate return (rval); 2210Sstevel@tonic-gate } 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate assert(epid < dtp->dt_maxprobe); 2240Sstevel@tonic-gate assert(dtp->dt_edesc[epid] != NULL); 2250Sstevel@tonic-gate assert(dtp->dt_pdesc[epid] != NULL); 2260Sstevel@tonic-gate *epdp = dtp->dt_edesc[epid]; 2270Sstevel@tonic-gate *pdp = dtp->dt_pdesc[epid]; 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate return (0); 2300Sstevel@tonic-gate } 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate void 2330Sstevel@tonic-gate dt_epid_destroy(dtrace_hdl_t *dtp) 2340Sstevel@tonic-gate { 2350Sstevel@tonic-gate size_t i; 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate assert((dtp->dt_pdesc != NULL && dtp->dt_edesc != NULL && 2380Sstevel@tonic-gate dtp->dt_maxprobe > 0) || (dtp->dt_pdesc == NULL && 2390Sstevel@tonic-gate dtp->dt_edesc == NULL && dtp->dt_maxprobe == 0)); 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate if (dtp->dt_pdesc == NULL) 2420Sstevel@tonic-gate return; 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate for (i = 0; i < dtp->dt_maxprobe; i++) { 2450Sstevel@tonic-gate if (dtp->dt_edesc[i] == NULL) { 2460Sstevel@tonic-gate assert(dtp->dt_pdesc[i] == NULL); 2470Sstevel@tonic-gate continue; 2480Sstevel@tonic-gate } 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate assert(dtp->dt_pdesc[i] != NULL); 2510Sstevel@tonic-gate free(dtp->dt_edesc[i]); 2520Sstevel@tonic-gate free(dtp->dt_pdesc[i]); 2530Sstevel@tonic-gate } 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate free(dtp->dt_pdesc); 2560Sstevel@tonic-gate dtp->dt_pdesc = NULL; 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate free(dtp->dt_edesc); 2590Sstevel@tonic-gate dtp->dt_edesc = NULL; 2600Sstevel@tonic-gate dtp->dt_maxprobe = 0; 2610Sstevel@tonic-gate } 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate void * 2640Sstevel@tonic-gate dt_format_lookup(dtrace_hdl_t *dtp, int format) 2650Sstevel@tonic-gate { 2660Sstevel@tonic-gate if (format == 0 || format > dtp->dt_maxformat) 2670Sstevel@tonic-gate return (NULL); 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate if (dtp->dt_formats == NULL) 2700Sstevel@tonic-gate return (NULL); 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate return (dtp->dt_formats[format - 1]); 2730Sstevel@tonic-gate } 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate void 2760Sstevel@tonic-gate dt_format_destroy(dtrace_hdl_t *dtp) 2770Sstevel@tonic-gate { 2780Sstevel@tonic-gate int i; 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate for (i = 0; i < dtp->dt_maxformat; i++) { 2810Sstevel@tonic-gate if (dtp->dt_formats[i] != NULL) 2820Sstevel@tonic-gate dt_printf_destroy(dtp->dt_formats[i]); 2830Sstevel@tonic-gate } 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate free(dtp->dt_formats); 2860Sstevel@tonic-gate dtp->dt_formats = NULL; 2870Sstevel@tonic-gate } 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate static int 2900Sstevel@tonic-gate dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id) 2910Sstevel@tonic-gate { 2920Sstevel@tonic-gate dtrace_id_t max; 2930Sstevel@tonic-gate dtrace_epid_t epid; 2940Sstevel@tonic-gate int rval; 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate while (id >= (max = dtp->dt_maxagg) || dtp->dt_aggdesc == NULL) { 2970Sstevel@tonic-gate dtrace_id_t new_max = max ? (max << 1) : 1; 2980Sstevel@tonic-gate size_t nsize = new_max * sizeof (void *); 2990Sstevel@tonic-gate dtrace_aggdesc_t **new_aggdesc; 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate if ((new_aggdesc = malloc(nsize)) == NULL) 3020Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate bzero(new_aggdesc, nsize); 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate if (dtp->dt_aggdesc != NULL) { 3070Sstevel@tonic-gate bcopy(dtp->dt_aggdesc, new_aggdesc, 3080Sstevel@tonic-gate max * sizeof (void *)); 3090Sstevel@tonic-gate free(dtp->dt_aggdesc); 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate dtp->dt_aggdesc = new_aggdesc; 3130Sstevel@tonic-gate dtp->dt_maxagg = new_max; 3140Sstevel@tonic-gate } 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate if (dtp->dt_aggdesc[id] == NULL) { 3170Sstevel@tonic-gate dtrace_aggdesc_t *agg, *nagg; 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate if ((agg = malloc(sizeof (dtrace_aggdesc_t))) == NULL) 3200Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 3210Sstevel@tonic-gate 3220Sstevel@tonic-gate bzero(agg, sizeof (dtrace_aggdesc_t)); 3230Sstevel@tonic-gate agg->dtagd_id = id; 3240Sstevel@tonic-gate agg->dtagd_nrecs = 1; 3250Sstevel@tonic-gate 3260Sstevel@tonic-gate if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg) == -1) { 3270Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 3280Sstevel@tonic-gate free(agg); 3290Sstevel@tonic-gate return (rval); 3300Sstevel@tonic-gate } 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate if (DTRACE_SIZEOF_AGGDESC(agg) != sizeof (*agg)) { 3330Sstevel@tonic-gate /* 3340Sstevel@tonic-gate * There must be more than one action. Allocate the 3350Sstevel@tonic-gate * appropriate amount of space and try again. 3360Sstevel@tonic-gate */ 3370Sstevel@tonic-gate if ((nagg = malloc(DTRACE_SIZEOF_AGGDESC(agg))) != NULL) 3380Sstevel@tonic-gate bcopy(agg, nagg, sizeof (*agg)); 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate free(agg); 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate if ((agg = nagg) == NULL) 3430Sstevel@tonic-gate return (dt_set_errno(dtp, EDT_NOMEM)); 3440Sstevel@tonic-gate 3450Sstevel@tonic-gate rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg); 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate if (rval == -1) { 3480Sstevel@tonic-gate rval = dt_set_errno(dtp, errno); 3490Sstevel@tonic-gate free(agg); 3500Sstevel@tonic-gate return (rval); 3510Sstevel@tonic-gate } 3520Sstevel@tonic-gate } 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate if (agg->dtagd_rec[0].dtrd_uarg) { 3550Sstevel@tonic-gate dtrace_stmtdesc_t *sdp; 3560Sstevel@tonic-gate dt_ident_t *aid; 3570Sstevel@tonic-gate 358*191Sahl sdp = (dtrace_stmtdesc_t *)(uintptr_t) 359*191Sahl agg->dtagd_rec[0].dtrd_uarg; 3600Sstevel@tonic-gate aid = sdp->dtsd_aggdata; 3610Sstevel@tonic-gate agg->dtagd_name = aid->di_name; 3620Sstevel@tonic-gate } 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate if ((epid = agg->dtagd_epid) >= dtp->dt_maxprobe || 3650Sstevel@tonic-gate dtp->dt_pdesc[epid] == NULL) { 3660Sstevel@tonic-gate if ((rval = dt_epid_add(dtp, epid)) != 0) { 3670Sstevel@tonic-gate free(agg); 3680Sstevel@tonic-gate return (rval); 3690Sstevel@tonic-gate } 3700Sstevel@tonic-gate } 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate dtp->dt_aggdesc[id] = agg; 3730Sstevel@tonic-gate } 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate return (0); 3760Sstevel@tonic-gate } 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate int 3790Sstevel@tonic-gate dt_aggid_lookup(dtrace_hdl_t *dtp, dtrace_aggid_t aggid, 3800Sstevel@tonic-gate dtrace_aggdesc_t **adp) 3810Sstevel@tonic-gate { 3820Sstevel@tonic-gate int rval; 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate if (aggid >= dtp->dt_maxagg || dtp->dt_aggdesc[aggid] == NULL) { 3850Sstevel@tonic-gate if ((rval = dt_aggid_add(dtp, aggid)) != 0) 3860Sstevel@tonic-gate return (rval); 3870Sstevel@tonic-gate } 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate assert(aggid < dtp->dt_maxagg); 3900Sstevel@tonic-gate assert(dtp->dt_aggdesc[aggid] != NULL); 3910Sstevel@tonic-gate *adp = dtp->dt_aggdesc[aggid]; 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate return (0); 3940Sstevel@tonic-gate } 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate void 3970Sstevel@tonic-gate dt_aggid_destroy(dtrace_hdl_t *dtp) 3980Sstevel@tonic-gate { 3990Sstevel@tonic-gate size_t i; 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate assert((dtp->dt_aggdesc != NULL && dtp->dt_maxagg != 0) || 4020Sstevel@tonic-gate (dtp->dt_aggdesc == NULL && dtp->dt_maxagg == 0)); 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate if (dtp->dt_aggdesc == NULL) 4050Sstevel@tonic-gate return; 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate for (i = 0; i < dtp->dt_maxagg; i++) { 4080Sstevel@tonic-gate if (dtp->dt_aggdesc[i] != NULL) 4090Sstevel@tonic-gate free(dtp->dt_aggdesc[i]); 4100Sstevel@tonic-gate } 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate free(dtp->dt_aggdesc); 4130Sstevel@tonic-gate dtp->dt_aggdesc = NULL; 4140Sstevel@tonic-gate dtp->dt_maxagg = 0; 4150Sstevel@tonic-gate } 416