1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1998-2000 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _APPTRACE_H 28*7c478bd9Sstevel@tonic-gate #define _APPTRACE_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #include <stdio.h> 31*7c478bd9Sstevel@tonic-gate #include <string.h> 32*7c478bd9Sstevel@tonic-gate #include <stdarg.h> 33*7c478bd9Sstevel@tonic-gate #include <dlfcn.h> 34*7c478bd9Sstevel@tonic-gate #include <link.h> 35*7c478bd9Sstevel@tonic-gate #include <signal.h> 36*7c478bd9Sstevel@tonic-gate #include <synch.h> 37*7c478bd9Sstevel@tonic-gate #include <wchar.h> 38*7c478bd9Sstevel@tonic-gate #include <thread.h> 39*7c478bd9Sstevel@tonic-gate #include <apptrace_impl.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 42*7c478bd9Sstevel@tonic-gate extern "C" { 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * Extract the verbosity flag. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define ABI_VFLAG(lib, symbol) \ 49*7c478bd9Sstevel@tonic-gate __abi_ ## lib ## _ ## symbol ## _sym.a_vflag 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate * Extract the function pointer to the real ABI function. 53*7c478bd9Sstevel@tonic-gate */ 54*7c478bd9Sstevel@tonic-gate #define ABI_REAL(lib, symbol) \ 55*7c478bd9Sstevel@tonic-gate __abi_ ## lib ## _ ## symbol ## _sym.a_real 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * Macro to create the part of a function call prior 59*7c478bd9Sstevel@tonic-gate * to the arg list. 60*7c478bd9Sstevel@tonic-gate * cast is a full cast expression for a _pointer_ to 61*7c478bd9Sstevel@tonic-gate * the ABI function being called. 62*7c478bd9Sstevel@tonic-gate * 63*7c478bd9Sstevel@tonic-gate * e.g. ABI_CALL_REAL(libc, getpid, (pid_t (*)(void))) (); 64*7c478bd9Sstevel@tonic-gate */ 65*7c478bd9Sstevel@tonic-gate #define ABI_CALL_REAL(lib, sym, cast) \ 66*7c478bd9Sstevel@tonic-gate (cast __abi_ ## lib ## _ ## sym ## _sym.a_real) 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate #define ABISTREAM __abi_outfile 69*7c478bd9Sstevel@tonic-gate #define ABIPUTS(x) (void) fputs((x), ABISTREAM) 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * The following declarations and macros are needed for 73*7c478bd9Sstevel@tonic-gate * anybody needing the vprintf family of calls where they 74*7c478bd9Sstevel@tonic-gate * MUST come from the BASE link map instead of the auditing 75*7c478bd9Sstevel@tonic-gate * link map. 76*7c478bd9Sstevel@tonic-gate */ 77*7c478bd9Sstevel@tonic-gate #define ABI_VSNPRINTF __abi_real_vsnprintf 78*7c478bd9Sstevel@tonic-gate #define ABI_VSWPRINTF __abi_real_vswprintf 79*7c478bd9Sstevel@tonic-gate #define ABI_VWPRINTF __abi_real_vwprintf 80*7c478bd9Sstevel@tonic-gate #define ABI_VFPRINTF __abi_real_vfprintf 81*7c478bd9Sstevel@tonic-gate #define ABI_VFWPRINTF __abi_real_vfwprintf 82*7c478bd9Sstevel@tonic-gate #define ABI_VPRINTF __abi_real_vprintf 83*7c478bd9Sstevel@tonic-gate #define ABI_VSPRINTF __abi_real_vsprintf 84*7c478bd9Sstevel@tonic-gate #define ABI_ERRNO (*(__abi_real_errno())) 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* From libstabspf */ 87*7c478bd9Sstevel@tonic-gate typedef enum { 88*7c478bd9Sstevel@tonic-gate STAB_SUCCESS = 0, /* All is well. */ 89*7c478bd9Sstevel@tonic-gate STAB_FAIL = -1, /* Parsing error. */ 90*7c478bd9Sstevel@tonic-gate STAB_NA = -2, /* Information is Not Applicable. */ 91*7c478bd9Sstevel@tonic-gate STAB_NOMEM = -3 /* Out of Memory! */ 92*7c478bd9Sstevel@tonic-gate } stabsret_t; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate extern int (*ABI_VFPRINTF)(FILE *, const char *, va_list); 95*7c478bd9Sstevel@tonic-gate extern int (*ABI_VFWPRINTF)(FILE *, const wchar_t *, va_list); 96*7c478bd9Sstevel@tonic-gate extern int (*ABI_VPRINTF)(const char *, va_list); 97*7c478bd9Sstevel@tonic-gate extern int (*ABI_VSNPRINTF)(char *, size_t, const char *, va_list); 98*7c478bd9Sstevel@tonic-gate extern int (*ABI_VSPRINTF)(char *, const char *, va_list); 99*7c478bd9Sstevel@tonic-gate extern int (*ABI_VSWPRINTF)(wchar_t *, size_t, const wchar_t *, va_list); 100*7c478bd9Sstevel@tonic-gate extern int (*ABI_VWPRINTF)(const wchar_t *, va_list); 101*7c478bd9Sstevel@tonic-gate extern int *(*__abi_real_errno)(void); 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate extern void *abi_malloc(size_t); 104*7c478bd9Sstevel@tonic-gate extern void *abi_calloc(size_t, size_t); 105*7c478bd9Sstevel@tonic-gate extern void *abi_realloc(void *, size_t); 106*7c478bd9Sstevel@tonic-gate extern int abi_putc(int, FILE *); 107*7c478bd9Sstevel@tonic-gate extern int abi_fputs(const char *, FILE *); 108*7c478bd9Sstevel@tonic-gate extern void abi_free(void *); 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* From libstabspf */ 111*7c478bd9Sstevel@tonic-gate extern stabsret_t spf_load_stabs(const char *); 112*7c478bd9Sstevel@tonic-gate extern int spf_prtype(FILE *, char const *, int, void const *); 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate extern int abi_strpsz; /* size constraint for string printing */ 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 117*7c478bd9Sstevel@tonic-gate } 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #endif /* _APPTRACE_H */ 121