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 */
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 if (mdb_getopts(argc, argv,
368 'i', MDB_OPT_SETBITS, TRUE, &ident) != argc)
369 return (DCMD_USAGE);
370
371 if (ident)
372 refs = 0;
373
374 /* Determine if there is an ldi handle address */
375 if (!(flags & DCMD_ADDRSPEC)) {
376 if (mdb_walk_dcmd("ldi_handle", "ldi_handle",
377 argc, argv) == -1) {
378 mdb_warn("can't walk ldi handles");
379 return (DCMD_ERR);
380 } return (DCMD_OK);
381 }
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 }
|
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 /*
28 * Copyright (c) 2018, Joyent, Inc.
29 */
30
31 #include <sys/types.h>
32 #include <sys/sysmacros.h>
33 #include <sys/dditypes.h>
34 #include <sys/ddi_impldefs.h>
35 #include <sys/ddipropdefs.h>
36 #include <sys/modctl.h>
37 #include <sys/file.h>
38 #include <sys/sunldi_impl.h>
39
40 #include <mdb/mdb_modapi.h>
41 #include <mdb/mdb_ks.h>
42
43 #include "ldi.h"
44
45 /*
46 * ldi handle walker structure
47 */
48 typedef struct lh_walk {
49 struct ldi_handle **hash; /* current bucket pointer */
50 struct ldi_handle *lhp; /* ldi handle pointer */
364
365 int
366 ldi_handle(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
367 {
368 int ident = 0;
369 int refs = 1;
370
371 if (mdb_getopts(argc, argv,
372 'i', MDB_OPT_SETBITS, TRUE, &ident) != argc)
373 return (DCMD_USAGE);
374
375 if (ident)
376 refs = 0;
377
378 /* Determine if there is an ldi handle address */
379 if (!(flags & DCMD_ADDRSPEC)) {
380 if (mdb_walk_dcmd("ldi_handle", "ldi_handle",
381 argc, argv) == -1) {
382 mdb_warn("can't walk ldi handles");
383 return (DCMD_ERR);
384 }
385 return (DCMD_OK);
386 }
387
388 /* display the header line */
389 if (DCMD_HDRSPEC(flags))
390 ldi_handle_header(refs, ident);
391
392 /* display the ldi handle */
393 if (ldi_handle_print(addr, ident, refs))
394 return (DCMD_ERR);
395
396 return (DCMD_OK);
397 }
398
399 void
400 ldi_ident_help(void)
401 {
402 mdb_printf("Displays an ldi identifier.\n"
403 "Without the address of an \"ldi_ident_t\", "
404 "print all identifiers.\n"
405 "With an address, print the specified identifier.\n");
406 }
|