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]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
32 * If any run-time linker debugging is being carried out always indicate the
33 * fact and specify the point at which we transfer control to the main program.
36 Dbg_util_call_main(Rt_map
*lmp
)
38 Lm_list
*lml
= LIST(lmp
);
40 Dbg_util_nl(lml
, DBG_NL_FRC
);
41 dbg_print(lml
, MSG_INTL(MSG_UTL_TRANS
), NAME(lmp
));
42 Dbg_util_nl(lml
, DBG_NL_FRC
);
46 Dbg_util_call_init(Rt_map
*lmp
, int flag
)
48 Lm_list
*lml
= LIST(lmp
);
51 if (DBG_NOTCLASS(DBG_C_INIT
))
54 if (flag
== DBG_INIT_SORT
)
55 str
= MSG_INTL(MSG_UTL_SORT
);
56 else if (flag
== DBG_INIT_PEND
)
57 str
= MSG_INTL(MSG_UTL_PEND
);
58 else if (flag
== DBG_INIT_DYN
)
59 str
= MSG_INTL(MSG_UTL_DYN
);
61 str
= MSG_INTL(MSG_UTL_DONE
);
63 Dbg_util_nl(lml
, DBG_NL_STD
);
64 dbg_print(lml
, MSG_INTL(MSG_UTL_INIT
), str
, NAME(lmp
));
65 Dbg_util_nl(lml
, DBG_NL_STD
);
69 Dbg_util_intoolate(Rt_map
*lmp
)
71 Lm_list
*lml
= LIST(lmp
);
73 Dbg_util_nl(lml
, DBG_NL_STD
);
74 dbg_print(lml
, MSG_INTL(MSG_UTL_INTOOLATE
), NAME(lmp
));
75 Dbg_util_nl(lml
, DBG_NL_STD
);
79 Dbg_util_dbnotify(Lm_list
*lml
, rd_event_e event
, r_state_e state
)
84 if (DBG_NOTCLASS(DBG_C_FILES
))
91 estr
= MSG_ORIG(MSG_UTL_EVNT_PREINIT
);
92 sstr
= MSG_INTL(MSG_STR_NULL
);
95 estr
= MSG_ORIG(MSG_UTL_EVNT_POSTINIT
);
96 sstr
= MSG_INTL(MSG_STR_NULL
);
99 estr
= MSG_ORIG(MSG_UTL_EVNT_DLACT
);
102 sstr
= MSG_ORIG(MSG_UTL_STA_CONSIST
);
105 sstr
= MSG_ORIG(MSG_UTL_STA_ADD
);
108 sstr
= MSG_ORIG(MSG_UTL_STA_DELETE
);
111 sstr
= MSG_INTL(MSG_STR_NULL
);
116 sstr
= MSG_INTL(MSG_STR_NULL
);
117 estr
= MSG_INTL(MSG_STR_UNKNOWN
);
121 Dbg_util_nl(lml
, DBG_NL_STD
);
122 dbg_print(lml
, MSG_INTL(MSG_UTL_DBNOTIFY
), estr
, sstr
);
123 Dbg_util_nl(lml
, DBG_NL_STD
);
127 Dbg_util_call_array(Rt_map
*lmp
, void *addr
, int ndx
, Word shtype
)
129 Lm_list
*lml
= LIST(lmp
);
132 if (DBG_NOTCLASS(DBG_C_INIT
))
135 if (shtype
== SHT_INIT_ARRAY
)
136 str
= MSG_ORIG(MSG_SCN_INITARRAY
);
137 else if (shtype
== SHT_FINI_ARRAY
)
138 str
= MSG_ORIG(MSG_SCN_FINIARRAY
);
140 str
= MSG_ORIG(MSG_SCN_PREINITARRAY
);
142 dbg_print(lml
, MSG_INTL(MSG_UTL_ARRAY
), str
, ndx
, EC_NATPTR(addr
),
147 Dbg_util_call_fini(Rt_map
*lmp
)
149 Lm_list
*lml
= LIST(lmp
);
151 if (DBG_NOTCLASS(DBG_C_INIT
))
154 Dbg_util_nl(lml
, DBG_NL_STD
);
155 dbg_print(lml
, MSG_INTL(MSG_UTL_FINI
), NAME(lmp
));
156 Dbg_util_nl(lml
, DBG_NL_STD
);
160 Dbg_util_str(Lm_list
*lml
, const char *str
)
162 Dbg_util_nl(lml
, DBG_NL_STD
);
163 Dbg_util_nl(lml
, DBG_NL_FRC
);
164 dbg_print(lml
, MSG_ORIG(MSG_FMT_STR
), str
);
165 Dbg_util_nl(lml
, DBG_NL_FRC
);
166 Dbg_util_nl(lml
, DBG_NL_STD
);
170 Dbg_util_scc_title(Lm_list
*lml
, int sec
)
174 if (DBG_NOTCLASS(DBG_C_INIT
))
180 _sec
= MSG_INTL(MSG_UTL_SCC_SUBI
);
182 _sec
= MSG_INTL(MSG_UTL_SCC_SUBF
);
184 Dbg_util_nl(lml
, DBG_NL_STD
);
185 dbg_print(lml
, MSG_INTL(MSG_UTL_SCC_TITLE
), _sec
);
189 Dbg_util_scc_entry(Rt_map
*lmp
, uint_t idx
)
191 if (DBG_NOTCLASS(DBG_C_INIT
))
196 dbg_print(LIST(lmp
), MSG_ORIG(MSG_UTL_SCC_ENTRY
), idx
, NAME(lmp
));
199 static int ectoggle
= 0;
202 Dbg_util_edge_in(Lm_list
*lml
, Rt_map
*clmp
, uint_t flags
, Rt_map
*dlmp
,
205 Conv_bnd_type_buf_t bnd_type_buf
;
208 if (DBG_NOTCLASS(DBG_C_INIT
))
213 if (flag
& RT_SORT_REV
)
214 str
= MSG_ORIG(MSG_SCN_INIT
);
216 str
= MSG_ORIG(MSG_SCN_FINI
);
218 if ((clmp
== 0) || (ectoggle
== 0))
219 Dbg_util_nl(lml
, DBG_NL_STD
);
221 if (flag
& RT_SORT_INTPOSE
)
222 dbg_print(lml
, MSG_INTL(MSG_UTL_EDGE_TITLE_I
), str
);
224 dbg_print(lml
, MSG_INTL(MSG_UTL_EDGE_TITLE_S
), str
);
226 dbg_print(lml
, MSG_INTL(MSG_UTL_EDGE_START
), ndx
, NAME(dlmp
));
228 dbg_print(lml
, MSG_INTL(MSG_UTL_EDGE_IN
), ndx
, NAME(dlmp
),
229 NAME(clmp
), conv_bnd_type(flags
, &bnd_type_buf
));
235 Dbg_util_edge_out(Rt_map
*clmp
, Rt_map
*dlmp
)
237 if (DBG_NOTCLASS(DBG_C_INIT
))
242 dbg_print(LIST(clmp
), MSG_INTL(MSG_UTL_EDGE_OUT
), SORTVAL(clmp
),
243 NAME(clmp
), NAME(dlmp
));
247 Dbg_util_collect(Rt_map
*lmp
, int ndx
, int flag
)
249 Lm_list
*lml
= LIST(lmp
);
252 if (DBG_NOTCLASS(DBG_C_INIT
))
257 if (flag
& RT_SORT_REV
)
258 str
= MSG_ORIG(MSG_SCN_INIT
);
260 str
= MSG_ORIG(MSG_SCN_FINI
);
263 Dbg_util_nl(lml
, DBG_NL_STD
);
266 dbg_print(lml
, MSG_INTL(MSG_UTL_COLLECT
), ndx
, NAME(lmp
), str
);
269 static const Msg tags
[] = {
270 MSG_CI_NULL
, /* MSG_ORIG(MSG_CI_NULL) */
271 MSG_CI_VERSION
, /* MSG_ORIG(MSG_CI_VERSION) */
272 MSG_CI_ATEXIT
, /* MSG_ORIG(MSG_CI_ATEXIT) */
273 MSG_CI_LCMESSAGES
, /* MSG_ORIG(MSG_CI_LCMESSAGES) */
274 MSG_CI_BIND_GUARD
, /* MSG_ORIG(MSG_CI_BIND_GUARD) */
275 MSG_CI_BIND_CLEAR
, /* MSG_ORIG(MSG_CI_BIND_CLEAR) */
276 MSG_CI_THR_SELF
, /* MSG_ORIG(MSG_CI_THR_SELF) */
277 MSG_CI_TLS_MODADD
, /* MSG_ORIG(MSG_CI_TLS_MODADD) */
278 MSG_CI_TLS_MODREM
, /* MSG_ORIG(MSG_CI_TLS_MODREM) */
279 MSG_CI_TLS_STATMOD
, /* MSG_ORIG(MSG_CI_TLS_STATMOD) */
280 MSG_CI_THRINIT
, /* MSG_ORIG(MSG_CI_THRINIT) */
281 MSG_CI_CRITICAL
/* MSG_ORIG(MSG_CI_CRITICAL) */
285 Dbg_util_lcinterface(Rt_map
*lmp
, int tag
, char *val
)
288 Conv_inv_buf_t inv_buf
;
294 str
= MSG_ORIG(tags
[tag
]);
296 str
= conv_invalid_val(&inv_buf
, tag
, 0);
298 dbg_print(LIST(lmp
), MSG_INTL(MSG_UTL_LCINTERFACE
), NAME(lmp
), str
,
303 Dbg_unused_lcinterface(Rt_map
*nlmp
, Rt_map
*olmp
, int tag
)
306 Conv_inv_buf_t inv_buf
;
308 if (DBG_NOTCLASS(DBG_C_UNUSED
))
312 str
= MSG_ORIG(tags
[tag
]);
314 str
= conv_invalid_val(&inv_buf
, tag
, 0);
316 dbg_print(LIST(nlmp
), MSG_INTL(MSG_USD_LCINTERFACE
), NAME(nlmp
), str
,
321 * Generic new line generator. To prevent multiple newlines from being
322 * generated, a flag is maintained in the global debug descriptor. This flag
323 * is cleared by the callers dbg_print() function to indicate that a newline
324 * (actually, any line) has been printed. Multiple newlines can be generated
325 * using the DBG_NL_FRC flag.
328 Dbg_util_nl(Lm_list
*lml
, int flag
)
330 if ((flag
== DBG_NL_STD
) && (dbg_desc
->d_extra
& DBG_E_STDNL
))
333 dbg_print(lml
, MSG_ORIG(MSG_STR_EMPTY
));
335 if (flag
== DBG_NL_STD
)
336 dbg_desc
->d_extra
|= DBG_E_STDNL
;
340 * Define name demanglers.
343 Dbg_demangle_name(const char *name
)
345 if (DBG_NOTCLASS(DBG_C_DEMANGLE
))
348 return (conv_demangle_name(name
));
352 Elf_demangle_name(const char *name
)
354 if (DBG_ISDEMANGLE())
355 return (conv_demangle_name(name
));