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