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_MODULE_H 28 #define _MDB_MODULE_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <mdb/mdb_argvec.h> 33 #include <mdb/mdb_nv.h> 34 #include <mdb/mdb_modapi.h> 35 #include <mdb/mdb_target.h> 36 #include <mdb/mdb_disasm.h> 37 38 #include <libctf.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #ifdef _MDB 45 46 struct mdb_callb; 47 48 typedef struct mdb_module { 49 mdb_nv_t mod_dcmds; /* Module dcmds hash */ 50 mdb_nv_t mod_walkers; /* Module walkers hash */ 51 const char *mod_name; /* Module name */ 52 void *mod_hdl; /* Module object handle */ 53 mdb_modinfo_t *mod_info; /* Module information */ 54 const mdb_modinfo_t *(*mod_init)(void); /* Module load callback */ 55 void (*mod_fini)(void); /* Module unload callback */ 56 mdb_tgt_ctor_f *mod_tgt_ctor; /* Module target constructor */ 57 mdb_dis_ctor_f *mod_dis_ctor; /* Module disassembler constructor */ 58 struct mdb_module *mod_prev; /* Previous module on dependency list */ 59 struct mdb_module *mod_next; /* Next module on dependency list */ 60 ctf_file_t *mod_ctfp; /* CTF container for this module */ 61 struct mdb_callb *mod_cb; /* First callback for this module */ 62 } mdb_module_t; 63 64 typedef struct mdb_idcmd { 65 const char *idc_name; /* Backpointer to variable name */ 66 const char *idc_usage; /* Usage message */ 67 const char *idc_descr; /* Description */ 68 mdb_dcmd_f *idc_funcp; /* Command function */ 69 void (*idc_help)(void); /* Help function */ 70 mdb_module_t *idc_modp; /* Backpointer to module */ 71 mdb_var_t *idc_var; /* Backpointer to global variable */ 72 } mdb_idcmd_t; 73 74 typedef struct mdb_iwalker { 75 const char *iwlk_name; /* Walk type name */ 76 char *iwlk_descr; /* Walk description */ 77 int (*iwlk_init)(struct mdb_walk_state *); /* Walk constructor */ 78 int (*iwlk_step)(struct mdb_walk_state *); /* Walk iterator */ 79 void (*iwlk_fini)(struct mdb_walk_state *); /* Walk destructor */ 80 void *iwlk_init_arg; /* Walk constructor argument */ 81 mdb_module_t *iwlk_modp; /* Backpointer to module */ 82 mdb_var_t *iwlk_var; /* Backpointer to global variable */ 83 } mdb_iwalker_t; 84 85 #define MDB_MOD_LOCAL 0x00 /* Load module RTLD_LOCAL */ 86 #define MDB_MOD_GLOBAL 0x01 /* Load module RTLD_GLOBAL */ 87 #define MDB_MOD_SILENT 0x02 /* Remain silent if no module found */ 88 #define MDB_MOD_FORCE 0x04 /* Forcibly interpose module defs */ 89 #define MDB_MOD_BUILTIN 0x08 /* Module is compiled into debugger */ 90 #define MDB_MOD_DEFER 0x10 /* Defer load/unload (kmdb only) */ 91 92 extern int mdb_module_load(const char *, int); 93 extern mdb_module_t *mdb_module_load_builtin(const char *); 94 extern void mdb_module_load_all(int); 95 96 extern int mdb_module_unload(const char *, int); 97 extern void mdb_module_unload_all(int); 98 extern int mdb_module_unload_common(const char *); 99 100 extern int mdb_module_add_dcmd(mdb_module_t *, const mdb_dcmd_t *, int); 101 extern int mdb_module_remove_dcmd(mdb_module_t *, const char *); 102 103 extern int mdb_module_add_walker(mdb_module_t *, const mdb_walker_t *, int); 104 extern int mdb_module_remove_walker(mdb_module_t *, const char *); 105 106 extern int mdb_module_create(const char *, const char *, int, mdb_module_t **); 107 108 extern int mdb_module_validate_name(const char *, const char **); 109 110 #endif /* _MDB */ 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* _MDB_MODULE_H */ 117