dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / sgs / liblddbg / common / cap.c
blobd1429920c7587186821012fee6d9e8581f92b069
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
26 #include <stdio.h>
27 #include <debug.h>
28 #include <libld.h>
29 #include <conv.h>
30 #include "msg.h"
31 #include "_debug.h"
33 void
34 Dbg_cap_candidate(Lm_list *lml, const char *name)
36 if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
37 return;
39 dbg_print(lml, MSG_INTL(MSG_CAP_CANDIDATE), name);
42 void
43 Dbg_cap_filter(Lm_list *lml, const char *dir, Rt_map *flmp)
45 if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
46 return;
48 Dbg_util_nl(lml, DBG_NL_STD);
49 if (flmp)
50 dbg_print(lml, MSG_INTL(MSG_CAP_FILTER_1), dir, NAME(flmp));
51 else
52 dbg_print(lml, MSG_INTL(MSG_CAP_FILTER_2), dir);
55 void
56 Dbg_cap_identical(Lm_list *lml, const char *file1, const char *file2)
58 if (DBG_NOTCLASS(DBG_C_CAP | DBG_C_FILES))
59 return;
61 dbg_print(lml, MSG_INTL(MSG_CAP_IDENTICAL), file1, file2);
64 void
65 Dbg_cap_val(Lm_list *lml, Syscapset *sys, Syscapset *alt, Half mach)
67 Conv_cap_val_buf_t cap_val_buf;
69 if ((sys->sc_plat == NULL) && (sys->sc_mach == NULL) &&
70 (sys->sc_hw_2 == 0) && (sys->sc_hw_1 == 0) &&
71 (sys->sc_sf_1 == 0))
72 return;
74 Dbg_util_nl(lml, DBG_NL_FRC);
77 * Print any capabilities in precedence order.
79 if (sys->sc_plat) {
80 dbg_print(lml, MSG_INTL(MSG_CAP_SYS_PLAT), sys->sc_plat);
82 if (sys->sc_mach) {
83 dbg_print(lml, MSG_INTL(MSG_CAP_SYS_MACH), sys->sc_mach);
85 if (sys->sc_hw_2) {
86 dbg_print(lml, MSG_INTL(MSG_CAP_SYS_HW_2),
87 conv_cap_val_hw2(sys->sc_hw_2, mach, 0,
88 &cap_val_buf.cap_val_hw2_buf));
90 if (sys->sc_hw_1) {
91 dbg_print(lml, MSG_INTL(MSG_CAP_SYS_HW_1),
92 conv_cap_val_hw1(sys->sc_hw_1, mach, 0,
93 &cap_val_buf.cap_val_hw1_buf));
95 if (sys->sc_sf_1) {
96 dbg_print(lml, MSG_INTL(MSG_CAP_SYS_SF_1),
97 conv_cap_val_sf1(sys->sc_sf_1, mach, 0,
98 &cap_val_buf.cap_val_sf1_buf));
101 if (alt != sys) {
102 Dbg_util_nl(lml, DBG_NL_FRC);
103 if (alt->sc_plat != sys->sc_plat) {
104 dbg_print(lml, MSG_INTL(MSG_CAP_ALT_PLAT),
105 alt->sc_plat);
107 if (alt->sc_mach != sys->sc_mach) {
108 dbg_print(lml, MSG_INTL(MSG_CAP_ALT_MACH),
109 alt->sc_mach);
111 if (alt->sc_hw_2 != sys->sc_hw_2) {
112 dbg_print(lml, MSG_INTL(MSG_CAP_ALT_HW_2),
113 conv_cap_val_hw2(alt->sc_hw_2, mach, 0,
114 &cap_val_buf.cap_val_hw2_buf));
116 if (alt->sc_hw_1 != sys->sc_hw_1) {
117 dbg_print(lml, MSG_INTL(MSG_CAP_ALT_HW_1),
118 conv_cap_val_hw1(alt->sc_hw_1, mach, 0,
119 &cap_val_buf.cap_val_hw1_buf));
121 if (alt->sc_sf_1 != sys->sc_sf_1) {
122 dbg_print(lml, MSG_INTL(MSG_CAP_ALT_SF_1),
123 conv_cap_val_sf1(alt->sc_sf_1, mach, 0,
124 &cap_val_buf.cap_val_sf1_buf));
128 Dbg_util_nl(lml, DBG_NL_FRC);
132 * This version takes a pointer to a Capmask, and will report the exclusion
133 * bits if they exist.
135 void
136 Dbg_cap_ptr_entry(Lm_list *lml, dbg_state_t dbg_state, Xword tag,
137 const char *ptr)
139 Conv_inv_buf_t inv_buf;
141 if (DBG_NOTCLASS(DBG_C_CAP))
142 return;
144 dbg_print(lml, MSG_INTL(MSG_CAP_SEC_ENTRY), Dbg_state_str(dbg_state),
145 conv_cap_tag(tag, 0, &inv_buf), ptr);
149 * This version takes a pointer to a CapMask, and will report the exclusion
150 * bits if they exist.
152 void
153 Dbg_cap_val_entry(Lm_list *lml, dbg_state_t dbg_state, Xword tag, Xword val,
154 Half mach)
156 Conv_inv_buf_t inv_buf;
157 Conv_cap_val_buf_t cap_val_buf;
159 if (DBG_NOTCLASS(DBG_C_CAP))
160 return;
162 dbg_print(lml, MSG_INTL(MSG_CAP_SEC_ENTRY), Dbg_state_str(dbg_state),
163 conv_cap_tag(tag, 0, &inv_buf), conv_cap_val(tag, val, mach, 0,
164 &cap_val_buf));
167 void
168 Dbg_cap_sec_title(Lm_list *lml, const char *name)
170 if (DBG_NOTCLASS(DBG_C_CAP))
171 return;
173 Dbg_util_nl(lml, DBG_NL_STD);
174 dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), name);
177 void
178 Dbg_cap_mapfile_title(Lm_list *lml, Lineno lineno)
180 if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_CAP))
181 return;
183 dbg_print(lml, MSG_INTL(MSG_MAP_CAP), EC_LINENO(lineno));
186 void
187 Dbg_cap_id(Lm_list *lml, Lineno lineno, const char *oid, const char *nid)
189 Dbg_cap_mapfile_title(lml, lineno);
190 Dbg_cap_ptr_entry(lml, DBG_STATE_CURRENT, CA_SUNW_ID, oid);
191 Dbg_cap_ptr_entry(lml, DBG_STATE_NEW, CA_SUNW_ID, nid);
192 Dbg_cap_ptr_entry(lml, DBG_STATE_RESOLVED, CA_SUNW_ID, nid);
195 void
196 Dbg_cap_post_title(Lm_list *lml, int *title)
198 if (DBG_NOTCLASS(DBG_C_CAP))
199 return;
201 Dbg_util_nl(lml, DBG_NL_STD);
202 if ((*title)++ == 0)
203 dbg_print(lml, MSG_INTL(MSG_CAP_POST_TITLE));
206 void
207 Elf_cap_title(Lm_list *lml)
209 dbg_print(lml, MSG_INTL(MSG_CAP_ELF_TITLE));
212 void
213 Elf_cap_entry(Lm_list *lml, Cap *cap, int ndx, const char *str, size_t str_size,
214 Half mach)
216 Conv_inv_buf_t inv_buf;
217 Conv_cap_val_buf_t cap_val_buf;
218 char index[INDEX_STR_SIZE];
220 (void) snprintf(index, INDEX_STR_SIZE, MSG_ORIG(MSG_FMT_INDEX), ndx);
222 switch (cap->c_tag) {
223 case CA_SUNW_PLAT:
224 case CA_SUNW_MACH:
225 case CA_SUNW_ID:
226 /* If offset is in range, format as a string */
227 if (str && (cap->c_un.c_ptr < str_size)) {
228 str += cap->c_un.c_ptr;
229 break;
231 /*FALLTHROUGH*/
232 default:
233 /* Format numerically */
234 str = conv_cap_val(cap->c_tag, cap->c_un.c_val, mach, 0,
235 &cap_val_buf);
238 dbg_print(lml, MSG_INTL(MSG_CAP_ELF_ENTRY), index,
239 conv_cap_tag(cap->c_tag, 0, &inv_buf), str);