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