xref: /titanic_44/usr/src/cmd/sgs/liblddbg/common/audit.c (revision e79c98e6c943cb3032f272714ff4ce6137d40394)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<dlfcn.h>
29 #include	<stdio.h>
30 #include	"_debug.h"
31 #include	"msg.h"
32 #include	"libld.h"
33 
34 void
35 Dbg_audit_version(Lm_list *lml, const char *lib, ulong_t version)
36 {
37 	if (DBG_NOTCLASS(DBG_C_AUDITING))
38 		return;
39 
40 	Dbg_util_nl(lml, DBG_NL_STD);
41 	dbg_print(lml, MSG_INTL(MSG_AUD_VERSION), lib, (int)version);
42 }
43 
44 void
45 Dbg_audit_lib(Lm_list *lml, const char *lib)
46 {
47 	if (DBG_NOTCLASS(DBG_C_AUDITING))
48 		return;
49 
50 	Dbg_util_nl(lml, DBG_NL_STD);
51 	dbg_print(lml, MSG_INTL(MSG_AUD_INIT), lib);
52 }
53 
54 void
55 Dbg_audit_interface(Lm_list *lml, const char *lib, const char *interface)
56 {
57 	if (DBG_NOTCLASS(DBG_C_AUDITING))
58 		return;
59 
60 	Dbg_util_nl(lml, DBG_NL_STD);
61 	dbg_print(lml, MSG_INTL(MSG_AUD_INTERFACE), lib, interface);
62 }
63 
64 void
65 Dbg_audit_object(Lm_list *lml, const char *lib, const char *obj)
66 {
67 	if (DBG_NOTCLASS(DBG_C_AUDITING))
68 		return;
69 
70 	Dbg_util_nl(lml, DBG_NL_STD);
71 	dbg_print(lml, MSG_INTL(MSG_AUD_OBJECT), lib, obj);
72 }
73 
74 void
75 Dbg_audit_symval(Lm_list *lml, const char *lib, const char *func,
76     const char *sym, Addr pval, Addr nval)
77 {
78 	char	mesg[100];
79 
80 	if (DBG_NOTCLASS(DBG_C_AUDITING))
81 		return;
82 	if (DBG_NOTDETAIL())
83 		return;
84 
85 	if (pval == nval)
86 		mesg[0] = '\0';
87 	else
88 		(void) sprintf(mesg, MSG_INTL(MSG_AUD_SYMNEW), EC_XWORD(nval));
89 
90 	dbg_print(lml, MSG_INTL(MSG_AUD_SYM), lib, func, Dbg_demangle_name(sym),
91 	    EC_XWORD(pval), mesg);
92 }
93 
94 void
95 Dbg_audit_skip(Lm_list *lml, const char *name, const char *lmid)
96 {
97 	if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
98 		return;
99 
100 	dbg_print(lml, MSG_INTL(MSG_AUD_SKIP), name, lmid);
101 }
102 
103 void
104 Dbg_audit_terminate(Lm_list *lml, const char *name)
105 {
106 	if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
107 		return;
108 
109 	dbg_print(lml, MSG_INTL(MSG_AUD_TERM), name);
110 }
111 
112 void
113 Dbg_audit_ignore(Rt_map *lmp)
114 {
115 	if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES))
116 		return;
117 
118 	dbg_print(LIST(lmp), MSG_INTL(MSG_AUD_IGNORE), NAME(lmp));
119 }
120