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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include "msg.h" 29 #include "_debug.h" 30 #include "libld.h" 31 32 /* 33 * Generic new line generator. 34 */ 35 void 36 Dbg_util_nl() 37 { 38 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 39 } 40 41 /* 42 * If any run-time linker debugging is being carried out always indicate the 43 * fact and specify the point at which we transfer control to the main program. 44 */ 45 void 46 Dbg_util_call_main(const char *name) 47 { 48 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 49 dbg_print(MSG_INTL(MSG_UTL_TRANS), name); 50 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 51 } 52 53 void 54 Dbg_util_call_init(const char *name, int flag) 55 { 56 const char *str; 57 58 if (DBG_NOTCLASS(DBG_INIT)) 59 return; 60 61 if (flag == DBG_INIT_SORT) 62 str = MSG_INTL(MSG_UTL_SORT); 63 else if (flag == DBG_INIT_PEND) 64 str = MSG_INTL(MSG_UTL_PEND); 65 else if (flag == DBG_INIT_DYN) 66 str = MSG_INTL(MSG_UTL_DYN); 67 else 68 str = MSG_INTL(MSG_UTL_DONE); 69 70 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 71 dbg_print(MSG_INTL(MSG_UTL_INIT), str, name); 72 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 73 } 74 75 void 76 Dbg_util_no_init(const char *name) 77 { 78 if (DBG_NOTCLASS(DBG_INIT)) 79 return; 80 81 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 82 dbg_print(MSG_INTL(MSG_UTL_NOINIT), name); 83 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 84 } 85 86 void 87 Dbg_util_intoolate(const char *name) 88 { 89 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 90 dbg_print(MSG_INTL(MSG_UTL_INTOOLATE), name); 91 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 92 } 93 94 void 95 Dbg_util_dbnotify(rd_event_e event, r_state_e state) 96 { 97 const char *estr; 98 const char *sstr; 99 100 if (DBG_NOTCLASS(DBG_FILES)) 101 return; 102 if (DBG_NOTDETAIL()) 103 return; 104 105 switch (event) { 106 case RD_PREINIT: 107 estr = MSG_ORIG(MSG_UTL_EVNT_PREINIT); 108 sstr = MSG_INTL(MSG_STR_NULL); 109 break; 110 case RD_POSTINIT: 111 estr = MSG_ORIG(MSG_UTL_EVNT_POSTINIT); 112 sstr = MSG_INTL(MSG_STR_NULL); 113 break; 114 case RD_DLACTIVITY: 115 estr = MSG_ORIG(MSG_UTL_EVNT_DLACT); 116 switch (state) { 117 case RT_CONSISTENT: 118 sstr = MSG_ORIG(MSG_UTL_STA_CONSIST); 119 break; 120 case RT_ADD: 121 sstr = MSG_ORIG(MSG_UTL_STA_ADD); 122 break; 123 case RT_DELETE: 124 sstr = MSG_ORIG(MSG_UTL_STA_DELETE); 125 break; 126 default: 127 sstr = MSG_INTL(MSG_STR_NULL); 128 break; 129 } 130 break; 131 default: 132 sstr = MSG_INTL(MSG_STR_NULL); 133 estr = MSG_INTL(MSG_STR_UNKNOWN); 134 break; 135 } 136 137 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 138 dbg_print(MSG_INTL(MSG_UTL_DBNOTIFY), estr, sstr); 139 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 140 } 141 142 void 143 Dbg_util_call_array(const char *libname, void *addr, uint_t ndx, 144 uint_t shtype) 145 { 146 const char *str; 147 148 if (DBG_NOTCLASS(DBG_INIT)) 149 return; 150 151 if (shtype == SHT_INIT_ARRAY) 152 str = MSG_ORIG(MSG_SCN_INITARRAY); 153 else if (shtype == SHT_FINI_ARRAY) 154 str = MSG_ORIG(MSG_SCN_FINIARRAY); 155 else 156 str = MSG_ORIG(MSG_SCN_PREINITARRAY); 157 dbg_print(MSG_INTL(MSG_UTL_ARRAY), str, ndx, EC_ADDR(addr), libname); 158 } 159 160 void 161 Dbg_util_call_fini(const char *name) 162 { 163 if (DBG_NOTCLASS(DBG_INIT)) 164 return; 165 166 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 167 dbg_print(MSG_INTL(MSG_UTL_FINI), name); 168 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 169 } 170 171 void 172 Dbg_util_str(const char *name) 173 { 174 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 175 dbg_print(MSG_ORIG(MSG_FMT_STR), name); 176 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 177 } 178 179 void 180 Dbg_util_scc_title(int sec) 181 { 182 const char *_sec; 183 184 if (DBG_NOTCLASS(DBG_INIT)) 185 return; 186 if (DBG_NOTDETAIL()) 187 return; 188 189 if (sec) 190 _sec = MSG_INTL(MSG_UTL_SCC_SUBI); 191 else 192 _sec = MSG_INTL(MSG_UTL_SCC_SUBF); 193 194 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 195 dbg_print(MSG_INTL(MSG_UTL_SCC_TITLE), _sec); 196 } 197 198 void 199 Dbg_util_scc_entry(uint_t idx, const char *name) 200 { 201 if (DBG_NOTCLASS(DBG_INIT)) 202 return; 203 if (DBG_NOTDETAIL()) 204 return; 205 206 dbg_print(MSG_ORIG(MSG_UTL_SCC_ENTRY), idx, name); 207 } 208 209 void 210 Dbg_util_broadcast(const char *name) 211 { 212 if (DBG_NOTCLASS(DBG_INIT)) 213 return; 214 if (DBG_NOTDETAIL()) 215 return; 216 217 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 218 dbg_print(MSG_INTL(MSG_UTL_BROAD), name); 219 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 220 } 221 222 void 223 Dbg_util_wait(int what, const char *cname, const char *dname) 224 { 225 const char *str; 226 227 if (DBG_NOTCLASS(DBG_INIT)) 228 return; 229 if (DBG_NOTDETAIL()) 230 return; 231 232 if (what == DBG_WAIT_INIT) 233 str = MSG_ORIG(MSG_SCN_INIT); 234 else if (what == DBG_WAIT_FINI) 235 str = MSG_ORIG(MSG_SCN_FINI); 236 else 237 str = MSG_INTL(MSG_STR_SYMBOL); 238 239 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 240 dbg_print(MSG_INTL(MSG_UTL_WAIT), str, cname, dname); 241 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 242 } 243 244 static int ectoggle = 0; 245 246 void 247 Dbg_util_edge_in(Rt_map *clmp, uint_t flags, Rt_map *dlmp, int ndx, int flag) 248 { 249 const char *str; 250 251 if (DBG_NOTCLASS(DBG_INIT)) 252 return; 253 if (DBG_NOTDETAIL()) 254 return; 255 256 if (flag & RT_SORT_REV) 257 str = MSG_ORIG(MSG_SCN_INIT); 258 else 259 str = MSG_ORIG(MSG_SCN_FINI); 260 261 if ((clmp == 0) || (ectoggle == 0)) 262 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 263 if (clmp == 0) { 264 dbg_print(MSG_INTL(MSG_UTL_EDGE_TITLE), str); 265 dbg_print(MSG_INTL(MSG_UTL_EDGE_START), ndx, NAME(dlmp)); 266 } else 267 dbg_print(MSG_INTL(MSG_UTL_EDGE_IN), ndx, NAME(dlmp), 268 NAME(clmp), conv_bindent_str(flags)); 269 270 ectoggle = 1; 271 } 272 273 void 274 Dbg_util_edge_out(const char *cname, int ndx, const char *dname) 275 { 276 if (DBG_NOTCLASS(DBG_INIT)) 277 return; 278 if (DBG_NOTDETAIL()) 279 return; 280 281 dbg_print(MSG_INTL(MSG_UTL_EDGE_OUT), ndx, cname, dname); 282 } 283 284 void 285 Dbg_util_collect(const char *name, int ndx, int flag) 286 { 287 const char *str; 288 289 if (DBG_NOTCLASS(DBG_INIT)) 290 return; 291 if (DBG_NOTDETAIL()) 292 return; 293 294 if (flag & RT_SORT_REV) 295 str = MSG_ORIG(MSG_SCN_INIT); 296 else 297 str = MSG_ORIG(MSG_SCN_FINI); 298 299 if (ectoggle == 1) { 300 dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 301 ectoggle = 0; 302 } 303 dbg_print(MSG_INTL(MSG_UTL_COLLECT), ndx, name, str); 304 } 305