xref: /titanic_44/usr/src/cmd/sgs/liblddbg/common/audit.c (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
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 2005 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 
35 void
36 Dbg_audit_version(const char *lib, ulong_t version)
37 {
38 	if (DBG_NOTCLASS(DBG_AUDITING))
39 		return;
40 
41 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
42 	dbg_print(MSG_INTL(MSG_AUD_VERSION), lib, (int)version);
43 }
44 
45 void
46 Dbg_audit_lib(const char *lib)
47 {
48 	if (DBG_NOTCLASS(DBG_AUDITING))
49 		return;
50 
51 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
52 	dbg_print(MSG_INTL(MSG_AUD_INIT), lib);
53 }
54 
55 void
56 Dbg_audit_interface(const char *lib, const char *interface)
57 {
58 	if (DBG_NOTCLASS(DBG_AUDITING))
59 		return;
60 
61 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
62 	dbg_print(MSG_INTL(MSG_AUD_INTERFACE), lib, interface);
63 }
64 
65 void
66 Dbg_audit_object(const char *lib, const char *obj)
67 {
68 	if (DBG_NOTCLASS(DBG_AUDITING))
69 		return;
70 
71 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
72 	dbg_print(MSG_INTL(MSG_AUD_OBJECT), lib, obj);
73 }
74 
75 void
76 Dbg_audit_symval(const char *lib, const char *func, const char *sym,
77     Addr pval, Addr nval)
78 {
79 	char	mesg[100];
80 
81 	if (DBG_NOTCLASS(DBG_AUDITING))
82 		return;
83 	if (DBG_NOTDETAIL())
84 		return;
85 
86 	if (pval == nval)
87 		mesg[0] = '\0';
88 	else
89 		(void) sprintf(mesg, MSG_INTL(MSG_AUD_SYMNEW), EC_XWORD(nval));
90 
91 	dbg_print(MSG_INTL(MSG_AUD_SYM), lib, func, _Dbg_sym_dem(sym),
92 	    EC_XWORD(pval), mesg);
93 }
94