7712 mandoc -Tlint does always exit with error code 0
[unleashed.git] / usr / src / cmd / mdb / common / modules / md / walk_nm.c
blob404c04f43434e3b3a96d53ede4060b61d7d6ac15
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include "mdinclude.h"
31 * walk the namespace
33 /* ARGSUSED */
34 int
35 namespace_walk_init(mdb_walk_state_t *wsp)
37 uintptr_t addr;
39 snarf_sets();
40 wsp->walk_data = mdb_alloc(sizeof (int), UM_SLEEP);
41 /* cycle through sets, start with set 0 */
42 *((int *)wsp->walk_data) = 0;
43 addr = (uintptr_t)mdset[0].s_nm;
45 wsp->walk_addr = addr;
46 return (WALK_NEXT);
49 int
50 namespace_walk_step(mdb_walk_state_t *wsp)
52 int status;
53 struct nm_header_hdr hdr;
55 if (wsp->walk_addr == NULL) {
56 if (*((int *)wsp->walk_data) < md_nsets) {
57 *((int *)wsp->walk_data) += 1;
58 wsp->walk_addr =
59 (uintptr_t)mdset[*((int *)wsp->walk_data)].s_nm;
60 if (wsp->walk_addr == NULL)
61 return (WALK_NEXT);
62 } else {
63 return (WALK_DONE);
67 mdb_printf("Namespace for set number %d\n", *((int *)wsp->walk_data));
68 if (mdb_vread(&hdr, sizeof (struct nm_header_hdr), wsp->walk_addr) !=
69 sizeof (struct nm_header_hdr)) {
70 mdb_warn("failed to read nm_header_hdr at %p",
71 wsp->walk_addr);
72 return (WALK_DONE);
77 status = wsp->walk_callback(wsp->walk_addr, (&hdr)->hh_header,
78 wsp->walk_cbdata);
80 *((int *)wsp->walk_data) += 1;
81 wsp->walk_addr = (uintptr_t)mdset[*((int *)wsp->walk_data)].s_nm;
82 return (status);
85 void
86 namespace_walk_fini(mdb_walk_state_t *wsp)
88 mdb_free(wsp->walk_data, sizeof (int));