4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 * Copyright (c) 2013 by Delphix. All rights reserved.
39 struct ps_prochandle *Pcreate(const char *file, char *const *argv,
40 int *perr, char *path, size_t len);
41 const char *Pcreate_error(int error);
42 void Pcreate_callback(struct ps_prochandle *Pr);
43 struct ps_prochandle *Pgrab(pid_t pid, int gflag, int *perr);
44 const char *Pgrab_error(int error);
45 void Pfree(struct ps_prochandle *Pr);
46 int Pstate(struct ps_prochandle *Pr);
47 int Pasfd(struct ps_prochandle *Pr);
48 int Pctlfd(struct ps_prochandle *Pr);
49 const psinfo_t *Ppsinfo(struct ps_prochandle *Pr);
50 const pstatus_t *Pstatus(struct ps_prochandle *Pr);
51 int Pcred(struct ps_prochandle *Pr, prcred_t *pcrp, int ngroups);
52 int Ppriv(struct ps_prochandle *Pr, prpriv_t **pprivp);
53 void Ppriv_free(struct ps_prochandle *Pr, prpriv_t *privp);
54 void Psync(struct ps_prochandle *Pr);
55 int Pcreate_agent(struct ps_prochandle *Pr);
56 void Pdestroy_agent(struct ps_prochandle *Pr);
57 int Preopen(struct ps_prochandle *Pr);
58 void Prelease(struct ps_prochandle *Pr, int flags);
59 int Pstopstatus(struct ps_prochandle *Pr, long cmd, uint_t msec);
60 int Pwait(struct ps_prochandle *Pr, uint_t msec);
61 int Pstop(struct ps_prochandle *Pr, uint_t msec);
62 int Pdstop(struct ps_prochandle *Pr);
63 int Pgetareg(struct ps_prochandle *Pr, int regno, prgreg_t *preg);
64 int Pputareg(struct ps_prochandle *Pr, int regno, prgreg_t reg);
65 int Psetrun(struct ps_prochandle *Pr, int sig, int flags);
66 ssize_t Pread(struct ps_prochandle *Pr,
67 void *buf, size_t nbyte, uintptr_t address);
68 ssize_t Pread_string(struct ps_prochandle *Pr,
69 char *buf, size_t nbyte, uintptr_t address);
70 ssize_t Pwrite(struct ps_prochandle *Pr,
71 const void *buf, size_t nbyte, uintptr_t address);
72 int Pclearsig(struct ps_prochandle *Pr);
73 int Pclearfault(struct ps_prochandle *Pr);
74 int Psetbkpt(struct ps_prochandle *Pr, uintptr_t address, ulong_t *saved);
75 int Pdelbkpt(struct ps_prochandle *Pr, uintptr_t address, ulong_t saved);
76 int Pxecbkpt(struct ps_prochandle *Pr, ulong_t saved);
77 int Psetwapt(struct ps_prochandle *Pr, const prwatch_t *wp);
78 int Pdelwapt(struct ps_prochandle *Pr, const prwatch_t *wp);
79 int Pxecwapt(struct ps_prochandle *Pr, const prwatch_t *wp);
80 int Psetflags(struct ps_prochandle *Pr, long flags);
81 int Punsetflags(struct ps_prochandle *Pr, long flags);
82 int Psignal(struct ps_prochandle *Pr, int which, int stop);
83 void Psetsignal(struct ps_prochandle *Pr, const sigset_t *set);
84 int Pfault(struct ps_prochandle *Pr, int which, int stop);
85 void Psetfault(struct ps_prochandle *Pr, const fltset_t *set);
86 int Psysentry(struct ps_prochandle *Pr, int which, int stop);
87 void Psetsysentry(struct ps_prochandle *Pr, const sysset_t *set);
88 int Psysexit(struct ps_prochandle *Pr, int which, int stop);
89 void Psetsysexit(struct ps_prochandle *Pr, const sysset_t *set);
90 int Plwp_iter(struct ps_prochandle *Pr, proc_lwp_f *func, void *cd);
91 int Psyscall(struct ps_prochandle *Pr, sysret_t *,
92 int sysindex, uint_t nargs, argdes_t *argp);
94 struct ps_lwphandle *Lgrab(struct ps_prochandle *P, lwpid_t lwpid, int *perr);
95 const char *Lgrab_error(int error);
96 struct ps_prochandle *Lprochandle(struct ps_lwphandle *Lwp);
97 void Lfree(struct ps_lwphandle *Lwp);
98 int Lctlfd(struct ps_lwphandle *Lwp);
99 int Lwait(struct ps_lwphandle *Lwp, uint_t msec);
100 int Lstop(struct ps_lwphandle *Lwp, uint_t msec);
101 int Ldstop(struct ps_lwphandle *Lwp);
102 int Lstate(struct ps_lwphandle *Lwp);
103 const lwpsinfo_t *Lpsinfo(struct ps_lwphandle *Lwp);
104 const lwpstatus_t *Lstatus(struct ps_lwphandle *Lwp);
105 int Lgetareg(struct ps_lwphandle *Lwp, int regno, prgreg_t *preg);
106 int Lputareg(struct ps_lwphandle *Lwp, int regno, prgreg_t reg);
107 int Lsetrun(struct ps_lwphandle *Lwp, int sig, int flags);
108 int Lclearsig(struct ps_lwphandle *Lwp);
109 int Lclearfault(struct ps_lwphandle *Lwp);
110 int Lxecbkpt(struct ps_lwphandle *Lwp, ulong_t saved);
111 int Lxecwapt(struct ps_lwphandle *Lwp, const prwatch_t *wp);
112 void Lsync(struct ps_lwphandle *Lwp);
115 int Plwp_getregs(struct ps_prochandle *Pr, lwpid_t i, prgregset_t gr);
116 int Plwp_setregs(struct ps_prochandle *Pr, lwpid_t i, const prgregset_t gr);
117 int Plwp_getfpregs(struct ps_prochandle *Pr, lwpid_t i, prfpregset_t *fp);
118 int Plwp_setfpregs(struct ps_prochandle *Pr, lwpid_t i, const prfpregset_t *fp);
119 #if defined(sparc) || defined(__sparc)
120 int Plwp_getxregs(struct ps_prochandle *Pr, lwpid_t i, prxregset_t *xr);
121 int Plwp_setxregs(struct ps_prochandle *Pr, lwpid_t i, const prxregset_t *xr);
122 #if defined(__sparcv9)
123 int Plwp_getasrs(struct ps_prochandle *Pr, lwpid_t i, asrset_t asrs);
124 int Plwp_setasrs(struct ps_prochandle *Pr, lwpid_t i, const asrset_t asrs);
125 #endif /* __sparcv9 */
127 int Plwp_getpsinfo(struct ps_prochandle *Pr, lwpid_t i, lwpsinfo_t *lps);
130 struct ps_prochandle *Pfgrab_core(int fd, const char *aout, int *perr);
131 struct ps_prochandle *Pgrab_core(const char *core, const char *aout,
132 int gflag, int *perr);
135 int Pisprocdir(struct ps_prochandle *Pr, const char *dir);
138 ps_err_e ps_pdmodel(struct ps_prochandle *Pr, int *modelp);
139 ps_err_e ps_pread(struct ps_prochandle *Pr,
140 psaddr_t addr, void *buf, size_t size);
141 ps_err_e ps_pwrite(struct ps_prochandle *Pr,
142 psaddr_t addr, const void *buf, size_t size);
143 ps_err_e ps_pdread(struct ps_prochandle *Pr,
144 psaddr_t addr, void *buf, size_t size);
145 ps_err_e ps_pdwrite(struct ps_prochandle *Pr,
146 psaddr_t addr, const void *buf, size_t size);
147 ps_err_e ps_ptread(struct ps_prochandle *Pr,
148 psaddr_t addr, void *buf, size_t size);
149 ps_err_e ps_ptwrite(struct ps_prochandle *Pr,
150 psaddr_t addr, const void *buf, size_t size);
151 ps_err_e ps_pstop(struct ps_prochandle *Pr);
152 ps_err_e ps_pcontinue(struct ps_prochandle *Pr);
153 ps_err_e ps_lstop(struct ps_prochandle *Pr, lwpid_t lwpid);
154 ps_err_e ps_lcontinue(struct ps_prochandle *Pr, lwpid_t lwpid);
155 ps_err_e ps_lgetregs(struct ps_prochandle *Pr,
156 lwpid_t lwpid, prgregset_t regs);
157 ps_err_e ps_lsetregs(struct ps_prochandle *Pr,
158 lwpid_t lwpid, const prgregset_t regs);
159 ps_err_e ps_lgetfpregs(struct ps_prochandle *Pr,
160 lwpid_t lwpid, prfpregset_t *regs);
161 ps_err_e ps_lsetfpregs(struct ps_prochandle *Pr,
162 lwpid_t lwpid, const prfpregset_t *regs);
163 #if defined(sparc) || defined(__sparc)
164 ps_err_e ps_lgetxregsize(struct ps_prochandle *Pr,
165 lwpid_t lwpid, int *xrsize);
166 ps_err_e ps_lgetxregs(struct ps_prochandle *Pr,
167 lwpid_t lwpid, caddr_t xregs);
168 ps_err_e ps_lsetxregs(struct ps_prochandle *Pr,
169 lwpid_t lwpid, caddr_t xregs);
171 #if defined(__i386) || defined(__amd64)
172 ps_err_e ps_lgetLDT(struct ps_prochandle *Pr,
173 lwpid_t lwpid, struct ssd *ldt);
174 #endif /* __i386 || __amd6464 */
175 void ps_plog(const char *fmt, ...);
178 void Pupdate_maps(struct ps_prochandle *Pr);
179 void Pupdate_syms(struct ps_prochandle *Pr);
180 rd_agent_t *Prd_agent(struct ps_prochandle *Pr);
181 const prmap_t *Paddr_to_map(struct ps_prochandle *Pr, uintptr_t addr);
182 const prmap_t *Paddr_to_text_map(struct ps_prochandle *Pr, uintptr_t addr);
183 const prmap_t *Pname_to_map(struct ps_prochandle *Pr, const char *name);
184 const prmap_t *Plmid_to_map(struct ps_prochandle *Pr, Lmid_t lmid,
186 int Plookup_by_addr(struct ps_prochandle *Pr, uintptr_t addr,
187 char *sym_name_buffer, size_t bufsize, GElf_Sym *symbolp);
188 int Plookup_by_name(struct ps_prochandle *Pr,
189 const char *object_name, const char *symbol_name,
191 int Plookup_by_lmid(struct ps_prochandle *Pr,
192 Lmid_t lmid, const char *object_name, const char *symbol_name,
194 const rd_loadobj_t *Paddr_to_loadobj(struct ps_prochandle *, uintptr_t);
195 const rd_loadobj_t *Pname_to_loadobj(struct ps_prochandle *, const char *);
196 const rd_loadobj_t *Plmid_to_loadobj(struct ps_prochandle *, Lmid_t,
198 int Pmapping_iter(struct ps_prochandle *Pr, proc_map_f *func, void *cd);
199 int Pmapping_iter_resolved(struct ps_prochandle *Pr, proc_map_f *func,
201 int Pobject_iter(struct ps_prochandle *Pr, proc_map_f *func, void *cd);
202 int Pobject_iter_resolved(struct ps_prochandle *Pr, proc_map_f *func,
204 char *Pobjname(struct ps_prochandle *Pr, uintptr_t addr,
205 char *buffer, size_t bufsize);
206 char *Pobjname_resolved(struct ps_prochandle *Pr, uintptr_t addr,
207 char *buffer, size_t bufsize);
208 int Plmid(struct ps_prochandle *Pr, uintptr_t addr, Lmid_t *lmidp);
209 int Psymbol_iter(struct ps_prochandle *Pr, const char *object_name,
210 int which, int type, proc_sym_f *func, void *cd);
211 int Psymbol_iter_by_lmid(struct ps_prochandle *Pr, Lmid_t lmid,
212 const char *object_name, int which, int type,
213 proc_sym_f *func, void *cd);
214 char *Pgetenv(struct ps_prochandle *Pr, const char *name,
215 char *buffer, size_t bufsize);
216 char *Pplatform(struct ps_prochandle *Pr, char *s, size_t n);
217 int Puname(struct ps_prochandle *Pr, struct utsname *u);
218 char *Pzonename(struct ps_prochandle *Pr, char *s, size_t n);
219 char *Pfindobj(struct ps_prochandle *Pr, const char *path,
221 char *Pexecname(struct ps_prochandle *Pr, char *buffer, size_t bufsize);
222 void Preset_maps(struct ps_prochandle *Pr);
224 ps_err_e ps_pglobal_lookup(struct ps_prochandle *Pr,
225 const char *object_name, const char *sym_name,
228 ps_err_e ps_pglobal_sym(struct ps_prochandle *Pr,
229 const char *object_name, const char *sym_name,
232 long Pgetauxval(struct ps_prochandle *Pr, int type);
233 const auxv_t *Pgetauxvec(struct ps_prochandle *Pr);
234 ps_err_e ps_pauxv(struct ps_prochandle *Pr, const auxv_t **aux);
237 void Perror_printf(struct ps_prochandle *Pr, const char *format, ...);
240 int pr_door_info(struct ps_prochandle *Pr, int did, door_info_t *di);
243 int pr_exit(struct ps_prochandle *Pr, int status);
244 int pr_lwp_exit(struct ps_prochandle *Pr);
247 int pr_fcntl(struct ps_prochandle *Pr, int fd, int cmd, void *argp);
250 int pr_getitimer(struct ps_prochandle *Pr,
251 int which, struct itimerval *itv);
252 int pr_setitimer(struct ps_prochandle *Pr,
253 int which, const struct itimerval *itv, struct itimerval *oitv);
256 int pr_getrctl(struct ps_prochandle *Pr, const char *rname,
257 rctlblk_t *old_blk, rctlblk_t *new_blk, int rflag);
258 int pr_setrctl(struct ps_prochandle *Pr, const char *rname,
259 rctlblk_t *old_blk, rctlblk_t *new_blk, int rflag);
260 int pr_setprojrctl(struct ps_prochandle *Pr, const char *rname,
261 rctlblk_t *new_blk, size_t size, int rflag);
264 int pr_getrlimit(struct ps_prochandle *Pr,
265 int resource, struct rlimit *rlp);
266 int pr_setrlimit(struct ps_prochandle *Pr,
267 int resource, const struct rlimit *rlp);
268 int pr_getrlimit64(struct ps_prochandle *Pr,
269 int resource, struct rlimit64 *rlp);
270 int pr_setrlimit64(struct ps_prochandle *Pr,
271 int resource, const struct rlimit64 *rlp);
273 /* pr_getsockname.c */
274 int pr_getsockname(struct ps_prochandle *Pr,
275 int sock, struct sockaddr *name, socklen_t *namelen);
276 int pr_getpeername(struct ps_prochandle *Pr,
277 int sock, struct sockaddr *name, socklen_t *namelen);
280 int pr_ioctl(struct ps_prochandle *Pr,
281 int fd, int code, void *buf, size_t size);
284 off_t pr_lseek(struct ps_prochandle *Pr,
285 int filedes, off_t offset, int whence);
286 offset_t pr_llseek(struct ps_prochandle *Pr,
287 int filedes, offset_t offset, int whence);
290 int pr_memcntl(struct ps_prochandle *Pr,
291 caddr_t addr, size_t len, int cmd, caddr_t arg, int attr, int mask);
294 void *pr_mmap(struct ps_prochandle *Pr,
295 void *addr, size_t len, int prot, int flags, int fd, off_t off);
296 int pr_munmap(struct ps_prochandle *Pr,
297 void *addr, size_t len);
298 void *pr_zmap(struct ps_prochandle *Pr,
299 void *addr, size_t len, int prot, int flags);
302 int pr_open(struct ps_prochandle *Pr,
303 const char *filename, int flags, mode_t mode);
304 int pr_creat(struct ps_prochandle *Pr,
305 const char *filename, mode_t mode);
306 int pr_close(struct ps_prochandle *Pr, int fd);
307 int pr_access(struct ps_prochandle *Pr, const char *path, int amode);
310 int pr_processor_bind(struct ps_prochandle *Pr, idtype_t, id_t, int, int *);
313 int pr_rename(struct ps_prochandle *Pr, const char *old, const char *new);
314 int pr_link(struct ps_prochandle *Pr, const char *exist, const char *new);
315 int pr_unlink(struct ps_prochandle *Pr, const char *);
318 int pr_sigaction(struct ps_prochandle *Pr,
319 int sig, const struct sigaction *act, struct sigaction *oact);
322 int pr_stat(struct ps_prochandle *Pr, const char *path, struct stat *buf);
323 int pr_lstat(struct ps_prochandle *Pr, const char *path, struct stat *buf);
324 int pr_fstat(struct ps_prochandle *Pr, int fd, struct stat *buf);
325 int pr_stat64(struct ps_prochandle *Pr, const char *path,
327 int pr_lstat64(struct ps_prochandle *Pr, const char *path,
329 int pr_fstat64(struct ps_prochandle *Pr, int fd, struct stat64 *buf);
332 int pr_statvfs(struct ps_prochandle *Pr, const char *path, statvfs_t *buf);
333 int pr_fstatvfs(struct ps_prochandle *Pr, int fd, statvfs_t *buf);
336 projid_t pr_getprojid(struct ps_prochandle *Pr);
337 taskid_t pr_gettaskid(struct ps_prochandle *Pr);
338 taskid_t pr_settaskid(struct ps_prochandle *Pr, projid_t project, int flags);
341 int pr_waitid(struct ps_prochandle *Pr,
342 idtype_t idtype, id_t id, siginfo_t *infop, int options);
344 /* proc_get_info.c */
345 int proc_get_cred(pid_t pid, prcred_t *credp, int ngroups);
346 prpriv_t *proc_get_priv(pid_t pid);
347 void proc_free_priv(prpriv_t *);
348 int proc_get_psinfo(pid_t pid, psinfo_t *psp);
349 int proc_get_status(pid_t pid, pstatus_t *psp);
350 int proc_get_auxv(pid_t pid, auxv_t *pauxv, int naux);
353 char *proc_fltname(int flt, char *buf, size_t bufsz);
354 char *proc_signame(int sig, char *buf, size_t bufsz);
355 char *proc_sysname(int sys, char *buf, size_t bufsz);
357 int proc_str2flt(const char *str, int *fltnum);
358 int proc_str2sig(const char *str, int *signum);
359 int proc_str2sys(const char *str, int *sysnum);
361 char *proc_fltset2str(const fltset_t *set, const char *delim, int members,
362 char *buf, size_t nbytes);
363 char *proc_sigset2str(const sigset_t *set, const char *delim, int members,
364 char *buf, size_t nbytes);
365 char *proc_sysset2str(const sysset_t *set, const char *delim, int members,
366 char *buf, size_t nbytes);
368 char *proc_str2fltset(const char *str, const char *delim, int members,
370 char *proc_str2sigset(const char *str, const char *delim, int members,
372 char *proc_str2sysset(const char *str, const char *delim, int members,
375 int proc_walk(proc_walk_f *func, void *arg, int flags);
378 struct ps_prochandle *proc_arg_grab(const char *arg,
379 int oflag, int gflag, int *perr);
381 pid_t proc_arg_psinfo(const char *arg, int oflag, psinfo_t *psp, int *perr);
382 void proc_unctrl_psinfo(psinfo_t *psp);
385 int Psetcred(struct ps_prochandle *Pr, const prcred_t *pcred);
388 int Pstack_iter(struct ps_prochandle *Pr,
389 const prgregset_t regs, proc_stack_f *func, void *arg);
392 const char *Ppltdest(struct ps_prochandle *Pr, uintptr_t addr);