1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _MDB_MODAPI_H 28*7c478bd9Sstevel@tonic-gate #define _MDB_MODAPI_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * MDB Module API 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * The debugger provides a set of interfaces for use in writing loadable 36*7c478bd9Sstevel@tonic-gate * debugger modules. Modules that call functions not listed in this header 37*7c478bd9Sstevel@tonic-gate * file may not be compatible with future versions of the debugger. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 41*7c478bd9Sstevel@tonic-gate #include <gelf.h> 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 44*7c478bd9Sstevel@tonic-gate extern "C" { 45*7c478bd9Sstevel@tonic-gate #endif 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate /* 48*7c478bd9Sstevel@tonic-gate * Make sure that NULL, TRUE, FALSE, MIN, and MAX have the usual definitions 49*7c478bd9Sstevel@tonic-gate * so module writers can depend on these macros and defines. 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate #ifndef NULL 52*7c478bd9Sstevel@tonic-gate #if defined(_LP64) && !defined(__cplusplus) 53*7c478bd9Sstevel@tonic-gate #define NULL 0L 54*7c478bd9Sstevel@tonic-gate #else 55*7c478bd9Sstevel@tonic-gate #define NULL 0 56*7c478bd9Sstevel@tonic-gate #endif 57*7c478bd9Sstevel@tonic-gate #endif 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate #ifndef TRUE 60*7c478bd9Sstevel@tonic-gate #define TRUE 1 61*7c478bd9Sstevel@tonic-gate #endif 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate #ifndef FALSE 64*7c478bd9Sstevel@tonic-gate #define FALSE 0 65*7c478bd9Sstevel@tonic-gate #endif 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate #ifndef MIN 68*7c478bd9Sstevel@tonic-gate #define MIN(x, y) ((x) < (y) ? (x) : (y)) 69*7c478bd9Sstevel@tonic-gate #endif 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate #ifndef MAX 72*7c478bd9Sstevel@tonic-gate #define MAX(x, y) ((x) > (y) ? (x) : (y)) 73*7c478bd9Sstevel@tonic-gate #endif 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate #define MDB_API_VERSION 3 /* Current API version number */ 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* 78*7c478bd9Sstevel@tonic-gate * Debugger command function flags: 79*7c478bd9Sstevel@tonic-gate */ 80*7c478bd9Sstevel@tonic-gate #define DCMD_ADDRSPEC 0x01 /* Dcmd invoked with explicit address */ 81*7c478bd9Sstevel@tonic-gate #define DCMD_LOOP 0x02 /* Dcmd invoked in loop with ,cnt syntax */ 82*7c478bd9Sstevel@tonic-gate #define DCMD_LOOPFIRST 0x04 /* Dcmd invoked as first iteration of LOOP */ 83*7c478bd9Sstevel@tonic-gate #define DCMD_PIPE 0x08 /* Dcmd invoked with input from pipe */ 84*7c478bd9Sstevel@tonic-gate #define DCMD_PIPE_OUT 0x10 /* Dcmd invoked with output set to pipe */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #define DCMD_HDRSPEC(fl) (((fl) & DCMD_LOOPFIRST) || !((fl) & DCMD_LOOP)) 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * Debugger command function return values: 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate #define DCMD_OK 0 /* Dcmd completed successfully */ 92*7c478bd9Sstevel@tonic-gate #define DCMD_ERR 1 /* Dcmd failed due to an error */ 93*7c478bd9Sstevel@tonic-gate #define DCMD_USAGE 2 /* Dcmd usage error; abort and print usage */ 94*7c478bd9Sstevel@tonic-gate #define DCMD_NEXT 3 /* Invoke next dcmd in precedence list */ 95*7c478bd9Sstevel@tonic-gate #define DCMD_ABORT 4 /* Dcmd failed; abort current loop or pipe */ 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate #define OFFSETOF(s, m) (size_t)(&(((s *)0)->m)) 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate extern int mdb_prop_postmortem; /* Are we looking at a static dump? */ 100*7c478bd9Sstevel@tonic-gate extern int mdb_prop_kernel; /* Are we looking at a kernel? */ 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate typedef enum { 103*7c478bd9Sstevel@tonic-gate MDB_TYPE_STRING, /* a_un.a_str is valid */ 104*7c478bd9Sstevel@tonic-gate MDB_TYPE_IMMEDIATE, /* a_un.a_val is valid */ 105*7c478bd9Sstevel@tonic-gate MDB_TYPE_CHAR /* a_un.a_char is valid */ 106*7c478bd9Sstevel@tonic-gate } mdb_type_t; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate typedef struct mdb_arg { 109*7c478bd9Sstevel@tonic-gate mdb_type_t a_type; 110*7c478bd9Sstevel@tonic-gate union { 111*7c478bd9Sstevel@tonic-gate const char *a_str; 112*7c478bd9Sstevel@tonic-gate uintmax_t a_val; 113*7c478bd9Sstevel@tonic-gate char a_char; 114*7c478bd9Sstevel@tonic-gate } a_un; 115*7c478bd9Sstevel@tonic-gate } mdb_arg_t; 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate typedef int mdb_dcmd_f(uintptr_t, uint_t, int, const mdb_arg_t *); 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate typedef struct mdb_dcmd { 120*7c478bd9Sstevel@tonic-gate const char *dc_name; /* Command name */ 121*7c478bd9Sstevel@tonic-gate const char *dc_usage; /* Usage message (optional) */ 122*7c478bd9Sstevel@tonic-gate const char *dc_descr; /* Description */ 123*7c478bd9Sstevel@tonic-gate mdb_dcmd_f *dc_funcp; /* Command function */ 124*7c478bd9Sstevel@tonic-gate void (*dc_help)(void); /* Command help function (or NULL) */ 125*7c478bd9Sstevel@tonic-gate } mdb_dcmd_t; 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate #define WALK_ERR -1 /* Walk fatal error (terminate walk) */ 128*7c478bd9Sstevel@tonic-gate #define WALK_NEXT 0 /* Walk should continue to next step */ 129*7c478bd9Sstevel@tonic-gate #define WALK_DONE 1 /* Walk is complete (no errors) */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate typedef int (*mdb_walk_cb_t)(uintptr_t, const void *, void *); 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate typedef struct mdb_walk_state { 134*7c478bd9Sstevel@tonic-gate mdb_walk_cb_t walk_callback; /* Callback to issue */ 135*7c478bd9Sstevel@tonic-gate void *walk_cbdata; /* Callback private data */ 136*7c478bd9Sstevel@tonic-gate uintptr_t walk_addr; /* Current address */ 137*7c478bd9Sstevel@tonic-gate void *walk_data; /* Walk private data */ 138*7c478bd9Sstevel@tonic-gate void *walk_arg; /* Walk private argument */ 139*7c478bd9Sstevel@tonic-gate const void *walk_layer; /* Data from underlying layer */ 140*7c478bd9Sstevel@tonic-gate } mdb_walk_state_t; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate typedef struct mdb_walker { 143*7c478bd9Sstevel@tonic-gate const char *walk_name; /* Walk type name */ 144*7c478bd9Sstevel@tonic-gate const char *walk_descr; /* Walk description */ 145*7c478bd9Sstevel@tonic-gate int (*walk_init)(mdb_walk_state_t *); /* Walk constructor */ 146*7c478bd9Sstevel@tonic-gate int (*walk_step)(mdb_walk_state_t *); /* Walk iterator */ 147*7c478bd9Sstevel@tonic-gate void (*walk_fini)(mdb_walk_state_t *); /* Walk destructor */ 148*7c478bd9Sstevel@tonic-gate void *walk_init_arg; /* Walk constructor argument */ 149*7c478bd9Sstevel@tonic-gate } mdb_walker_t; 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate typedef struct mdb_modinfo { 152*7c478bd9Sstevel@tonic-gate ushort_t mi_dvers; /* Debugger version number */ 153*7c478bd9Sstevel@tonic-gate const mdb_dcmd_t *mi_dcmds; /* NULL-terminated list of dcmds */ 154*7c478bd9Sstevel@tonic-gate const mdb_walker_t *mi_walkers; /* NULL-terminated list of walks */ 155*7c478bd9Sstevel@tonic-gate } mdb_modinfo_t; 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate typedef struct mdb_bitmask { 158*7c478bd9Sstevel@tonic-gate const char *bm_name; /* String name to print */ 159*7c478bd9Sstevel@tonic-gate u_longlong_t bm_mask; /* Mask for bits */ 160*7c478bd9Sstevel@tonic-gate u_longlong_t bm_bits; /* Result required for value & mask */ 161*7c478bd9Sstevel@tonic-gate } mdb_bitmask_t; 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate typedef struct mdb_pipe { 164*7c478bd9Sstevel@tonic-gate uintptr_t *pipe_data; /* Array of pipe values */ 165*7c478bd9Sstevel@tonic-gate size_t pipe_len; /* Array length */ 166*7c478bd9Sstevel@tonic-gate } mdb_pipe_t; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate extern int mdb_pwalk(const char *, mdb_walk_cb_t, void *, uintptr_t); 169*7c478bd9Sstevel@tonic-gate extern int mdb_walk(const char *, mdb_walk_cb_t, void *); 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate extern int mdb_pwalk_dcmd(const char *, const char *, 172*7c478bd9Sstevel@tonic-gate int, const mdb_arg_t *, uintptr_t); 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate extern int mdb_walk_dcmd(const char *, const char *, int, const mdb_arg_t *); 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate extern int mdb_layered_walk(const char *, mdb_walk_state_t *); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate extern int mdb_call_dcmd(const char *, uintptr_t, 179*7c478bd9Sstevel@tonic-gate uint_t, int, const mdb_arg_t *); 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate extern int mdb_add_walker(const mdb_walker_t *); 182*7c478bd9Sstevel@tonic-gate extern int mdb_remove_walker(const char *); 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_vread(void *, size_t, uintptr_t); 185*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_vwrite(const void *, size_t, uintptr_t); 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_fread(void *, size_t, uintptr_t); 188*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_fwrite(const void *, size_t, uintptr_t); 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_pread(void *, size_t, uint64_t); 191*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_pwrite(const void *, size_t, uint64_t); 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_readstr(char *, size_t, uintptr_t); 194*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_writestr(const char *, uintptr_t); 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_readsym(void *, size_t, const char *); 197*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_writesym(const void *, size_t, const char *); 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_readvar(void *, const char *); 200*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_writevar(const void *, const char *); 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate #define MDB_SYM_NAMLEN 1024 /* Recommended max name len */ 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate #define MDB_SYM_FUZZY 0 /* Match closest address */ 205*7c478bd9Sstevel@tonic-gate #define MDB_SYM_EXACT 1 /* Match exact address only */ 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate #define MDB_OBJ_EXEC ((const char *)0L) /* Primary executable file */ 208*7c478bd9Sstevel@tonic-gate #define MDB_OBJ_RTLD ((const char *)1L) /* Run-time link-editor */ 209*7c478bd9Sstevel@tonic-gate #define MDB_OBJ_EVERY ((const char *)-1L) /* All known symbols */ 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_name(const char *, GElf_Sym *); 212*7c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_obj(const char *, const char *, GElf_Sym *); 213*7c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_addr(uintptr_t, uint_t, char *, size_t, GElf_Sym *); 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate #define MDB_OPT_SETBITS 1 /* Set specified flag bits */ 216*7c478bd9Sstevel@tonic-gate #define MDB_OPT_CLRBITS 2 /* Clear specified flag bits */ 217*7c478bd9Sstevel@tonic-gate #define MDB_OPT_STR 3 /* const char * argument */ 218*7c478bd9Sstevel@tonic-gate #define MDB_OPT_UINTPTR 4 /* uintptr_t argument */ 219*7c478bd9Sstevel@tonic-gate #define MDB_OPT_UINT64 5 /* uint64_t argument */ 220*7c478bd9Sstevel@tonic-gate #define MDB_OPT_UINTPTR_SET 6 /* boolean_t+uintptr_t args */ 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate extern int mdb_getopts(int, const mdb_arg_t *, ...); 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate extern u_longlong_t mdb_strtoull(const char *); 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate #define UM_NOSLEEP 0x0 /* Do not call failure handler; may fail */ 227*7c478bd9Sstevel@tonic-gate #define UM_SLEEP 0x1 /* Can block for memory; will always succeed */ 228*7c478bd9Sstevel@tonic-gate #define UM_GC 0x2 /* Garbage-collect this block automatically */ 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate extern void *mdb_alloc(size_t, uint_t); 231*7c478bd9Sstevel@tonic-gate extern void *mdb_zalloc(size_t, uint_t); 232*7c478bd9Sstevel@tonic-gate extern void mdb_free(void *, size_t); 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate extern size_t mdb_snprintf(char *, size_t, const char *, ...); 235*7c478bd9Sstevel@tonic-gate extern void mdb_printf(const char *, ...); 236*7c478bd9Sstevel@tonic-gate extern void mdb_warn(const char *, ...); 237*7c478bd9Sstevel@tonic-gate extern void mdb_flush(void); 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate extern void mdb_nhconvert(void *, const void *, size_t); 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_RELATIVE 0x0001 /* Start numbering at 0 */ 242*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_ALIGN 0x0002 /* Enforce paragraph alignment */ 243*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_PEDANT 0x0004 /* Full-width addresses */ 244*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_ASCII 0x0008 /* Display ASCII values */ 245*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_HEADER 0x0010 /* Display a header */ 246*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_TRIM 0x0020 /* Trim at boundaries */ 247*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_SQUISH 0x0040 /* Eliminate redundant lines */ 248*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_NEWDOT 0x0080 /* Update dot when done */ 249*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_ENDIAN 0x0100 /* Adjust for endianness */ 250*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_WIDTH(x) ((((x) - 1) & 0xf) << 16) /* paragraphs/line */ 251*7c478bd9Sstevel@tonic-gate #define MDB_DUMP_GROUP(x) ((((x) - 1) & 0xff) << 20) /* bytes/group */ 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate typedef ssize_t (*mdb_dumpptr_cb_t)(void *, size_t, uintptr_t, void *); 254*7c478bd9Sstevel@tonic-gate typedef ssize_t (*mdb_dump64_cb_t)(void *, size_t, uint64_t, void *); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate extern int mdb_dumpptr(uintptr_t, size_t, uint_t, mdb_dumpptr_cb_t, void *); 257*7c478bd9Sstevel@tonic-gate extern int mdb_dump64(uint64_t, uint64_t, uint_t, mdb_dump64_cb_t, void *); 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate extern const char *mdb_one_bit(int, int, int); 260*7c478bd9Sstevel@tonic-gate extern const char *mdb_inval_bits(int, int, int); 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate extern ulong_t mdb_inc_indent(ulong_t); 263*7c478bd9Sstevel@tonic-gate extern ulong_t mdb_dec_indent(ulong_t); 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate extern int mdb_eval(const char *); 266*7c478bd9Sstevel@tonic-gate extern void mdb_set_dot(uintmax_t); 267*7c478bd9Sstevel@tonic-gate extern uintmax_t mdb_get_dot(void); 268*7c478bd9Sstevel@tonic-gate 269*7c478bd9Sstevel@tonic-gate extern void mdb_get_pipe(mdb_pipe_t *); 270*7c478bd9Sstevel@tonic-gate extern void mdb_set_pipe(const mdb_pipe_t *); 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate extern ssize_t mdb_get_xdata(const char *, void *, size_t); 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate #define MDB_STATE_IDLE 0 /* Target is idle (not running yet) */ 275*7c478bd9Sstevel@tonic-gate #define MDB_STATE_RUNNING 1 /* Target is currently executing */ 276*7c478bd9Sstevel@tonic-gate #define MDB_STATE_STOPPED 2 /* Target is stopped */ 277*7c478bd9Sstevel@tonic-gate #define MDB_STATE_UNDEAD 3 /* Target is undead (zombie) */ 278*7c478bd9Sstevel@tonic-gate #define MDB_STATE_DEAD 4 /* Target is dead (core dump) */ 279*7c478bd9Sstevel@tonic-gate #define MDB_STATE_LOST 5 /* Target lost by debugger */ 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate extern int mdb_get_state(void); 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate #define MDB_CALLBACK_STCHG 1 284*7c478bd9Sstevel@tonic-gate #define MDB_CALLBACK_PROMPT 2 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate typedef void (*mdb_callback_f)(void *); 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate extern void *mdb_callback_add(int, mdb_callback_f, void *); 289*7c478bd9Sstevel@tonic-gate extern void mdb_callback_remove(void *); 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate extern char *strcat(char *, const char *); 292*7c478bd9Sstevel@tonic-gate extern char *strcpy(char *, const char *); 293*7c478bd9Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t); 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */ 296*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 297*7c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int); 298*7c478bd9Sstevel@tonic-gate #ifndef _STRCHR_INLINE 299*7c478bd9Sstevel@tonic-gate #define _STRCHR_INLINE 300*7c478bd9Sstevel@tonic-gate extern "C++" { 301*7c478bd9Sstevel@tonic-gate inline char *strchr(char *__s, int __c) { 302*7c478bd9Sstevel@tonic-gate return (char *)strchr((const char *)__s, __c); 303*7c478bd9Sstevel@tonic-gate } 304*7c478bd9Sstevel@tonic-gate } 305*7c478bd9Sstevel@tonic-gate #endif /* _STRCHR_INLINE */ 306*7c478bd9Sstevel@tonic-gate extern const char *strrchr(const char *, int); 307*7c478bd9Sstevel@tonic-gate #ifndef _STRRCHR_INLINE 308*7c478bd9Sstevel@tonic-gate #define _STRRCHR_INLINE 309*7c478bd9Sstevel@tonic-gate extern "C++" { 310*7c478bd9Sstevel@tonic-gate inline char *strrchr(char *__s, int __c) { 311*7c478bd9Sstevel@tonic-gate return (char *)strrchr((const char *)__s, __c); 312*7c478bd9Sstevel@tonic-gate } 313*7c478bd9Sstevel@tonic-gate } 314*7c478bd9Sstevel@tonic-gate #endif /* _STRRCHR_INLINE */ 315*7c478bd9Sstevel@tonic-gate extern const char *strstr(const char *, const char *); 316*7c478bd9Sstevel@tonic-gate #ifndef _STRSTR_INLINE 317*7c478bd9Sstevel@tonic-gate #define _STRSTR_INLINE 318*7c478bd9Sstevel@tonic-gate extern "C++" { 319*7c478bd9Sstevel@tonic-gate inline char *strstr(char *__s1, const char *__s2) { 320*7c478bd9Sstevel@tonic-gate return (char *)strstr((const char *)__s1, __s2); 321*7c478bd9Sstevel@tonic-gate } 322*7c478bd9Sstevel@tonic-gate } 323*7c478bd9Sstevel@tonic-gate #endif /* _STRSTR_INLINE */ 324*7c478bd9Sstevel@tonic-gate #else 325*7c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int); 326*7c478bd9Sstevel@tonic-gate extern char *strrchr(const char *, int); 327*7c478bd9Sstevel@tonic-gate extern char *strstr(const char *, const char *); 328*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 329*7c478bd9Sstevel@tonic-gate 330*7c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *); 331*7c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t); 332*7c478bd9Sstevel@tonic-gate extern int strcasecmp(const char *, const char *); 333*7c478bd9Sstevel@tonic-gate extern int strncasecmp(const char *, const char *, size_t); 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate extern size_t strlen(const char *); 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t); 338*7c478bd9Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t); 339*7c478bd9Sstevel@tonic-gate extern void bzero(void *, size_t); 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const void *, size_t); 342*7c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t); 343*7c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t); 344*7c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */ 345*7c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L 346*7c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t); 347*7c478bd9Sstevel@tonic-gate #ifndef _MEMCHR_INLINE 348*7c478bd9Sstevel@tonic-gate #define _MEMCHR_INLINE 349*7c478bd9Sstevel@tonic-gate extern "C++" { 350*7c478bd9Sstevel@tonic-gate inline void *memchr(void * __s, int __c, size_t __n) { 351*7c478bd9Sstevel@tonic-gate return (void *)memchr((const void *)__s, __c, __n); 352*7c478bd9Sstevel@tonic-gate } 353*7c478bd9Sstevel@tonic-gate } 354*7c478bd9Sstevel@tonic-gate #endif /* _MEMCHR_INLINE */ 355*7c478bd9Sstevel@tonic-gate #else 356*7c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t); 357*7c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */ 358*7c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t); 359*7c478bd9Sstevel@tonic-gate extern void *memccpy(void *, const void *, int, size_t); 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate extern void *bsearch(const void *, const void *, size_t, size_t, 362*7c478bd9Sstevel@tonic-gate int (*)(const void *, const void *)); 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate extern void qsort(void *, size_t, size_t, 365*7c478bd9Sstevel@tonic-gate int (*)(const void *, const void *)); 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 368*7c478bd9Sstevel@tonic-gate } 369*7c478bd9Sstevel@tonic-gate #endif 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate #endif /* _MDB_MODAPI_H */ 372