xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/version.c (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
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 2004 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	<link.h>
29 #include	<stdio.h>
30 #include	"msg.h"
31 #include	"_debug.h"
32 
33 #if	!defined(_ELF64)
34 void
35 Gelf_ver_def_title()
36 {
37 	dbg_print(MSG_ORIG(MSG_VER_DEF_2));
38 }
39 
40 void
41 Gelf_ver_need_title()
42 {
43 	dbg_print(MSG_ORIG(MSG_VER_NEED_2));
44 }
45 
46 void
47 Gelf_ver_line_1(const char * index, const char * name, const char * dep,
48     const char * flags)
49 {
50 	if (DBG_NOTLONG())
51 		dbg_print(MSG_ORIG(MSG_VER_LINE_1), index, name, dep, flags);
52 	else
53 		dbg_print(MSG_ORIG(MSG_VER_L_LINE_1), index, name, dep, flags);
54 }
55 
56 void
57 Gelf_ver_line_2(const char * name, const char * dep)
58 {
59 	dbg_print(MSG_ORIG(MSG_VER_LINE_2), name, dep);
60 }
61 
62 void
63 Gelf_ver_line_3(const char * name, const char * dep, const char * flags)
64 {
65 	dbg_print(MSG_ORIG(MSG_VER_LINE_3), name, dep, flags);
66 }
67 
68 void
69 Dbg_ver_avail_title(const char * file)
70 {
71 	if (DBG_NOTCLASS(DBG_VERSIONS))
72 		return;
73 
74 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
75 	dbg_print(MSG_INTL(MSG_VER_AVAIL_1), file);
76 	dbg_print(MSG_INTL(MSG_VER_AVAIL_2));
77 }
78 
79 void
80 Dbg_ver_def_title(const char * file)
81 {
82 	if (DBG_NOTCLASS(DBG_VERSIONS))
83 		return;
84 
85 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
86 	dbg_print(MSG_INTL(MSG_VER_DEF_1), file);
87 	Gelf_ver_def_title();
88 }
89 
90 void
91 Dbg_ver_need_title(const char * file)
92 {
93 	if (DBG_NOTCLASS(DBG_VERSIONS))
94 		return;
95 
96 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
97 	dbg_print(MSG_INTL(MSG_VER_NEED_1), file);
98 	Gelf_ver_need_title();
99 }
100 
101 void
102 Dbg_ver_need_entry(Half cnt, const char * file, const char * version)
103 {
104 	if (DBG_NOTCLASS(DBG_VERSIONS))
105 		return;
106 
107 	if (cnt == 0) {
108 		if (DBG_NOTLONG())
109 			dbg_print(MSG_ORIG(MSG_VER_LINE_5), file, version);
110 		else
111 			dbg_print(MSG_ORIG(MSG_VER_L_LINE_5), file, version);
112 	} else
113 		dbg_print(MSG_ORIG(MSG_VER_LINE_4), MSG_ORIG(MSG_STR_EMPTY),
114 		    version);
115 }
116 
117 void
118 Dbg_ver_symbol(const char * name)
119 {
120 	static Boolean	ver_symbol_title = TRUE;
121 
122 	if (DBG_NOTCLASS(DBG_VERSIONS | DBG_SYMBOLS))
123 		return;
124 
125 	if (DBG_NOTCLASS(DBG_VERSIONS))
126 		if (ver_symbol_title) {
127 			ver_symbol_title = FALSE;
128 			dbg_print(MSG_ORIG(MSG_STR_EMPTY));
129 			dbg_print(MSG_INTL(MSG_SYM_VERSION));
130 		}
131 
132 	Dbg_syms_created(name);
133 }
134 
135 /*
136  * This function doesn't test for any specific debugging category, thus it will
137  * be generated for any debugging family.
138  */
139 void
140 Dbg_ver_nointerface(const char * name)
141 {
142 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
143 	dbg_print(MSG_INTL(MSG_VER_NOINTERFACE), name);
144 	dbg_print(MSG_ORIG(MSG_STR_EMPTY));
145 }
146 
147 #endif	/* !defined(_ELF64) */
148 
149 /*
150  * Print a version descriptor.
151  */
152 void
153 Dbg_ver_desc_entry(Ver_desc * vdp)
154 {
155 	const char *	dep;
156 	Ver_desc *	_vdp, * __vdp;
157 	Listnode *	lnp;
158 	char		index[10];
159 
160 	if (DBG_NOTCLASS(DBG_VERSIONS))
161 		return;
162 
163 	if (vdp->vd_deps.head) {
164 		_vdp = (Ver_desc *)vdp->vd_deps.head->data;
165 		dep = _vdp->vd_name;
166 	} else {
167 		_vdp = 0;
168 		dep = MSG_ORIG(MSG_STR_EMPTY);
169 	}
170 	(void) sprintf(index, MSG_ORIG(MSG_FMT_INDEX), vdp->vd_ndx);
171 	Gelf_ver_line_1(index, vdp->vd_name, dep,
172 	    conv_verflg_str(vdp->vd_flags));
173 
174 	/*
175 	 * Loop through the dependency list in case there are more that one
176 	 * dependency.
177 	 */
178 	for (LIST_TRAVERSE(&vdp->vd_deps, lnp, __vdp)) {
179 		if (_vdp == __vdp)
180 			continue;
181 		dbg_print(MSG_ORIG(MSG_VER_LINE_4), MSG_ORIG(MSG_STR_EMPTY),
182 		    __vdp->vd_name);
183 	}
184 }
185 
186 void
187 Dbg_ver_avail_entry(Ver_index * vip, const char * select)
188 {
189 	if (DBG_NOTCLASS(DBG_VERSIONS))
190 		return;
191 
192 	if (select) {
193 		if (DBG_NOTLONG())
194 		    dbg_print(MSG_ORIG(MSG_VER_SELECTED), vip->vi_name, select);
195 		else
196 		    dbg_print(MSG_ORIG(MSG_VER_L_SELECTED),
197 		    vip->vi_name, select);
198 	} else {
199 		if (DBG_NOTLONG())
200 		    dbg_print(MSG_ORIG(MSG_VER_ALL), vip->vi_name);
201 		else
202 		    dbg_print(MSG_ORIG(MSG_VER_L_ALL), vip->vi_name);
203 	}
204 }
205