xref: /titanic_41/usr/src/head/apptrace.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <stdio.h>
33 #include <string.h>
34 #include <stdarg.h>
35 #include <dlfcn.h>
36 #include <link.h>
37 #include <signal.h>
38 #include <synch.h>
39 #include <wchar.h>
40 #include <thread.h>
41 #include <apptrace_impl.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Extract the verbosity flag.
49  */
50 #define	ABI_VFLAG(lib, symbol) \
51 	__abi_ ## lib ## _ ## symbol ## _sym.a_vflag
52 
53 /*
54  * Extract the function pointer to the real ABI function.
55  */
56 #define	ABI_REAL(lib, symbol) \
57 	__abi_ ## lib ## _ ## symbol ## _sym.a_real
58 
59 /*
60  * Macro to create the part of a function call prior
61  * to the arg list.
62  *   cast is a full cast expression for a _pointer_ to
63  *   the ABI function being called.
64  *
65  * e.g.  ABI_CALL_REAL(libc, getpid, (pid_t (*)(void)))  ();
66  */
67 #define	ABI_CALL_REAL(lib, sym, cast) \
68 	(cast __abi_ ## lib ## _ ## sym ## _sym.a_real)
69 
70 #define	ABISTREAM	__abi_outfile
71 #define	ABIPUTS(x)	(void) fputs((x), ABISTREAM)
72 
73 /*
74  * The following declarations and macros are needed for
75  * anybody needing the vprintf family of calls where they
76  * MUST come from the BASE link map instead of the auditing
77  * link map.
78  */
79 #define	ABI_VSNPRINTF	__abi_real_vsnprintf
80 #define	ABI_VSWPRINTF	__abi_real_vswprintf
81 #define	ABI_VWPRINTF	__abi_real_vwprintf
82 #define	ABI_VFPRINTF	__abi_real_vfprintf
83 #define	ABI_VFWPRINTF	__abi_real_vfwprintf
84 #define	ABI_VPRINTF	__abi_real_vprintf
85 #define	ABI_VSPRINTF	__abi_real_vsprintf
86 #define	ABI_ERRNO	(*(__abi_real_errno()))
87 
88 /* From libstabspf */
89 typedef enum {
90 	STAB_SUCCESS	= 0,	/* All is well. */
91 	STAB_FAIL	= -1,	/* Parsing error. */
92 	STAB_NA		= -2,	/* Information is Not Applicable. */
93 	STAB_NOMEM	= -3	/* Out of Memory! */
94 } stabsret_t;
95 
96 extern int (*ABI_VFPRINTF)(FILE *, const char *, va_list);
97 extern int (*ABI_VFWPRINTF)(FILE *, const wchar_t *, va_list);
98 extern int (*ABI_VPRINTF)(const char *, va_list);
99 extern int (*ABI_VSNPRINTF)(char *, size_t, const char *, va_list);
100 extern int (*ABI_VSPRINTF)(char *, const char *, va_list);
101 extern int (*ABI_VSWPRINTF)(wchar_t *, size_t, const wchar_t *, va_list);
102 extern int (*ABI_VWPRINTF)(const wchar_t *, va_list);
103 extern int *(*__abi_real_errno)(void);
104 
105 extern void *abi_malloc(size_t);
106 extern void *abi_calloc(size_t, size_t);
107 extern void *abi_realloc(void *, size_t);
108 extern int  abi_putc(int, FILE *);
109 extern int  abi_fputs(const char *, FILE *);
110 extern void abi_free(void *);
111 
112 /* From libstabspf */
113 extern stabsret_t spf_load_stabs(const char *);
114 extern int spf_prtype(FILE *, char const *, int, void const *);
115 
116 extern int abi_strpsz;	/* size constraint for string printing */
117 
118 #ifdef	__cplusplus
119 }
120 #endif
121 
122 #endif	/* _APPTRACE_H */
123