xref: /titanic_52/usr/src/cmd/sgs/liblddbg/common/cap.c (revision 1c2187e7a735b31a46941879f0bd124e0aa325a3)
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	<stdio.h>
29 #include	<debug.h>
30 #include	<libld.h>
31 #include	<conv.h>
32 #include	"msg.h"
33 #include	"_debug.h"
34 
35 void
36 Dbg_cap_hw_candidate(Lm_list *lml, const char *name)
37 {
38 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
39 		return;
40 
41 	dbg_print(lml, MSG_INTL(MSG_CAP_HW_CANDIDATE), name);
42 }
43 
44 void
45 Dbg_cap_hw_filter(Lm_list *lml, const char *dir, Rt_map *flmp)
46 {
47 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
48 		return;
49 
50 	Dbg_util_nl(lml, DBG_NL_STD);
51 	if (flmp)
52 		dbg_print(lml, MSG_INTL(MSG_CAP_HWFILTR_1), dir, NAME(flmp));
53 	else
54 		dbg_print(lml, MSG_INTL(MSG_CAP_HWFILTR_2), dir);
55 }
56 
57 void
58 Dbg_cap_val_hw1(Lm_list *lml, Xword val, Half mach)
59 {
60 	Conv_cap_val_hw1_buf_t cap_val_hw1_buf;
61 
62 	Dbg_util_nl(lml, DBG_NL_FRC);
63 	dbg_print(lml, MSG_INTL(MSG_CAP_VAL_HW1),
64 	    conv_cap_val_hw1(val, mach, 0, &cap_val_hw1_buf));
65 	Dbg_util_nl(lml, DBG_NL_FRC);
66 }
67 
68 static const Msg captype[] = {
69 	MSG_STR_INITIAL,		/* MSG_INTL(MSG_STR_INITIAL) */
70 	MSG_STR_IGNORE,			/* MSG_INTL(MSG_STR_IGNORE) */
71 	MSG_STR_OLD,			/* MSG_INTL(MSG_STR_OLD) */
72 	MSG_STR_NEW,			/* MSG_INTL(MSG_STR_NEW) */
73 	MSG_STR_RESOLVED		/* MSG_INTL(MSG_STR_RESOLVED) */
74 };
75 
76 void
77 Dbg_cap_mapfile(Lm_list *lml, Xword tag, Xword val, Half mach)
78 {
79 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_CAP))
80 		return;
81 
82 	dbg_print(lml, MSG_INTL(MSG_MAP_CAP));
83 	Dbg_cap_sec_entry(lml, DBG_CAP_INITIAL, tag, val, mach);
84 }
85 
86 void
87 Dbg_cap_sec_entry(Lm_list *lml, uint_t type, Xword tag, Xword val, Half mach)
88 {
89 	Conv_inv_buf_t		inv_buf;
90 	Conv_cap_val_buf_t	cap_val_buf;
91 
92 	if (DBG_NOTCLASS(DBG_C_CAP))
93 		return;
94 
95 	dbg_print(lml, MSG_INTL(MSG_CAP_SEC_ENTRY), MSG_INTL(captype[type]),
96 	    conv_cap_tag(tag, &inv_buf), conv_cap_val(tag, val, mach,
97 	    &cap_val_buf));
98 }
99 
100 void
101 Dbg_cap_sec_title(Ofl_desc *ofl)
102 {
103 	Lm_list	*lml = ofl->ofl_lml;
104 
105 	if (DBG_NOTCLASS(DBG_C_CAP))
106 		return;
107 
108 	Dbg_util_nl(lml, DBG_NL_STD);
109 	dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), ofl->ofl_name);
110 }
111 
112 void
113 Elf_cap_title(Lm_list *lml)
114 {
115 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_TITLE));
116 }
117 
118 void
119 Elf_cap_entry(Lm_list *lml, Cap *cap, int ndx, Half mach)
120 {
121 	Conv_inv_buf_t		inv_buf;
122 	Conv_cap_val_buf_t	cap_val_buf;
123 	char			index[INDEX_STR_SIZE];
124 
125 	(void) snprintf(index, INDEX_STR_SIZE, MSG_ORIG(MSG_FMT_INDEX), ndx);
126 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_ENTRY), index,
127 	    conv_cap_tag(cap->c_tag, &inv_buf),
128 	    conv_cap_val(cap->c_tag, cap->c_un.c_val, mach, &cap_val_buf));
129 }
130