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