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
5*dc0093f4Seschrock  * Common Development and Distribution License (the "License").
6*dc0093f4Seschrock  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*dc0093f4Seschrock  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_MDB_MODAPI_H
277c478bd9Sstevel@tonic-gate #define	_MDB_MODAPI_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * MDB Module API
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * The debugger provides a set of interfaces for use in writing loadable
357c478bd9Sstevel@tonic-gate  * debugger modules.  Modules that call functions not listed in this header
367c478bd9Sstevel@tonic-gate  * file may not be compatible with future versions of the debugger.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <gelf.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Make sure that NULL, TRUE, FALSE, MIN, and MAX have the usual definitions
487c478bd9Sstevel@tonic-gate  * so module writers can depend on these macros and defines.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #ifndef NULL
517c478bd9Sstevel@tonic-gate #if defined(_LP64) && !defined(__cplusplus)
527c478bd9Sstevel@tonic-gate #define	NULL	0L
537c478bd9Sstevel@tonic-gate #else
547c478bd9Sstevel@tonic-gate #define	NULL	0
557c478bd9Sstevel@tonic-gate #endif
567c478bd9Sstevel@tonic-gate #endif
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #ifndef TRUE
597c478bd9Sstevel@tonic-gate #define	TRUE	1
607c478bd9Sstevel@tonic-gate #endif
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #ifndef FALSE
637c478bd9Sstevel@tonic-gate #define	FALSE	0
647c478bd9Sstevel@tonic-gate #endif
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #ifndef MIN
677c478bd9Sstevel@tonic-gate #define	MIN(x, y) ((x) < (y) ? (x) : (y))
687c478bd9Sstevel@tonic-gate #endif
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #ifndef MAX
717c478bd9Sstevel@tonic-gate #define	MAX(x, y) ((x) > (y) ? (x) : (y))
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #define	MDB_API_VERSION	3	/* Current API version number */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * Debugger command function flags:
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	DCMD_ADDRSPEC	0x01	/* Dcmd invoked with explicit address */
807c478bd9Sstevel@tonic-gate #define	DCMD_LOOP	0x02	/* Dcmd invoked in loop with ,cnt syntax */
817c478bd9Sstevel@tonic-gate #define	DCMD_LOOPFIRST	0x04	/* Dcmd invoked as first iteration of LOOP */
827c478bd9Sstevel@tonic-gate #define	DCMD_PIPE	0x08	/* Dcmd invoked with input from pipe */
837c478bd9Sstevel@tonic-gate #define	DCMD_PIPE_OUT	0x10	/* Dcmd invoked with output set to pipe */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	DCMD_HDRSPEC(fl)	(((fl) & DCMD_LOOPFIRST) || !((fl) & DCMD_LOOP))
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Debugger command function return values:
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	DCMD_OK		0	/* Dcmd completed successfully */
917c478bd9Sstevel@tonic-gate #define	DCMD_ERR	1	/* Dcmd failed due to an error */
927c478bd9Sstevel@tonic-gate #define	DCMD_USAGE	2	/* Dcmd usage error; abort and print usage */
937c478bd9Sstevel@tonic-gate #define	DCMD_NEXT	3	/* Invoke next dcmd in precedence list */
947c478bd9Sstevel@tonic-gate #define	DCMD_ABORT	4	/* Dcmd failed; abort current loop or pipe */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #define	OFFSETOF(s, m)		(size_t)(&(((s *)0)->m))
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate extern int mdb_prop_postmortem;	/* Are we looking at a static dump? */
997c478bd9Sstevel@tonic-gate extern int mdb_prop_kernel;	/* Are we looking at a kernel? */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate typedef enum {
1027c478bd9Sstevel@tonic-gate 	MDB_TYPE_STRING,	/* a_un.a_str is valid */
1037c478bd9Sstevel@tonic-gate 	MDB_TYPE_IMMEDIATE,	/* a_un.a_val is valid */
1047c478bd9Sstevel@tonic-gate 	MDB_TYPE_CHAR		/* a_un.a_char is valid */
1057c478bd9Sstevel@tonic-gate } mdb_type_t;
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate typedef struct mdb_arg {
1087c478bd9Sstevel@tonic-gate 	mdb_type_t a_type;
1097c478bd9Sstevel@tonic-gate 	union {
1107c478bd9Sstevel@tonic-gate 		const char *a_str;
1117c478bd9Sstevel@tonic-gate 		uintmax_t a_val;
1127c478bd9Sstevel@tonic-gate 		char a_char;
1137c478bd9Sstevel@tonic-gate 	} a_un;
1147c478bd9Sstevel@tonic-gate } mdb_arg_t;
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate typedef int mdb_dcmd_f(uintptr_t, uint_t, int, const mdb_arg_t *);
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate typedef struct mdb_dcmd {
1197c478bd9Sstevel@tonic-gate 	const char *dc_name;		/* Command name */
1207c478bd9Sstevel@tonic-gate 	const char *dc_usage;		/* Usage message (optional) */
1217c478bd9Sstevel@tonic-gate 	const char *dc_descr;		/* Description */
1227c478bd9Sstevel@tonic-gate 	mdb_dcmd_f *dc_funcp;		/* Command function */
1237c478bd9Sstevel@tonic-gate 	void (*dc_help)(void);		/* Command help function (or NULL) */
1247c478bd9Sstevel@tonic-gate } mdb_dcmd_t;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #define	WALK_ERR	-1		/* Walk fatal error (terminate walk) */
1277c478bd9Sstevel@tonic-gate #define	WALK_NEXT	0		/* Walk should continue to next step */
1287c478bd9Sstevel@tonic-gate #define	WALK_DONE	1		/* Walk is complete (no errors) */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate typedef int (*mdb_walk_cb_t)(uintptr_t, const void *, void *);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate typedef struct mdb_walk_state {
1337c478bd9Sstevel@tonic-gate 	mdb_walk_cb_t walk_callback;	/* Callback to issue */
1347c478bd9Sstevel@tonic-gate 	void *walk_cbdata;		/* Callback private data */
1357c478bd9Sstevel@tonic-gate 	uintptr_t walk_addr;		/* Current address */
1367c478bd9Sstevel@tonic-gate 	void *walk_data;		/* Walk private data */
1377c478bd9Sstevel@tonic-gate 	void *walk_arg;			/* Walk private argument */
1387c478bd9Sstevel@tonic-gate 	const void *walk_layer;		/* Data from underlying layer */
1397c478bd9Sstevel@tonic-gate } mdb_walk_state_t;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate typedef struct mdb_walker {
1427c478bd9Sstevel@tonic-gate 	const char *walk_name;		/* Walk type name */
1437c478bd9Sstevel@tonic-gate 	const char *walk_descr;		/* Walk description */
1447c478bd9Sstevel@tonic-gate 	int (*walk_init)(mdb_walk_state_t *);	/* Walk constructor */
1457c478bd9Sstevel@tonic-gate 	int (*walk_step)(mdb_walk_state_t *);	/* Walk iterator */
1467c478bd9Sstevel@tonic-gate 	void (*walk_fini)(mdb_walk_state_t *);	/* Walk destructor */
1477c478bd9Sstevel@tonic-gate 	void *walk_init_arg;		/* Walk constructor argument */
1487c478bd9Sstevel@tonic-gate } mdb_walker_t;
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate typedef struct mdb_modinfo {
1517c478bd9Sstevel@tonic-gate 	ushort_t mi_dvers;		/* Debugger version number */
1527c478bd9Sstevel@tonic-gate 	const mdb_dcmd_t *mi_dcmds;	/* NULL-terminated list of dcmds */
1537c478bd9Sstevel@tonic-gate 	const mdb_walker_t *mi_walkers;	/* NULL-terminated list of walks */
1547c478bd9Sstevel@tonic-gate } mdb_modinfo_t;
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate typedef struct mdb_bitmask {
1577c478bd9Sstevel@tonic-gate 	const char *bm_name;		/* String name to print */
1587c478bd9Sstevel@tonic-gate 	u_longlong_t bm_mask;		/* Mask for bits */
1597c478bd9Sstevel@tonic-gate 	u_longlong_t bm_bits;		/* Result required for value & mask */
1607c478bd9Sstevel@tonic-gate } mdb_bitmask_t;
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate typedef struct mdb_pipe {
1637c478bd9Sstevel@tonic-gate 	uintptr_t *pipe_data;		/* Array of pipe values */
1647c478bd9Sstevel@tonic-gate 	size_t pipe_len;		/* Array length */
1657c478bd9Sstevel@tonic-gate } mdb_pipe_t;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate extern int mdb_pwalk(const char *, mdb_walk_cb_t, void *, uintptr_t);
1687c478bd9Sstevel@tonic-gate extern int mdb_walk(const char *, mdb_walk_cb_t, void *);
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate extern int mdb_pwalk_dcmd(const char *, const char *,
1717c478bd9Sstevel@tonic-gate 	int, const mdb_arg_t *, uintptr_t);
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate extern int mdb_walk_dcmd(const char *, const char *, int, const mdb_arg_t *);
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate extern int mdb_layered_walk(const char *, mdb_walk_state_t *);
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate extern int mdb_call_dcmd(const char *, uintptr_t,
1787c478bd9Sstevel@tonic-gate 	uint_t, int, const mdb_arg_t *);
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate extern int mdb_add_walker(const mdb_walker_t *);
1817c478bd9Sstevel@tonic-gate extern int mdb_remove_walker(const char *);
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate extern ssize_t mdb_vread(void *, size_t, uintptr_t);
1847c478bd9Sstevel@tonic-gate extern ssize_t mdb_vwrite(const void *, size_t, uintptr_t);
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate extern ssize_t mdb_fread(void *, size_t, uintptr_t);
1877c478bd9Sstevel@tonic-gate extern ssize_t mdb_fwrite(const void *, size_t, uintptr_t);
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate extern ssize_t mdb_pread(void *, size_t, uint64_t);
1907c478bd9Sstevel@tonic-gate extern ssize_t mdb_pwrite(const void *, size_t, uint64_t);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate extern ssize_t mdb_readstr(char *, size_t, uintptr_t);
1937c478bd9Sstevel@tonic-gate extern ssize_t mdb_writestr(const char *, uintptr_t);
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate extern ssize_t mdb_readsym(void *, size_t, const char *);
1967c478bd9Sstevel@tonic-gate extern ssize_t mdb_writesym(const void *, size_t, const char *);
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate extern ssize_t mdb_readvar(void *, const char *);
1997c478bd9Sstevel@tonic-gate extern ssize_t mdb_writevar(const void *, const char *);
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #define	MDB_SYM_NAMLEN	1024			/* Recommended max name len */
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate #define	MDB_SYM_FUZZY	0			/* Match closest address */
2047c478bd9Sstevel@tonic-gate #define	MDB_SYM_EXACT	1			/* Match exact address only */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate #define	MDB_OBJ_EXEC	((const char *)0L)	/* Primary executable file */
2077c478bd9Sstevel@tonic-gate #define	MDB_OBJ_RTLD	((const char *)1L)	/* Run-time link-editor */
2087c478bd9Sstevel@tonic-gate #define	MDB_OBJ_EVERY	((const char *)-1L)	/* All known symbols */
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_name(const char *, GElf_Sym *);
2117c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_obj(const char *, const char *, GElf_Sym *);
2127c478bd9Sstevel@tonic-gate extern int mdb_lookup_by_addr(uintptr_t, uint_t, char *, size_t, GElf_Sym *);
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate #define	MDB_OPT_SETBITS	1			/* Set specified flag bits */
2157c478bd9Sstevel@tonic-gate #define	MDB_OPT_CLRBITS	2			/* Clear specified flag bits */
2167c478bd9Sstevel@tonic-gate #define	MDB_OPT_STR	3			/* const char * argument */
2177c478bd9Sstevel@tonic-gate #define	MDB_OPT_UINTPTR	4			/* uintptr_t argument */
2187c478bd9Sstevel@tonic-gate #define	MDB_OPT_UINT64	5			/* uint64_t argument */
2197c478bd9Sstevel@tonic-gate #define	MDB_OPT_UINTPTR_SET	6		/* boolean_t+uintptr_t args */
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate extern int mdb_getopts(int, const mdb_arg_t *, ...);
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate extern u_longlong_t mdb_strtoull(const char *);
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate #define	UM_NOSLEEP	0x0	/* Do not call failure handler; may fail */
2267c478bd9Sstevel@tonic-gate #define	UM_SLEEP	0x1	/* Can block for memory; will always succeed */
2277c478bd9Sstevel@tonic-gate #define	UM_GC		0x2	/* Garbage-collect this block automatically */
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate extern void *mdb_alloc(size_t, uint_t);
2307c478bd9Sstevel@tonic-gate extern void *mdb_zalloc(size_t, uint_t);
2317c478bd9Sstevel@tonic-gate extern void mdb_free(void *, size_t);
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate extern size_t mdb_snprintf(char *, size_t, const char *, ...);
2347c478bd9Sstevel@tonic-gate extern void mdb_printf(const char *, ...);
2357c478bd9Sstevel@tonic-gate extern void mdb_warn(const char *, ...);
2367c478bd9Sstevel@tonic-gate extern void mdb_flush(void);
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate extern void mdb_nhconvert(void *, const void *, size_t);
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate #define	MDB_DUMP_RELATIVE	0x0001	/* Start numbering at 0 */
2417c478bd9Sstevel@tonic-gate #define	MDB_DUMP_ALIGN		0x0002	/* Enforce paragraph alignment */
2427c478bd9Sstevel@tonic-gate #define	MDB_DUMP_PEDANT		0x0004	/* Full-width addresses */
2437c478bd9Sstevel@tonic-gate #define	MDB_DUMP_ASCII		0x0008	/* Display ASCII values */
2447c478bd9Sstevel@tonic-gate #define	MDB_DUMP_HEADER		0x0010	/* Display a header */
2457c478bd9Sstevel@tonic-gate #define	MDB_DUMP_TRIM		0x0020	/* Trim at boundaries */
2467c478bd9Sstevel@tonic-gate #define	MDB_DUMP_SQUISH		0x0040	/* Eliminate redundant lines */
2477c478bd9Sstevel@tonic-gate #define	MDB_DUMP_NEWDOT		0x0080	/* Update dot when done */
2487c478bd9Sstevel@tonic-gate #define	MDB_DUMP_ENDIAN		0x0100	/* Adjust for endianness */
2497c478bd9Sstevel@tonic-gate #define	MDB_DUMP_WIDTH(x)	((((x) - 1) & 0xf) << 16) /* paragraphs/line */
2507c478bd9Sstevel@tonic-gate #define	MDB_DUMP_GROUP(x)	((((x) - 1) & 0xff) << 20) /* bytes/group */
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate typedef ssize_t (*mdb_dumpptr_cb_t)(void *, size_t, uintptr_t, void *);
2537c478bd9Sstevel@tonic-gate typedef ssize_t (*mdb_dump64_cb_t)(void *, size_t, uint64_t, void *);
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate extern int mdb_dumpptr(uintptr_t, size_t, uint_t, mdb_dumpptr_cb_t, void *);
2567c478bd9Sstevel@tonic-gate extern int mdb_dump64(uint64_t, uint64_t, uint_t, mdb_dump64_cb_t, void *);
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate extern const char *mdb_one_bit(int, int, int);
2597c478bd9Sstevel@tonic-gate extern const char *mdb_inval_bits(int, int, int);
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate extern ulong_t mdb_inc_indent(ulong_t);
2627c478bd9Sstevel@tonic-gate extern ulong_t mdb_dec_indent(ulong_t);
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate extern int mdb_eval(const char *);
2657c478bd9Sstevel@tonic-gate extern void mdb_set_dot(uintmax_t);
2667c478bd9Sstevel@tonic-gate extern uintmax_t mdb_get_dot(void);
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate extern void mdb_get_pipe(mdb_pipe_t *);
2697c478bd9Sstevel@tonic-gate extern void mdb_set_pipe(const mdb_pipe_t *);
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate extern ssize_t mdb_get_xdata(const char *, void *, size_t);
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate #define	MDB_STATE_IDLE		0	/* Target is idle (not running yet) */
2747c478bd9Sstevel@tonic-gate #define	MDB_STATE_RUNNING	1	/* Target is currently executing */
2757c478bd9Sstevel@tonic-gate #define	MDB_STATE_STOPPED	2	/* Target is stopped */
2767c478bd9Sstevel@tonic-gate #define	MDB_STATE_UNDEAD	3	/* Target is undead (zombie) */
2777c478bd9Sstevel@tonic-gate #define	MDB_STATE_DEAD		4	/* Target is dead (core dump) */
2787c478bd9Sstevel@tonic-gate #define	MDB_STATE_LOST		5	/* Target lost by debugger */
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate extern int mdb_get_state(void);
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate #define	MDB_CALLBACK_STCHG	1
2837c478bd9Sstevel@tonic-gate #define	MDB_CALLBACK_PROMPT	2
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate typedef void (*mdb_callback_f)(void *);
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate extern void *mdb_callback_add(int, mdb_callback_f, void *);
2887c478bd9Sstevel@tonic-gate extern void mdb_callback_remove(void *);
2897c478bd9Sstevel@tonic-gate 
290*dc0093f4Seschrock extern size_t strlcat(char *, const char *, size_t);
2917c478bd9Sstevel@tonic-gate extern char *strcat(char *, const char *);
2927c478bd9Sstevel@tonic-gate extern char *strcpy(char *, const char *);
2937c478bd9Sstevel@tonic-gate extern char *strncpy(char *, const char *, size_t);
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */
2967c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
2977c478bd9Sstevel@tonic-gate extern const char *strchr(const char *, int);
2987c478bd9Sstevel@tonic-gate #ifndef	_STRCHR_INLINE
2997c478bd9Sstevel@tonic-gate #define	_STRCHR_INLINE
3007c478bd9Sstevel@tonic-gate extern "C++" {
3017c478bd9Sstevel@tonic-gate 	inline char *strchr(char *__s, int __c) {
3027c478bd9Sstevel@tonic-gate 		return (char *)strchr((const char *)__s, __c);
3037c478bd9Sstevel@tonic-gate 	}
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate #endif	/* _STRCHR_INLINE */
3067c478bd9Sstevel@tonic-gate extern const char *strrchr(const char *, int);
3077c478bd9Sstevel@tonic-gate #ifndef	_STRRCHR_INLINE
3087c478bd9Sstevel@tonic-gate #define	_STRRCHR_INLINE
3097c478bd9Sstevel@tonic-gate extern	"C++" {
3107c478bd9Sstevel@tonic-gate 	inline char *strrchr(char *__s, int __c) {
3117c478bd9Sstevel@tonic-gate 		return (char *)strrchr((const char *)__s, __c);
3127c478bd9Sstevel@tonic-gate 	}
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate #endif	/* _STRRCHR_INLINE */
3157c478bd9Sstevel@tonic-gate extern const char *strstr(const char *, const char *);
3167c478bd9Sstevel@tonic-gate #ifndef	_STRSTR_INLINE
3177c478bd9Sstevel@tonic-gate #define	_STRSTR_INLINE
3187c478bd9Sstevel@tonic-gate extern "C++" {
3197c478bd9Sstevel@tonic-gate 	inline char *strstr(char *__s1, const char *__s2) {
3207c478bd9Sstevel@tonic-gate 		return (char *)strstr((const char *)__s1, __s2);
3217c478bd9Sstevel@tonic-gate 	}
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate #endif	/* _STRSTR_INLINE */
3247c478bd9Sstevel@tonic-gate #else
3257c478bd9Sstevel@tonic-gate extern char *strchr(const char *, int);
3267c478bd9Sstevel@tonic-gate extern char *strrchr(const char *, int);
3277c478bd9Sstevel@tonic-gate extern char *strstr(const char *, const char *);
3287c478bd9Sstevel@tonic-gate #endif	/* __cplusplus >= 199711L */
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate extern int strcmp(const char *, const char *);
3317c478bd9Sstevel@tonic-gate extern int strncmp(const char *, const char *, size_t);
3327c478bd9Sstevel@tonic-gate extern int strcasecmp(const char *, const char *);
3337c478bd9Sstevel@tonic-gate extern int strncasecmp(const char *, const char *, size_t);
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate extern size_t strlen(const char *);
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate extern int bcmp(const void *, const void *, size_t);
3387c478bd9Sstevel@tonic-gate extern void bcopy(const void *, void *, size_t);
3397c478bd9Sstevel@tonic-gate extern void bzero(void *, size_t);
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate extern void *memcpy(void *, const void *, size_t);
3427c478bd9Sstevel@tonic-gate extern void *memmove(void *, const void *, size_t);
3437c478bd9Sstevel@tonic-gate extern int memcmp(const void *, const void *, size_t);
3447c478bd9Sstevel@tonic-gate /* Need to be consistent with <string.h> C++ definitions */
3457c478bd9Sstevel@tonic-gate #if __cplusplus >= 199711L
3467c478bd9Sstevel@tonic-gate extern const void *memchr(const void *, int, size_t);
3477c478bd9Sstevel@tonic-gate #ifndef _MEMCHR_INLINE
3487c478bd9Sstevel@tonic-gate #define	_MEMCHR_INLINE
3497c478bd9Sstevel@tonic-gate extern "C++" {
3507c478bd9Sstevel@tonic-gate 	inline void *memchr(void * __s, int __c, size_t __n) {
3517c478bd9Sstevel@tonic-gate 		return (void *)memchr((const void *)__s, __c, __n);
3527c478bd9Sstevel@tonic-gate 	}
3537c478bd9Sstevel@tonic-gate }
3547c478bd9Sstevel@tonic-gate #endif  /* _MEMCHR_INLINE */
3557c478bd9Sstevel@tonic-gate #else
3567c478bd9Sstevel@tonic-gate extern void *memchr(const void *, int, size_t);
3577c478bd9Sstevel@tonic-gate #endif /* __cplusplus >= 199711L */
3587c478bd9Sstevel@tonic-gate extern void *memset(void *, int, size_t);
3597c478bd9Sstevel@tonic-gate extern void *memccpy(void *, const void *, int, size_t);
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate extern void *bsearch(const void *, const void *, size_t, size_t,
3627c478bd9Sstevel@tonic-gate     int (*)(const void *, const void *));
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate extern void qsort(void *, size_t, size_t,
3657c478bd9Sstevel@tonic-gate     int (*)(const void *, const void *));
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3687c478bd9Sstevel@tonic-gate }
3697c478bd9Sstevel@tonic-gate #endif
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate #endif	/* _MDB_MODAPI_H */
372