Print this page
4785 mdb crashes in ::ldi_handle


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2004 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 <sys/types.h>
  30 #include <sys/sysmacros.h>
  31 #include <sys/dditypes.h>
  32 #include <sys/ddi_impldefs.h>
  33 #include <sys/ddipropdefs.h>
  34 #include <sys/modctl.h>
  35 #include <sys/file.h>
  36 #include <sys/sunldi_impl.h>
  37 
  38 #include <mdb/mdb_modapi.h>
  39 #include <mdb/mdb_ks.h>
  40 
  41 #include "ldi.h"
  42 
  43 /*
  44  * ldi handle walker structure
  45  */
  46 typedef struct lh_walk {
  47         struct ldi_handle       **hash; /* current bucket pointer       */
  48         struct ldi_handle       *lhp;   /* ldi handle pointer           */


 349         } else {
 350                 mdb_printf("%?s ", "-");
 351         }
 352 
 353         if (!ident) {
 354                 /* display the ident address */
 355                 mdb_printf("%0?p\n", lh.lh_ident);
 356                 return (0);
 357         }
 358 
 359         /* display the entire ident  */
 360         return (ldi_ident_print((uintptr_t)lh.lh_ident, refs));
 361 }
 362 
 363 int
 364 ldi_handle(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 365 {
 366         int                     ident = 0;
 367         int                     refs = 1;
 368 
 369         if (mdb_getopts(argc, argv,
 370             'i', MDB_OPT_SETBITS, TRUE, &ident) != argc)
 371                 return (DCMD_USAGE);
 372 
 373         if (ident)
 374                 refs = 0;
 375 
 376         /* Determine if there is an ldi handle address */
 377         if (!(flags & DCMD_ADDRSPEC)) {
 378                 if (mdb_walk_dcmd("ldi_handle", "ldi_handle",
 379                     argc, argv) == -1) {
 380                         mdb_warn("can't walk ldi handles");
 381                         return (DCMD_ERR);
 382                 } return (DCMD_OK);
 383         }
 384 







 385         /* display the header line */
 386         if (DCMD_HDRSPEC(flags))
 387                 ldi_handle_header(refs, ident);
 388 
 389         /* display the ldi handle */
 390         if (ldi_handle_print(addr, ident, refs))
 391                 return (DCMD_ERR);
 392 
 393         return (DCMD_OK);
 394 }
 395 
 396 void
 397 ldi_ident_help(void)
 398 {
 399         mdb_printf("Displays an ldi identifier.\n"
 400             "Without the address of an \"ldi_ident_t\", "
 401             "print all identifiers.\n"
 402             "With an address, print the specified identifier.\n");
 403 }
 404 


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 


  27 #include <sys/types.h>
  28 #include <sys/sysmacros.h>
  29 #include <sys/dditypes.h>
  30 #include <sys/ddi_impldefs.h>
  31 #include <sys/ddipropdefs.h>
  32 #include <sys/modctl.h>
  33 #include <sys/file.h>
  34 #include <sys/sunldi_impl.h>
  35 
  36 #include <mdb/mdb_modapi.h>
  37 #include <mdb/mdb_ks.h>
  38 
  39 #include "ldi.h"
  40 
  41 /*
  42  * ldi handle walker structure
  43  */
  44 typedef struct lh_walk {
  45         struct ldi_handle       **hash; /* current bucket pointer       */
  46         struct ldi_handle       *lhp;   /* ldi handle pointer           */


 347         } else {
 348                 mdb_printf("%?s ", "-");
 349         }
 350 
 351         if (!ident) {
 352                 /* display the ident address */
 353                 mdb_printf("%0?p\n", lh.lh_ident);
 354                 return (0);
 355         }
 356 
 357         /* display the entire ident  */
 358         return (ldi_ident_print((uintptr_t)lh.lh_ident, refs));
 359 }
 360 
 361 int
 362 ldi_handle(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 363 {
 364         int                     ident = 0;
 365         int                     refs = 1;
 366 







 367         /* Determine if there is an ldi handle address */
 368         if (!(flags & DCMD_ADDRSPEC)) {
 369                 if (mdb_walk_dcmd("ldi_handle", "ldi_handle",
 370                     argc, argv) == -1) {
 371                         mdb_warn("can't walk ldi handles");
 372                         return (DCMD_ERR);
 373                 } return (DCMD_OK);
 374         }
 375 
 376         if (mdb_getopts(argc, argv,
 377             'i', MDB_OPT_SETBITS, TRUE, &ident) != argc)
 378                 return (DCMD_USAGE);
 379 
 380         if (ident)
 381                 refs = 0;
 382 
 383         /* display the header line */
 384         if (DCMD_HDRSPEC(flags))
 385                 ldi_handle_header(refs, ident);
 386 
 387         /* display the ldi handle */
 388         if (ldi_handle_print(addr, ident, refs))
 389                 return (DCMD_ERR);
 390 
 391         return (DCMD_OK);
 392 }
 393 
 394 void
 395 ldi_ident_help(void)
 396 {
 397         mdb_printf("Displays an ldi identifier.\n"
 398             "Without the address of an \"ldi_ident_t\", "
 399             "print all identifiers.\n"
 400             "With an address, print the specified identifier.\n");
 401 }
 402