xref: /titanic_50/usr/src/cmd/sgs/liblddbg/common/_debug.h (revision 4445fffbbb1ea25fd0e9ea68b9380dd7a6709025)
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 #ifndef	_DEBUG_DOT_H
28 #define	_DEBUG_DOT_H
29 
30 #include <debug.h>
31 #include <conv.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * Debugging is enabled by various tokens (see debug.c) that result in an
39  * internal bit mask (d_class) being initialized.  Each debugging function is
40  * appropriate for one or more of the classes specified by the bit mask.  Each
41  * debugging function validates whether it is appropriate for the present
42  * classes before printing anything.
43  */
44 #define	DBG_NOTCLASS(c)	!(dbg_desc->d_class & (c))
45 
46 #define	DBG_C_ARGS	0x00000001
47 #define	DBG_C_AUDITING	0x00000002
48 #define	DBG_C_BASIC	0x00000004
49 #define	DBG_C_BINDINGS	0x00000008
50 #define	DBG_C_CAP	0x00000010
51 #define	DBG_C_DEMANGLE	0x00000020
52 #define	DBG_C_ENTRY	0x00000040
53 #define	DBG_C_FILES	0x00000080
54 #define	DBG_C_GOT	0x00000100
55 #define	DBG_C_INIT	0x00000200
56 #define	DBG_C_LIBS	0x00000400
57 #define	DBG_C_MAP	0x00000800
58 #define	DBG_C_MOVE	0x00001000
59 #define	DBG_C_RELOC	0x00002000
60 #define	DBG_C_SECTIONS	0x00004000
61 #define	DBG_C_SEGMENTS	0x00008000
62 #define	DBG_C_STATS	0x00010000
63 #define	DBG_C_STRTAB	0x00020000
64 #define	DBG_C_SUPPORT	0x00040000
65 #define	DBG_C_SYMBOLS	0x00080000
66 #define	DBG_C_TLS	0x00100000
67 #define	DBG_C_UNUSED	0x00200000
68 #define	DBG_C_VERSIONS	0x00400000
69 #define	DBG_C_DL	0x00800000
70 
71 
72 #define	DBG_C_ALL	0xffffffff
73 
74 typedef struct {
75 	const char	*o_name;	/* command line argument name */
76 	uint_t		o_class;	/* associated class for this name */
77 	uint_t		o_extra;	/* associated extra for this name */
78 } DBG_options;
79 
80 #define	AL_CNT_DEBUG	4
81 
82 /*
83  * Some Dbg_*() format strings differ depending on whether they are used for
84  * 32-bit or 64-bit values.
85  */
86 #if	defined(_ELF64)
87 
88 #define	MSG_EDATA_TITLE		MSG_EDATA_TITLE_64
89 #define	MSG_EDATA_ENTRY		MSG_EDATA_ENTRY_64
90 
91 #else
92 
93 #define	MSG_EDATA_TITLE		MSG_EDATA_TITLE_32
94 #define	MSG_EDATA_ENTRY		MSG_EDATA_ENTRY_32
95 
96 #endif
97 
98 /*
99  * Some Elf_*() format strings differ depending on whether they are used for
100  * 32-bit or 64-bit values.
101  */
102 #if	defined(_ELF64)
103 
104 #define	MSG_DL_IPHDR_ADDR	MSG_DL_IPHDR_ADDR_64
105 #define	MSG_DL_IPHDR_PHDR	MSG_DL_IPHDR_PHDR_64
106 
107 #define	MSG_GOT_TITLE		MSG_GOT_TITLE_64
108 #define	MSG_GOT_ENTRY_RE	MSG_GOT_ENTRY_RE_64
109 #define	MSG_GOT_ENTRY_NR	MSG_GOT_ENTRY_NR_64
110 #define	MSG_GOT_COLUMNS1	MSG_GOT_COLUMNS1_64
111 #define	MSG_GOT_COLUMNS2	MSG_GOT_COLUMNS2_64
112 #define	MSG_GOT_FORMAT1		MSG_GOT_FORMAT1_64
113 #define	MSG_GOT_FORMAT2		MSG_GOT_FORMAT2_64
114 
115 #define	MSG_PHD_VADDR		MSG_PHD_VADDR_64
116 #define	MSG_PHD_PADDR		MSG_PHD_PADDR_64
117 #define	MSG_PHD_FILESZ		MSG_PHD_FILESZ_64
118 #define	MSG_PHD_OFFSET		MSG_PHD_OFFSET_64
119 
120 #define	MSG_REL_EFSA_TITLE	MSG_REL_EFSA_TITLE_64
121 #define	MSG_REL_EFLA_TITLE	MSG_REL_EFLA_TITLE_64
122 #define	MSG_REL_EFSN_TITLE	MSG_REL_EFSN_TITLE_64
123 #define	MSG_REL_EFLN_TITLE	MSG_REL_EFLN_TITLE_64
124 #define	MSG_REL_EFSA_ENTRY	MSG_REL_EFSA_ENTRY_64
125 #define	MSG_REL_EFLA_ENTRY	MSG_REL_EFLA_ENTRY_64
126 #define	MSG_REL_EFSN_ENTRY	MSG_REL_EFSN_ENTRY_64
127 #define	MSG_REL_EFLN_ENTRY	MSG_REL_EFLN_ENTRY_64
128 #define	MSG_REL_RT_APLREG	MSG_REL_RT_APLREG_64
129 #define	MSG_REL_RT_APLVAL	MSG_REL_RT_APLVAL_64
130 #define	MSG_REL_RTA_TITLE	MSG_REL_RTA_TITLE_64
131 #define	MSG_REL_RTN_TITLE	MSG_REL_RTN_TITLE_64
132 #define	MSG_REL_RTV_TITLE	MSG_REL_RTV_TITLE_64
133 #define	MSG_REL_RTA_ENTRY	MSG_REL_RTA_ENTRY_64
134 #define	MSG_REL_RTN_ENTRY	MSG_REL_RTN_ENTRY_64
135 #define	MSG_REL_LDSA_TITLE	MSG_REL_LDSA_TITLE_64
136 #define	MSG_REL_LDSN_TITLE	MSG_REL_LDSN_TITLE_64
137 #define	MSG_REL_LDSA_ENTRY	MSG_REL_LDSA_ENTRY_64
138 #define	MSG_REL_LDSN_ENTRY	MSG_REL_LDSN_ENTRY_64
139 #define	MSG_REL_LDSV_TITLE	MSG_REL_LDSV_TITLE_64
140 #define	MSG_REL_LDSV_ENTRY	MSG_REL_LDSV_ENTRY_64
141 #define	MSG_REL_LDLA_TITLE	MSG_REL_LDLA_TITLE_64
142 #define	MSG_REL_LDLN_TITLE	MSG_REL_LDLN_TITLE_64
143 #define	MSG_REL_LDLA_ENTRY	MSG_REL_LDLA_ENTRY_64
144 #define	MSG_REL_LDLN_ENTRY	MSG_REL_LDLN_ENTRY_64
145 #define	MSG_REL_LDLV_TITLE	MSG_REL_LDLV_TITLE_64
146 #define	MSG_REL_LDLV_ENTRY	MSG_REL_LDLV_ENTRY_64
147 
148 #define	MSG_SHD_ADDR		MSG_SHD_ADDR_64
149 #define	MSG_SHD_SIZE		MSG_SHD_SIZE_64
150 #define	MSG_SHD_OFFSET		MSG_SHD_OFFSET_64
151 #define	MSG_SHD_OFFSET_ENT	MSG_SHD_OFFSET_ENT_64
152 #define	MSG_SHD_ALIGN		MSG_SHD_ALIGN_64
153 #define	MSG_SHD_LINK		MSG_SHD_LINK_64
154 
155 #define	MSG_SYM_EFS_ENTRY	MSG_SYM_EFS_ENTRY_64
156 #define	MSG_SYM_EFL_ENTRY	MSG_SYM_EFL_ENTRY_64
157 #define	MSG_SYM_EFS_TITLE	MSG_SYM_EFS_TITLE_64
158 #define	MSG_SYM_EFL_TITLE	MSG_SYM_EFL_TITLE_64
159 #define	MSG_SYM_LDS_TITLE	MSG_SYM_LDS_TITLE_64
160 #define	MSG_SYM_LDL_TITLE	MSG_SYM_LDL_TITLE_64
161 
162 #else
163 
164 #define	MSG_DL_IPHDR_ADDR	MSG_DL_IPHDR_ADDR_32
165 #define	MSG_DL_IPHDR_PHDR	MSG_DL_IPHDR_PHDR_32
166 
167 #define	MSG_GOT_TITLE		MSG_GOT_TITLE_32
168 #define	MSG_GOT_ENTRY_RE	MSG_GOT_ENTRY_RE_32
169 #define	MSG_GOT_ENTRY_NR	MSG_GOT_ENTRY_NR_32
170 #define	MSG_GOT_COLUMNS1	MSG_GOT_COLUMNS1_32
171 #define	MSG_GOT_COLUMNS2	MSG_GOT_COLUMNS2_32
172 #define	MSG_GOT_FORMAT1		MSG_GOT_FORMAT1_32
173 #define	MSG_GOT_FORMAT2		MSG_GOT_FORMAT2_32
174 
175 #define	MSG_PHD_VADDR		MSG_PHD_VADDR_32
176 #define	MSG_PHD_PADDR		MSG_PHD_PADDR_32
177 #define	MSG_PHD_FILESZ		MSG_PHD_FILESZ_32
178 #define	MSG_PHD_OFFSET		MSG_PHD_OFFSET_32
179 
180 #define	MSG_REL_EFSA_TITLE	MSG_REL_EFSA_TITLE_32
181 #define	MSG_REL_EFLA_TITLE	MSG_REL_EFLA_TITLE_32
182 #define	MSG_REL_EFSN_TITLE	MSG_REL_EFSN_TITLE_32
183 #define	MSG_REL_EFLN_TITLE	MSG_REL_EFLN_TITLE_32
184 #define	MSG_REL_EFSA_ENTRY	MSG_REL_EFSA_ENTRY_32
185 #define	MSG_REL_EFLA_ENTRY	MSG_REL_EFLA_ENTRY_32
186 #define	MSG_REL_EFSN_ENTRY	MSG_REL_EFSN_ENTRY_32
187 #define	MSG_REL_EFLN_ENTRY	MSG_REL_EFLN_ENTRY_32
188 #define	MSG_REL_RT_APLREG	MSG_REL_RT_APLREG_32
189 #define	MSG_REL_RT_APLVAL	MSG_REL_RT_APLVAL_32
190 #define	MSG_REL_RTA_TITLE	MSG_REL_RTA_TITLE_32
191 #define	MSG_REL_RTN_TITLE	MSG_REL_RTN_TITLE_32
192 #define	MSG_REL_RTV_TITLE	MSG_REL_RTV_TITLE_32
193 #define	MSG_REL_RTA_ENTRY	MSG_REL_RTA_ENTRY_32
194 #define	MSG_REL_RTN_ENTRY	MSG_REL_RTN_ENTRY_32
195 #define	MSG_REL_LDSA_TITLE	MSG_REL_LDSA_TITLE_32
196 #define	MSG_REL_LDSN_TITLE	MSG_REL_LDSN_TITLE_32
197 #define	MSG_REL_LDSA_ENTRY	MSG_REL_LDSA_ENTRY_32
198 #define	MSG_REL_LDSN_ENTRY	MSG_REL_LDSN_ENTRY_32
199 #define	MSG_REL_LDSV_TITLE	MSG_REL_LDSV_TITLE_32
200 #define	MSG_REL_LDSV_ENTRY	MSG_REL_LDSV_ENTRY_32
201 #define	MSG_REL_LDLA_TITLE	MSG_REL_LDLA_TITLE_32
202 #define	MSG_REL_LDLN_TITLE	MSG_REL_LDLN_TITLE_32
203 #define	MSG_REL_LDLA_ENTRY	MSG_REL_LDLA_ENTRY_32
204 #define	MSG_REL_LDLN_ENTRY	MSG_REL_LDLN_ENTRY_32
205 #define	MSG_REL_LDLV_TITLE	MSG_REL_LDLV_TITLE_32
206 #define	MSG_REL_LDLV_ENTRY	MSG_REL_LDLV_ENTRY_32
207 
208 #define	MSG_SHD_ADDR		MSG_SHD_ADDR_32
209 #define	MSG_SHD_SIZE		MSG_SHD_SIZE_32
210 #define	MSG_SHD_OFFSET		MSG_SHD_OFFSET_32
211 #define	MSG_SHD_OFFSET_ENT	MSG_SHD_OFFSET_ENT_32
212 #define	MSG_SHD_ALIGN		MSG_SHD_ALIGN_32
213 #define	MSG_SHD_LINK		MSG_SHD_LINK_32
214 
215 #define	MSG_SYM_EFS_ENTRY	MSG_SYM_EFS_ENTRY_32
216 #define	MSG_SYM_EFL_ENTRY	MSG_SYM_EFL_ENTRY_32
217 #define	MSG_SYM_EFS_TITLE	MSG_SYM_EFS_TITLE_32
218 #define	MSG_SYM_EFL_TITLE	MSG_SYM_EFL_TITLE_32
219 #define	MSG_SYM_LDS_TITLE	MSG_SYM_LDS_TITLE_32
220 #define	MSG_SYM_LDL_TITLE	MSG_SYM_LDL_TITLE_32
221 
222 #endif
223 
224 #define	INDEX_STR_SIZE		10
225 
226 /*
227  * Buffer used by dbg_isec_name() to format input section
228  * names. The size was selected to satisfy two opposing
229  * constraints:
230  * -	To be large enough to handle the largest C++ mangled name.
231  *	Although we can malloc buffers, we don't want that to happen.
232  * -	To be small enough on the thread stack to not cause problems.
233  */
234 typedef char dbg_isec_name_buf_t[INDEX_STR_SIZE + 2048];
235 
236 #if	defined(_ELF64)
237 #define	dbg_fmt_isec_name	dbg64_fmt_isec_name
238 #define	dbg_fmt_isec_name2	dbg64_fmt_isec_name2
239 #else
240 #define	dbg_fmt_isec_name	dbg32_fmt_isec_name
241 #define	dbg_fmt_isec_name2	dbg32_fmt_isec_name2
242 #endif
243 extern	const char	*dbg_fmt_isec_name(Is_desc *, dbg_isec_name_buf_t,
244 			    char **);
245 extern	const char	*dbg_fmt_isec_name2(const char *, Word,
246 			    dbg_isec_name_buf_t, char **);
247 
248 #ifdef	__cplusplus
249 }
250 #endif
251 
252 #endif	/* _DEBUG_DOT_H */
253