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 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <msg.h> 30 #include <_rtld.h> 31 #include <conv.h> 32 #include <sys/mdb_modapi.h> 33 #include <sys/param.h> 34 #include <stdlib.h> 35 36 /* 37 * Data structure for walkers. 38 */ 39 typedef struct { 40 uint_t w_flags; 41 } W_desc; 42 43 44 /* 45 * Flags values for dcmds 46 */ 47 48 #define RTLD_FLG_VERBOSE 0x0001 /* verbose output */ 49 50 static const mdb_bitmask_t rtflags_bits[] = { 51 { MSG_ORIG(MSG_FLG_ISMAIN), FLG_RT_ISMAIN, FLG_RT_ISMAIN}, 52 { MSG_ORIG(MSG_FLG_IMGALLOC), FLG_RT_IMGALLOC, FLG_RT_IMGALLOC}, 53 { MSG_ORIG(MSG_FLG_RELOCED), FLG_RT_RELOCED, FLG_RT_RELOCED}, 54 { MSG_ORIG(MSG_FLG_SETGROUP), FLG_RT_SETGROUP, FLG_RT_SETGROUP}, 55 { MSG_ORIG(MSG_FLG_HWCAP), FLG_RT_HWCAP, FLG_RT_HWCAP}, 56 { MSG_ORIG(MSG_FLG_OBJECT), FLG_RT_OBJECT, FLG_RT_OBJECT}, 57 { MSG_ORIG(MSG_FLG_NODUMP), FLG_RT_NODUMP, FLG_RT_NODUMP}, 58 { MSG_ORIG(MSG_FLG_DELETE), FLG_RT_DELETE, FLG_RT_DELETE}, 59 { MSG_ORIG(MSG_FLG_ANALYZED), FLG_RT_ANALYZED, FLG_RT_ANALYZED}, 60 { MSG_ORIG(MSG_FLG_INITDONE), FLG_RT_INITDONE, FLG_RT_INITDONE}, 61 { MSG_ORIG(MSG_FLG_TRANS), FLG_RT_TRANS, FLG_RT_TRANS}, 62 { MSG_ORIG(MSG_FLG_FIXED), FLG_RT_FIXED, FLG_RT_FIXED}, 63 { MSG_ORIG(MSG_FLG_PRELOAD), FLG_RT_PRELOAD, FLG_RT_PRELOAD}, 64 { MSG_ORIG(MSG_FLG_ALTER), FLG_RT_ALTER, FLG_RT_ALTER}, 65 { MSG_ORIG(MSG_FLG_LOADFLTR), FLG_RT_LOADFLTR, FLG_RT_LOADFLTR}, 66 { MSG_ORIG(MSG_FLG_AUDIT), FLG_RT_AUDIT, FLG_RT_AUDIT}, 67 { MSG_ORIG(MSG_FLG_MODESET), FLG_RT_MODESET, FLG_RT_MODESET}, 68 { MSG_ORIG(MSG_FLG_ANALZING), FLG_RT_ANALZING, FLG_RT_ANALZING}, 69 { MSG_ORIG(MSG_FLG_INITFRST), FLG_RT_INITFRST, FLG_RT_INITFRST}, 70 { MSG_ORIG(MSG_FLG_NOOPEN), FLG_RT_NOOPEN, FLG_RT_NOOPEN}, 71 { MSG_ORIG(MSG_FLG_FINICLCT), FLG_RT_FINICLCT, FLG_RT_FINICLCT}, 72 { MSG_ORIG(MSG_FLG_INITCALL), FLG_RT_INITCALL, FLG_RT_INITCALL}, 73 { MSG_ORIG(MSG_FLG_SUNWBSS), FLG_RT_SUNWBSS, FLG_RT_SUNWBSS}, 74 { MSG_ORIG(MSG_FLG_OBJINTPO), FLG_RT_OBJINTPO, FLG_RT_OBJINTPO}, 75 { MSG_ORIG(MSG_FLG_SYMINTPO), FLG_RT_SYMINTPO, FLG_RT_SYMINTPO}, 76 { MSG_ORIG(MSG_FLG_MOVE), FLG_RT_MOVE, FLG_RT_MOVE}, 77 { MSG_ORIG(MSG_FLG_DLSYM), FLG_RT_DLSYM, FLG_RT_DLSYM}, 78 { MSG_ORIG(MSG_FLG_REGSYMS), FLG_RT_REGSYMS, FLG_RT_REGSYMS}, 79 { MSG_ORIG(MSG_FLG_INITCLCT), FLG_RT_INITCLCT, FLG_RT_INITCLCT}, 80 { MSG_ORIG(MSG_FLG_HANDLE), FLG_RT_HANDLE, FLG_RT_HANDLE}, 81 { MSG_ORIG(MSG_FLG_RELOCING), FLG_RT_RELOCING, FLG_RT_RELOCING}, 82 { NULL, 0, 0} 83 }; 84 85 static const mdb_bitmask_t rtflags1_bits[] = { 86 { MSG_ORIG(MSG_FL1_COPYTOOK), FL1_RT_COPYTOOK, FL1_RT_COPYTOOK}, 87 { MSG_ORIG(MSG_FL1_RELATIVE), FL1_RT_RELATIVE, FL1_RT_RELATIVE }, 88 { MSG_ORIG(MSG_FL1_CONFSET), FL1_RT_CONFSET, FL1_RT_CONFSET }, 89 { MSG_ORIG(MSG_FL1_NODEFLIB), FL1_RT_NODEFLIB, FL1_RT_NODEFLIB }, 90 { MSG_ORIG(MSG_FL1_ENDFILTE), FL1_RT_ENDFILTE, FL1_RT_ENDFILTE }, 91 { MSG_ORIG(MSG_FL1_DISPREL), FL1_RT_DISPREL, FL1_RT_DISPREL }, 92 { MSG_ORIG(MSG_FL1_TEXTREL), FL1_RT_TEXTREL, FL1_RT_TEXTREL }, 93 { MSG_ORIG(MSG_FL1_INITWAIT), FL1_RT_INITWAIT, FL1_RT_INITWAIT }, 94 { MSG_ORIG(MSG_FL1_LDDSTUB), FL1_RT_LDDSTUB, FL1_RT_LDDSTUB}, 95 { MSG_ORIG(MSG_FL1_NOINIFIN), FL1_RT_NOINIFIN, FL1_RT_NOINIFIN }, 96 { MSG_ORIG(MSG_FL1_USED), FL1_RT_USED, FL1_RT_USED }, 97 { MSG_ORIG(MSG_FL1_SYMBOLIC), FL1_RT_SYMBOLIC, FL1_RT_SYMBOLIC }, 98 { MSG_ORIG(MSG_FL1_OBJSFLTR), FL1_RT_OBJSFLTR, FL1_RT_OBJSFLTR }, 99 { MSG_ORIG(MSG_FL1_OBJAFLTR), FL1_RT_OBJAFLTR, FL1_RT_OBJAFLTR }, 100 { MSG_ORIG(MSG_FL1_SYMSFLTR), FL1_RT_SYMSFLTR, FL1_RT_SYMSFLTR }, 101 { MSG_ORIG(MSG_FL1_SYMAFLTR), FL1_RT_SYMAFLTR, FL1_RT_SYMAFLTR }, 102 { MSG_ORIG(MSG_FL1_TLSADD), FL1_RT_TLSADD, FL1_RT_TLSADD }, 103 { MSG_ORIG(MSG_FL1_TLSSTAT), FL1_RT_TLSSTAT, FL1_RT_TLSSTAT }, 104 { MSG_ORIG(MSG_FL1_DIRECT), FL1_RT_DIRECT, FL1_RT_DIRECT}, 105 106 { MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT, 107 LML_TFLG_AUD_PREINIT }, 108 { MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH, 109 LML_TFLG_AUD_OBJSEARCH }, 110 { MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN, 111 LML_TFLG_AUD_OBJOPEN }, 112 { MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER, 113 LML_TFLG_AUD_OBJFILTER }, 114 { MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE, 115 LML_TFLG_AUD_OBJCLOSE }, 116 { MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND, 117 LML_TFLG_AUD_SYMBIND }, 118 { MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER, 119 LML_TFLG_AUD_PLTENTER }, 120 { MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT, 121 LML_TFLG_AUD_PLTEXIT }, 122 { MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY, 123 LML_TFLG_AUD_ACTIVITY }, 124 { NULL, 0, 0} 125 }; 126 127 static const mdb_bitmask_t rtmode_bits[] = { 128 { MSG_ORIG(MSG_MODE_LAZY), RTLD_LAZY, RTLD_LAZY }, 129 { MSG_ORIG(MSG_MODE_NOW), RTLD_NOW, RTLD_NOW }, 130 { MSG_ORIG(MSG_MODE_NOLOAD), RTLD_NOLOAD, RTLD_NOLOAD }, 131 { MSG_ORIG(MSG_MODE_GLOBAL), RTLD_GLOBAL, RTLD_GLOBAL }, 132 { MSG_ORIG(MSG_MODE_PARENT), RTLD_PARENT, RTLD_PARENT }, 133 { MSG_ORIG(MSG_MODE_GROUP), RTLD_GROUP, RTLD_GROUP }, 134 { MSG_ORIG(MSG_MODE_WORLD), RTLD_WORLD, RTLD_WORLD }, 135 { MSG_ORIG(MSG_MODE_NODELETE), RTLD_NODELETE, RTLD_NODELETE }, 136 { MSG_ORIG(MSG_MODE_FIRST), RTLD_FIRST, RTLD_FIRST }, 137 { MSG_ORIG(MSG_MODE_CONFGEN), RTLD_CONFGEN, RTLD_CONFGEN }, 138 { NULL, 0, 0} 139 }; 140 141 static const mdb_bitmask_t bndflags_bits[] = { 142 { MSG_ORIG(MSG_BFL_NEEDED), BND_NEEDED, BND_NEEDED }, 143 { MSG_ORIG(MSG_BFL_REFER), BND_REFER, BND_REFER }, 144 { MSG_ORIG(MSG_BFL_FILTER), BND_FILTER, BND_FILTER }, 145 { NULL, 0, 0} 146 }; 147 148 static const mdb_bitmask_t grhflags_bits[] = { 149 { MSG_ORIG(MSG_GPH_ZERO), GPH_ZERO, GPH_ZERO }, 150 { MSG_ORIG(MSG_GPH_LDSO), GPH_LDSO, GPH_LDSO }, 151 { MSG_ORIG(MSG_GPH_FIRST), GPH_FIRST, GPH_FIRST }, 152 { MSG_ORIG(MSG_GPH_PARENT), GPH_PARENT, GPH_PARENT }, 153 { MSG_ORIG(MSG_GPH_FILTEE), GPH_FILTEE, GPH_FILTEE }, 154 { MSG_ORIG(MSG_GPH_INITIAL), GPH_INITIAL, GPH_INITIAL }, 155 { MSG_ORIG(MSG_GPH_NOPENDLAZY), GPH_NOPENDLAZY, GPH_NOPENDLAZY }, 156 { NULL, 0, 0} 157 }; 158 159 static const mdb_bitmask_t grdflags_bits[] = { 160 { MSG_ORIG(MSG_GPD_AVAIL), GPD_AVAIL, GPD_AVAIL }, 161 { MSG_ORIG(MSG_GPD_ADDEPS), GPD_ADDEPS, GPD_ADDEPS }, 162 { MSG_ORIG(MSG_GPD_PARENT), GPD_PARENT, GPD_PARENT }, 163 { MSG_ORIG(MSG_GPD_FILTER), GPD_FILTER, GPD_FILTER }, 164 { MSG_ORIG(MSG_GPD_REMOVE), GPD_REMOVE, GPD_REMOVE }, 165 { NULL, 0, 0} 166 }; 167 168 static const mdb_bitmask_t lmc_bits[] = { 169 { MSG_ORIG(MSG_LMC_ANALYZING), LMC_FLG_ANALYZING, LMC_FLG_ANALYZING}, 170 { MSG_ORIG(MSG_LMC_RELOCATING), LMC_FLG_RELOCATING, LMC_FLG_RELOCATING}, 171 { MSG_ORIG(MSG_LMC_REANALYZE), LMC_FLG_REANALYZE, LMC_FLG_REANALYZE}, 172 { NULL, 0, 0} 173 }; 174 175 /* 176 * Obtain a string - typically a link-map name. 177 */ 178 static char * 179 String(uintptr_t addr, const char *name) 180 { 181 static char str[MAXPATHLEN]; 182 183 if (addr) { 184 if (mdb_readstr(str, MAXPATHLEN, addr) == -1) { 185 mdb_warn(MSG_ORIG(MSG_ERR_READ), name, addr); 186 return (0); 187 } 188 return (str); 189 } 190 return ((char *)MSG_ORIG(MSG_STR_EMPTY)); 191 } 192 193 /* 194 * Obtain a link-map name. 195 */ 196 static char * 197 Rtmap_Name(uintptr_t addr) 198 { 199 Rt_map rtmap; 200 201 if (addr) { 202 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 203 mdb_warn(MSG_ORIG(MSG_ERR_READ), 204 MSG_ORIG(MSG_RTMAP_STR), addr); 205 return (0); 206 } 207 return (String((uintptr_t)NAME(&rtmap), 208 MSG_ORIG(MSG_STR_NAME))); 209 } 210 return ((char *)MSG_ORIG(MSG_STR_EMPTY)); 211 } 212 213 void 214 dcmd_Bind_help(void) 215 { 216 mdb_printf(MSG_ORIG(MSG_BND_HELP)); 217 } 218 219 static int 220 /* ARGSUSED2 */ 221 dcmd_Bind(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 222 { 223 Bnd_desc bnd; 224 char *str; 225 226 /* 227 * Insure we have a valid address. 228 */ 229 if ((flags & DCMD_ADDRSPEC) == 0) { 230 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_BND_STR)); 231 return (DCMD_USAGE); 232 } 233 234 /* 235 * Obtain the binding descriptor. 236 */ 237 if (mdb_vread(&bnd, sizeof (Bnd_desc), addr) == -1) { 238 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_BND_STR), addr); 239 return (DCMD_ERR); 240 } 241 mdb_printf(MSG_ORIG(MSG_BND_TITLE), addr); 242 243 /* 244 * Establish the identity of the caller. 245 */ 246 if ((str = Rtmap_Name((uintptr_t)bnd.b_caller)) == 0) 247 return (DCMD_ERR); 248 mdb_printf(MSG_ORIG(MSG_BND_LINE1), bnd.b_caller, str); 249 250 /* 251 * Establish the identity of the dependency. 252 */ 253 if ((str = Rtmap_Name((uintptr_t)bnd.b_depend)) == 0) 254 return (DCMD_ERR); 255 mdb_printf(MSG_ORIG(MSG_BND_LINE2), bnd.b_depend, str); 256 257 /* 258 * Display any flags. 259 */ 260 mdb_printf(MSG_ORIG(MSG_BND_LINE3), bnd.b_flags, bnd.b_flags, 261 bndflags_bits); 262 263 return (DCMD_OK); 264 } 265 266 static void 267 dcmd_Depends_help(void) 268 { 269 mdb_printf(MSG_ORIG(MSG_DEPENDS_HELP)); 270 } 271 272 static int 273 Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv, 274 uint_t flg, const char *msg) 275 { 276 Alist al; 277 uintptr_t listcalc, listnext; 278 size_t ucnt, tcnt; 279 Bnd_desc * bdp; 280 281 /* 282 * Obtain the Alist and determine its number of elements and those 283 * that are in use. 284 */ 285 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 286 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr); 287 return (DCMD_ERR); 288 } 289 290 ucnt = (al.al_next - sizeof (Alist) + sizeof (void *)) / al.al_size; 291 tcnt = (al.al_end - sizeof (Alist) + sizeof (void *)) / al.al_size; 292 mdb_printf(msg, addr, ucnt, tcnt); 293 294 if (((flg & RTLD_FLG_VERBOSE) == 0) || (ucnt == 0)) 295 return (DCMD_OK); 296 297 /* 298 * Under verbose mode print the name of each dependency. An Alist can 299 * have a variable number of data items, so read each individual entry. 300 */ 301 listcalc = (uintptr_t)(&(al.al_data[0])); 302 listcalc -= (uintptr_t)(&al); 303 listcalc += addr; 304 if (mdb_vread(&bdp, sizeof (Bnd_desc *), listcalc) == -1) { 305 mdb_warn(MSG_ORIG(MSG_ERR_READ), 306 MSG_ORIG(MSG_BNDDESC_STR), listcalc); 307 return (DCMD_ERR); 308 } 309 310 mdb_inc_indent(4); 311 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 312 313 if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) { 314 mdb_dec_indent(4); 315 return (DCMD_ERR); 316 } 317 318 listnext = (uintptr_t)(al.al_next + addr); 319 for (listcalc += al.al_size; listcalc < listnext; 320 listcalc += al.al_size) { 321 if (mdb_vread(&bdp, sizeof (Bnd_desc *), listcalc) == -1) { 322 mdb_warn(MSG_ORIG(MSG_ERR_READ), 323 MSG_ORIG(MSG_BNDDESC_STR), listcalc); 324 return (DCMD_ERR); 325 } 326 327 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 328 if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) { 329 mdb_dec_indent(4); 330 return (DCMD_ERR); 331 } 332 } 333 mdb_dec_indent(4); 334 return (DCMD_OK); 335 } 336 337 static int 338 dcmd_Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 339 { 340 Rt_map rtmap; 341 char *str; 342 uint_t flg = 0; 343 344 /* 345 * Insure we have a valid address, and provide for a -v option. 346 */ 347 if ((flags & DCMD_ADDRSPEC) == 0) { 348 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR)); 349 return (DCMD_USAGE); 350 } 351 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 352 &flg, NULL) != argc) 353 return (DCMD_USAGE); 354 355 /* 356 * Read the Rt_map contents. 357 */ 358 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 359 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 360 return (DCMD_ERR); 361 } 362 if ((str = String((uintptr_t)NAME(&rtmap), 363 MSG_ORIG(MSG_STR_NAME))) == 0) 364 return (DCMD_ERR); 365 366 mdb_printf(MSG_ORIG(MSG_DEPENDS_LINE1), str); 367 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 368 369 if (DEPENDS(&rtmap) == 0) 370 return (DCMD_OK); 371 372 return (Depends((uintptr_t)DEPENDS(&rtmap), flags, argc, argv, flg, 373 MSG_ORIG(MSG_DEPENDS_LINE2))); 374 } 375 376 static void 377 dcmd_Callers_help(void) 378 { 379 mdb_printf(MSG_ORIG(MSG_CALLERS_HELP)); 380 } 381 382 static int 383 dcmd_Callers(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 384 { 385 Rt_map rtmap; 386 char *str; 387 uint_t flg = 0; 388 389 /* 390 * Insure we have a valid address, and provide for a -v option. 391 */ 392 if ((flags & DCMD_ADDRSPEC) == 0) { 393 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR)); 394 return (DCMD_USAGE); 395 } 396 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 397 &flg, NULL) != argc) 398 return (DCMD_USAGE); 399 400 /* 401 * Read the Rt_map contents. 402 */ 403 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 404 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 405 return (DCMD_ERR); 406 } 407 if ((str = String((uintptr_t)NAME(&rtmap), 408 MSG_ORIG(MSG_STR_NAME))) == 0) 409 return (DCMD_ERR); 410 411 mdb_printf(MSG_ORIG(MSG_CALLERS_LINE1), str); 412 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 413 414 if (CALLERS(&rtmap) == 0) 415 return (DCMD_OK); 416 417 return (Depends((uintptr_t)CALLERS(&rtmap), flags, argc, argv, flg, 418 MSG_ORIG(MSG_CALLERS_LINE2))); 419 } 420 421 void 422 dcmd_rtmap_help(void) 423 { 424 mdb_printf(MSG_ORIG(MSG_RTMAP_HELP)); 425 } 426 427 static int 428 /* ARGSUSED2 */ 429 dcmd_rtmap(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 430 { 431 Rt_map rtmap; 432 char *str; 433 434 if ((flags & DCMD_ADDRSPEC) == 0) { 435 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR)); 436 return (DCMD_USAGE); 437 } 438 439 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 440 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 441 return (DCMD_ERR); 442 } 443 444 mdb_printf(MSG_ORIG(MSG_RTMAP_TITLE), addr); 445 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 446 447 /* 448 * Determine the objects name. NAME() is the name by which the object 449 * has been opened, typically from adding a search path to a file name. 450 * PATHNAME() is the fully resolve name, which is displayed by the proc 451 * tools and debuggers. If the two names differ, print the PATHNAME(). 452 */ 453 if ((str = String((uintptr_t)NAME(&rtmap), 454 MSG_ORIG(MSG_STR_NAME))) == 0) 455 return (DCMD_ERR); 456 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE1), str); 457 if (NAME(&rtmap) != PATHNAME(&rtmap)) { 458 if ((str = String((uintptr_t)PATHNAME(&rtmap), 459 MSG_ORIG(MSG_STR_PATHNAME))) == 0) 460 return (DCMD_ERR); 461 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE2), str); 462 } 463 464 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE3), ADDR(&rtmap), DYN(&rtmap)); 465 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE4), NEXT(&rtmap), PREV(&rtmap)); 466 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE5), rtmap.rt_fct, TLSMODID(&rtmap)); 467 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE6), INIT(&rtmap), FINI(&rtmap)); 468 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE7), GROUPS(&rtmap), HANDLES(&rtmap)); 469 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE8), DEPENDS(&rtmap), CALLERS(&rtmap)); 470 471 if ((str = String((uintptr_t)REFNAME(&rtmap), 472 MSG_ORIG(MSG_STR_REFNAME))) == 0) 473 return (DCMD_ERR); 474 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE9), DYNINFO(&rtmap), str); 475 476 if ((str = String((uintptr_t)RPATH(&rtmap), 477 MSG_ORIG(MSG_STR_RPATH))) == 0) 478 return (DCMD_ERR); 479 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE10), RLIST(&rtmap), str); 480 481 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE11), LIST(&rtmap), LIST(&rtmap)); 482 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE12), FLAGS(&rtmap)); 483 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS(&rtmap), rtflags_bits); 484 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE13), FLAGS1(&rtmap)); 485 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS1(&rtmap), rtflags1_bits); 486 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE14), MODE(&rtmap)); 487 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), MODE(&rtmap), rtmode_bits); 488 489 return (DCMD_OK); 490 } 491 492 493 static int 494 rtmap_format(uintptr_t addr, const void * data, void * private) 495 { 496 const Rt_map *lmp = (const Rt_map *)data; 497 W_desc *wdp = (W_desc *)private; 498 char *str; 499 500 if (wdp && (wdp->w_flags & RTLD_FLG_VERBOSE)) { 501 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 502 mdb_call_dcmd(MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC, 503 NULL, NULL); 504 return (0); 505 } 506 507 if ((str = String((uintptr_t)NAME(lmp), 508 MSG_ORIG(MSG_STR_NAME))) == 0) 509 return (DCMD_ERR); 510 511 mdb_printf(MSG_ORIG(MSG_FMT_RT), CNTL(lmp), addr, ADDR(lmp), str); 512 return (0); 513 } 514 515 void 516 dcmd_Rtmaps_help(void) 517 { 518 mdb_printf(MSG_ORIG(MSG_RTMAPS_HELP)); 519 } 520 521 static int 522 dcmd_Rtmaps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 523 { 524 uint_t flg = 0; 525 GElf_Sym gsym; 526 List l; 527 Listnode ln; 528 uintptr_t naddr; 529 const char *str; 530 W_desc wdesc; 531 532 /* 533 * '-v' - Verbose output of rtmap 534 */ 535 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 536 &flg, NULL) != argc) 537 return (DCMD_USAGE); 538 539 /* 540 * If an address was provided use it. 541 */ 542 if (flags & DCMD_ADDRSPEC) { 543 if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) && 544 !(flg & RTLD_FLG_VERBOSE)) { 545 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 546 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 547 } 548 549 wdesc.w_flags = flg; 550 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format, 551 (void *)&wdesc, addr) == -1) 552 return (DCMD_ERR); 553 return (DCMD_OK); 554 } 555 556 /* 557 * Otherwise traverse the dynlm_list and display each link-map. 558 */ 559 if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1), 560 MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) { 561 mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1), 562 MSG_ORIG(MSG_STR_DYNLMLIST)); 563 return (DCMD_ERR); 564 } 565 if (mdb_vread((void *)&l, sizeof (l), (uintptr_t)gsym.st_value) == -1) { 566 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LIST_STR), 567 gsym.st_value); 568 return (DCMD_ERR); 569 } 570 571 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST), 572 &gsym); 573 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 574 575 flags |= (DCMD_LOOP | DCMD_LOOPFIRST); 576 for (naddr = (uintptr_t)l.head; naddr; naddr = (uintptr_t)ln.next) { 577 Lm_list lml; 578 579 if (mdb_vread(&ln, sizeof (ln), naddr) == -1) { 580 mdb_warn(MSG_ORIG(MSG_ERR_READ), 581 MSG_ORIG(MSG_STR_LISTNODE), naddr); 582 return (DCMD_ERR); 583 } 584 if (mdb_vread(&lml, sizeof (lml), (uintptr_t)ln.data) == -1) { 585 mdb_warn(MSG_ORIG(MSG_ERR_READ), 586 MSG_ORIG(MSG_LMLIST_STR), ln.data); 587 return (DCMD_ERR); 588 } 589 590 mdb_inc_indent(2); 591 if (lml.lm_flags & LML_FLG_BASELM) 592 str = MSG_ORIG(MSG_LMLIST_BASE); 593 else if (lml.lm_flags & LML_FLG_RTLDLM) 594 str = MSG_ORIG(MSG_LMLIST_LDSO); 595 else 596 str = MSG_ORIG(MSG_LMLIST_NEWLM); 597 598 if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0)) 599 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 600 601 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), ln.data, str); 602 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 603 604 mdb_inc_indent(2); 605 606 if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) && 607 !(flg & RTLD_FLG_VERBOSE)) { 608 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 609 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 610 } 611 612 wdesc.w_flags = flg; 613 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format, 614 (void *)&wdesc, (uintptr_t)lml.lm_head) == -1) { 615 mdb_dec_indent(4); 616 return (DCMD_ERR); 617 } 618 mdb_dec_indent(4); 619 flags &= ~DCMD_LOOPFIRST; 620 } 621 return (DCMD_OK); 622 } 623 624 static int 625 /* ARGSUSED2 */ 626 format_listnode(uintptr_t addr, const void * data, void * private) 627 { 628 Listnode * lnp = (Listnode *)data; 629 630 mdb_printf(MSG_ORIG(MSG_FMT_LN), addr, lnp->data, lnp->next); 631 return (0); 632 } 633 634 void 635 dcmd_List_help(void) 636 { 637 mdb_printf(MSG_ORIG(MSG_LIST_HELP)); 638 } 639 640 static int 641 /* ARGSUSED2 */ 642 dcmd_List(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 643 { 644 if ((flags & DCMD_ADDRSPEC) == 0) 645 return (DCMD_USAGE); 646 if ((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) { 647 mdb_printf(MSG_ORIG(MSG_LIST_TITLE)); 648 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 649 } 650 if (mdb_pwalk(MSG_ORIG(MSG_LIST_STR), format_listnode, 651 (void *)0, addr) == -1) 652 return (DCMD_ERR); 653 return (DCMD_OK); 654 } 655 656 void 657 dcmd_Setenv_help(void) 658 { 659 mdb_printf(MSG_ORIG(MSG_SETENV_HELP)); 660 } 661 662 /* 663 * As of s10, mdb provides its own setenv command. This command allows the 664 * environment of the process being controlled to be changed at any time. 665 * Prior to this, ld.so.1 provided it's own, more primitive implementation. 666 * This allowed for changing mdb's environment only, which if it was changed 667 * before the application ws executed, would be copied to the applications 668 * environment. Thus, we could start mdb, set an LD_ variable within its 669 * environment (which it's own ld.so.1 had already finished processing), and 670 * have this setting be inherited by the application. 671 */ 672 static int 673 /* ARGSUSED */ 674 dcmd_Setenv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 675 { 676 char *str; 677 678 if (mdb_call_dcmd(MSG_ORIG(MSG_STR_SETENV), addr, flags, argc, 679 argv) == 0) 680 return (DCMD_OK); 681 682 if (((flags & DCMD_ADDRSPEC) != 0) || (argc == 0) || (argc > 1) || 683 (argv->a_type != MDB_TYPE_STRING)) 684 return (DCMD_USAGE); 685 686 str = mdb_alloc((strlen(argv->a_un.a_str) + 1), UM_NOSLEEP); 687 if (str == NULL) 688 return (DCMD_ERR); 689 690 (void) strcpy(str, argv->a_un.a_str); 691 (void) putenv(str); 692 return (DCMD_OK); 693 } 694 695 int 696 walk_List_init(mdb_walk_state_t *wsp) 697 { 698 List lst; 699 700 if (wsp->walk_addr == NULL) { 701 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_LIST_STR)); 702 return (WALK_ERR); 703 } 704 705 if (mdb_vread(&lst, sizeof (List), wsp->walk_addr) == -1) { 706 mdb_warn(MSG_ORIG(MSG_ERR_READ), 707 MSG_ORIG(MSG_LIST_STR), wsp->walk_addr); 708 return (WALK_DONE); 709 } 710 711 wsp->walk_addr = (uintptr_t)lst.head; 712 return (WALK_NEXT); 713 } 714 715 716 static int 717 walk_List_step(mdb_walk_state_t *wsp) 718 { 719 Listnode lnp; 720 int status; 721 722 if (wsp->walk_addr == NULL) 723 return (WALK_DONE); 724 725 if (mdb_vread(&lnp, sizeof (Listnode), wsp->walk_addr) == -1) { 726 mdb_warn(MSG_ORIG(MSG_ERR_READ), 727 MSG_ORIG(MSG_STR_LISTNODE), wsp->walk_addr); 728 return (WALK_DONE); 729 } 730 731 status = wsp->walk_callback(wsp->walk_addr, &lnp, wsp->walk_cbdata); 732 wsp->walk_addr = (uintptr_t)lnp.next; 733 return (status); 734 } 735 736 /* 737 * Walk Rt_map lists 738 */ 739 static int 740 walk_rtmap_init(mdb_walk_state_t *wsp) 741 { 742 if (wsp->walk_addr == NULL) { 743 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR)); 744 return (WALK_ERR); 745 } 746 return (WALK_NEXT); 747 } 748 749 static int 750 walk_rtmap_step(mdb_walk_state_t *wsp) 751 { 752 int status; 753 Rt_map lmp; 754 755 if (wsp->walk_addr == NULL) 756 return (WALK_DONE); 757 if (mdb_vread(&lmp, sizeof (Rt_map), wsp->walk_addr) == -1) { 758 mdb_warn(MSG_ORIG(MSG_ERR_READ), 759 MSG_ORIG(MSG_RTMAP_STR), wsp->walk_addr); 760 return (WALK_DONE); 761 } 762 763 status = wsp->walk_callback(wsp->walk_addr, &lmp, wsp->walk_cbdata); 764 wsp->walk_addr = (uintptr_t)(NEXT(&lmp)); 765 return (status); 766 } 767 768 static const mdb_bitmask_t lml_flags_bit[] = { 769 { MSG_ORIG(MSG_LFL_BASELM), LML_FLG_BASELM, LML_FLG_BASELM }, 770 { MSG_ORIG(MSG_LFL_RTLDLM), LML_FLG_RTLDLM, LML_FLG_RTLDLM }, 771 { MSG_ORIG(MSG_LFL_NOAUDIT), LML_FLG_NOAUDIT, LML_FLG_NOAUDIT }, 772 { MSG_ORIG(MSG_LFL_PLTREL), LML_FLG_PLTREL, LML_FLG_PLTREL }, 773 { MSG_ORIG(MSG_LFL_HOLDLOCK), LML_FLG_HOLDLOCK, LML_FLG_HOLDLOCK }, 774 { MSG_ORIG(MSG_LFL_ENVIRON), LML_FLG_ENVIRON, LML_FLG_ENVIRON }, 775 { MSG_ORIG(MSG_LFL_INTRPOSE), LML_FLG_INTRPOSE, LML_FLG_INTRPOSE }, 776 { MSG_ORIG(MSG_LFL_LOCAUDIT), LML_FLG_LOCAUDIT, LML_FLG_LOCAUDIT }, 777 { MSG_ORIG(MSG_LFL_LOADAVAIL), LML_FLG_LOADAVAIL, LML_FLG_LOADAVAIL }, 778 { MSG_ORIG(MSG_LFL_IGNRELERR), LML_FLG_IGNRELERR, LML_FLG_IGNRELERR }, 779 { MSG_ORIG(MSG_LFL_DBNOTIF), LML_FLG_DBNOTIF, LML_FLG_DBNOTIF }, 780 { MSG_ORIG(MSG_LFL_STARTREL), LML_FLG_STARTREL, LML_FLG_STARTREL }, 781 { MSG_ORIG(MSG_LFL_ATEXIT), LML_FLG_ATEXIT, LML_FLG_ATEXIT }, 782 { MSG_ORIG(MSG_LFL_OBJADDED), LML_FLG_OBJADDED, LML_FLG_OBJADDED }, 783 { MSG_ORIG(MSG_LFL_OBJDELETED), LML_FLG_OBJDELETED, 784 LML_FLG_OBJDELETED }, 785 { MSG_ORIG(MSG_LFL_OBJREEVAL), LML_FLG_OBJREEVAL, LML_FLG_OBJREEVAL }, 786 { MSG_ORIG(MSG_LFL_NOPENDGLBLAZY), LML_FLG_NOPENDGLBLAZY, 787 LML_FLG_NOPENDGLBLAZY }, 788 789 { MSG_ORIG(MSG_LFL_TRC_LDDSTUB), LML_FLG_TRC_LDDSTUB, 790 LML_FLG_TRC_LDDSTUB }, 791 { MSG_ORIG(MSG_LFL_TRC_ENABLE), LML_FLG_TRC_ENABLE, 792 LML_FLG_TRC_ENABLE }, 793 { MSG_ORIG(MSG_LFL_TRC_WARN), LML_FLG_TRC_WARN, LML_FLG_TRC_WARN }, 794 { MSG_ORIG(MSG_LFL_TRC_VERBOSE), LML_FLG_TRC_VERBOSE, 795 LML_FLG_TRC_VERBOSE }, 796 { MSG_ORIG(MSG_LFL_TRC_SEARCH), LML_FLG_TRC_SEARCH, 797 LML_FLG_TRC_SEARCH }, 798 { MSG_ORIG(MSG_LFL_TRC_UNREF), LML_FLG_TRC_UNREF, LML_FLG_TRC_UNREF }, 799 { MSG_ORIG(MSG_LFL_TRC_UNUSED), LML_FLG_TRC_UNUSED, 800 LML_FLG_TRC_UNUSED }, 801 { MSG_ORIG(MSG_LFL_TRC_INIT), LML_FLG_TRC_INIT, LML_FLG_TRC_INIT }, 802 { NULL, 0, 0} 803 }; 804 805 static const mdb_bitmask_t lml_tflags_bit[] = { 806 { MSG_ORIG(MSG_LTFL_NOLAZYLD), LML_TFLG_NOLAZYLD, LML_TFLG_NOLAZYLD }, 807 { MSG_ORIG(MSG_LTFL_NODIRECT), LML_TFLG_NODIRECT, LML_TFLG_NODIRECT }, 808 { MSG_ORIG(MSG_LTFL_LOADFLTR), LML_TFLG_LOADFLTR, LML_TFLG_LOADFLTR }, 809 810 { MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT, 811 LML_TFLG_AUD_PREINIT }, 812 { MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH, 813 LML_TFLG_AUD_OBJSEARCH }, 814 { MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN, 815 LML_TFLG_AUD_OBJOPEN }, 816 { MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER, 817 LML_TFLG_AUD_OBJFILTER }, 818 { MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE, 819 LML_TFLG_AUD_OBJCLOSE }, 820 { MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND, 821 LML_TFLG_AUD_SYMBIND }, 822 { MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER, 823 LML_TFLG_AUD_PLTENTER }, 824 { MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT, 825 LML_TFLG_AUD_PLTEXIT }, 826 { MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY, 827 LML_TFLG_AUD_ACTIVITY }, 828 { NULL, 0, 0} 829 }; 830 831 void 832 dcmd_Lm_list_help(void) 833 { 834 mdb_printf(MSG_ORIG(MSG_LMLIST_HELP)); 835 } 836 837 static int 838 /* ARGSUSED1 */ 839 _dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 840 { 841 Lm_list lml; 842 const char *str; 843 uint_t flg = 0; 844 845 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 846 &flg, NULL) != argc) 847 return (DCMD_USAGE); 848 849 if (mdb_vread(&lml, sizeof (lml), addr) == -1) { 850 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LMLIST_STR), 851 addr); 852 return (DCMD_ERR); 853 } 854 855 if (lml.lm_flags & LML_FLG_BASELM) 856 str = MSG_ORIG(MSG_LMLIST_BASE); 857 else if (lml.lm_flags & LML_FLG_RTLDLM) 858 str = MSG_ORIG(MSG_LMLIST_LDSO); 859 else 860 str = MSG_ORIG(MSG_LMLIST_NEWLM); 861 862 if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0)) 863 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 864 865 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), addr, str); 866 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 867 868 if (lml.lm_lists) { 869 Alist al; 870 size_t ucnt, tcnt; 871 Lm_cntl lmc; 872 uintptr_t listcalc; 873 874 addr = (uintptr_t)lml.lm_lists; 875 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 876 mdb_warn(MSG_ORIG(MSG_ERR_READ), 877 MSG_ORIG(MSG_STR_ALIST), addr); 878 return (DCMD_ERR); 879 } 880 881 /* 882 * Determine whether the Alist has been populated. Note, the 883 * implementation first reserves an alist entry, and initializes 884 * this element when the first link-map is processed. Thus, 885 * there's a window when ucnt is updated, but before the next 886 * element has been initialized. 887 */ 888 ucnt = (al.al_next - sizeof (Alist) + sizeof (void *)) / 889 al.al_size; 890 tcnt = (al.al_end - sizeof (Alist) + sizeof (void *)) / 891 al.al_size; 892 893 if (ucnt && (flg & RTLD_FLG_VERBOSE)) { 894 listcalc = (uintptr_t)(&(al.al_data[0])); 895 listcalc -= (uintptr_t)(&al); 896 listcalc += addr; 897 898 if (mdb_vread(&lmc, sizeof (Lm_cntl), 899 listcalc) == -1) { 900 mdb_warn(MSG_ORIG(MSG_ERR_READ), 901 MSG_ORIG(MSG_LMLIST_STR), listcalc); 902 return (DCMD_ERR); 903 } 904 } 905 906 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE0), addr, ucnt, tcnt); 907 mdb_inc_indent(2); 908 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 909 910 if (ucnt && (flg & RTLD_FLG_VERBOSE)) { 911 uintptr_t listnext; 912 913 mdb_inc_indent(2); 914 mdb_printf(MSG_ORIG(MSG_LMC_LINE1), listcalc); 915 mdb_printf(MSG_ORIG(MSG_LMC_LINE2), lmc.lc_head, 916 lmc.lc_tail); 917 mdb_printf(MSG_ORIG(MSG_LMC_LINE3), lmc.lc_flags, 918 lmc.lc_now); 919 mdb_printf(MSG_ORIG(MSG_LMC_LINE4), lmc.lc_flags, 920 lmc_bits); 921 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 922 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 923 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 924 925 if (lmc.lc_head) { 926 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), 927 rtmap_format, (void *)0, 928 (uintptr_t)lmc.lc_head) == -1) { 929 mdb_dec_indent(4); 930 return (DCMD_ERR); 931 } 932 } else 933 mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0, 0, 934 MSG_ORIG(MSG_STR_EMPTY)); 935 936 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 937 938 listnext = (uintptr_t)(al.al_next + addr); 939 for (listcalc += al.al_size; listcalc < listnext; 940 listcalc += al.al_size) { 941 if (mdb_vread(&lmc, sizeof (Lm_cntl), 942 listcalc) == -1) { 943 mdb_warn(MSG_ORIG(MSG_ERR_READ), 944 MSG_ORIG(MSG_LMLIST_STR), listcalc); 945 mdb_dec_indent(4); 946 return (DCMD_ERR); 947 } 948 949 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 950 mdb_printf(MSG_ORIG(MSG_LMC_LINE1), listcalc); 951 mdb_printf(MSG_ORIG(MSG_LMC_LINE2), 952 lmc.lc_head, lmc.lc_tail); 953 mdb_printf(MSG_ORIG(MSG_LMC_LINE3), 954 lmc.lc_flags, lmc.lc_now); 955 mdb_printf(MSG_ORIG(MSG_LMC_LINE4), 956 lmc.lc_flags, lmc_bits); 957 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 958 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 959 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 960 961 if (lmc.lc_head) { 962 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), 963 rtmap_format, (void *)0, 964 (uintptr_t)lmc.lc_head) == -1) { 965 mdb_dec_indent(4); 966 return (DCMD_ERR); 967 } 968 } else 969 mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0, 970 0, MSG_ORIG(MSG_STR_EMPTY)); 971 972 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 973 } 974 mdb_dec_indent(2); 975 } 976 mdb_dec_indent(2); 977 } 978 979 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE1), lml.lm_head, lml.lm_tail); 980 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE2), lml.lm_alp, lml.lm_rti); 981 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE3), lml.lm_handle, lml.lm_obj, 982 lml.lm_init, lml.lm_lazy); 983 984 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE4), lml.lm_flags); 985 if (lml.lm_flags) 986 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_flags, 987 lml_flags_bit); 988 989 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE5), lml.lm_tflags); 990 if (lml.lm_tflags) 991 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_tflags, 992 lml_tflags_bit); 993 994 return (DCMD_OK); 995 } 996 997 static int 998 /* ARGSUSED2 */ 999 dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1000 { 1001 GElf_Sym gsym; 1002 List l; 1003 Listnode ln; 1004 uintptr_t naddr; 1005 1006 /* 1007 * If an address was provided us it. 1008 */ 1009 if (flags & DCMD_ADDRSPEC) 1010 return (_dcmd_Lm_list(addr, flags, argc, argv)); 1011 1012 /* 1013 * Otherwise traverse the dynlm_list and display each link-map list. 1014 */ 1015 if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1), 1016 MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) { 1017 mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1), 1018 MSG_ORIG(MSG_STR_DYNLMLIST)); 1019 return (DCMD_ERR); 1020 } 1021 if (mdb_vread((void *)&l, sizeof (l), (uintptr_t)gsym.st_value) == -1) { 1022 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LIST_STR), 1023 gsym.st_value); 1024 return (DCMD_ERR); 1025 } 1026 1027 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST), 1028 &gsym); 1029 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1030 1031 flags |= (DCMD_LOOP | DCMD_LOOPFIRST); 1032 for (naddr = (uintptr_t)l.head; naddr; naddr = (uintptr_t)ln.next) { 1033 if (mdb_vread(&ln, sizeof (ln), naddr) == -1) { 1034 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1035 MSG_ORIG(MSG_STR_LISTNODE), naddr); 1036 return (DCMD_ERR); 1037 } 1038 1039 mdb_inc_indent(2); 1040 if (_dcmd_Lm_list((uintptr_t)ln.data, flags, 1041 argc, argv) == DCMD_ERR) { 1042 mdb_dec_indent(2); 1043 return (DCMD_ERR); 1044 } 1045 mdb_dec_indent(2); 1046 flags &= ~DCMD_LOOPFIRST; 1047 } 1048 return (DCMD_OK); 1049 } 1050 1051 void 1052 dcmd_GrpDesc_help(void) 1053 { 1054 mdb_printf(MSG_ORIG(MSG_GRPDESC_HELP)); 1055 } 1056 1057 static int 1058 /* ARGSUSED2 */ 1059 dcmd_GrpDesc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1060 { 1061 Grp_desc gd; 1062 char *str; 1063 1064 /* 1065 * Insure we have a valid address. 1066 */ 1067 if ((flags & DCMD_ADDRSPEC) == 0) { 1068 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPDESC_STR)); 1069 return (DCMD_USAGE); 1070 } 1071 1072 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE1), addr); 1073 if (mdb_vread(&gd, sizeof (Grp_desc), addr) == -1) { 1074 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPDESC_STR), 1075 addr); 1076 return (DCMD_ERR); 1077 } 1078 1079 if ((str = Rtmap_Name((uintptr_t)gd.gd_depend)) == 0) 1080 return (DCMD_ERR); 1081 1082 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE2), gd.gd_depend, str); 1083 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE3), gd.gd_flags, gd.gd_flags, 1084 grdflags_bits); 1085 1086 return (DCMD_OK); 1087 } 1088 1089 void 1090 dcmd_GrpHdl_help(void) 1091 { 1092 mdb_printf(MSG_ORIG(MSG_GRPHDL_HELP)); 1093 } 1094 1095 static int 1096 /* ARGSUSED2 */ 1097 dcmd_GrpHdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1098 { 1099 Grp_hdl gh; 1100 Alist al; 1101 uintptr_t listcalc, listnext; 1102 char *str; 1103 uint_t flg = 0; 1104 size_t ucnt, tcnt; 1105 1106 /* 1107 * Insure we have a valid address, and provide for a -v option. 1108 */ 1109 if ((flags & DCMD_ADDRSPEC) == 0) { 1110 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPHDL_STR)); 1111 return (DCMD_USAGE); 1112 } 1113 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1114 &flg, NULL) != argc) 1115 return (DCMD_USAGE); 1116 1117 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE1), addr); 1118 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1119 1120 if (mdb_vread(&gh, sizeof (Grp_hdl), addr) == -1) { 1121 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPHDL_STR), 1122 addr); 1123 return (DCMD_ERR); 1124 } 1125 1126 /* 1127 * Determine the handles owner. Note that an orphaned handle may no 1128 * longer contain its originating owner. 1129 */ 1130 if (gh.gh_ownlmp) { 1131 if ((str = Rtmap_Name((uintptr_t)gh.gh_ownlmp)) == 0) 1132 return (DCMD_ERR); 1133 } else 1134 str = (char *)MSG_ORIG(MSG_STR_ORPHANED); 1135 1136 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE2), str); 1137 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE3), gh.gh_flags, gh.gh_flags, 1138 grhflags_bits); 1139 1140 if (gh.gh_depends == 0) { 1141 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE4), gh.gh_refcnt); 1142 return (DCMD_OK); 1143 } 1144 1145 addr = (uintptr_t)gh.gh_depends; 1146 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 1147 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr); 1148 return (DCMD_ERR); 1149 } 1150 1151 ucnt = (al.al_next - sizeof (Alist) + sizeof (void *)) / al.al_size; 1152 tcnt = (al.al_end - sizeof (Alist) + sizeof (void *)) / al.al_size; 1153 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE5), gh.gh_refcnt, addr, ucnt, tcnt); 1154 1155 if (((flg & RTLD_FLG_VERBOSE) == 0) || (ucnt == 0)) 1156 return (DCMD_OK); 1157 1158 mdb_inc_indent(4); 1159 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1160 1161 /* 1162 * Under verbose mode print the name of each dependency. An Alist can 1163 * have a variable number of data items, so read each individual entry. 1164 */ 1165 listcalc = (uintptr_t)(&(al.al_data[0])); 1166 listcalc -= (uintptr_t)(&al); 1167 listcalc += addr; 1168 if (dcmd_GrpDesc(listcalc, flags, argc, argv) == DCMD_ERR) { 1169 mdb_dec_indent(4); 1170 return (DCMD_ERR); 1171 } 1172 1173 listnext = (uintptr_t)(al.al_next + addr); 1174 for (listcalc += al.al_size; listcalc < listnext; 1175 listcalc += al.al_size) { 1176 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1177 if (dcmd_GrpDesc(listcalc, flags, argc, argv) == DCMD_ERR) { 1178 mdb_dec_indent(4); 1179 return (DCMD_ERR); 1180 } 1181 } 1182 1183 mdb_dec_indent(4); 1184 return (DCMD_OK); 1185 } 1186 1187 static void 1188 dcmd_Handles_help(void) 1189 { 1190 mdb_printf(MSG_ORIG(MSG_HANDLES_HELP)); 1191 } 1192 1193 static int 1194 dcmd_Handles(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1195 { 1196 Rt_map rtmap; 1197 char *str; 1198 uint_t flg = 0; 1199 Alist al; 1200 uintptr_t listcalc, listnext; 1201 size_t ucnt, tcnt; 1202 Grp_hdl * ghp; 1203 1204 /* 1205 * Insure we have a valid address, and provide for a -v option. 1206 */ 1207 if ((flags & DCMD_ADDRSPEC) == 0) { 1208 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_HANDLES_STR)); 1209 return (DCMD_USAGE); 1210 } 1211 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1212 &flg, NULL) != argc) 1213 return (DCMD_USAGE); 1214 1215 /* 1216 * Read the Rt_map contents. 1217 */ 1218 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 1219 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 1220 return (DCMD_ERR); 1221 } 1222 if ((str = String((uintptr_t)NAME(&rtmap), 1223 MSG_ORIG(MSG_STR_NAME))) == 0) 1224 return (DCMD_ERR); 1225 1226 mdb_printf(MSG_ORIG(MSG_HANDLES_LINE1), str); 1227 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1228 1229 if (HANDLES(&rtmap) == 0) 1230 return (DCMD_OK); 1231 1232 addr = (uintptr_t)HANDLES(&rtmap); 1233 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 1234 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr); 1235 return (DCMD_ERR); 1236 } 1237 1238 ucnt = (al.al_next - sizeof (Alist) + sizeof (void *)) / al.al_size; 1239 tcnt = (al.al_end - sizeof (Alist) + sizeof (void *)) / al.al_size; 1240 mdb_printf(MSG_ORIG(MSG_HANDLES_LINE2), addr, ucnt, tcnt); 1241 1242 if (((flg & RTLD_FLG_VERBOSE) == 0) || (ucnt == 0)) 1243 return (DCMD_OK); 1244 1245 /* 1246 * Under verbose mode print the name of each dependency. An Alist can 1247 * have a variable number of data items, so read each individual entry. 1248 */ 1249 listcalc = (uintptr_t)(&(al.al_data[0])); 1250 listcalc -= (uintptr_t)(&al); 1251 listcalc += addr; 1252 if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) { 1253 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1254 MSG_ORIG(MSG_GRPHDL_STR), listcalc); 1255 return (DCMD_ERR); 1256 } 1257 1258 mdb_inc_indent(4); 1259 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1260 1261 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) { 1262 mdb_dec_indent(4); 1263 return (DCMD_ERR); 1264 } 1265 1266 listnext = (uintptr_t)(al.al_next + addr); 1267 for (listcalc += al.al_size; listcalc < listnext; 1268 listcalc += al.al_size) { 1269 if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) { 1270 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1271 MSG_ORIG(MSG_GRPHDL_STR), listcalc); 1272 return (DCMD_ERR); 1273 } 1274 1275 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1276 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, 1277 argv) == DCMD_ERR) { 1278 mdb_dec_indent(4); 1279 return (DCMD_ERR); 1280 } 1281 } 1282 mdb_dec_indent(4); 1283 return (DCMD_OK); 1284 } 1285 1286 static void 1287 dcmd_Groups_help(void) 1288 { 1289 mdb_printf(MSG_ORIG(MSG_GROUPS_HELP)); 1290 } 1291 1292 1293 static int 1294 dcmd_Groups(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1295 { 1296 Rt_map rtmap; 1297 char *str; 1298 Alist al; 1299 uint_t flg = 0; 1300 uintptr_t listcalc, listnext; 1301 size_t ucnt, tcnt; 1302 Grp_hdl * ghp; 1303 1304 /* 1305 * Insure we have a valid address, and provide for a -v option. 1306 */ 1307 if ((flags & DCMD_ADDRSPEC) == 0) { 1308 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GROUPS_STR)); 1309 return (DCMD_USAGE); 1310 } 1311 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1312 &flg, NULL) != argc) 1313 return (DCMD_USAGE); 1314 1315 /* 1316 * Read the Rt_map contents. 1317 */ 1318 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 1319 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 1320 return (DCMD_ERR); 1321 } 1322 if ((str = String((uintptr_t)NAME(&rtmap), 1323 MSG_ORIG(MSG_STR_NAME))) == 0) 1324 return (DCMD_ERR); 1325 1326 mdb_printf(MSG_ORIG(MSG_GROUPS_LINE1), str); 1327 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1328 1329 if (GROUPS(&rtmap) == 0) 1330 return (DCMD_OK); 1331 1332 addr = (uintptr_t)GROUPS(&rtmap); 1333 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 1334 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr); 1335 return (DCMD_ERR); 1336 } 1337 1338 ucnt = (al.al_next - sizeof (Alist) + sizeof (void *)) / al.al_size; 1339 tcnt = (al.al_end - sizeof (Alist) + sizeof (void *)) / al.al_size; 1340 mdb_printf(MSG_ORIG(MSG_GROUPS_LINE2), addr, ucnt, tcnt); 1341 1342 if (((flg & RTLD_FLG_VERBOSE) == 0) || (ucnt == 0)) 1343 return (DCMD_OK); 1344 1345 /* 1346 * Under verbose mode print the name of each dependency. An Alist can 1347 * have a variable number of data items, so read each individual entry. 1348 */ 1349 listcalc = (uintptr_t)(&(al.al_data[0])); 1350 listcalc -= (uintptr_t)(&al); 1351 listcalc += addr; 1352 if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) { 1353 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1354 MSG_ORIG(MSG_GRPHDL_STR), listcalc); 1355 return (DCMD_ERR); 1356 } 1357 1358 mdb_inc_indent(4); 1359 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1360 1361 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) { 1362 mdb_dec_indent(4); 1363 return (DCMD_ERR); 1364 } 1365 1366 listnext = (uintptr_t)(al.al_next + addr); 1367 for (listcalc += al.al_size; listcalc < listnext; 1368 listcalc += al.al_size) { 1369 if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) { 1370 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1371 MSG_ORIG(MSG_GRPHDL_STR), listcalc); 1372 return (DCMD_ERR); 1373 } 1374 1375 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1376 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, 1377 argv) == DCMD_ERR) { 1378 mdb_dec_indent(4); 1379 return (DCMD_ERR); 1380 } 1381 } 1382 mdb_dec_indent(4); 1383 return (DCMD_OK); 1384 } 1385 static void 1386 dcmd_ElfDyn_help(void) 1387 { 1388 mdb_printf(MSG_ORIG(MSG_ELFDYN_HELP)); 1389 } 1390 1391 static int 1392 /* ARGSUSED2 */ 1393 dcmd_ElfDyn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1394 { 1395 Dyn dyn; 1396 const char *dynstr; 1397 1398 if ((flags & DCMD_ADDRSPEC) == 0) 1399 return (DCMD_USAGE); 1400 if (mdb_vread(&dyn, sizeof (dyn), addr) == -1) { 1401 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_ELFDYN_STR), 1402 addr); 1403 return (DCMD_ERR); 1404 } 1405 1406 mdb_printf(MSG_ORIG(MSG_ELFDYN_TITLE), addr); 1407 dynstr = conv_dyn_tag(dyn.d_tag, M_MACH, 0); 1408 mdb_printf(MSG_ORIG(MSG_ELFDYN_LINE1), addr, dynstr, dyn.d_un.d_ptr); 1409 1410 mdb_set_dot(addr + sizeof (Dyn)); 1411 1412 return (DCMD_OK); 1413 } 1414 1415 static void 1416 dcmd_ElfEhdr_help(void) 1417 { 1418 mdb_printf(MSG_ORIG(MSG_EHDR_HELP)); 1419 } 1420 1421 static int 1422 /* ARGSUSED2 */ 1423 dcmd_ElfEhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1424 { 1425 Ehdr ehdr; 1426 Byte *byte; 1427 const char *flgs; 1428 1429 if ((flags & DCMD_ADDRSPEC) == 0) 1430 return (DCMD_USAGE); 1431 1432 if (mdb_vread(&ehdr, sizeof (ehdr), addr) == -1) { 1433 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EHDR_STR), 1434 addr); 1435 return (DCMD_ERR); 1436 } 1437 1438 mdb_printf(MSG_ORIG(MSG_EHDR_TITLE), addr); 1439 byte = &ehdr.e_ident[0]; 1440 mdb_printf(MSG_ORIG(MSG_EHDR_LINE1), byte[EI_MAG0], 1441 (byte[EI_MAG1] ? byte[EI_MAG1] : '0'), 1442 (byte[EI_MAG2] ? byte[EI_MAG2] : '0'), 1443 (byte[EI_MAG3] ? byte[EI_MAG3] : '0')); 1444 mdb_printf(MSG_ORIG(MSG_EHDR_LINE2), 1445 conv_ehdr_class(ehdr.e_ident[EI_CLASS], 0), 1446 conv_ehdr_data(ehdr.e_ident[EI_DATA], 0)); 1447 1448 mdb_printf(MSG_ORIG(MSG_EHDR_LINE3), 1449 conv_ehdr_mach(ehdr.e_machine, 0), 1450 conv_ehdr_vers(ehdr.e_version, 0)); 1451 mdb_printf(MSG_ORIG(MSG_EHDR_LINE4), conv_ehdr_type(ehdr.e_type, 0)); 1452 1453 /* 1454 * Line up the flags differently depending on whether we 1455 * received a numeric (e.g. "0x200") or text representation 1456 * (e.g. "[ EF_SPARC_SUN_US1 ]"). 1457 */ 1458 flgs = conv_ehdr_flags(ehdr.e_machine, ehdr.e_flags); 1459 if (flgs[0] == '[') 1460 mdb_printf(MSG_ORIG(MSG_EHDR_LINE5), flgs); 1461 else 1462 mdb_printf(MSG_ORIG(MSG_EHDR_LINE6), flgs); 1463 1464 mdb_printf(MSG_ORIG(MSG_EHDR_LINE7), ehdr.e_entry, ehdr.e_ehsize, 1465 ehdr.e_shstrndx); 1466 mdb_printf(MSG_ORIG(MSG_EHDR_LINE8), ehdr.e_shoff, ehdr.e_shentsize, 1467 ehdr.e_shnum); 1468 mdb_printf(MSG_ORIG(MSG_EHDR_LINE9), ehdr.e_phoff, ehdr.e_phentsize, 1469 ehdr.e_phnum); 1470 1471 mdb_set_dot(addr + sizeof (Ehdr)); 1472 1473 return (DCMD_OK); 1474 } 1475 1476 static void 1477 dcmd_ElfPhdr_help(void) 1478 { 1479 mdb_printf(MSG_ORIG(MSG_EPHDR_HELP)); 1480 } 1481 1482 static int 1483 /* ARGSUSED2 */ 1484 dcmd_ElfPhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1485 { 1486 Phdr phdr; 1487 1488 if ((flags & DCMD_ADDRSPEC) == 0) 1489 return (DCMD_USAGE); 1490 1491 if (mdb_vread(&phdr, sizeof (phdr), addr) == -1) { 1492 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EPHDR_STR), 1493 addr); 1494 return (DCMD_ERR); 1495 } 1496 1497 mdb_printf(MSG_ORIG(MSG_EPHDR_TITLE), addr); 1498 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE1), phdr.p_vaddr, 1499 conv_phdr_flags(phdr.p_flags)); 1500 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE2), phdr.p_paddr, 1501 conv_phdr_type(M_MACH, phdr.p_type)); 1502 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE3), phdr.p_filesz, phdr.p_memsz); 1503 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE4), phdr.p_offset, phdr.p_align); 1504 1505 mdb_set_dot(addr + sizeof (Phdr)); 1506 1507 return (DCMD_OK); 1508 } 1509 1510 1511 static const mdb_dcmd_t dcmds[] = { 1512 { MSG_ORIG(MSG_BND_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1513 MSG_ORIG(MSG_BND_DCD), 1514 dcmd_Bind, dcmd_Bind_help}, 1515 { MSG_ORIG(MSG_DEPENDS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1516 MSG_ORIG(MSG_DEPENDS_DCD), 1517 dcmd_Depends, dcmd_Depends_help}, 1518 { MSG_ORIG(MSG_CALLERS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1519 MSG_ORIG(MSG_CALLERS_DCD), 1520 dcmd_Callers, dcmd_Callers_help}, 1521 { MSG_ORIG(MSG_GRPHDL_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1522 MSG_ORIG(MSG_GRPHDL_DCD), 1523 dcmd_GrpHdl, dcmd_GrpHdl_help}, 1524 { MSG_ORIG(MSG_GRPDESC_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1525 MSG_ORIG(MSG_GRPDESC_DCD), 1526 dcmd_GrpDesc, dcmd_GrpDesc_help}, 1527 { MSG_ORIG(MSG_HANDLES_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1528 MSG_ORIG(MSG_HANDLES_DCD), 1529 dcmd_Handles, dcmd_Handles_help}, 1530 { MSG_ORIG(MSG_GROUPS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1531 MSG_ORIG(MSG_GROUPS_DCD), 1532 dcmd_Groups, dcmd_Groups_help}, 1533 { MSG_ORIG(MSG_ELFDYN_STR), MSG_ORIG(MSG_USG_ADDREQ), 1534 MSG_ORIG(MSG_ELFDYN_DCD), 1535 dcmd_ElfDyn, dcmd_ElfDyn_help}, 1536 { MSG_ORIG(MSG_EHDR_STR), MSG_ORIG(MSG_USG_ADDREQ), 1537 MSG_ORIG(MSG_EHDR_DCD), 1538 dcmd_ElfEhdr, dcmd_ElfEhdr_help}, 1539 { MSG_ORIG(MSG_EPHDR_STR), MSG_ORIG(MSG_USG_ADDREQ), 1540 MSG_ORIG(MSG_EPHDR_DCD), 1541 dcmd_ElfPhdr, dcmd_ElfPhdr_help}, 1542 { MSG_ORIG(MSG_LIST_STR), MSG_ORIG(MSG_USG_ADDREQ), 1543 MSG_ORIG(MSG_LIST_DCD), 1544 dcmd_List, dcmd_List_help}, 1545 { MSG_ORIG(MSG_LMLIST_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1546 MSG_ORIG(MSG_LMLIST_DCD), 1547 dcmd_Lm_list, dcmd_Lm_list_help}, 1548 { MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_USG_ADDOPT_V), 1549 MSG_ORIG(MSG_RTMAPS_DCD), 1550 dcmd_Rtmaps, dcmd_Rtmaps_help}, 1551 { MSG_ORIG(MSG_RTMAP_STR), MSG_ORIG(MSG_USG_ADDREQ), 1552 MSG_ORIG(MSG_RTMAP_DCD), 1553 dcmd_rtmap, dcmd_rtmap_help}, 1554 { MSG_ORIG(MSG_SETENV_STR), MSG_ORIG(MSG_USG_SETENV), 1555 MSG_ORIG(MSG_SETENV_DCD), 1556 dcmd_Setenv, dcmd_Setenv_help}, 1557 { NULL } 1558 }; 1559 1560 static const mdb_walker_t walkers[] = { 1561 { MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_WWD_RTMAP), 1562 walk_rtmap_init, walk_rtmap_step, NULL, NULL }, 1563 { MSG_ORIG(MSG_LIST_STR), MSG_ORIG(MSG_WWD_LIST), 1564 walk_List_init, walk_List_step, NULL, NULL }, 1565 { NULL } 1566 }; 1567 1568 static const mdb_modinfo_t modinfo = { 1569 MDB_API_VERSION, dcmds, walkers 1570 }; 1571 1572 const mdb_modinfo_t * 1573 _mdb_init(void) 1574 { 1575 return (&modinfo); 1576 } 1577