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