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