14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * DTrace D Language Compiler
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The code in this source file implements the main engine for the D language
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * compiler. The driver routine for the compiler is dt_compile(), below. The
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * compiler operates on either stdio FILEs or in-memory strings as its input
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and can produce either dtrace_prog_t structures from a D program or a single
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dtrace_difo_t structure from a D expression. Multiple entry points are
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * provided as wrappers around dt_compile() for the various input/output pairs.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The compiler itself is implemented across the following source files:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_lex.l - lex scanner
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_grammar.y - yacc grammar
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_parser.c - parse tree creation and semantic checking
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_decl.c - declaration stack processing
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_xlator.c - D translator lookup and creation
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_ident.c - identifier and symbol table routines
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_pragma.c - #pragma processing and D pragmas
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_printf.c - D printf() and printa() argument checking and processing
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_cc.c - compiler driver and dtrace_prog_t construction
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_cg.c - DIF code generator
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_as.c - DIF assembler
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dt_dof.c - dtrace_prog_t -> DOF conversion
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Several other source files provide collections of utility routines used by
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * these major files. The compiler itself is implemented in multiple passes:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (1) The input program is scanned and parsed by dt_lex.l and dt_grammar.y
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and parse tree nodes are constructed using the routines in dt_parser.c.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This node construction pass is described further in dt_parser.c.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (2) The parse tree is "cooked" by assigning each clause a context (see the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * routine dt_setcontext(), below) based on its probe description and then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * recursively descending the tree performing semantic checking. The cook
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * routines are also implemented in dt_parser.c and described there.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (3) For actions that are DIF expression statements, the DIF code generator
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and assembler are invoked to create a finished DIFO for the statement.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (4) The dtrace_prog_t data structures for the program clauses and actions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * are built, containing pointers to any DIFOs created in step (3).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (5) The caller invokes a routine in dt_dof.c to convert the finished program
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * into DOF format for use in anonymous tracing or enabling in the kernel.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * In the implementation, steps 2-4 are intertwined in that they are performed
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * in order for each clause as part of a loop that executes over the clauses.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The D compiler currently implements nearly no optimization. The compiler
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * implements integer constant folding as part of pass (1), and a set of very
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * simple peephole optimizations as part of pass (3). As with any C compiler,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * a large number of optimizations are possible on both the intermediate data
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * structures and the generated DIF code. These possibilities should be
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * investigated in the context of whether they will have any substantive effect
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * on the overall DTrace probe effect before they are undertaken.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <sys/types.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <sys/wait.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <assert.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <strings.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <signal.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <unistd.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <stdlib.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <stdio.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <errno.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <ucontext.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <limits.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <ctype.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dirent.h>
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else /* VBOX */
15131f635944423d12704f2e6e51799511ac51ccvboxsync# include <ctype.h>
15131f635944423d12704f2e6e51799511ac51ccvboxsync# include <iprt/dir.h>
15131f635944423d12704f2e6e51799511ac51ccvboxsync# ifdef _MSC_VER
15131f635944423d12704f2e6e51799511ac51ccvboxsync# include <io.h>
15131f635944423d12704f2e6e51799511ac51ccvboxsync# else
15131f635944423d12704f2e6e51799511ac51ccvboxsync# include <unistd.h>
15131f635944423d12704f2e6e51799511ac51ccvboxsync# endif
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# if defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN)
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# ifdef _MSC_VER
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# define ftruncate64 _chsize
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# else
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# define ftruncate64 ftruncate
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# endif
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# define lseek64 lseek
971ff477625b7d741a5ef6c2e5cec5a7642f83favboxsync# endif
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif /* VBOX */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_module.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_program.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_provider.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_printf.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_pid.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_grammar.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_ident.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_string.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dt_impl.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic const dtrace_diftype_t dt_void_rtype = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DIF_TYPE_CTF, CTF_K_INTEGER, 0, 0, 0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic const dtrace_diftype_t dt_int_rtype = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DIF_TYPE_CTF, CTF_K_INTEGER, 0, 0, sizeof (uint64_t)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void *dt_compile(dtrace_hdl_t *, int, dtrace_probespec_t, void *,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t, int, char *const[], FILE *, const char *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_idreset(dt_idhash_t *dhp, dt_ident_t *idp, void *ignored)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_flags &= ~(DT_IDFLG_REF | DT_IDFLG_MOD |
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DT_IDFLG_DIFR | DT_IDFLG_DIFW);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_idpragma(dt_idhash_t *dhp, dt_ident_t *idp, void *ignored)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yylineno = idp->di_lineno;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync xyerror(D_PRAGMA_UNUSED, "unused #pragma %s\n", (char *)idp->di_iarg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic dtrace_stmtdesc_t *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_attribute_t descattr, dtrace_attribute_t stmtattr)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_stmtdesc_t *sdp = dtrace_stmt_create(dtp, edp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (sdp == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_stmt == NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_stmt = sdp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp->dtsd_descattr = descattr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp->dtsd_stmtattr = stmtattr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic dtrace_actdesc_t *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_stmt_action(dtrace_hdl_t *dtp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *new;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((new = dtrace_stmt_action(dtp, sdp)) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (new);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Utility function to determine if a given action description is destructive.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The dtdo_destructive bit is set for us by the DIF assembler (see dt_as.c).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_destructive(const dtrace_actdesc_t *ap)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) || (ap->dtad_kind ==
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACEACT_DIFEXPR && ap->dtad_difo->dtdo_destructive));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_stmt_append(dtrace_stmtdesc_t *sdp, const dt_node_t *dnp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap, *tap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int commit = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int speculate = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int datarec = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Make sure that the new statement jibes with the rest of the ECB.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (ap = edp->dted_action; ap != NULL; ap = ap->dtad_next) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (ap->dtad_kind == DTRACEACT_COMMIT) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (commit) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_COMM_COMM, "commit( ) may "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not follow commit( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (datarec) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_COMM_DREC, "commit( ) may "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not follow data-recording action(s)\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (tap = ap; tap != NULL; tap = tap->dtad_next) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!DTRACEACT_ISAGG(tap->dtad_kind))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_AGG_COMM, "aggregating actions "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "may not follow commit( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync commit = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (ap->dtad_kind == DTRACEACT_SPECULATE) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (speculate) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_SPEC_SPEC, "speculate( ) may "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not follow speculate( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (commit) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_SPEC_COMM, "speculate( ) may "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not follow commit( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (datarec) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_SPEC_DREC, "speculate( ) may "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not follow data-recording action(s)\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync speculate = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (DTRACEACT_ISAGG(ap->dtad_kind)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (speculate) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_AGG_SPEC, "aggregating actions "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "may not follow speculate( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync datarec = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (speculate) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_action_destructive(ap)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_ACT_SPEC, "destructive actions "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "may not follow speculate( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (ap->dtad_kind == DTRACEACT_EXIT) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_EXIT_SPEC, "exit( ) may not "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "follow speculate( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Exclude all non data-recording actions.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_action_destructive(ap) ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind == DTRACEACT_DISCARD)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_CTF &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (commit) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_DREC_COMM, "data-recording actions "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "may not follow commit( )\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!speculate)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync datarec = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtrace_stmt_add(yypcb->pcb_hdl, yypcb->pcb_prog, sdp) != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, dtrace_errno(yypcb->pcb_hdl));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yypcb->pcb_stmt == sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_stmt = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * For the first element of an aggregation tuple or for printa(), we create a
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * simple DIF program that simply returns the immediate value that is the ID
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * of the aggregation itself. This could be optimized in the future by
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * creating a new in-kernel dtad_kind that just returns an integer.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_difconst(dtrace_actdesc_t *ap, uint_t id, dtrace_actkind_t kind)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_hdl_t *dtp = yypcb->pcb_hdl;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_difo_t *dp = dt_zalloc(dtp, sizeof (dtrace_difo_t));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dp == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_buf = dt_alloc(dtp, sizeof (dif_instr_t) * 2);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_inttab = dt_alloc(dtp, sizeof (uint64_t));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dp->dtdo_buf == NULL || dp->dtdo_inttab == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_difo_free(dtp, dp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_buf[0] = DIF_INSTR_SETX(0, 1); /* setx DIF_INTEGER[0], %r1 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_buf[1] = DIF_INSTR_RET(1); /* ret %r1 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_len = 2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_inttab[0] = id;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_intlen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_rtype = dt_int_rtype;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = kind;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_clear(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *aid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc++; /* count up arguments for error messages below */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc != 1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_CLEAR_PROTO,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) prototype mismatch: %d args passed, 1 expected\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name, argc);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(anp != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_kind != DT_NODE_AGG) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_CLEAR_AGGARG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #1 is incompatible with prototype:\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\tprototype: aggregation\n\t argument: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(anp, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync aid = anp->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_CLEAR_AGGBAD,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "undefined aggregation: @%s\n", aid->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_CLEAR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_normalize(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *aid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp, *normal;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int denormal = (strcmp(dnp->dn_ident->di_name, "denormalize") == 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc++; /* count up arguments for error messages below */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((denormal && argc != 1) || (!denormal && argc != 2)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_NORMALIZE_PROTO,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) prototype mismatch: %d args passed, %d expected\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name, argc, denormal ? 1 : 2);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(anp != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_kind != DT_NODE_AGG) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_NORMALIZE_AGGARG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #1 is incompatible with prototype:\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\tprototype: aggregation\n\t argument: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(anp, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((normal = anp->dn_list) != NULL && !dt_node_is_scalar(normal)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_NORMALIZE_SCALAR,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #2 must be of scalar type\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync aid = anp->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_NORMALIZE_AGGBAD,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "undefined aggregation: @%s\n", aid->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (denormal) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_DENORMALIZE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_NORMALIZE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(normal != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, normal);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_LIBACT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_NORMALIZE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_trunc(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *aid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp, *trunc;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc++; /* count up arguments for error messages below */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc > 2 || argc < 1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_TRUNC_PROTO,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) prototype mismatch: %d args passed, %s expected\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name, argc,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc < 1 ? "at least 1" : "no more than 2");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(anp != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync trunc = anp->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_kind != DT_NODE_AGG) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_TRUNC_AGGARG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #1 is incompatible with prototype:\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\tprototype: aggregation\n\t argument: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(anp, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc == 2) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(trunc != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!dt_node_is_scalar(trunc)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_TRUNC_SCALAR,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #2 must be of scalar type\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync aid = anp->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_TRUNC_AGGBAD,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "undefined aggregation: @%s\n", aid->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_TRUNC;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc == 1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(trunc != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, trunc);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_LIBACT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_TRUNC;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_printa(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *aid, *fid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *format;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp, *proto = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = 0, argr = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc++; /* count up arguments for error messages below */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (dnp->dn_args->dn_kind) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_STRING:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync format = dnp->dn_args->dn_string;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argr = 2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_AGG:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync format = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argr = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync default:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync format = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argr = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc < argr) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_PRINTA_PROTO,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) prototype mismatch: %d args passed, %d expected\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name, argc, argr);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(anp != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while (anp != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_kind != DT_NODE_AGG) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_PRINTA_AGGARG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #%d is incompatible with "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "prototype:\n\tprototype: aggregation\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\t argument: %s\n", dnp->dn_ident->di_name, argr,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(anp, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync aid = anp->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fid = aid->di_iarg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (aid->di_gen == dtp->dt_gen &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync !(aid->di_flags & DT_IDFLG_MOD)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_PRINTA_AGGBAD,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "undefined aggregation: @%s\n", aid->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If we have multiple aggregations, we must be sure that
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * their key signatures match.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (proto != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_printa_validate(proto, anp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync proto = anp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (format != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yylineno = dnp->dn_line;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp->dtsd_fmtdata =
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_printf_create(yypcb->pcb_hdl, format);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_printf_validate(sdp->dtsd_fmtdata,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DT_PRINTF_AGGREGATION, dnp->dn_ident, 1,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fid->di_id, ((dt_idsig_t *)aid->di_data)->dis_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync format = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_PRINTA);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp = anp->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argr++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_printflike(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actkind_t kind)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp, *arg1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN], *str;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(DTRACEACT_ISPRINTFLIKE(kind));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_args->dn_kind != DT_NODE_STRING) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_PRINTF_ARG_FMT,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #1 is incompatible with prototype:\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\tprototype: string constant\n\t argument: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(dnp->dn_args, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync arg1 = dnp->dn_args->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yylineno = dnp->dn_line;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str = dnp->dn_args->dn_string;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If this is an freopen(), we use an empty string to denote that
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * stdout should be restored. For other printf()-like actions, an
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * empty format string is illegal: an empty format string would
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * result in malformed DOF, and the compiler thus flags an empty
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * format string as a compile-time error. To avoid propagating the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * freopen() special case throughout the system, we simply transpose
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * an empty string into a sentinel string (DT_FREOPEN_RESTORE) that
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * denotes that stdout should be restored.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (kind == DTRACEACT_FREOPEN) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (strcmp(str, DT_FREOPEN_RESTORE) == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Our sentinel is always an invalid argument to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * freopen(), but if it's been manually specified, we
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * must fail now instead of when the freopen() is
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * actually evaluated.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_FREOPEN_INVALID,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s( ) argument #1 cannot be \"%s\"\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name, DT_FREOPEN_RESTORE);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (str[0] == '\0')
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str = DT_FREOPEN_RESTORE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp->dtsd_fmtdata = dt_printf_create(dtp, str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_printf_validate(sdp->dtsd_fmtdata, DT_PRINTF_EXACTLEN,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident, 1, DTRACEACT_AGGREGATION, arg1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1 == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dif_instr_t *dbuf;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_difo_t *dp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dbuf = dt_alloc(dtp, sizeof (dif_instr_t))) == NULL ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (dp = dt_zalloc(dtp, sizeof (dtrace_difo_t))) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dbuf);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dbuf[0] = DIF_INSTR_RET(DIF_REG_R0); /* ret %r0 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_buf = dbuf;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_len = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dp->dtdo_rtype = dt_int_rtype;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = kind;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = arg1; anp != NULL; anp = anp->dn_list) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, anp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = kind;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_node_is_void(dnp->dn_args)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp->dn_args, D_TRACE_VOID,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "trace( ) may not be applied to a void expression\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_node_is_dynamic(dnp->dn_args)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp->dn_args, D_TRACE_DYN,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "trace( ) may not be applied to a dynamic expression\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DIFEXPR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_tracemem(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *addr = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *size = dnp->dn_args->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char n[DT_TYPE_NAMELEN];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_node_is_integer(addr) == 0 && dt_node_is_pointer(addr) == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(addr, D_TRACEMEM_ADDR,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "tracemem( ) argument #1 is incompatible with "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "prototype:\n\tprototype: pointer or integer\n"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "\t argument: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_type_name(addr, n, sizeof (n)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_node_is_posconst(size) == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(size, D_TRACEMEM_SIZE, "tracemem( ) argument #2 must "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "be a non-zero positive integral constant expression\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, addr);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DIFEXPR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_size = size->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_stack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *arg0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_STACK;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_options[DTRACEOPT_STACKFRAMES] != DTRACEOPT_UNSET) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = dtp->dt_options[DTRACEOPT_STACKFRAMES];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg0 != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg0->dn_list != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg0, D_STACK_PROTO, "stack( ) prototype "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "mismatch: too many arguments\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_node_is_posconst(arg0) == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg0, D_STACK_SIZE, "stack( ) size must be a "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "non-zero positive integral constant expression\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = arg0->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_stack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_stack_args(dtp, ap, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_ustack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *dnp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t nframes = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t strsize = 0; /* default string table size */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg0 = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg1 = arg0 != NULL ? arg0->dn_list : NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(dnp->dn_ident->di_id == DT_ACT_JSTACK ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_id == DT_ACT_USTACK);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_ident->di_id == DT_ACT_JSTACK) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_options[DTRACEOPT_JSTACKFRAMES] != DTRACEOPT_UNSET)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nframes = dtp->dt_options[DTRACEOPT_JSTACKFRAMES];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE] != DTRACEOPT_UNSET)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync strsize = dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_JSTACK;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(dnp->dn_ident->di_id == DT_ACT_USTACK);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_options[DTRACEOPT_USTACKFRAMES] != DTRACEOPT_UNSET)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nframes = dtp->dt_options[DTRACEOPT_USTACKFRAMES];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_USTACK;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg0 != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!dt_node_is_posconst(arg0)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg0, D_USTACK_FRAMES, "ustack( ) argument #1 "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "must be a non-zero positive integer constant\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nframes = (uint32_t)arg0->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1 != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1->dn_kind != DT_NODE_INT ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ((arg1->dn_flags & DT_NF_SIGNED) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (int64_t)arg1->dn_value < 0)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg1, D_USTACK_STRSIZE, "ustack( ) argument #2 "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "must be a positive integer constant\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1->dn_list != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg1, D_USTACK_PROTO, "ustack( ) prototype "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "mismatch: too many arguments\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync strsize = (uint32_t)arg1->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DTRACE_USTACK_ARG(nframes, strsize);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_ustack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_ustack_args(dtp, ap, dnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_setopt(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg0, *arg1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The prototype guarantees that we are called with either one or
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * two arguments, and that any arguments that are present are strings.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync arg0 = dnp->dn_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync arg1 = arg0->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, arg0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_LIBACT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_SETOPT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1 == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, arg1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_LIBACT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_SETOPT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_symmod_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *dnp, dtrace_actkind_t kind)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(kind == DTRACEACT_SYM || kind == DTRACEACT_MOD ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync kind == DTRACEACT_USYM || kind == DTRACEACT_UMOD ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync kind == DTRACEACT_UADDR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = kind;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof (uint64_t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_symmod(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actkind_t kind)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap, dnp->dn_args, kind);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_ftruncate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Library actions need a DIFO that serves as an argument. As
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * ftruncate() doesn't take an argument, we generate the constant 0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * in a DIFO; this constant will be ignored when the ftruncate() is
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * processed.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = DT_ACT_FTRUNCATE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_stop(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_STOP;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_breakpoint(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_BREAKPOINT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*ARGSUSED*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_panic(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_PANIC;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_chill(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_CHILL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_raise(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_RAISE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_exit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_EXIT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof (int);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_speculate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_SPECULATE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_commit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_COMMIT;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_action_discard(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DISCARD;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (dnp->dn_expr->dn_ident->di_id) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_BREAKPOINT:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_breakpoint(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_CHILL:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_chill(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_CLEAR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_clear(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_COMMIT:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_commit(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_DENORMALIZE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_normalize(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_DISCARD:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_discard(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_EXIT:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_exit(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_FREOPEN:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_FREOPEN);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_FTRUNCATE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_ftruncate(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_MOD:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_MOD);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_NORMALIZE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_normalize(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_PANIC:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_panic(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_PRINTA:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_printa(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_PRINTF:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_PRINTF);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_RAISE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_raise(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_SETOPT:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_setopt(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_SPECULATE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_speculate(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_STACK:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_stack(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_STOP:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_stop(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_SYM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_SYM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_SYSTEM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_SYSTEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_TRACE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_trace(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_TRACEMEM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_tracemem(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_TRUNC:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_trunc(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_UADDR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UADDR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_UMOD:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UMOD);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_USYM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_USYM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_USTACK:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_JSTACK:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_ustack(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync default:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp->dn_expr, D_UNKNOWN, "tracing function %s( ) is "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not yet supported\n", dnp->dn_expr->dn_ident->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_exp(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_expr);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype = dt_void_rtype;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DIFEXPR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_agg(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *aid, *fid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *anp, *incr = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_actdesc_t *ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t n = 1, argmax;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint64_t arg = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If the aggregation has no aggregating function applied to it, then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * this statement has no effect. Flag this as a programming error.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_aggfun == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_AGG_NULL, "expression has null effect: @%s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnp->dn_ident->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync aid = dnp->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fid = dnp->dn_aggfun->dn_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_aggfun->dn_args != NULL &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_is_scalar(dnp->dn_aggfun->dn_args) == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp->dn_aggfun, D_AGG_SCALAR, "%s( ) argument #1 must "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "be of scalar type\n", fid->di_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The ID of the aggregation itself is implicitly recorded as the first
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * member of each aggregation tuple so we can distinguish them later.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_difconst(ap, aid->di_id, DTRACEACT_DIFEXPR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (anp = dnp->dn_aggtup; anp != NULL; anp = anp->dn_list) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync n++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_kind == DT_NODE_FUNC) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_ident->di_id == DT_ACT_STACK) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_stack_args(dtp, ap, anp->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (anp->dn_ident->di_id == DT_ACT_USTACK ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_ident->di_id == DT_ACT_JSTACK) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_ustack_args(dtp, ap, anp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (anp->dn_ident->di_id) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_UADDR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_args, DTRACEACT_UADDR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_USYM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_args, DTRACEACT_USYM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_UMOD:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_args, DTRACEACT_UMOD);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_SYM:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_args, DTRACEACT_SYM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_ACT_MOD:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_action_symmod_args(dtp, ap,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync anp->dn_args, DTRACEACT_MOD);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync default:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, anp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DIFEXPR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (fid->di_id == DTRACEAGG_LQUANTIZE) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * For linear quantization, we have between two and four
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * arguments in addition to the expression:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * arg1 => Base value
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * arg2 => Limit value
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * arg3 => Quantization level step size (defaults to 1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * arg4 => Quantization increment value (defaults to 1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg1 = dnp->dn_aggfun->dn_args->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg2 = arg1->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *arg3 = arg2->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_idsig_t *isp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint64_t nlevels, step = 1, oarg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int64_t baseval, limitval;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg1->dn_kind != DT_NODE_INT) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg1, D_LQUANT_BASETYPE, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #1 must be an integer constant\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync baseval = (int64_t)arg1->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (baseval < INT32_MIN || baseval > INT32_MAX) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg1, D_LQUANT_BASEVAL, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #1 must be a 32-bit quantity\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg2->dn_kind != DT_NODE_INT) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg2, D_LQUANT_LIMTYPE, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #2 must be an integer constant\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync limitval = (int64_t)arg2->dn_value;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (limitval < INT32_MIN || limitval > INT32_MAX) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg2, D_LQUANT_LIMVAL, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #2 must be a 32-bit quantity\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (limitval < baseval) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_MISMATCH,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "lquantize( ) base (argument #1) must be less "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "than limit (argument #2)\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (arg3 != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!dt_node_is_posconst(arg3)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg3, D_LQUANT_STEPTYPE, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #3 must be a non-zero positive "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "integer constant\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((step = arg3->dn_value) > UINT16_MAX) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(arg3, D_LQUANT_STEPVAL, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "argument #3 must be a 16-bit quantity\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nlevels = (limitval - baseval) / step;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (nlevels == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_STEPLARGE,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "lquantize( ) step (argument #3) too large: must "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "have at least one quantization level\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (nlevels > UINT16_MAX) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_STEPSMALL, "lquantize( ) step "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "(argument #3) too small: number of quantization "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "levels must be a 16-bit quantity\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync arg = (step << DTRACE_LQUANTIZE_STEPSHIFT) |
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (nlevels << DTRACE_LQUANTIZE_LEVELSHIFT) |
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ((baseval << DTRACE_LQUANTIZE_BASESHIFT) &
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_LQUANTIZE_BASEMASK);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(arg != 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync isp = (dt_idsig_t *)aid->di_data;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (isp->dis_auxinfo == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This is the first time we've seen an lquantize()
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * for this aggregation; we'll store our argument
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * as the auxiliary signature information.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync isp->dis_auxinfo = arg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else if ((oarg = isp->dis_auxinfo) != arg) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If we have seen this lquantize() before and the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * argument doesn't match the original argument, pick
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * the original argument apart to concisely report the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * mismatch.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int obaseval = DTRACE_LQUANTIZE_BASE(oarg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int onlevels = DTRACE_LQUANTIZE_LEVELS(oarg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int ostep = DTRACE_LQUANTIZE_STEP(oarg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (obaseval != baseval) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_MATCHBASE, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "base (argument #1) doesn't match previous "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "declaration: expected %d, found %d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync obaseval, (int)baseval);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (onlevels * ostep != nlevels * step) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_MATCHLIM, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "limit (argument #2) doesn't match previous"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync " declaration: expected %d, found %d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync obaseval + onlevels * ostep,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (int)baseval + (int)nlevels * (int)step);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (ostep != step) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_LQUANT_MATCHSTEP, "lquantize( ) "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "step (argument #3) doesn't match previous "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "declaration: expected %d, found %d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ostep, (int)step);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * We shouldn't be able to get here -- one of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * parameters must be mismatched if the arguments
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * didn't match.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync incr = arg3 != NULL ? arg3->dn_list : NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argmax = 5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (fid->di_id == DTRACEAGG_QUANTIZE) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync incr = dnp->dn_aggfun->dn_args->dn_list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argmax = 2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (incr != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (!dt_node_is_scalar(incr)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_PROTO_ARG, "%s( ) increment value "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "(argument #%d) must be of scalar type\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fid->di_name, argmax);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((anp = incr->dn_list) != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = argmax;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (; anp != NULL; anp = anp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argc++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(incr, D_PROTO_LEN, "%s( ) prototype "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "mismatch: %d args passed, at most %d expected",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fid->di_name, argc, argmax);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync n++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, incr);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo->dtdo_rtype = dt_void_rtype;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = DTRACEACT_DIFEXPR;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(sdp->dtsd_aggdata == NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp->dtsd_aggdata = aid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap = dt_stmt_action(dtp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(fid->di_kind == DT_IDENT_AGGFUNC);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(DTRACEACT_ISAGG(fid->di_id));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_kind = fid->di_id;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_ntuple = n;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_arg = arg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_aggfun->dn_args != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, dnp->dn_aggfun->dn_args);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ap->dtad_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_one_clause(dtrace_hdl_t *dtp, dt_node_t *cnp, dt_node_t *pnp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_ecbdesc_t *edp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_stmtdesc_t *sdp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *dnp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yylineno = pnp->dn_line;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_setcontext(dtp, pnp->dn_desc);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_node_cook(cnp, DT_IDFLG_REF);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (DT_TREEDUMP_PASS(dtp, 2))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_printr(cnp, stderr, 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((edp = dt_ecbdesc_create(dtp, pnp->dn_desc)) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_ecbdesc == NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_ecbdesc = edp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (cnp->dn_pred != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, cnp->dn_pred);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync edp->dted_pred.dtpdd_difo = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (cnp->dn_acts == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_stmt_append(dt_stmt_create(dtp, edp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cnp->dn_ctxattr, _dtrace_defattr), cnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dnp = cnp->dn_acts; dnp != NULL; dnp = dnp->dn_list) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_stmt == NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sdp = dt_stmt_create(dtp, edp, cnp->dn_ctxattr, cnp->dn_attr);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (dnp->dn_kind) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_DEXPR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dnp->dn_expr->dn_kind == DT_NODE_AGG)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_agg(dtp, dnp->dn_expr, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync else
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_exp(dtp, dnp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_DFUNC:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_fun(dtp, dnp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_AGG:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_agg(dtp, dnp, sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync default:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dnerror(dnp, D_UNKNOWN, "internal error -- node kind "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%u is not a valid statement\n", dnp->dn_kind);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_stmt == sdp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_stmt_append(sdp, dnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_ecbdesc == edp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ecbdesc_release(dtp, edp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_endcontext(dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_ecbdesc = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_clause(dtrace_hdl_t *dtp, dt_node_t *cnp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *pnp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (pnp = cnp->dn_pdescs; pnp != NULL; pnp = pnp->dn_list)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_one_clause(dtp, cnp, pnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile_xlator(dt_node_t *dnp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_xlator_t *dxp = dnp->dn_xlator;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *mnp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (mnp = dnp->dn_members; mnp != NULL; mnp = mnp->dn_list) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(dxp->dx_membdif[mnp->dn_membid] == NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, mnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dxp->dx_membdif[mnp->dn_membid] = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_setcontext(dtrace_hdl_t *dtp, dtrace_probedesc_t *pdp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const dtrace_pattr_t *pap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_probe_t *prp;
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_provider_t *pvp;
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *idp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char attrstr[8];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Both kernel and pid based providers are allowed to have names
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * ending with what could be interpreted as a number. We assume it's
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * a pid and that we may need to dynamically create probes for
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * that process if:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (1) The provider doesn't exist, or,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (2) The provider exists and has DTRACE_PRIV_PROC privilege.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * On an error, dt_pid_create_probes() will set the error message
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and tag -- we just have to longjmp() out of here.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (isdigit(pdp->dtpd_provider[strlen(pdp->dtpd_provider) - 1]) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ((pvp = dt_provider_lookup(dtp, pdp->dtpd_provider)) == NULL ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pvp->pv_desc.dtvd_priv.dtpp_flags & DTRACE_PRIV_PROC) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pid_create_probes(pdp, dtp, yypcb) != 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Call dt_probe_info() to get the probe arguments and attributes. If
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * a representative probe is found, set 'pap' to the probe provider's
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * attributes. Otherwise set 'pap' to default Unstable attributes.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((prp = dt_probe_info(dtp, pdp, &yypcb->pcb_pinfo)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pap = &_dtrace_prvdesc;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync err = dtrace_errno(dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bzero(&yypcb->pcb_pinfo, sizeof (dtrace_probeinfo_t));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_pinfo.dtp_attr = pap->dtpa_provider;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_pinfo.dtp_arga = pap->dtpa_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pap = &prp->pr_pvp->pv_desc.dtvd_attr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync err = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (err == EDT_NOPROBE && !(yypcb->pcb_cflags & DTRACE_C_ZDEFS)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync xyerror(D_PDESC_ZERO, "probe description %s:%s:%s:%s does not "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "match any probes\n", pdp->dtpd_provider, pdp->dtpd_mod,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pdp->dtpd_func, pdp->dtpd_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (err != EDT_NOPROBE && err != EDT_UNSTABLE && err != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync xyerror(D_PDESC_INVAL, "%s\n", dtrace_errmsg(dtp, err));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("set context to %s:%s:%s:%s [%u] prp=%p attr=%s argc=%d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pdp->dtpd_id, (void *)prp, dt_attr_str(yypcb->pcb_pinfo.dtp_attr,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync attrstr, sizeof (attrstr)), yypcb->pcb_pinfo.dtp_argc);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Reset the stability attributes of D global variables that vary
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * based on the attributes of the provider and context itself.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, "probeprov")) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = pap->dtpa_provider;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, "probemod")) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = pap->dtpa_mod;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, "probefunc")) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = pap->dtpa_func;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, "probename")) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = pap->dtpa_name;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, "args")) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = pap->dtpa_args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_pdesc = pdp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_probe = prp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Reset context-dependent variables and state at the end of cooking a D probe
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * definition clause. This ensures that external declarations between clauses
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * do not reference any stale context-dependent data from the previous clause.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_endcontext(dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync static const char *const cvars[] = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "probeprov", "probemod", "probefunc", "probename", "args", NULL
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync };
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_ident_t *idp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int i;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (i = 0; cvars[i] != NULL; i++) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((idp = dt_idhash_lookup(dtp->dt_globals, cvars[i])) != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync idp->di_attr = _dtrace_defattr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_pdesc = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_probe = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_reduceid(dt_idhash_t *dhp, dt_ident_t *idp, dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (idp->di_vers != 0 && idp->di_vers > dtp->dt_vmax)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_idhash_delete(dhp, idp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When dtrace_setopt() is called for "version", it calls dt_reduce() to remove
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * any identifiers or translators that have been previously defined as bound to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * a version greater than the specified version. Therefore, in our current
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * version implementation, establishing a binding is a one-way transformation.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * In addition, no versioning is currently provided for types as our .d library
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * files do not define any types and we reserve prefixes DTRACE_ and dtrace_
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * for our exclusive use. If required, type versioning will require more work.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_reduce(dtrace_hdl_t *dtp, dt_version_t v)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char s[DT_VERSION_STRMAX];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_xlator_t *dxp, *nxp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (v > dtp->dt_vmax)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EDT_VERSREDUCED));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync else if (v == dtp->dt_vmax)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0); /* no reduction necessary */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("reducing api version to %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_version_num2str(v, s, sizeof (s)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_vmax = v;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dxp = dt_list_next(&dtp->dt_xlators); dxp != NULL; dxp = nxp) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nxp = dt_list_next(dxp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dxp->dx_souid.di_vers != 0 && dxp->dx_souid.di_vers > v) ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (dxp->dx_ptrid.di_vers != 0 && dxp->dx_ptrid.di_vers > v))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_delete(&dtp->dt_xlators, dxp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_macros, (dt_idhash_f *)dt_reduceid, dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_aggs, (dt_idhash_f *)dt_reduceid, dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_globals, (dt_idhash_f *)dt_reduceid, dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_tls, (dt_idhash_f *)dt_reduceid, dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Fork and exec the cpp(1) preprocessor to run over the specified input file,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and return a FILE handle for the cpp output. We use the /dev/fd filesystem
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * here to simplify the code by leveraging file descriptor inheritance.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic FILE *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int argc = dtp->dt_cpp_argc;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char **argv = malloc(sizeof (char *) * (argc + 5));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync FILE *ofp = tmpfile();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct sigaction act, oact;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync sigset_t mask, omask;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int wstat, estat;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pid_t pid;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync off64_t off;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int c;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argv == NULL || ofp == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, errno);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If the input is a seekable file, see if it is an interpreter file.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If we see #!, seek past the first line because cpp will choke on it.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * We start cpp just prior to the \n at the end of this line so that
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * it still sees the newline, ensuring that #line values are correct.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (isatty(fileno(ifp)) == 0 && (off = ftello64(ifp)) != -1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((c = fgetc(ifp)) == '#' && (c = fgetc(ifp)) == '!') {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (off += 2; c != '\n'; off++) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((c = fgetc(ifp)) == EOF)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (c == '\n')
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync off--; /* start cpp just prior to \n */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fflush(ifp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fseeko64(ifp, off, SEEK_SET);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bcopy(dtp->dt_cpp_argv, argv, sizeof (char *) * argc);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) snprintf(verdef, sizeof (verdef),
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc++] = verdef;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (dtp->dt_stdcmode) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_STDC_XA:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_STDC_XT:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc++] = "-D__STDC__=0";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_STDC_XC:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc++] = "-D__STDC__=1";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc++] = ipath;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc++] = opath;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync argv[argc] = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * libdtrace must be able to be embedded in other programs that may
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * include application-specific signal handlers. Therefore, if we
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * need to fork to run cpp(1), we must avoid generating a SIGCHLD
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * that could confuse the containing application. To do this,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * we block SIGCHLD and reset its disposition to SIG_DFL.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * We restore our signal state once we are done.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigemptyset(&mask);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigaddset(&mask, SIGCHLD);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigprocmask(SIG_BLOCK, &mask, &omask);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bzero(&act, sizeof (act));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync act.sa_handler = SIG_DFL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigaction(SIGCHLD, &act, &oact);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((pid = fork1()) == -1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigaction(SIGCHLD, &oact, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigprocmask(SIG_SETMASK, &omask, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, EDT_CPPFORK);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (pid == 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) execvp(dtp->dt_cpp_path, argv);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync _exit(errno == ENOENT ? 127 : 126);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync do {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("waiting for %s (PID %d)\n", dtp->dt_cpp_path,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (int)pid);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } while (waitpid(pid, &wstat, 0) == -1 && errno == EINTR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigaction(SIGCHLD, &oact, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) sigprocmask(SIG_SETMASK, &omask, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("%s returned exit status 0x%x\n", dtp->dt_cpp_path, wstat);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync estat = WIFEXITED(wstat) ? WEXITSTATUS(wstat) : -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (estat != 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (estat) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case 126:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, EDT_CPPEXEC);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case 127:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, EDT_CPPENT);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync default:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, EDT_CPPERR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync free(argv);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fflush(ofp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fseek(ofp, 0, SEEK_SET);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (ofp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncerr:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync free(argv);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fclose(ofp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (NULL);
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else /* VBOX */
15131f635944423d12704f2e6e51799511ac51ccvboxsync (void) dt_set_errno(dtp, EDT_CPPERR);
15131f635944423d12704f2e6e51799511ac51ccvboxsync return (NULL);
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif /* VBOX */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_error(dtrace_hdl_t *dtp, const char *format, ...)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync va_list ap;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync va_start(ap, format);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_set_errmsg(dtp, NULL, NULL, NULL, 0, format, ap);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync va_end(ap);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_add(dtrace_hdl_t *dtp, dt_list_t *dlp, const char *arg)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dld;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *end;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(arg != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((end = strrchr(arg, '/')) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EINVAL));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dld = dt_zalloc(dtp, sizeof (dt_lib_depend_t))) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dld->dtld_libpath = dt_alloc(dtp, MAXPATHLEN)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) strlcpy(dld->dtld_libpath, arg, end - arg + 2);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dld->dtld_library = strdup(arg)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld->dtld_libpath);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EDT_NOMEM));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_append(dlp, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_t *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_lookup(dt_list_t *dld, const char *arg)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dldn;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dldn = dt_list_next(dld); dldn != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dldn = dt_list_next(dldn)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (strcmp(dldn->dtld_library, arg) == 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dldn);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Go through all the library files, and, if any library dependencies exist for
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * that file, add it to that node's list of dependents. The result of this
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * will be a graph which can then be topologically sorted to produce a
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * compilation order.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_build_graph(dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dld, *dpld;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld = dt_list_next(dld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char *library = dld->dtld_library;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dpld = dt_list_next(&dld->dtld_dependencies); dpld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld = dt_list_next(dpld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dlda;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld->dtld_library)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_error(dtp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "Invalid library dependency in %s: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_library, dpld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EDT_COMPILER));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dt_lib_depend_add(dtp, &dlda->dtld_dependents,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync library)) != 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1); /* preserve dt_errno */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_topo_sort(dtrace_hdl_t *dtp, dt_lib_depend_t *dld, int *count)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dpld, *dlda, *new;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_start = ++(*count);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dpld = dt_list_next(&dld->dtld_dependents); dpld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld = dt_list_next(dpld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(dlda != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dlda->dtld_start == 0 &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_topo_sort(dtp, dlda, count) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((new = dt_zalloc(dtp, sizeof (dt_lib_depend_t))) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((new->dtld_library = strdup(dld->dtld_library)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, new);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EDT_NOMEM));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync new->dtld_start = dld->dtld_start;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync new->dtld_finish = dld->dtld_finish = ++(*count);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_prepend(&dtp->dt_lib_dep_sorted, new);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("library %s sorted (%d/%d)\n", new->dtld_library,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync new->dtld_start, new->dtld_finish);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_sort(dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dld, *dpld, *dlda;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int count = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_lib_build_graph(dtp) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1); /* preserve dt_errno */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Perform a topological sort of the graph that hangs off
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dtp->dt_lib_dep. The result of this process will be a
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * dependency ordered list located at dtp->dt_lib_dep_sorted.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld = dt_list_next(dld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dld->dtld_start == 0 &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_topo_sort(dtp, dld, &count) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1); /* preserve dt_errno */;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Check the graph for cycles. If an ancestor's finishing time is
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * less than any of its dependent's finishing times then a back edge
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * exists in the graph and this is a cycle.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld = dt_list_next(dld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dpld = dt_list_next(&dld->dtld_dependents); dpld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld = dt_list_next(dpld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dlda = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dpld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(dlda != NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dlda->dtld_finish > dld->dtld_finish) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_error(dtp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "Cyclic dependency detected: %s => %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_library, dpld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_set_errno(dtp, EDT_COMPILER));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_lib_depend_free(dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dld, *dlda;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while ((dld = dt_list_next(&dtp->dt_lib_dep)) != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while ((dlda = dt_list_next(&dld->dtld_dependencies)) != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_delete(&dld->dtld_dependencies, dlda);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda->dtld_libpath);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while ((dlda = dt_list_next(&dld->dtld_dependents)) != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_delete(&dld->dtld_dependents, dlda);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda->dtld_libpath);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dlda);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_delete(&dtp->dt_lib_dep, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld->dtld_libpath);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while ((dld = dt_list_next(&dtp->dt_lib_dep_sorted)) != NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_list_delete(&dtp->dt_lib_dep_sorted, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld->dtld_library);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_free(dtp, dld);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Open all of the .d library files found in the specified directory and
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * compile each one in topological order to cache its inlines and translators,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * etc. We silently ignore any missing directories and other files found
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * therein. We only fail (and thereby fail dt_load_libs()) if we fail to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * compile a library and the error is something other than #pragma D depends_on.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Dependency errors are silently ignored to permit a library directory to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * contain libraries which may not be accessible depending on our privileges.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_load_libs_dir(dtrace_hdl_t *dtp, const char *path)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct dirent *dp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *p;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DIR *dirp;
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else
15131f635944423d12704f2e6e51799511ac51ccvboxsync PRTDIR pDir;
15131f635944423d12704f2e6e51799511ac51ccvboxsync RTDIRENTRY DirEntry;
15131f635944423d12704f2e6e51799511ac51ccvboxsync const char *p;
15131f635944423d12704f2e6e51799511ac51ccvboxsync int rc;
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char fname[PATH_MAX];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_prog_t *pgp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync FILE *fp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void *rv;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_t *dld;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dirp = opendir(path)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("skipping lib dir %s: %s\n", path, strerror(errno));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else
15131f635944423d12704f2e6e51799511ac51ccvboxsync rc = RTDirOpen(&pDir, path);
15131f635944423d12704f2e6e51799511ac51ccvboxsync if (RT_FAILURE(rc)) {
15131f635944423d12704f2e6e51799511ac51ccvboxsync dt_dprintf("skipping lib dir %s: %s\n", path, RTErrGetShort(rc));
15131f635944423d12704f2e6e51799511ac51ccvboxsync return (0);
15131f635944423d12704f2e6e51799511ac51ccvboxsync }
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* First, parse each file for library dependencies. */
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync while ((dp = readdir(dirp)) != NULL) {
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else
15131f635944423d12704f2e6e51799511ac51ccvboxsync while (RT_SUCCESS(RTDirRead(pDir, &DirEntry, 0))) {
15131f635944423d12704f2e6e51799511ac51ccvboxsync struct FakeDirEntry {
15131f635944423d12704f2e6e51799511ac51ccvboxsync const char *d_name;
15131f635944423d12704f2e6e51799511ac51ccvboxsync } FakeDirEntry = { DirEntry.szName }, *dp = &FakeDirEntry;
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((p = strrchr(dp->d_name, '.')) == NULL || strcmp(p, ".d"))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue; /* skip any filename not ending in .d */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) snprintf(fname, sizeof (fname),
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "%s/%s", path, dp->d_name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((fp = fopen(fname, "r")) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("skipping library %s: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fname, strerror(errno));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_filetag = fname;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_lib_depend_add(dtp, &dtp->dt_lib_dep, fname) != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rv = dt_compile(dtp, DT_CTX_DPROG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_PROBESPEC_NAME, NULL,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_C_EMPTY | DTRACE_C_CTL, 0, NULL, fp, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (rv != NULL && dtp->dt_errno &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (dtp->dt_errno != EDT_COMPILER ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_errtag != dt_errtag(D_PRAGMA_DEPEND)))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_errno)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("error parsing library %s: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync fname, dtrace_errmsg(dtp, dtrace_errno(dtp)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fclose(fp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_filetag = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
15131f635944423d12704f2e6e51799511ac51ccvboxsync#ifndef VBOX
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) closedir(dirp);
15131f635944423d12704f2e6e51799511ac51ccvboxsync#else
15131f635944423d12704f2e6e51799511ac51ccvboxsync RTDirClose(pDir);
15131f635944423d12704f2e6e51799511ac51ccvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Finish building the graph containing the library dependencies
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and perform a topological sort to generate an ordered list
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * for compilation.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_lib_depend_sort(dtp) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dld = dt_list_next(&dtp->dt_lib_dep_sorted); dld != NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld = dt_list_next(dld)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((fp = fopen(dld->dtld_library, "r")) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("skipping library %s: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_library, strerror(errno));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync continue;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_filetag = dld->dtld_library;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pgp = dtrace_program_fcompile(dtp, fp, DTRACE_C_EMPTY, 0, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fclose(fp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_filetag = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (pgp == NULL && (dtp->dt_errno != EDT_COMPILER ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_errtag != dt_errtag(D_PRAGMA_DEPEND)))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (pgp == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("skipping library %s: %s\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_library,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_errmsg(dtp, dtrace_errno(dtp)));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync } else {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dld->dtld_loaded = B_TRUE;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_program_destroy(dtp, pgp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_free(dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncerr:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_lib_depend_free(dtp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1); /* preserve dt_errno */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Load the contents of any appropriate DTrace .d library files. These files
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * contain inlines and translators that will be cached by the compiler. We
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * defer this activity until the first compile to permit libdtrace clients to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * add their own library directories and so that we can properly report errors.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic int
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_load_libs(dtrace_hdl_t *dtp)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dirpath_t *dirp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_cflags & DTRACE_C_NOLIBS)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0); /* libraries already processed */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_cflags |= DTRACE_C_NOLIBS;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (dirp = dt_list_next(&dtp->dt_lib_path);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dirp != NULL; dirp = dt_list_next(dirp)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_load_libs_dir(dtp, dirp->dir_path) != 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_cflags &= ~DTRACE_C_NOLIBS;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1); /* errno is set for us */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t cflags, int argc, char *const argv[], FILE *fp, const char *s)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_t *dnp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_decl_t *ddp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pcb_t pcb;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void *rv;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int err;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((fp == NULL && s == NULL) || (cflags & ~DTRACE_C_MASK) != 0) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, EINVAL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_list_next(&dtp->dt_lib_path) != NULL && dt_load_libs(dtp) != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (NULL); /* errno is set for us */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_globals->dh_nelems != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_tls->dh_nelems != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (fp && (cflags & DTRACE_C_CPP) && (fp = dt_preproc(dtp, fp)) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (NULL); /* errno is set for us */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pcb_push(dtp, &pcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_fileptr = fp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_string = s;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_strptr = s;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_strlen = s ? strlen(s) : 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_sargc = argc;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_sargv = argv;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_sflagv = argc ? calloc(argc, sizeof (ushort_t)) : NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_pspec = pspec;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_cflags = dtp->dt_cflags | cflags;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_amin = dtp->dt_amin;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_yystate = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_context = context;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pcb.pcb_token = context;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
2fc831009973ba4f02b68bfccfd69fa85d8f522bvboxsync#ifdef USING_FLEX /* In case flex starts work too early. Moved from dt_pcb_push. */
2fc831009973ba4f02b68bfccfd69fa85d8f522bvboxsync yyinit(&pcb);
2fc831009973ba4f02b68bfccfd69fa85d8f522bvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (context != DT_CTX_DPROG)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yybegin(YYS_EXPR);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync else if (cflags & DTRACE_C_CTL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yybegin(YYS_CONTROL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync else
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yybegin(YYS_CLAUSE);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((err = setjmp(yypcb->pcb_jmpbuf)) != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto out;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yypcb->pcb_sargc != 0 && yypcb->pcb_sflagv == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_idents = dt_idhash_create("ambiguous", NULL, 0, 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_locals = dt_idhash_create("clause local", NULL,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DIF_VAR_OTHER_UBASE, DIF_VAR_OTHER_MAX);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yypcb->pcb_idents == NULL || yypcb->pcb_locals == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Invoke the parser to evaluate the D source code. If any errors
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * occur during parsing, an error function will be called and we
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * will longjmp back to pcb_jmpbuf to abort. If parsing succeeds,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * we optionally display the parse tree if debugging is enabled.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yyparse() != 0 || yypcb->pcb_root == NULL)
2fc831009973ba4f02b68bfccfd69fa85d8f522bvboxsync xyerror(D_EMPTY, "empty D program translation unit\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yybegin(YYS_DONE);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (cflags & DTRACE_C_CTL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync goto out;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 1))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_printr(yypcb->pcb_root, stderr, 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yypcb->pcb_pragmas != NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_idhash_iter(yypcb->pcb_pragmas, dt_idpragma, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (argc > 1 && !(yypcb->pcb_cflags & DTRACE_C_ARGREF) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync !(yypcb->pcb_sflagv[argc - 1] & DT_IDFLG_REF)) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync xyerror(D_MACRO_UNUSED, "extraneous argument '%s' ($%d is "
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "not referenced)\n", yypcb->pcb_sargv[argc - 1], argc - 1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If we have successfully created a parse tree for a D program, loop
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * over the clauses and actions and instantiate the corresponding
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * libdtrace program. If we are parsing a D expression, then we
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * simply run the code generator and assembler on the resulting tree.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (context) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_CTX_DPROG:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync assert(yypcb->pcb_root->dn_kind == DT_NODE_PROG);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dnp = yypcb->pcb_root->dn_list) == NULL &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync !(yypcb->pcb_cflags & DTRACE_C_EMPTY))
2fc831009973ba4f02b68bfccfd69fa85d8f522bvboxsync xyerror(D_EMPTY, "empty D program translation unit\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((yypcb->pcb_prog = dt_program_create(dtp)) == NULL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, dtrace_errno(dtp));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (; dnp != NULL; dnp = dnp->dn_list) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync switch (dnp->dn_kind) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_CLAUSE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_clause(dtp, dnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_XLATOR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_xlatemode == DT_XL_DYNAMIC)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_compile_xlator(dnp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_NODE_PROVIDER:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_node_cook(dnp, DT_IDFLG_REF);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_prog->dp_xrefs = yypcb->pcb_asxrefs;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_prog->dp_xrefslen = yypcb->pcb_asxreflen;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_asxrefs = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync yypcb->pcb_asxreflen = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rv = yypcb->pcb_prog;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_CTX_DEXPR:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_node_cook(yypcb->pcb_root, DT_IDFLG_REF);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_cg(yypcb, yypcb->pcb_root);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rv = dt_as(yypcb);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync case DT_CTX_DTYPE:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ddp = (dt_decl_t *)yypcb->pcb_root; /* root is really a decl */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync err = dt_decl_type(ddp, arg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_decl_free(ddp);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (err != 0)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rv = NULL;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync break;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncout:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 3))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_node_printr(yypcb->pcb_root, stderr, 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_cdefs_fd != -1 && (ftruncate64(dtp->dt_cdefs_fd, 0) == -1 ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync lseek64(dtp->dt_cdefs_fd, 0, SEEK_SET) == -1 ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_write(dtp->dt_cdefs->dm_ctfp, dtp->dt_cdefs_fd) == CTF_ERR))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("failed to update CTF cache: %s\n", strerror(errno));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_ddefs_fd != -1 && (ftruncate64(dtp->dt_ddefs_fd, 0) == -1 ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync lseek64(dtp->dt_ddefs_fd, 0, SEEK_SET) == -1 ||
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_write(dtp->dt_ddefs->dm_ctfp, dtp->dt_ddefs_fd) == CTF_ERR))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_dprintf("failed to update CTF cache: %s\n", strerror(errno));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (yypcb->pcb_fileptr && (cflags & DTRACE_C_CPP))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) fclose(yypcb->pcb_fileptr); /* close dt_preproc() file */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pcb_pop(dtp, err);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_set_errno(dtp, err);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (err ? NULL : rv);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_prog_t *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_program_strcompile(dtrace_hdl_t *dtp, const char *s,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_probespec_t spec, uint_t cflags, int argc, char *const argv[])
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_compile(dtp, DT_CTX_DPROG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync spec, NULL, cflags, argc, argv, NULL, s));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_prog_t *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_program_fcompile(dtrace_hdl_t *dtp, FILE *fp,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t cflags, int argc, char *const argv[])
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dt_compile(dtp, DT_CTX_DPROG,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_PROBESPEC_NAME, NULL, cflags, argc, argv, fp, NULL));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_type_strcompile(dtrace_hdl_t *dtp, const char *s, dtrace_typeinfo_t *dtt)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_compile(dtp, DT_CTX_DTYPE,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_PROBESPEC_NONE, dtt, 0, 0, NULL, NULL, s);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dtp->dt_errno ? -1 : 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace_type_fcompile(dtrace_hdl_t *dtp, FILE *fp, dtrace_typeinfo_t *dtt)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dt_compile(dtp, DT_CTX_DTYPE,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync DTRACE_PROBESPEC_NONE, dtt, 0, 0, NULL, fp, NULL);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (dtp->dt_errno ? -1 : 0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}