xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/cap.c (revision cd997836b08639dc4d44a032cadd0c7d526f960c)
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 2009 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 static const Msg captype[] = {
68 	MSG_STR_INITIAL,		/* MSG_INTL(MSG_STR_INITIAL) */
69 	MSG_STR_IGNORE,			/* MSG_INTL(MSG_STR_IGNORE) */
70 	MSG_STR_OLD,			/* MSG_INTL(MSG_STR_OLD) */
71 	MSG_STR_NEW,			/* MSG_INTL(MSG_STR_NEW) */
72 	MSG_STR_RESOLVED		/* MSG_INTL(MSG_STR_RESOLVED) */
73 };
74 
75 void
76 Dbg_cap_mapfile(Lm_list *lml, Xword tag, Xword val, Half mach)
77 {
78 	if (DBG_NOTCLASS(DBG_C_MAP | DBG_C_CAP))
79 		return;
80 
81 	dbg_print(lml, MSG_INTL(MSG_MAP_CAP));
82 	Dbg_cap_sec_entry(lml, DBG_CAP_INITIAL, tag, val, mach);
83 }
84 
85 void
86 Dbg_cap_sec_entry(Lm_list *lml, uint_t type, Xword tag, Xword val, Half mach)
87 {
88 	Conv_inv_buf_t		inv_buf;
89 	Conv_cap_val_buf_t	cap_val_buf;
90 
91 	if (DBG_NOTCLASS(DBG_C_CAP))
92 		return;
93 
94 	dbg_print(lml, MSG_INTL(MSG_CAP_SEC_ENTRY), MSG_INTL(captype[type]),
95 	    conv_cap_tag(tag, 0, &inv_buf), conv_cap_val(tag, val, mach,
96 	    &cap_val_buf));
97 }
98 
99 void
100 Dbg_cap_sec_title(Lm_list *lml, const char *name)
101 {
102 	if (DBG_NOTCLASS(DBG_C_CAP))
103 		return;
104 
105 	Dbg_util_nl(lml, DBG_NL_STD);
106 	dbg_print(lml, MSG_INTL(MSG_CAP_SEC_TITLE), name);
107 }
108 
109 void
110 Elf_cap_title(Lm_list *lml)
111 {
112 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_TITLE));
113 }
114 
115 void
116 Elf_cap_entry(Lm_list *lml, Cap *cap, int ndx, Half mach)
117 {
118 	Conv_inv_buf_t		inv_buf;
119 	Conv_cap_val_buf_t	cap_val_buf;
120 	char			index[INDEX_STR_SIZE];
121 
122 	(void) snprintf(index, INDEX_STR_SIZE, MSG_ORIG(MSG_FMT_INDEX), ndx);
123 	dbg_print(lml, MSG_INTL(MSG_CAP_ELF_ENTRY), index,
124 	    conv_cap_tag(cap->c_tag, 0, &inv_buf),
125 	    conv_cap_val(cap->c_tag, cap->c_un.c_val, mach, &cap_val_buf));
126 }
127