xref: /illumos-gate/usr/src/cmd/mdb/common/mdb/mdb_wcb.h (revision 2a8bcb4e)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
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 #ifndef	_MDB_WCB_H
28 #define	_MDB_WCB_H
29 
30 #include <mdb/mdb_module.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Values for w_buftag, used as a guard to ensure that the walk state hasn't
38  * overflowed into the wcb.  w_buftag is INITIAL when the wcb is first
39  * allocated, ACTIVE when added to a frame, and PASSIVE when removed.
40  */
41 #define	WCB_TAG_INITIAL	0xcbbabecb	/* Magic tag for initialized wcb */
42 #define	WCB_TAG_ACTIVE	0xcba1cba1	/* Magic tag for active wcb */
43 #define	WCB_TAG_PASSIVE	0xcbdeadcb	/* Magic tag for inactive wcb */
44 
45 struct mdb_frame;			/* Forward declaration */
46 
47 typedef struct mdb_wcb {
48 	mdb_walk_state_t w_state;	/* Walk soft state */
49 	uint32_t w_buftag;		/* WCB_TAG_* */
50 	int w_inited;			/* Set if we've called walk_init */
51 	struct mdb_wcb *w_lyr_head;	/* Link to head wcb in layer chain */
52 	struct mdb_wcb *w_lyr_link;	/* Link to next wcb in layer chain */
53 	struct mdb_wcb *w_link;		/* Link to next wcb in global chain */
54 	const mdb_iwalker_t *w_walker;	/* Walker corresponding to this wcb */
55 } mdb_wcb_t;
56 
57 extern mdb_wcb_t *mdb_wcb_create(mdb_iwalker_t *, mdb_walk_cb_t,
58     void *, uintptr_t);
59 
60 extern void mdb_wcb_destroy(mdb_wcb_t *);
61 extern mdb_wcb_t *mdb_wcb_from_state(mdb_walk_state_t *);
62 
63 extern void mdb_wcb_insert(mdb_wcb_t *, struct mdb_frame *);
64 extern void mdb_wcb_delete(mdb_wcb_t *, struct mdb_frame *);
65 extern void mdb_wcb_purge(mdb_wcb_t **);
66 
67 #ifdef	__cplusplus
68 }
69 #endif
70 
71 #endif	/* _MDB_WCB_H */
72