dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / sgs / liblddbg / common / audit.c
blob9b2186c11ce03e2336ebcc301f5577cf25c5e8af
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
26 #include <dlfcn.h>
27 #include <stdio.h>
28 #include "_debug.h"
29 #include "msg.h"
30 #include "libld.h"
32 void
33 Dbg_audit_lib(Rt_map *clmp, const char *lib, int type)
35 Lm_list *clml = LIST(clmp);
36 const char *str;
38 if (DBG_NOTCLASS(DBG_C_AUDITING))
39 return;
41 Dbg_util_nl(clml, DBG_NL_STD);
42 switch (type) {
43 case DBG_AUD_PRELOAD:
44 str = MSG_ORIG(MSG_AUD_PRELOAD);
45 break;
46 case DBG_AUD_GLOBAL:
47 str = MSG_ORIG(MSG_AUD_GLOBAL);
48 break;
49 case DBG_AUD_LOCAL:
50 /* FALLTHROUGH */
51 default:
52 str = MSG_ORIG(MSG_STR_EMPTY);
55 dbg_print(clml, MSG_INTL(MSG_AUD_LIB), lib, NAME(clmp), str);
58 void
59 Dbg_audit_interface(Lm_list *lml, const char *lib, const char *interface)
61 if (DBG_NOTCLASS(DBG_C_AUDITING))
62 return;
64 dbg_print(lml, MSG_INTL(MSG_AUD_INTERFACE), lib, interface);
67 void
68 Dbg_audit_version(Lm_list *lml, const char *lib, uint_t overs, uint_t nvers)
70 if (DBG_NOTCLASS(DBG_C_AUDITING))
71 return;
73 dbg_print(lml, MSG_INTL(MSG_AUD_VERSION), lib, overs, nvers);
76 void
77 Dbg_audit_activity(Lm_list *lml, const char *lib, const char *obj, uint_t flags)
79 Conv_inv_buf_t inv_buf;
81 if (DBG_NOTCLASS(DBG_C_AUDITING))
82 return;
84 Dbg_util_nl(lml, DBG_NL_STD);
85 dbg_print(lml, MSG_INTL(MSG_AUD_ACTIVITY), lib, obj,
86 conv_la_activity(flags, CONV_FMT_ALT_DEFAULT, &inv_buf));
89 void
90 Dbg_audit_preinit(Lm_list *lml, const char *lib, const char *obj)
92 if (DBG_NOTCLASS(DBG_C_AUDITING))
93 return;
95 Dbg_util_nl(lml, DBG_NL_STD);
96 dbg_print(lml, MSG_INTL(MSG_AUD_PREINIT), lib, obj);
99 void
100 Dbg_audit_objsearch(Lm_list *lml, int call, const char *lib,
101 const char *oobj, uint_t flags, const char *nobj)
103 Conv_la_search_buf_t la_search_buf;
105 if (DBG_NOTCLASS(DBG_C_AUDITING))
106 return;
108 if (call == DBG_AUD_CALL) {
109 Dbg_util_nl(lml, DBG_NL_STD);
110 dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH), lib, oobj,
111 conv_la_search(flags, &la_search_buf));
112 } else {
113 if (nobj)
114 dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH_R), lib,
115 oobj, nobj);
116 else
117 dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH_S), lib,
118 oobj);
122 void
123 Dbg_audit_objfilter(Lm_list *lml, int call, const char *lib,
124 const char *filter, const char *filtee, const char *ref)
126 if (DBG_NOTCLASS(DBG_C_AUDITING))
127 return;
129 if (call == DBG_AUD_CALL) {
130 Dbg_util_nl(lml, DBG_NL_STD);
131 dbg_print(lml, MSG_INTL(MSG_AUD_OBJFILTER), lib, filter,
132 filtee, ref);
133 } else
134 dbg_print(lml, MSG_INTL(MSG_AUD_OBJFILTER_R), lib, filter);
137 void
138 Dbg_audit_objopen(Lm_list *lml, int call, const char *lib, const char *obj,
139 uint_t flags, Boolean ignore)
141 Conv_la_bind_buf_t la_bind_buf;
143 if (DBG_NOTCLASS(DBG_C_AUDITING))
144 return;
146 if (call == DBG_AUD_CALL) {
147 Dbg_util_nl(lml, DBG_NL_STD);
148 dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN), lib, obj);
149 } else {
150 if (ignore)
151 dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN_RI), lib, obj,
152 conv_la_bind(flags, &la_bind_buf));
153 else
154 dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN_R), lib, obj,
155 conv_la_bind(flags, &la_bind_buf));
159 void
160 Dbg_audit_objclose(Lm_list *lml, const char *lib, const char *obj)
162 if (DBG_NOTCLASS(DBG_C_AUDITING))
163 return;
165 Dbg_util_nl(lml, DBG_NL_STD);
166 dbg_print(lml, MSG_INTL(MSG_AUD_OBJCLOSE), lib, obj);
169 void
170 Dbg_audit_symbind(Lm_list *lml, int call, const char *lib, const char *name,
171 Addr value, uint_t flags)
173 Conv_la_symbind_buf_t la_symbind_buf;
175 if (DBG_NOTCLASS(DBG_C_AUDITING))
176 return;
178 if (call == DBG_AUD_CALL) {
179 Dbg_util_nl(lml, DBG_NL_STD);
180 dbg_print(lml, MSG_INTL(MSG_AUD_SYMBIND), lib, name,
181 EC_XWORD(value), conv_la_symbind(flags, &la_symbind_buf));
182 } else {
183 dbg_print(lml, MSG_INTL(MSG_AUD_SYMBIND_R), lib, name,
184 EC_XWORD(value), conv_la_symbind(flags, &la_symbind_buf));
188 void
189 Dbg_audit_pltenter(Lm_list *lml, int call, const char *lib, const char *name,
190 Addr value)
192 if (DBG_NOTCLASS(DBG_C_AUDITING))
193 return;
195 if (call == DBG_AUD_CALL) {
196 Dbg_util_nl(lml, DBG_NL_STD);
197 dbg_print(lml, MSG_INTL(MSG_AUD_PLTENTER), lib, name,
198 EC_XWORD(value));
199 } else {
200 dbg_print(lml, MSG_INTL(MSG_AUD_PLTENTER_R), lib, name,
201 EC_XWORD(value));
205 void
206 Dbg_audit_pltexit(Lm_list *lml, const char *lib, const char *name)
208 if (DBG_NOTCLASS(DBG_C_AUDITING))
209 return;
211 dbg_print(lml, MSG_INTL(MSG_AUD_PLTEXIT), lib, name);
214 void
215 Dbg_audit_skip(Lm_list *lml, const char *name, const char *lmid)
217 if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
218 return;
220 dbg_print(lml, MSG_INTL(MSG_AUD_SKIP), name, lmid);
223 void
224 Dbg_audit_terminate(Lm_list *lml, const char *name)
226 if (DBG_NOTCLASS(DBG_C_FILES))
227 return;
229 dbg_print(lml, MSG_INTL(MSG_AUD_TERM), name);
232 void
233 Dbg_audit_ignore(Rt_map *lmp)
235 if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
236 return;
238 dbg_print(LIST(lmp), MSG_INTL(MSG_AUD_IGNORE), NAME(lmp));