xref: /illumos-gate/usr/src/cmd/sgs/liblddbg/common/_debug.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 #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 
70 
71 #define	DBG_C_ALL	0xffffffff
72 
73 typedef struct {
74 	const char	*o_name;	/* command line argument name */
75 	uint_t		o_class;	/* associated class for this name */
76 	uint_t		o_extra;	/* associated extra for this name */
77 } DBG_options;
78 
79 #define	AL_CNT_DEBUG	4
80 
81 /*
82  * Some Dbg_*() format strings differ depending on whether they are used for
83  * 32-bit or 64-bit values.
84  */
85 #if	defined(_ELF64)
86 
87 #define	MSG_EDATA_TITLE		MSG_EDATA_TITLE_64
88 #define	MSG_EDATA_ENTRY		MSG_EDATA_ENTRY_64
89 
90 #else
91 
92 #define	MSG_EDATA_TITLE		MSG_EDATA_TITLE_32
93 #define	MSG_EDATA_ENTRY		MSG_EDATA_ENTRY_32
94 
95 #endif
96 
97 /*
98  * Some Elf_*() format strings differ depending on whether they are used for
99  * 32-bit or 64-bit values.
100  */
101 #if	defined(_ELF64)
102 
103 #define	MSG_GOT_TITLE		MSG_GOT_TITLE_64
104 #define	MSG_GOT_ENTRY_RE	MSG_GOT_ENTRY_RE_64
105 #define	MSG_GOT_ENTRY_NR	MSG_GOT_ENTRY_NR_64
106 #define	MSG_GOT_COLUMNS1	MSG_GOT_COLUMNS1_64
107 #define	MSG_GOT_COLUMNS2	MSG_GOT_COLUMNS2_64
108 #define	MSG_GOT_FORMAT1		MSG_GOT_FORMAT1_64
109 #define	MSG_GOT_FORMAT2		MSG_GOT_FORMAT2_64
110 
111 #define	MSG_PHD_VADDR		MSG_PHD_VADDR_64
112 #define	MSG_PHD_PADDR		MSG_PHD_PADDR_64
113 #define	MSG_PHD_FILESZ		MSG_PHD_FILESZ_64
114 #define	MSG_PHD_OFFSET		MSG_PHD_OFFSET_64
115 
116 #define	MSG_REL_EFSA_TITLE	MSG_REL_EFSA_TITLE_64
117 #define	MSG_REL_EFLA_TITLE	MSG_REL_EFLA_TITLE_64
118 #define	MSG_REL_EFSN_TITLE	MSG_REL_EFSN_TITLE_64
119 #define	MSG_REL_EFLN_TITLE	MSG_REL_EFLN_TITLE_64
120 #define	MSG_REL_EFSA_ENTRY	MSG_REL_EFSA_ENTRY_64
121 #define	MSG_REL_EFLA_ENTRY	MSG_REL_EFLA_ENTRY_64
122 #define	MSG_REL_EFSN_ENTRY	MSG_REL_EFSN_ENTRY_64
123 #define	MSG_REL_EFLN_ENTRY	MSG_REL_EFLN_ENTRY_64
124 #define	MSG_REL_RT_APLREG	MSG_REL_RT_APLREG_64
125 #define	MSG_REL_RT_APLVAL	MSG_REL_RT_APLVAL_64
126 #define	MSG_REL_RTA_TITLE	MSG_REL_RTA_TITLE_64
127 #define	MSG_REL_RTN_TITLE	MSG_REL_RTN_TITLE_64
128 #define	MSG_REL_RTV_TITLE	MSG_REL_RTV_TITLE_64
129 #define	MSG_REL_RTA_ENTRY	MSG_REL_RTA_ENTRY_64
130 #define	MSG_REL_RTN_ENTRY	MSG_REL_RTN_ENTRY_64
131 #define	MSG_REL_LDSA_TITLE	MSG_REL_LDSA_TITLE_64
132 #define	MSG_REL_LDSN_TITLE	MSG_REL_LDSN_TITLE_64
133 #define	MSG_REL_LDSV_TITLE	MSG_REL_LDSV_TITLE_64
134 #define	MSG_REL_LDSA_ENTRY	MSG_REL_LDSA_ENTRY_64
135 #define	MSG_REL_LDSN_ENTRY	MSG_REL_LDSN_ENTRY_64
136 #define	MSG_REL_LDLA_TITLE	MSG_REL_LDLA_TITLE_64
137 #define	MSG_REL_LDLN_TITLE	MSG_REL_LDLN_TITLE_64
138 #define	MSG_REL_LDLV_TITLE	MSG_REL_LDLV_TITLE_64
139 #define	MSG_REL_LDLA_ENTRY	MSG_REL_LDLA_ENTRY_64
140 #define	MSG_REL_LDLN_ENTRY	MSG_REL_LDLN_ENTRY_64
141 
142 #define	MSG_SHD_ADDR		MSG_SHD_ADDR_64
143 #define	MSG_SHD_SIZE		MSG_SHD_SIZE_64
144 #define	MSG_SHD_OFFSET		MSG_SHD_OFFSET_64
145 #define	MSG_SHD_OFFSET_ENT	MSG_SHD_OFFSET_ENT_64
146 #define	MSG_SHD_ALIGN		MSG_SHD_ALIGN_64
147 #define	MSG_SHD_LINK		MSG_SHD_LINK_64
148 
149 #define	MSG_SYM_EFS_ENTRY	MSG_SYM_EFS_ENTRY_64
150 #define	MSG_SYM_EFL_ENTRY	MSG_SYM_EFL_ENTRY_64
151 #define	MSG_SYM_EFS_TITLE	MSG_SYM_EFS_TITLE_64
152 #define	MSG_SYM_EFL_TITLE	MSG_SYM_EFL_TITLE_64
153 #define	MSG_SYM_LDS_TITLE	MSG_SYM_LDS_TITLE_64
154 #define	MSG_SYM_LDL_TITLE	MSG_SYM_LDL_TITLE_64
155 
156 #else
157 
158 #define	MSG_GOT_TITLE		MSG_GOT_TITLE_32
159 #define	MSG_GOT_ENTRY_RE	MSG_GOT_ENTRY_RE_32
160 #define	MSG_GOT_ENTRY_NR	MSG_GOT_ENTRY_NR_32
161 #define	MSG_GOT_COLUMNS1	MSG_GOT_COLUMNS1_32
162 #define	MSG_GOT_COLUMNS2	MSG_GOT_COLUMNS2_32
163 #define	MSG_GOT_FORMAT1		MSG_GOT_FORMAT1_32
164 #define	MSG_GOT_FORMAT2		MSG_GOT_FORMAT2_32
165 
166 #define	MSG_PHD_VADDR		MSG_PHD_VADDR_32
167 #define	MSG_PHD_PADDR		MSG_PHD_PADDR_32
168 #define	MSG_PHD_FILESZ		MSG_PHD_FILESZ_32
169 #define	MSG_PHD_OFFSET		MSG_PHD_OFFSET_32
170 
171 #define	MSG_REL_EFSA_TITLE	MSG_REL_EFSA_TITLE_32
172 #define	MSG_REL_EFLA_TITLE	MSG_REL_EFLA_TITLE_32
173 #define	MSG_REL_EFSN_TITLE	MSG_REL_EFSN_TITLE_32
174 #define	MSG_REL_EFLN_TITLE	MSG_REL_EFLN_TITLE_32
175 #define	MSG_REL_EFSA_ENTRY	MSG_REL_EFSA_ENTRY_32
176 #define	MSG_REL_EFLA_ENTRY	MSG_REL_EFLA_ENTRY_32
177 #define	MSG_REL_EFSN_ENTRY	MSG_REL_EFSN_ENTRY_32
178 #define	MSG_REL_EFLN_ENTRY	MSG_REL_EFLN_ENTRY_32
179 #define	MSG_REL_RT_APLREG	MSG_REL_RT_APLREG_32
180 #define	MSG_REL_RT_APLVAL	MSG_REL_RT_APLVAL_32
181 #define	MSG_REL_RTA_TITLE	MSG_REL_RTA_TITLE_32
182 #define	MSG_REL_RTN_TITLE	MSG_REL_RTN_TITLE_32
183 #define	MSG_REL_RTV_TITLE	MSG_REL_RTV_TITLE_32
184 #define	MSG_REL_RTA_ENTRY	MSG_REL_RTA_ENTRY_32
185 #define	MSG_REL_RTN_ENTRY	MSG_REL_RTN_ENTRY_32
186 #define	MSG_REL_LDSA_TITLE	MSG_REL_LDSA_TITLE_32
187 #define	MSG_REL_LDSN_TITLE	MSG_REL_LDSN_TITLE_32
188 #define	MSG_REL_LDSV_TITLE	MSG_REL_LDSV_TITLE_32
189 #define	MSG_REL_LDSA_ENTRY	MSG_REL_LDSA_ENTRY_32
190 #define	MSG_REL_LDSN_ENTRY	MSG_REL_LDSN_ENTRY_32
191 #define	MSG_REL_LDLA_TITLE	MSG_REL_LDLA_TITLE_32
192 #define	MSG_REL_LDLN_TITLE	MSG_REL_LDLN_TITLE_32
193 #define	MSG_REL_LDLV_TITLE	MSG_REL_LDLV_TITLE_32
194 #define	MSG_REL_LDLA_ENTRY	MSG_REL_LDLA_ENTRY_32
195 #define	MSG_REL_LDLN_ENTRY	MSG_REL_LDLN_ENTRY_32
196 
197 #define	MSG_SHD_ADDR		MSG_SHD_ADDR_32
198 #define	MSG_SHD_SIZE		MSG_SHD_SIZE_32
199 #define	MSG_SHD_OFFSET		MSG_SHD_OFFSET_32
200 #define	MSG_SHD_OFFSET_ENT	MSG_SHD_OFFSET_ENT_32
201 #define	MSG_SHD_ALIGN		MSG_SHD_ALIGN_32
202 #define	MSG_SHD_LINK		MSG_SHD_LINK_32
203 
204 #define	MSG_SYM_EFS_ENTRY	MSG_SYM_EFS_ENTRY_32
205 #define	MSG_SYM_EFL_ENTRY	MSG_SYM_EFL_ENTRY_32
206 #define	MSG_SYM_EFS_TITLE	MSG_SYM_EFS_TITLE_32
207 #define	MSG_SYM_EFL_TITLE	MSG_SYM_EFL_TITLE_32
208 #define	MSG_SYM_LDS_TITLE	MSG_SYM_LDS_TITLE_32
209 #define	MSG_SYM_LDL_TITLE	MSG_SYM_LDL_TITLE_32
210 
211 #endif
212 
213 #define	INDEX_STR_SIZE		10
214 
215 /*
216  * Buffer used by dbg_isec_name() to format input section
217  * names. The size was selected to satisfy two opposing
218  * constraints:
219  * -	To be large enough to handle the largest C++ mangled name.
220  *	Although we can malloc buffers, we don't want that to happen.
221  * -	To be small enough on the thread stack to not cause problems.
222  */
223 typedef char dbg_isec_name_buf_t[INDEX_STR_SIZE + 2048];
224 
225 #if	defined(_ELF64)
226 #define	dbg_fmt_isec_name	dbg64_fmt_isec_name
227 #define	dbg_fmt_isec_name2	dbg64_fmt_isec_name2
228 #else
229 #define	dbg_fmt_isec_name	dbg32_fmt_isec_name
230 #define	dbg_fmt_isec_name2	dbg32_fmt_isec_name2
231 #endif
232 extern	const char	*dbg_fmt_isec_name(Is_desc *, dbg_isec_name_buf_t,
233 			    char **);
234 extern	const char	*dbg_fmt_isec_name2(const char *, Word,
235 			    dbg_isec_name_buf_t, char **);
236 
237 #ifdef	__cplusplus
238 }
239 #endif
240 
241 #endif	/* _DEBUG_DOT_H */
242