17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*3b6e0a59SMatt Amdur /* 28*3b6e0a59SMatt Amdur * Copyright (c) 2012 by Delphix. All rights reserved. 29*3b6e0a59SMatt Amdur * Copyright (c) 2012 Joyent, Inc. All rights reserved. 30*3b6e0a59SMatt Amdur */ 31*3b6e0a59SMatt Amdur 327c478bd9Sstevel@tonic-gate #ifndef _MDB_MODULE_H 337c478bd9Sstevel@tonic-gate #define _MDB_MODULE_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <mdb/mdb_argvec.h> 367c478bd9Sstevel@tonic-gate #include <mdb/mdb_nv.h> 377c478bd9Sstevel@tonic-gate #include <mdb/mdb_modapi.h> 387c478bd9Sstevel@tonic-gate #include <mdb/mdb_target.h> 397c478bd9Sstevel@tonic-gate #include <mdb/mdb_disasm.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #include <libctf.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #ifdef _MDB 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate struct mdb_callb; 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate typedef struct mdb_module { 527c478bd9Sstevel@tonic-gate mdb_nv_t mod_dcmds; /* Module dcmds hash */ 537c478bd9Sstevel@tonic-gate mdb_nv_t mod_walkers; /* Module walkers hash */ 547c478bd9Sstevel@tonic-gate const char *mod_name; /* Module name */ 557c478bd9Sstevel@tonic-gate void *mod_hdl; /* Module object handle */ 567c478bd9Sstevel@tonic-gate mdb_modinfo_t *mod_info; /* Module information */ 577c478bd9Sstevel@tonic-gate const mdb_modinfo_t *(*mod_init)(void); /* Module load callback */ 587c478bd9Sstevel@tonic-gate void (*mod_fini)(void); /* Module unload callback */ 597c478bd9Sstevel@tonic-gate mdb_tgt_ctor_f *mod_tgt_ctor; /* Module target constructor */ 607c478bd9Sstevel@tonic-gate mdb_dis_ctor_f *mod_dis_ctor; /* Module disassembler constructor */ 617c478bd9Sstevel@tonic-gate struct mdb_module *mod_prev; /* Previous module on dependency list */ 627c478bd9Sstevel@tonic-gate struct mdb_module *mod_next; /* Next module on dependency list */ 637c478bd9Sstevel@tonic-gate ctf_file_t *mod_ctfp; /* CTF container for this module */ 647c478bd9Sstevel@tonic-gate struct mdb_callb *mod_cb; /* First callback for this module */ 657c478bd9Sstevel@tonic-gate } mdb_module_t; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate typedef struct mdb_idcmd { 687c478bd9Sstevel@tonic-gate const char *idc_name; /* Backpointer to variable name */ 697c478bd9Sstevel@tonic-gate const char *idc_usage; /* Usage message */ 707c478bd9Sstevel@tonic-gate const char *idc_descr; /* Description */ 717c478bd9Sstevel@tonic-gate mdb_dcmd_f *idc_funcp; /* Command function */ 727c478bd9Sstevel@tonic-gate void (*idc_help)(void); /* Help function */ 73*3b6e0a59SMatt Amdur mdb_dcmd_tab_f *idc_tabp; /* Tab completion pointer */ 747c478bd9Sstevel@tonic-gate mdb_module_t *idc_modp; /* Backpointer to module */ 757c478bd9Sstevel@tonic-gate mdb_var_t *idc_var; /* Backpointer to global variable */ 767c478bd9Sstevel@tonic-gate } mdb_idcmd_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate typedef struct mdb_iwalker { 797c478bd9Sstevel@tonic-gate const char *iwlk_name; /* Walk type name */ 807c478bd9Sstevel@tonic-gate char *iwlk_descr; /* Walk description */ 817c478bd9Sstevel@tonic-gate int (*iwlk_init)(struct mdb_walk_state *); /* Walk constructor */ 827c478bd9Sstevel@tonic-gate int (*iwlk_step)(struct mdb_walk_state *); /* Walk iterator */ 837c478bd9Sstevel@tonic-gate void (*iwlk_fini)(struct mdb_walk_state *); /* Walk destructor */ 847c478bd9Sstevel@tonic-gate void *iwlk_init_arg; /* Walk constructor argument */ 857c478bd9Sstevel@tonic-gate mdb_module_t *iwlk_modp; /* Backpointer to module */ 867c478bd9Sstevel@tonic-gate mdb_var_t *iwlk_var; /* Backpointer to global variable */ 877c478bd9Sstevel@tonic-gate } mdb_iwalker_t; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #define MDB_MOD_LOCAL 0x00 /* Load module RTLD_LOCAL */ 907c478bd9Sstevel@tonic-gate #define MDB_MOD_GLOBAL 0x01 /* Load module RTLD_GLOBAL */ 917c478bd9Sstevel@tonic-gate #define MDB_MOD_SILENT 0x02 /* Remain silent if no module found */ 927c478bd9Sstevel@tonic-gate #define MDB_MOD_FORCE 0x04 /* Forcibly interpose module defs */ 937c478bd9Sstevel@tonic-gate #define MDB_MOD_BUILTIN 0x08 /* Module is compiled into debugger */ 947c478bd9Sstevel@tonic-gate #define MDB_MOD_DEFER 0x10 /* Defer load/unload (kmdb only) */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate extern int mdb_module_load(const char *, int); 977c478bd9Sstevel@tonic-gate extern mdb_module_t *mdb_module_load_builtin(const char *); 987c478bd9Sstevel@tonic-gate extern void mdb_module_load_all(int); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate extern int mdb_module_unload(const char *, int); 1017c478bd9Sstevel@tonic-gate extern void mdb_module_unload_all(int); 1027c478bd9Sstevel@tonic-gate extern int mdb_module_unload_common(const char *); 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate extern int mdb_module_add_dcmd(mdb_module_t *, const mdb_dcmd_t *, int); 1057c478bd9Sstevel@tonic-gate extern int mdb_module_remove_dcmd(mdb_module_t *, const char *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate extern int mdb_module_add_walker(mdb_module_t *, const mdb_walker_t *, int); 1087c478bd9Sstevel@tonic-gate extern int mdb_module_remove_walker(mdb_module_t *, const char *); 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate extern int mdb_module_create(const char *, const char *, int, mdb_module_t **); 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate extern int mdb_module_validate_name(const char *, const char **); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #endif /* _MDB */ 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1177c478bd9Sstevel@tonic-gate } 1187c478bd9Sstevel@tonic-gate #endif 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #endif /* _MDB_MODULE_H */ 121