Print this page
XXX AVX procfs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libproc/common/Pcontrol.h
+++ new/usr/src/lib/libproc/common/Pcontrol.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25 /*
26 26 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
27 27 */
28 28
29 29 #ifndef _PCONTROL_H
30 30 #define _PCONTROL_H
31 31
32 32 /*
33 33 * Implemention-specific include file for libproc process management.
34 34 * This is not to be seen by the clients of libproc.
35 35 */
36 36
37 37 #include <stdio.h>
38 38 #include <gelf.h>
39 39 #include <synch.h>
40 40 #include <procfs.h>
41 41 #include <rtld_db.h>
42 42 #include <libproc.h>
43 43 #include <libctf.h>
44 44 #include <limits.h>
45 45
46 46 #ifdef __cplusplus
47 47 extern "C" {
48 48 #endif
49 49
50 50 #include "Putil.h"
51 51
52 52 /*
53 53 * Definitions of the process control structures, internal to libproc.
54 54 * These may change without affecting clients of libproc.
55 55 */
56 56
57 57 /*
58 58 * sym_tbl_t contains a primary and an (optional) auxiliary symbol table, which
59 59 * we wish to treat as a single logical symbol table. In this logical table,
60 60 * the data from the auxiliary table preceeds that from the primary. Symbol
61 61 * indices start at [0], which is the first item in the auxiliary table
62 62 * if there is one. The sole purpose for this is so that we can treat the
63 63 * combination of .SUNW_ldynsym and .dynsym sections as a logically single
64 64 * entity without having to violate the public interface to libelf.
65 65 *
66 66 * Both tables must share the same string table section.
67 67 *
68 68 * The symtab_getsym() function serves as a gelf_getsym() replacement
69 69 * that is aware of the two tables and makes them look like a single table
70 70 * to the caller.
71 71 *
72 72 */
73 73 typedef struct sym_tbl { /* symbol table */
74 74 Elf_Data *sym_data_pri; /* primary table */
75 75 Elf_Data *sym_data_aux; /* auxiliary table */
76 76 size_t sym_symn_aux; /* number of entries in auxiliary table */
77 77 size_t sym_symn; /* total number of entries in both tables */
78 78 char *sym_strs; /* ptr to strings */
79 79 size_t sym_strsz; /* size of string table */
80 80 GElf_Shdr sym_hdr_pri; /* primary symbol table section header */
81 81 GElf_Shdr sym_hdr_aux; /* auxiliary symbol table section header */
82 82 GElf_Shdr sym_strhdr; /* string table section header */
83 83 Elf *sym_elf; /* faked-up ELF handle from core file */
84 84 void *sym_elfmem; /* data for faked-up ELF handle */
85 85 uint_t *sym_byname; /* symbols sorted by name */
86 86 uint_t *sym_byaddr; /* symbols sorted by addr */
87 87 size_t sym_count; /* number of symbols in each sorted list */
88 88 } sym_tbl_t;
89 89
90 90 typedef struct file_info { /* symbol information for a mapped file */
91 91 plist_t file_list; /* linked list */
92 92 char file_pname[PRMAPSZ]; /* name from prmap_t */
93 93 struct map_info *file_map; /* primary (text) mapping */
94 94 int file_ref; /* references from map_info_t structures */
95 95 int file_fd; /* file descriptor for the mapped file */
96 96 int file_init; /* 0: initialization yet to be performed */
97 97 GElf_Half file_etype; /* ELF e_type from ehdr */
98 98 GElf_Half file_class; /* ELF e_ident[EI_CLASS] from ehdr */
99 99 rd_loadobj_t *file_lo; /* load object structure from rtld_db */
100 100 char *file_lname; /* load object name from rtld_db */
101 101 char *file_lbase; /* pointer to basename of file_lname */
102 102 char *file_rname; /* resolved on-disk object pathname */
103 103 char *file_rbase; /* pointer to basename of file_rname */
104 104 Elf *file_elf; /* ELF handle so we can close */
105 105 void *file_elfmem; /* data for faked-up ELF handle */
106 106 sym_tbl_t file_symtab; /* symbol table */
107 107 sym_tbl_t file_dynsym; /* dynamic symbol table */
108 108 uintptr_t file_dyn_base; /* load address for ET_DYN files */
109 109 uintptr_t file_plt_base; /* base address for PLT */
110 110 size_t file_plt_size; /* size of PLT region */
111 111 uintptr_t file_jmp_rel; /* base address of PLT relocations */
112 112 uintptr_t file_ctf_off; /* offset of CTF data in object file */
113 113 size_t file_ctf_size; /* size of CTF data in object file */
114 114 int file_ctf_dyn; /* does the CTF data reference the dynsym */
115 115 void *file_ctf_buf; /* CTF data for this file */
116 116 ctf_file_t *file_ctfp; /* CTF container for this file */
117 117 char *file_shstrs; /* section header string table */
118 118 size_t file_shstrsz; /* section header string table size */
119 119 uintptr_t *file_saddrs; /* section header addresses */
120 120 uint_t file_nsaddrs; /* number of section header addresses */
121 121 } file_info_t;
122 122
123 123 typedef struct map_info { /* description of an address space mapping */
124 124 prmap_t map_pmap; /* /proc description of this mapping */
↓ open down ↓ |
124 lines elided |
↑ open up ↑ |
125 125 file_info_t *map_file; /* pointer into list of mapped files */
126 126 off64_t map_offset; /* offset into core file (if core) */
127 127 int map_relocate; /* associated file_map needs to be relocated */
128 128 } map_info_t;
129 129
130 130 typedef struct lwp_info { /* per-lwp information from core file */
131 131 plist_t lwp_list; /* linked list */
132 132 lwpid_t lwp_id; /* lwp identifier */
133 133 lwpsinfo_t lwp_psinfo; /* /proc/<pid>/lwp/<lwpid>/lwpsinfo data */
134 134 lwpstatus_t lwp_status; /* /proc/<pid>/lwp/<lwpid>/lwpstatus data */
135 + prxregset_t *lwp_xregs; /* /proc/<pid>/lwp/<lwpid>/xregs data */
135 136 #if defined(sparc) || defined(__sparc)
136 137 gwindows_t *lwp_gwins; /* /proc/<pid>/lwp/<lwpid>/gwindows data */
137 - prxregset_t *lwp_xregs; /* /proc/<pid>/lwp/<lwpid>/xregs data */
138 138 int64_t *lwp_asrs; /* /proc/<pid>/lwp/<lwpid>/asrs data */
139 139 #endif
140 140 } lwp_info_t;
141 141
142 142 typedef struct fd_info {
143 143 plist_t fd_list; /* linked list */
144 144 prfdinfo_t fd_info; /* fd info */
145 145 } fd_info_t;
146 146
147 147 typedef struct core_info { /* information specific to core files */
148 148 char core_dmodel; /* data model for core file */
149 149 int core_errno; /* error during initialization if != 0 */
150 150 plist_t core_lwp_head; /* head of list of lwp info */
151 151 lwp_info_t *core_lwp; /* current lwp information */
152 152 uint_t core_nlwp; /* number of lwp's in list */
153 153 off64_t core_size; /* size of core file in bytes */
154 154 char *core_platform; /* platform string from core file */
155 155 struct utsname *core_uts; /* uname(2) data from core file */
156 156 prcred_t *core_cred; /* process credential from core file */
157 157 core_content_t core_content; /* content dumped to core file */
158 158 prpriv_t *core_priv; /* process privileges from core file */
159 159 size_t core_priv_size; /* size of the privileges */
160 160 void *core_privinfo; /* system privileges info from core file */
161 161 priv_impl_info_t *core_ppii; /* NOTE entry for core_privinfo */
162 162 char *core_zonename; /* zone name from core file */
163 163 #if defined(__i386) || defined(__amd64)
164 164 struct ssd *core_ldt; /* LDT entries from core file */
165 165 uint_t core_nldt; /* number of LDT entries in core file */
166 166 #endif
167 167 } core_info_t;
168 168
169 169 typedef struct elf_file_header { /* extended ELF header */
170 170 unsigned char e_ident[EI_NIDENT];
171 171 Elf64_Half e_type;
172 172 Elf64_Half e_machine;
173 173 Elf64_Word e_version;
174 174 Elf64_Addr e_entry;
175 175 Elf64_Off e_phoff;
176 176 Elf64_Off e_shoff;
177 177 Elf64_Word e_flags;
178 178 Elf64_Half e_ehsize;
179 179 Elf64_Half e_phentsize;
180 180 Elf64_Half e_shentsize;
181 181 Elf64_Word e_phnum; /* phdr count extended to 32 bits */
182 182 Elf64_Word e_shnum; /* shdr count extended to 32 bits */
183 183 Elf64_Word e_shstrndx; /* shdr string index extended to 32 bits */
184 184 } elf_file_header_t;
185 185
186 186 typedef struct elf_file { /* convenience for managing ELF files */
187 187 elf_file_header_t e_hdr; /* Extended ELF header */
188 188 Elf *e_elf; /* ELF library handle */
189 189 int e_fd; /* file descriptor */
190 190 } elf_file_t;
191 191
192 192 typedef struct ps_rwops { /* ops vector for Pread() and Pwrite() */
193 193 ssize_t (*p_pread)(struct ps_prochandle *,
194 194 void *, size_t, uintptr_t);
195 195 ssize_t (*p_pwrite)(struct ps_prochandle *,
196 196 const void *, size_t, uintptr_t);
197 197 } ps_rwops_t;
198 198
199 199 #define HASHSIZE 1024 /* hash table size, power of 2 */
200 200
201 201 struct ps_prochandle {
202 202 struct ps_lwphandle **hashtab; /* hash table for LWPs (Lgrab()) */
203 203 mutex_t proc_lock; /* protects hash table; serializes Lgrab() */
204 204 pstatus_t orig_status; /* remembered status on Pgrab() */
205 205 pstatus_t status; /* status when stopped */
206 206 psinfo_t psinfo; /* psinfo_t from last Ppsinfo() request */
207 207 uintptr_t sysaddr; /* address of most recent syscall instruction */
208 208 pid_t pid; /* process-ID */
209 209 int state; /* state of the process, see "libproc.h" */
210 210 uint_t flags; /* see defines below */
211 211 uint_t agentcnt; /* Pcreate_agent()/Pdestroy_agent() ref count */
212 212 int asfd; /* /proc/<pid>/as filedescriptor */
213 213 int ctlfd; /* /proc/<pid>/ctl filedescriptor */
214 214 int statfd; /* /proc/<pid>/status filedescriptor */
215 215 int agentctlfd; /* /proc/<pid>/lwp/agent/ctl */
216 216 int agentstatfd; /* /proc/<pid>/lwp/agent/status */
217 217 int info_valid; /* if zero, map and file info need updating */
218 218 map_info_t *mappings; /* cached process mappings */
219 219 size_t map_count; /* number of mappings */
220 220 size_t map_alloc; /* number of mappings allocated */
221 221 uint_t num_files; /* number of file elements in file_info */
222 222 plist_t file_head; /* head of mapped files w/ symbol table info */
223 223 char *execname; /* name of the executable file */
224 224 auxv_t *auxv; /* the process's aux vector */
225 225 int nauxv; /* number of aux vector entries */
226 226 rd_agent_t *rap; /* cookie for rtld_db */
227 227 map_info_t *map_exec; /* the mapping for the executable file */
228 228 map_info_t *map_ldso; /* the mapping for ld.so.1 */
229 229 const ps_rwops_t *ops; /* pointer to ops-vector for read and write */
230 230 core_info_t *core; /* information specific to core (if PS_DEAD) */
231 231 uintptr_t *ucaddrs; /* ucontext-list addresses */
232 232 uint_t ucnelems; /* number of elements in the ucaddrs list */
233 233 char *zoneroot; /* cached path to zone root */
234 234 plist_t fd_head; /* head of file desc info list */
235 235 int num_fd; /* number of file descs in list */
236 236 };
237 237
238 238 /* flags */
239 239 #define CREATED 0x01 /* process was created by Pcreate() */
240 240 #define SETSIG 0x02 /* set signal trace mask before continuing */
241 241 #define SETFAULT 0x04 /* set fault trace mask before continuing */
242 242 #define SETENTRY 0x08 /* set sysentry trace mask before continuing */
243 243 #define SETEXIT 0x10 /* set sysexit trace mask before continuing */
244 244 #define SETHOLD 0x20 /* set signal hold mask before continuing */
245 245 #define SETREGS 0x40 /* set registers before continuing */
246 246
247 247 struct ps_lwphandle {
248 248 struct ps_prochandle *lwp_proc; /* process to which this lwp belongs */
249 249 struct ps_lwphandle *lwp_hash; /* hash table linked list */
250 250 lwpstatus_t lwp_status; /* status when stopped */
251 251 lwpsinfo_t lwp_psinfo; /* lwpsinfo_t from last Lpsinfo() */
252 252 lwpid_t lwp_id; /* lwp identifier */
253 253 int lwp_state; /* state of the lwp, see "libproc.h" */
254 254 uint_t lwp_flags; /* SETHOLD and/or SETREGS */
255 255 int lwp_ctlfd; /* /proc/<pid>/lwp/<lwpid>/lwpctl */
256 256 int lwp_statfd; /* /proc/<pid>/lwp/<lwpid>/lwpstatus */
257 257 };
258 258
259 259 /*
260 260 * Implementation functions in the process control library.
261 261 * These are not exported to clients of the library.
262 262 */
263 263 extern void prldump(const char *, lwpstatus_t *);
264 264 extern int dupfd(int, int);
265 265 extern int set_minfd(void);
266 266 extern int Pscantext(struct ps_prochandle *);
267 267 extern void Pinitsym(struct ps_prochandle *);
268 268 extern void Preadauxvec(struct ps_prochandle *);
269 269 extern void optimize_symtab(sym_tbl_t *);
270 270 extern void Pbuild_file_symtab(struct ps_prochandle *, file_info_t *);
271 271 extern ctf_file_t *Pbuild_file_ctf(struct ps_prochandle *, file_info_t *);
272 272 extern map_info_t *Paddr2mptr(struct ps_prochandle *, uintptr_t);
273 273 extern char *Pfindexec(struct ps_prochandle *, const char *,
274 274 int (*)(const char *, void *), void *);
275 275 extern int getlwpstatus(struct ps_prochandle *, lwpid_t, lwpstatus_t *);
276 276 int Pstopstatus(struct ps_prochandle *, long, uint32_t);
277 277 extern file_info_t *file_info_new(struct ps_prochandle *, map_info_t *);
278 278 extern char *Plofspath(const char *, char *, size_t);
279 279 extern char *Pzoneroot(struct ps_prochandle *, char *, size_t);
280 280 extern char *Pzonepath(struct ps_prochandle *, const char *, char *,
281 281 size_t);
282 282 extern fd_info_t *Pfd2info(struct ps_prochandle *, int);
283 283
284 284 extern char *Pfindmap(struct ps_prochandle *, map_info_t *, char *,
285 285 size_t);
286 286
287 287 extern int Padd_mapping(struct ps_prochandle *, off64_t, file_info_t *,
288 288 prmap_t *);
289 289 extern void Psort_mappings(struct ps_prochandle *);
290 290
291 291 extern char procfs_path[PATH_MAX];
292 292
293 293 /*
294 294 * Architecture-dependent definition of the breakpoint instruction.
295 295 */
296 296 #if defined(sparc) || defined(__sparc)
297 297 #define BPT ((instr_t)0x91d02001)
298 298 #elif defined(__i386) || defined(__amd64)
299 299 #define BPT ((instr_t)0xcc)
300 300 #endif
301 301
302 302 /*
303 303 * Simple convenience.
304 304 */
305 305 #define TRUE 1
306 306 #define FALSE 0
307 307
308 308 #ifdef __cplusplus
309 309 }
310 310 #endif
311 311
312 312 #endif /* _PCONTROL_H */
↓ open down ↓ |
165 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX