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
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.
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]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
34 * Header file that gives the interfaces to the proc layer. These are the
35 * interfaces for "native" /proc i.e. when libtnfctl uses /proc directly
36 * on the target process (tnfctl_exec_open() and tnfctl_pid_open())
43 #include <sys/types.h>
44 #include <sys/syscall.h>
45 #include <sys/procfs.h>
46 #include <sys/errno.h>
49 #include <tnf/probe.h>
55 typedef enum prb_status
{
56 /* successful status */
61 * Status values in the range 1 to -1023 are reserved for mapping
62 * standard errno values.
64 PRB_STATUS_MINERRNO
= 1, /* minimum errno value */
65 PRB_STATUS_EAGAIN
= EAGAIN
,
66 PRB_STATUS_MAXERRNO
= 1023, /* maximum errno value */
68 PRB_STATUS_ALLOCFAIL
, /* memory allocation failed */
69 PRB_STATUS_BADARG
, /* bad input argument */
70 PRB_STATUS_BADSYNC
, /* couldn't sync with rtld */
71 PRB_STATUS_BADLMAPSTATE
/* inconsistent link map */
74 typedef enum prb_syscall_op
{
75 PRB_SYS_ALL
, /* turn on all system calls */
76 PRB_SYS_NONE
, /* clears all system calls */
77 PRB_SYS_ADD
, /* add a system call */
78 PRB_SYS_DEL
/* delete a system call */
82 * status of /proc file descriptor
84 typedef struct prb_proc_state
{
85 boolean_t ps_isstopped
;
87 boolean_t ps_isrequested
;
88 boolean_t ps_issysexit
;
89 boolean_t ps_issysentry
;
90 boolean_t ps_isbptfault
;
97 typedef struct prb_proc_ctl prb_proc_ctl_t
;
100 * prb_dbgaddr() has to be called with the address of DT_DEBUG before
101 * most other interfaces in the prb layer can be used.
103 void prb_dbgaddr(prb_proc_ctl_t
*proc_p
, uintptr_t dbgaddr
);
106 * loadobject iteration callback specification
107 * WARNING: keep this structure in sync with tnfctl_ind_obj_info_t
109 typedef struct prb_loadobj
{
116 typedef int prb_loadobj_f(prb_proc_ctl_t
*proc_p
, const prb_loadobj_t
*obj
,
118 prb_status_t
prb_loadobj_iter(prb_proc_ctl_t
*, prb_loadobj_f
*, void *);
119 prb_status_t
prb_mainobj_get(prb_proc_ctl_t
*proc_p
, int *objfd
,
120 uintptr_t *baseaddr
);
122 const char *prb_status_str(prb_status_t prbstat
);
124 pid_t
prb_proc_pid_get(prb_proc_ctl_t
*proc_p
);
126 /* rtld interfaces */
127 prb_status_t
prb_rtld_sync_if_needed(prb_proc_ctl_t
*proc_p
);
128 prb_status_t
prb_rtld_stalk(prb_proc_ctl_t
*proc_p
);
129 prb_status_t
prb_rtld_unstalk(prb_proc_ctl_t
*proc_p
);
130 prb_status_t
prb_rtld_advance(prb_proc_ctl_t
*proc_p
);
132 /* generic /proc wrapper interfaces */
133 prb_status_t
prb_proc_open(pid_t pid
, prb_proc_ctl_t
**proc_pp
);
134 prb_status_t
prb_proc_reopen(pid_t pid
, prb_proc_ctl_t
**proc_pp
);
135 prb_status_t
prb_proc_close(prb_proc_ctl_t
*proc_p
);
136 prb_status_t
prb_proc_stop(prb_proc_ctl_t
*proc_p
);
137 prb_status_t
prb_proc_wait(prb_proc_ctl_t
*proc_p
, boolean_t use_sigmask
,
139 prb_status_t
prb_proc_cont(prb_proc_ctl_t
*proc_p
);
140 prb_status_t
prb_proc_state(prb_proc_ctl_t
*proc_p
,
141 prb_proc_state_t
*state_p
);
142 prb_status_t
prb_proc_setrlc(prb_proc_ctl_t
*proc_p
, boolean_t rlc
);
143 prb_status_t
prb_proc_setklc(prb_proc_ctl_t
*proc_p
, boolean_t klc
);
144 prb_status_t
prb_proc_exit(prb_proc_ctl_t
*proc_p
, uint_t syscall
,
145 prb_syscall_op_t op
);
146 prb_status_t
prb_proc_entry(prb_proc_ctl_t
*proc_p
, uint_t syscall
,
147 prb_syscall_op_t op
);
148 prb_status_t
prb_proc_read(prb_proc_ctl_t
*proc_p
, uintptr_t addr
,
149 void *buf
, size_t size
);
150 prb_status_t
prb_proc_write(prb_proc_ctl_t
*proc_p
, uintptr_t addr
,
151 void *buf
, size_t size
);
152 prb_status_t
prb_proc_setfork(prb_proc_ctl_t
*proc_p
, boolean_t inhfork
);
153 prb_status_t
prb_proc_get_r0_r1(prb_proc_ctl_t
*proc_p
,
154 prgreg_t
*r0
, prgreg_t
*r1
);
157 prb_status_t
prb_child_create(const char *cmdname
, char * const *cmdargs
,
158 const char *loption
, const char *libtnfprobe_path
,
159 char * const *envp
, prb_proc_ctl_t
**ret_val
);
165 #endif /* _PRB_PROC_H */