xref: /illumos-gate/usr/src/head/proc_service.h (revision 3db86aab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PROC_SERVICE_H
28 #define	_PROC_SERVICE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  *  Description:
34  *	Types, global variables, and function definitions for provider
35  * of import functions for users of libc_db and librtld_db.
36  */
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include <sys/types.h>
43 #include <sys/procfs_isa.h>
44 #include <sys/lwp.h>
45 #include <sys/auxv.h>
46 #include <elf.h>
47 #if defined(__i386) || defined(__amd64)	/* for struct ssd */
48 #include <sys/segments.h>
49 #include <sys/sysi86.h>
50 #endif
51 
52 
53 typedef unsigned long	psaddr_t;
54 
55 typedef enum {
56 	PS_OK,		/* generic "call succeeded" */
57 	PS_ERR,		/* generic error */
58 	PS_BADPID,	/* bad process handle */
59 	PS_BADLID,	/* bad lwp identifier */
60 	PS_BADADDR,	/* bad address */
61 	PS_NOSYM,	/* p_lookup() could not find given symbol */
62 	PS_NOFREGS	/* FPU register set not available for given lwp */
63 } ps_err_e;
64 
65 struct ps_prochandle;
66 
67 /*
68  * See <sys/procfs_isa.h> for possible values of data_model.
69  */
70 extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model);
71 
72 /*
73  * Special values for 'object_name' to refer to certain well-known objects.
74  */
75 #define	PS_OBJ_EXEC	((const char *)0x0)	/* the executable file */
76 #define	PS_OBJ_LDSO	((const char *)0x1)	/* the dynamic linker */
77 
78 extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *,
79 	const char *object_name, const char *sym_name, psaddr_t *sym_addr);
80 
81 #ifdef _LP64
82 typedef	Elf64_Sym	ps_sym_t;
83 #else
84 typedef	Elf32_Sym	ps_sym_t;
85 #endif
86 extern ps_err_e ps_pglobal_sym(struct ps_prochandle *,
87 	const char *object_name, const char *sym_name, ps_sym_t *sym);
88 
89 /*
90  * To read and write the process's address space.
91  */
92 extern ps_err_e ps_pread(struct ps_prochandle *,
93 			psaddr_t, void *, size_t);
94 extern ps_err_e ps_pwrite(struct ps_prochandle *,
95 			psaddr_t, const void *, size_t);
96 /*
97  * The following four functions can be implemented as simple aliases for
98  * the corresponding primary two functions above (#pragma weak ...).
99  * They are artifacts of history that must be maintained.
100  */
101 extern ps_err_e ps_pdread(struct ps_prochandle *,
102 			psaddr_t, void *, size_t);
103 extern ps_err_e ps_pdwrite(struct ps_prochandle *,
104 			psaddr_t, const void *, size_t);
105 extern ps_err_e ps_ptread(struct ps_prochandle *,
106 			psaddr_t, void *, size_t);
107 extern ps_err_e ps_ptwrite(struct ps_prochandle *,
108 			psaddr_t, const void *, size_t);
109 
110 extern ps_err_e ps_pstop(struct ps_prochandle *);
111 extern ps_err_e ps_pcontinue(struct ps_prochandle *);
112 extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t);
113 extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t);
114 
115 extern ps_err_e ps_lgetregs(struct ps_prochandle *,
116 			lwpid_t, prgregset_t);
117 extern ps_err_e ps_lsetregs(struct ps_prochandle *,
118 			lwpid_t, const prgregset_t);
119 extern ps_err_e ps_lgetfpregs(struct ps_prochandle *,
120 			lwpid_t, prfpregset_t *);
121 extern ps_err_e ps_lsetfpregs(struct ps_prochandle *,
122 			lwpid_t, const prfpregset_t *);
123 
124 #if defined(__sparc) || defined(__sparcv9)
125 extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *);
126 extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
127 extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
128 #endif
129 
130 #if defined(__i386) || defined(__amd64)
131 extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *);
132 #endif
133 
134 extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **);
135 
136 extern ps_err_e ps_kill(struct ps_prochandle *, int sig);
137 extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *,
138 			lwpid_t, psaddr_t go_addr, psaddr_t stop_addr);
139 
140 extern void	ps_plog(const char *fmt, ...);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif	/* _PROC_SERVICE_H */
147