xref: /onnv-gate/usr/src/head/proc_service.h (revision 2712:f74a135872bc)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2712Snn35248  * Common Development and Distribution License (the "License").
6*2712Snn35248  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2712Snn35248  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _PROC_SERVICE_H
270Sstevel@tonic-gate #define	_PROC_SERVICE_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  *  Description:
330Sstevel@tonic-gate  *	Types, global variables, and function definitions for provider
340Sstevel@tonic-gate  * of import functions for users of libc_db and librtld_db.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef __cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #include <sys/types.h>
420Sstevel@tonic-gate #include <sys/procfs_isa.h>
430Sstevel@tonic-gate #include <sys/lwp.h>
440Sstevel@tonic-gate #include <sys/auxv.h>
450Sstevel@tonic-gate #include <elf.h>
460Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)	/* for struct ssd */
470Sstevel@tonic-gate #include <sys/segments.h>
480Sstevel@tonic-gate #include <sys/sysi86.h>
490Sstevel@tonic-gate #endif
500Sstevel@tonic-gate 
510Sstevel@tonic-gate 
520Sstevel@tonic-gate typedef unsigned long	psaddr_t;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate typedef enum {
550Sstevel@tonic-gate 	PS_OK,		/* generic "call succeeded" */
560Sstevel@tonic-gate 	PS_ERR,		/* generic error */
570Sstevel@tonic-gate 	PS_BADPID,	/* bad process handle */
580Sstevel@tonic-gate 	PS_BADLID,	/* bad lwp identifier */
590Sstevel@tonic-gate 	PS_BADADDR,	/* bad address */
600Sstevel@tonic-gate 	PS_NOSYM,	/* p_lookup() could not find given symbol */
610Sstevel@tonic-gate 	PS_NOFREGS	/* FPU register set not available for given lwp */
620Sstevel@tonic-gate } ps_err_e;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate struct ps_prochandle;
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
670Sstevel@tonic-gate  * See <sys/procfs_isa.h> for possible values of data_model.
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model);
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /*
720Sstevel@tonic-gate  * Special values for 'object_name' to refer to certain well-known objects.
730Sstevel@tonic-gate  */
740Sstevel@tonic-gate #define	PS_OBJ_EXEC	((const char *)0x0)	/* the executable file */
750Sstevel@tonic-gate #define	PS_OBJ_LDSO	((const char *)0x1)	/* the dynamic linker */
760Sstevel@tonic-gate 
770Sstevel@tonic-gate extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *,
780Sstevel@tonic-gate 	const char *object_name, const char *sym_name, psaddr_t *sym_addr);
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #ifdef _LP64
810Sstevel@tonic-gate typedef	Elf64_Sym	ps_sym_t;
820Sstevel@tonic-gate #else
830Sstevel@tonic-gate typedef	Elf32_Sym	ps_sym_t;
840Sstevel@tonic-gate #endif
850Sstevel@tonic-gate extern ps_err_e ps_pglobal_sym(struct ps_prochandle *,
860Sstevel@tonic-gate 	const char *object_name, const char *sym_name, ps_sym_t *sym);
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate  * To read and write the process's address space.
900Sstevel@tonic-gate  */
910Sstevel@tonic-gate extern ps_err_e ps_pread(struct ps_prochandle *,
920Sstevel@tonic-gate 			psaddr_t, void *, size_t);
930Sstevel@tonic-gate extern ps_err_e ps_pwrite(struct ps_prochandle *,
940Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
950Sstevel@tonic-gate /*
960Sstevel@tonic-gate  * The following four functions can be implemented as simple aliases for
970Sstevel@tonic-gate  * the corresponding primary two functions above (#pragma weak ...).
980Sstevel@tonic-gate  * They are artifacts of history that must be maintained.
990Sstevel@tonic-gate  */
1000Sstevel@tonic-gate extern ps_err_e ps_pdread(struct ps_prochandle *,
1010Sstevel@tonic-gate 			psaddr_t, void *, size_t);
1020Sstevel@tonic-gate extern ps_err_e ps_pdwrite(struct ps_prochandle *,
1030Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
1040Sstevel@tonic-gate extern ps_err_e ps_ptread(struct ps_prochandle *,
1050Sstevel@tonic-gate 			psaddr_t, void *, size_t);
1060Sstevel@tonic-gate extern ps_err_e ps_ptwrite(struct ps_prochandle *,
1070Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate extern ps_err_e ps_pstop(struct ps_prochandle *);
1100Sstevel@tonic-gate extern ps_err_e ps_pcontinue(struct ps_prochandle *);
1110Sstevel@tonic-gate extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t);
1120Sstevel@tonic-gate extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t);
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate extern ps_err_e ps_lgetregs(struct ps_prochandle *,
1150Sstevel@tonic-gate 			lwpid_t, prgregset_t);
1160Sstevel@tonic-gate extern ps_err_e ps_lsetregs(struct ps_prochandle *,
1170Sstevel@tonic-gate 			lwpid_t, const prgregset_t);
1180Sstevel@tonic-gate extern ps_err_e ps_lgetfpregs(struct ps_prochandle *,
1190Sstevel@tonic-gate 			lwpid_t, prfpregset_t *);
1200Sstevel@tonic-gate extern ps_err_e ps_lsetfpregs(struct ps_prochandle *,
1210Sstevel@tonic-gate 			lwpid_t, const prfpregset_t *);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate #if defined(__sparc) || defined(__sparcv9)
1240Sstevel@tonic-gate extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *);
1250Sstevel@tonic-gate extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
1260Sstevel@tonic-gate extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
1270Sstevel@tonic-gate #endif
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1300Sstevel@tonic-gate extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *);
1310Sstevel@tonic-gate #endif
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **);
134*2712Snn35248 extern ps_err_e ps_pbrandname(struct ps_prochandle *, char *, size_t);
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate extern ps_err_e ps_kill(struct ps_prochandle *, int sig);
1370Sstevel@tonic-gate extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *,
1380Sstevel@tonic-gate 			lwpid_t, psaddr_t go_addr, psaddr_t stop_addr);
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate extern void	ps_plog(const char *fmt, ...);
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #ifdef __cplusplus
1430Sstevel@tonic-gate }
1440Sstevel@tonic-gate #endif
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #endif	/* _PROC_SERVICE_H */
147