xref: /titanic_51/usr/src/cmd/mdb/common/mdb/mdb_callb.h (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
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_CALLB_H
28 #define	_MDB_CALLB_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <mdb/mdb_list.h>
33 #include <mdb/mdb_module.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Callback facility designed to allow interested parties (dmods, targets, or
41  * even the core debugger framework) to register for notification when certain
42  * "interesting" events occur.
43  */
44 
45 /*
46  * Callback classes:
47  * (MDB_CALLBACK_* definitions in the module API need to be in sync with these)
48  */
49 #define	MDB_CALLB_STCHG		1	/* System execution state change */
50 #define	MDB_CALLB_PROMPT	2	/* Before printing the prompt */
51 
52 typedef void (*mdb_callb_f)(void *);
53 
54 typedef struct mdb_callb {
55 	mdb_list_t	cb_list;	/* List of callbacks */
56 	mdb_module_t	*cb_mod;	/* Requesting module (if any) */
57 	int		cb_class;	/* When to notify */
58 	mdb_callb_f	cb_func;	/* Function to invoke */
59 	void		*cb_arg;	/* Argument for cb_func */
60 } mdb_callb_t;
61 
62 extern mdb_callb_t *mdb_callb_add(mdb_module_t *, int, mdb_callb_f, void *);
63 extern void mdb_callb_remove(mdb_callb_t *);
64 extern void mdb_callb_remove_by_mod(mdb_module_t *);
65 extern void mdb_callb_remove_all(void);
66 extern void mdb_callb_fire(int);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _MDB_CALLB_H */
73