xref: /illumos-gate/usr/src/cmd/sgs/liblddbg/common/cap.c (revision 6ba597c5)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include	<stdio.h>
28 #include	<debug.h>
29 #include	<libld.h>
30 #include	<conv.h>
31 #include	"msg.h"
32 #include	"_debug.h"
33 
34 void
35 Dbg_cap_hw_candidate(Lm_list *lml, const char *name)
36 {
37 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
38 		return;
39 
40 	dbg_print(lml, MSG_INTL(MSG_CAP_HW_CANDIDATE), name);
41 }
42 
43 void
44 Dbg_cap_hw_filter(Lm_list *lml, const char *dir, Rt_map *flmp)
45 {
46 	if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
47 		return;
48 
49 	Dbg_util_nl(lml, DBG_NL_STD);
50 	if (flmp)
51 		dbg_print(lml, MSG_INTL(MSG_CAP_HWFILTR_1), dir, NAME(flmp));
52 	else
53 		dbg_print(lml, MSG_INTL(MSG_CAP_HWFILTR_2), dir);
54 }
55 
56 void
57 Dbg_cap_val_hw1(Lm_list *lml, Xword val, Half mach)
58 {
59 	Conv_cap_val_hw1_buf_t cap_val_hw1_buf;
60 
61 	Dbg_util_nl(lml, DBG_NL_FRC);
62 	dbg_print(lml, MSG_INTL(MSG_CAP_VAL_HW1),
63 	    conv_cap_val_hw1(val, mach, 0, &cap_val_hw1_buf));
64 	Dbg_util_nl(lml, DBG_NL_FRC);
65 }
66 
67 void
68 Dbg_cap_entry(Lm_list *lml, dbg_state_t dbg_state, Xword tag, Xword val,
69     Half mach)
70 {
71 	Conv_inv_buf_t		inv_buf;
72 	Conv_cap_val_buf_t	cap_val_buf;
73 
74 	if (DBG_NOTCLASS(DBG_C_CAP))
75 		return;
76 
77 	dbg_print(lml, MSG_INTL(MSG_CAP_ENTRY), Dbg_state_str(dbg_state),
78 	    conv_cap_tag(tag, 0, &inv_buf), conv_cap_val(tag, val, mach,
79 	    &cap_val_buf));
80 }
81 
82 /*
83  * This version takes a pointer to a CapMask, and will report the exclusion
84  * bits if they exist.
85  */
86 void
87 Dbg_cap_entry2(Lm_list *lml, dbg_state_t dbg_state, Xword tag, CapMask *cmp,
88     Half mach)
89 {
90 	Conv_inv_buf_t		inv_buf;
91 	Conv_cap_val_buf_t	cap_val_buf1, cap_val_buf2;
92 
93 	if (DBG_NOTCLASS(DBG_C_CAP))
94 		return;
95 
96 	/* If there is no exclusion mask, use the simpler format */
97 	if (cmp->cm_exclude == 0) {
98 		dbg_print(lml, MSG_INTL(MSG_CAP_ENTRY),
99 		    Dbg_state_str(dbg_state), conv_cap_tag(tag, 0, &inv_buf),
100 		    conv_cap_val(tag, cmp->cm_value, mach, &cap_val_buf1));
101 		return;
102 	}
103 
104 
105 	dbg_print(lml, MSG_INTL(MSG_CAP_ENTRY_EXC), Dbg_state_str(dbg_state),
106 	    conv_cap_tag(tag, 0, &inv_buf),
107 	    conv_cap_val(tag, cmp->cm_value, mach, &cap_val_buf1),
108 	    conv_cap_val(tag, cmp->cm_exclude, mach, &cap_val_buf2));
109 }
110 
111 void
112 Dbg_cap_sec_title(Lm_list *lml, const char *name)
113 {
114 	if (DBG_NOTCLASS(DBG_C_CAP))
115 		return;
116 
117 	Dbg_util_nl(lml, DBG_NL_STD);
118 	dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), name);
119 }
120 
121 void
122 Dbg_cap_out_title(Lm_list *lml)
123 {
124 	if (DBG_NOTCLASS(DBG_C_CAP))
125 		return;
126 
127 	Dbg_util_nl(lml, DBG_NL_STD);
128 	dbg_print(lml, MSG_INTL(MSG_CAP_OUT_TITLE));
129 }
130 
131 void
132 Dbg_cap_mapfile_title(Lm_list *lml, Lineno lineno)
133 {
134 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_CAP))
135 		return;
136 
137 	dbg_print(lml, MSG_INTL(MSG_MAP_CAP), EC_LINENO(lineno));
138 }
139 
140 void
141 Elf_cap_title(Lm_list *lml)
142 {
143 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_TITLE));
144 }
145 
146 void
147 Elf_cap_entry(Lm_list *lml, Cap *cap, int ndx, Half mach)
148 {
149 	Conv_inv_buf_t		inv_buf;
150 	Conv_cap_val_buf_t	cap_val_buf;
151 	char			index[INDEX_STR_SIZE];
152 
153 	(void) snprintf(index, INDEX_STR_SIZE, MSG_ORIG(MSG_FMT_INDEX), ndx);
154 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_ENTRY), index,
155 	    conv_cap_tag(cap->c_tag, 0, &inv_buf),
156 	    conv_cap_val(cap->c_tag, cap->c_un.c_val, mach, &cap_val_buf));
157 }
158