xref: /titanic_52/usr/src/head/proc_service.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
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*9acbbeafSnn35248  * Common Development and Distribution License (the "License").
6*9acbbeafSnn35248  * 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*9acbbeafSnn35248  * 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 _PROC_SERVICE_H
277c478bd9Sstevel@tonic-gate #define	_PROC_SERVICE_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  *  Description:
337c478bd9Sstevel@tonic-gate  *	Types, global variables, and function definitions for provider
347c478bd9Sstevel@tonic-gate  * of import functions for users of libc_db and librtld_db.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef __cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate #include <sys/procfs_isa.h>
437c478bd9Sstevel@tonic-gate #include <sys/lwp.h>
447c478bd9Sstevel@tonic-gate #include <sys/auxv.h>
457c478bd9Sstevel@tonic-gate #include <elf.h>
467c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)	/* for struct ssd */
477c478bd9Sstevel@tonic-gate #include <sys/segments.h>
487c478bd9Sstevel@tonic-gate #include <sys/sysi86.h>
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate typedef unsigned long	psaddr_t;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate typedef enum {
557c478bd9Sstevel@tonic-gate 	PS_OK,		/* generic "call succeeded" */
567c478bd9Sstevel@tonic-gate 	PS_ERR,		/* generic error */
577c478bd9Sstevel@tonic-gate 	PS_BADPID,	/* bad process handle */
587c478bd9Sstevel@tonic-gate 	PS_BADLID,	/* bad lwp identifier */
597c478bd9Sstevel@tonic-gate 	PS_BADADDR,	/* bad address */
607c478bd9Sstevel@tonic-gate 	PS_NOSYM,	/* p_lookup() could not find given symbol */
617c478bd9Sstevel@tonic-gate 	PS_NOFREGS	/* FPU register set not available for given lwp */
627c478bd9Sstevel@tonic-gate } ps_err_e;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate struct ps_prochandle;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * See <sys/procfs_isa.h> for possible values of data_model.
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Special values for 'object_name' to refer to certain well-known objects.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate #define	PS_OBJ_EXEC	((const char *)0x0)	/* the executable file */
757c478bd9Sstevel@tonic-gate #define	PS_OBJ_LDSO	((const char *)0x1)	/* the dynamic linker */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *,
787c478bd9Sstevel@tonic-gate 	const char *object_name, const char *sym_name, psaddr_t *sym_addr);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #ifdef _LP64
817c478bd9Sstevel@tonic-gate typedef	Elf64_Sym	ps_sym_t;
827c478bd9Sstevel@tonic-gate #else
837c478bd9Sstevel@tonic-gate typedef	Elf32_Sym	ps_sym_t;
847c478bd9Sstevel@tonic-gate #endif
857c478bd9Sstevel@tonic-gate extern ps_err_e ps_pglobal_sym(struct ps_prochandle *,
867c478bd9Sstevel@tonic-gate 	const char *object_name, const char *sym_name, ps_sym_t *sym);
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * To read and write the process's address space.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate extern ps_err_e ps_pread(struct ps_prochandle *,
927c478bd9Sstevel@tonic-gate 			psaddr_t, void *, size_t);
937c478bd9Sstevel@tonic-gate extern ps_err_e ps_pwrite(struct ps_prochandle *,
947c478bd9Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * The following four functions can be implemented as simple aliases for
977c478bd9Sstevel@tonic-gate  * the corresponding primary two functions above (#pragma weak ...).
987c478bd9Sstevel@tonic-gate  * They are artifacts of history that must be maintained.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdread(struct ps_prochandle *,
1017c478bd9Sstevel@tonic-gate 			psaddr_t, void *, size_t);
1027c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdwrite(struct ps_prochandle *,
1037c478bd9Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
1047c478bd9Sstevel@tonic-gate extern ps_err_e ps_ptread(struct ps_prochandle *,
1057c478bd9Sstevel@tonic-gate 			psaddr_t, void *, size_t);
1067c478bd9Sstevel@tonic-gate extern ps_err_e ps_ptwrite(struct ps_prochandle *,
1077c478bd9Sstevel@tonic-gate 			psaddr_t, const void *, size_t);
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate extern ps_err_e ps_pstop(struct ps_prochandle *);
1107c478bd9Sstevel@tonic-gate extern ps_err_e ps_pcontinue(struct ps_prochandle *);
1117c478bd9Sstevel@tonic-gate extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t);
1127c478bd9Sstevel@tonic-gate extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t);
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetregs(struct ps_prochandle *,
1157c478bd9Sstevel@tonic-gate 			lwpid_t, prgregset_t);
1167c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetregs(struct ps_prochandle *,
1177c478bd9Sstevel@tonic-gate 			lwpid_t, const prgregset_t);
1187c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetfpregs(struct ps_prochandle *,
1197c478bd9Sstevel@tonic-gate 			lwpid_t, prfpregset_t *);
1207c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetfpregs(struct ps_prochandle *,
1217c478bd9Sstevel@tonic-gate 			lwpid_t, const prfpregset_t *);
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #if defined(__sparc) || defined(__sparcv9)
1247c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *);
1257c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
1267c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
1277c478bd9Sstevel@tonic-gate #endif
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1307c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *);
1317c478bd9Sstevel@tonic-gate #endif
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **);
134*9acbbeafSnn35248 extern ps_err_e ps_pbrandname(struct ps_prochandle *, char *, size_t);
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate extern ps_err_e ps_kill(struct ps_prochandle *, int sig);
1377c478bd9Sstevel@tonic-gate extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *,
1387c478bd9Sstevel@tonic-gate 			lwpid_t, psaddr_t go_addr, psaddr_t stop_addr);
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate extern void	ps_plog(const char *fmt, ...);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate #endif
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #endif	/* _PROC_SERVICE_H */
147