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