agent/src/os/solaris/proc/libproc.h

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 /*
duke@435 26 * Interfaces available from the process control library, libproc.
duke@435 27 *
duke@435 28 * libproc provides process control functions for the /proc tools
duke@435 29 * (commands in /usr/proc/bin), /usr/bin/truss, and /usr/bin/gcore.
duke@435 30 * libproc is a private support library for these commands only.
duke@435 31 * It is _not_ a public interface, although it might become one
duke@435 32 * in the fullness of time, when the interfaces settle down.
duke@435 33 *
duke@435 34 * In the meantime, be aware that any program linked with libproc in this
duke@435 35 * release of Solaris is almost guaranteed to break in the next release.
duke@435 36 *
duke@435 37 * In short, do not use this header file or libproc for any purpose.
duke@435 38 */
duke@435 39
duke@435 40 #ifndef _LIBPROC_H
duke@435 41 #define _LIBPROC_H
duke@435 42
duke@435 43 #include <stdlib.h>
duke@435 44 #include <unistd.h>
duke@435 45 #include <fcntl.h>
duke@435 46 #include <nlist.h>
duke@435 47 #include <door.h>
duke@435 48 #include <gelf.h>
duke@435 49 #include <proc_service.h>
duke@435 50 #include <rtld_db.h>
duke@435 51 #include <procfs.h>
duke@435 52 #include <sys/stat.h>
duke@435 53 #include <sys/statvfs.h>
duke@435 54 #include <sys/auxv.h>
duke@435 55 #include <sys/resource.h>
duke@435 56 #include <sys/socket.h>
duke@435 57 #include <sys/utsname.h>
duke@435 58
duke@435 59 #ifdef __cplusplus
duke@435 60 extern "C" {
duke@435 61 #endif
duke@435 62
duke@435 63 /*
duke@435 64 * Opaque structure tag reference to a process control structure.
duke@435 65 * Clients of libproc cannot look inside the process control structure.
duke@435 66 * The implementation of struct ps_prochandle can change w/o affecting clients.
duke@435 67 */
duke@435 68 struct ps_prochandle;
duke@435 69
duke@435 70 extern int _libproc_debug; /* set non-zero to enable debugging fprintfs */
duke@435 71
duke@435 72 #if defined(sparc) || defined(__sparc)
duke@435 73 #define R_RVAL1 R_O0 /* register holding a function return value */
duke@435 74 #define R_RVAL2 R_O1 /* 32 more bits for a 64-bit return value */
duke@435 75 #define SYSCALL32 0x91d02008 /* 32-bit syscall (ta 8) instruction */
duke@435 76 #define SYSCALL64 0x91d02040 /* 64-bit syscall (ta 64) instruction */
duke@435 77 typedef uint32_t syscall_t; /* holds a syscall instruction */
duke@435 78 #endif /* sparc */
duke@435 79
duke@435 80 #if defined(__i386) || defined(__ia64)
duke@435 81 #define R_PC EIP
duke@435 82 #define R_SP UESP
duke@435 83 #define R_RVAL1 EAX /* register holding a function return value */
duke@435 84 #define R_RVAL2 EDX /* 32 more bits for a 64-bit return value */
duke@435 85 #define SYSCALL 0x9a /* syscall (lcall) instruction opcode */
duke@435 86 typedef uchar_t syscall_t[7]; /* holds a syscall instruction */
duke@435 87 #endif /* __i386 || __ia64 */
duke@435 88
duke@435 89 #define R_RVAL R_RVAL1 /* simple function return value register */
duke@435 90
duke@435 91 /* maximum sizes of things */
duke@435 92 #define PRMAXSIG (32 * sizeof (sigset_t) / sizeof (uint32_t))
duke@435 93 #define PRMAXFAULT (32 * sizeof (fltset_t) / sizeof (uint32_t))
duke@435 94 #define PRMAXSYS (32 * sizeof (sysset_t) / sizeof (uint32_t))
duke@435 95
duke@435 96 /* State values returned by Pstate() */
duke@435 97 #define PS_RUN 1 /* process is running */
duke@435 98 #define PS_STOP 2 /* process is stopped */
duke@435 99 #define PS_LOST 3 /* process is lost to control (EAGAIN) */
duke@435 100 #define PS_UNDEAD 4 /* process is terminated (zombie) */
duke@435 101 #define PS_DEAD 5 /* process is terminated (core file) */
duke@435 102
duke@435 103 /* Flags accepted by Pgrab() */
duke@435 104 #define PGRAB_RETAIN 0x01 /* Retain tracing flags, else clear flags */
duke@435 105 #define PGRAB_FORCE 0x02 /* Open the process w/o O_EXCL */
duke@435 106 #define PGRAB_RDONLY 0x04 /* Open the process or core w/ O_RDONLY */
duke@435 107 #define PGRAB_NOSTOP 0x08 /* Open the process but do not stop it */
duke@435 108
duke@435 109 /* Error codes from Pcreate() */
duke@435 110 #define C_STRANGE -1 /* Unanticipated error, errno is meaningful */
duke@435 111 #define C_FORK 1 /* Unable to fork */
duke@435 112 #define C_PERM 2 /* No permission (file set-id or unreadable) */
duke@435 113 #define C_NOEXEC 3 /* Cannot find executable file */
duke@435 114 #define C_INTR 4 /* Interrupt received while creating */
duke@435 115 #define C_LP64 5 /* Program is _LP64, self is _ILP32 */
duke@435 116
duke@435 117 /* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */
duke@435 118 #define G_STRANGE -1 /* Unanticipated error, errno is meaningful */
duke@435 119 #define G_NOPROC 1 /* No such process */
duke@435 120 #define G_NOCORE 2 /* No such core file */
duke@435 121 #define G_NOPROCORCORE 3 /* No such proc or core (for proc_arg_grab) */
duke@435 122 #define G_NOEXEC 4 /* Cannot locate executable file */
duke@435 123 #define G_ZOMB 5 /* Zombie process */
duke@435 124 #define G_PERM 6 /* No permission */
duke@435 125 #define G_BUSY 7 /* Another process has control */
duke@435 126 #define G_SYS 8 /* System process */
duke@435 127 #define G_SELF 9 /* Process is self */
duke@435 128 #define G_INTR 10 /* Interrupt received while grabbing */
duke@435 129 #define G_LP64 11 /* Process is _LP64, self is ILP32 */
duke@435 130 #define G_FORMAT 12 /* File is not an ELF format core file */
duke@435 131 #define G_ELF 13 /* Libelf error, elf_errno() is meaningful */
duke@435 132 #define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */
duke@435 133
duke@435 134 /* Flags accepted by Prelease */
duke@435 135 #define PRELEASE_CLEAR 0x10 /* Clear all tracing flags */
duke@435 136 #define PRELEASE_RETAIN 0x20 /* Retain final tracing flags */
duke@435 137 #define PRELEASE_HANG 0x40 /* Leave the process stopped */
duke@435 138 #define PRELEASE_KILL 0x80 /* Terminate the process */
duke@435 139
duke@435 140 typedef struct { /* argument descriptor for system call (Psyscall) */
duke@435 141 long arg_value; /* value of argument given to system call */
duke@435 142 void *arg_object; /* pointer to object in controlling process */
duke@435 143 char arg_type; /* AT_BYVAL, AT_BYREF */
duke@435 144 char arg_inout; /* AI_INPUT, AI_OUTPUT, AI_INOUT */
duke@435 145 ushort_t arg_size; /* if AT_BYREF, size of object in bytes */
duke@435 146 } argdes_t;
duke@435 147
duke@435 148 typedef struct { /* return values from system call (Psyscall) */
duke@435 149 int sys_errno; /* syscall error number */
duke@435 150 long sys_rval1; /* primary return value from system call */
duke@435 151 long sys_rval2; /* second return value from system call */
duke@435 152 } sysret_t;
duke@435 153
duke@435 154 /* values for type */
duke@435 155 #define AT_BYVAL 1
duke@435 156 #define AT_BYREF 2
duke@435 157
duke@435 158 /* values for inout */
duke@435 159 #define AI_INPUT 1
duke@435 160 #define AI_OUTPUT 2
duke@435 161 #define AI_INOUT 3
duke@435 162
duke@435 163 /* maximum number of syscall arguments */
duke@435 164 #define MAXARGS 8
duke@435 165
duke@435 166 /* maximum size in bytes of a BYREF argument */
duke@435 167 #define MAXARGL (4*1024)
duke@435 168
duke@435 169 /* Kludges to make things work on Solaris 2.6 */
duke@435 170 #if !defined(_LP64) && !defined(PR_MODEL_UNKNOWN)
duke@435 171 #define PR_MODEL_UNKNOWN 0
duke@435 172 #define PR_MODEL_ILP32 0 /* process data model is ILP32 */
duke@435 173 #define PR_MODEL_LP64 2 /* process data model is LP64 */
duke@435 174 #define PR_MODEL_NATIVE PR_MODEL_ILP32
duke@435 175 #define pr_dmodel pr_filler[0]
duke@435 176 #define STACK_BIAS 0
duke@435 177 #endif
duke@435 178
duke@435 179 /*
duke@435 180 * Function prototypes for routines in the process control package.
duke@435 181 */
duke@435 182 extern struct ps_prochandle *Pcreate(const char *, char *const *,
duke@435 183 int *, char *, size_t);
duke@435 184
duke@435 185 extern const char *Pcreate_error(int);
duke@435 186
duke@435 187 extern struct ps_prochandle *Pgrab(pid_t, int, int *);
duke@435 188 extern struct ps_prochandle *Pgrab_core(const char *, const char *, int, int *);
duke@435 189 extern struct ps_prochandle *Pfgrab_core(int, const char *, int *);
duke@435 190
duke@435 191 extern const char *Pgrab_error(int);
duke@435 192
duke@435 193 extern int Preopen(struct ps_prochandle *);
duke@435 194 extern void Prelease(struct ps_prochandle *, int);
duke@435 195 extern void Pfree(struct ps_prochandle *);
duke@435 196
duke@435 197 extern int Pasfd(struct ps_prochandle *);
duke@435 198 extern int Pctlfd(struct ps_prochandle *);
duke@435 199 extern int Pcreate_agent(struct ps_prochandle *);
duke@435 200 extern void Pdestroy_agent(struct ps_prochandle *);
duke@435 201 extern int Pwait(struct ps_prochandle *, uint_t);
duke@435 202 extern int Pstop(struct ps_prochandle *, uint_t);
duke@435 203 extern int Pstate(struct ps_prochandle *);
duke@435 204 extern const psinfo_t *Ppsinfo(struct ps_prochandle *);
duke@435 205 extern const pstatus_t *Pstatus(struct ps_prochandle *);
duke@435 206 extern int Pcred(struct ps_prochandle *, prcred_t *, int);
duke@435 207 extern int Pgetareg(struct ps_prochandle *, int, prgreg_t *);
duke@435 208 extern int Pputareg(struct ps_prochandle *, int, prgreg_t);
duke@435 209 extern int Psetrun(struct ps_prochandle *, int, int);
duke@435 210 extern ssize_t Pread(struct ps_prochandle *, void *, size_t, uintptr_t);
duke@435 211 extern ssize_t Pread_string(struct ps_prochandle *, char *, size_t, uintptr_t);
duke@435 212 extern ssize_t Pwrite(struct ps_prochandle *, const void *, size_t, uintptr_t);
duke@435 213 extern int Pclearsig(struct ps_prochandle *);
duke@435 214 extern int Pclearfault(struct ps_prochandle *);
duke@435 215 extern int Psetbkpt(struct ps_prochandle *, uintptr_t, ulong_t *);
duke@435 216 extern int Pdelbkpt(struct ps_prochandle *, uintptr_t, ulong_t);
duke@435 217 extern int Pxecbkpt(struct ps_prochandle *, ulong_t);
duke@435 218 extern int Psetflags(struct ps_prochandle *, long);
duke@435 219 extern int Punsetflags(struct ps_prochandle *, long);
duke@435 220 extern int Psignal(struct ps_prochandle *, int, int);
duke@435 221 extern int Pfault(struct ps_prochandle *, int, int);
duke@435 222 extern int Psysentry(struct ps_prochandle *, int, int);
duke@435 223 extern int Psysexit(struct ps_prochandle *, int, int);
duke@435 224 extern void Psetsignal(struct ps_prochandle *, const sigset_t *);
duke@435 225 extern void Psetfault(struct ps_prochandle *, const fltset_t *);
duke@435 226 extern void Psetsysentry(struct ps_prochandle *, const sysset_t *);
duke@435 227 extern void Psetsysexit(struct ps_prochandle *, const sysset_t *);
duke@435 228 extern void Psync(struct ps_prochandle *);
duke@435 229 extern sysret_t Psyscall(struct ps_prochandle *, int, uint_t, argdes_t *);
duke@435 230 extern int Pisprocdir(struct ps_prochandle *, const char *);
duke@435 231
duke@435 232 /*
duke@435 233 * Function prototypes for system calls forced on the victim process.
duke@435 234 */
duke@435 235 extern int pr_open(struct ps_prochandle *, const char *, int, mode_t);
duke@435 236 extern int pr_creat(struct ps_prochandle *, const char *, mode_t);
duke@435 237 extern int pr_close(struct ps_prochandle *, int);
duke@435 238 extern int pr_door_info(struct ps_prochandle *, int, struct door_info *);
duke@435 239 extern void *pr_mmap(struct ps_prochandle *,
duke@435 240 void *, size_t, int, int, int, off_t);
duke@435 241 extern void *pr_zmap(struct ps_prochandle *,
duke@435 242 void *, size_t, int, int);
duke@435 243 extern int pr_munmap(struct ps_prochandle *, void *, size_t);
duke@435 244 extern int pr_memcntl(struct ps_prochandle *,
duke@435 245 caddr_t, size_t, int, caddr_t, int, int);
duke@435 246 extern int pr_sigaction(struct ps_prochandle *,
duke@435 247 int, const struct sigaction *, struct sigaction *);
duke@435 248 extern int pr_getitimer(struct ps_prochandle *,
duke@435 249 int, struct itimerval *);
duke@435 250 extern int pr_setitimer(struct ps_prochandle *,
duke@435 251 int, const struct itimerval *, struct itimerval *);
duke@435 252 extern int pr_ioctl(struct ps_prochandle *, int, int, void *, size_t);
duke@435 253 extern int pr_fcntl(struct ps_prochandle *, int, int, void *);
duke@435 254 extern int pr_stat(struct ps_prochandle *, const char *, struct stat *);
duke@435 255 extern int pr_lstat(struct ps_prochandle *, const char *, struct stat *);
duke@435 256 extern int pr_fstat(struct ps_prochandle *, int, struct stat *);
duke@435 257 extern int pr_statvfs(struct ps_prochandle *, const char *, statvfs_t *);
duke@435 258 extern int pr_fstatvfs(struct ps_prochandle *, int, statvfs_t *);
duke@435 259 extern int pr_getrlimit(struct ps_prochandle *,
duke@435 260 int, struct rlimit *);
duke@435 261 extern int pr_setrlimit(struct ps_prochandle *,
duke@435 262 int, const struct rlimit *);
duke@435 263 #if defined(_LARGEFILE64_SOURCE)
duke@435 264 extern int pr_getrlimit64(struct ps_prochandle *,
duke@435 265 int, struct rlimit64 *);
duke@435 266 extern int pr_setrlimit64(struct ps_prochandle *,
duke@435 267 int, const struct rlimit64 *);
duke@435 268 #endif /* _LARGEFILE64_SOURCE */
duke@435 269 extern int pr_lwp_exit(struct ps_prochandle *);
duke@435 270 extern int pr_exit(struct ps_prochandle *, int);
duke@435 271 extern int pr_waitid(struct ps_prochandle *,
duke@435 272 idtype_t, id_t, siginfo_t *, int);
duke@435 273 extern off_t pr_lseek(struct ps_prochandle *, int, off_t, int);
duke@435 274 extern offset_t pr_llseek(struct ps_prochandle *, int, offset_t, int);
duke@435 275 extern int pr_rename(struct ps_prochandle *, const char *, const char *);
duke@435 276 extern int pr_link(struct ps_prochandle *, const char *, const char *);
duke@435 277 extern int pr_unlink(struct ps_prochandle *, const char *);
duke@435 278 extern int pr_getpeername(struct ps_prochandle *,
duke@435 279 int, struct sockaddr *, socklen_t *);
duke@435 280 extern int pr_getsockname(struct ps_prochandle *,
duke@435 281 int, struct sockaddr *, socklen_t *);
duke@435 282
duke@435 283 /*
duke@435 284 * Function prototypes for accessing per-LWP register information.
duke@435 285 */
duke@435 286 extern int Plwp_getregs(struct ps_prochandle *, lwpid_t, prgregset_t);
duke@435 287 extern int Plwp_setregs(struct ps_prochandle *, lwpid_t, const prgregset_t);
duke@435 288
duke@435 289 extern int Plwp_getfpregs(struct ps_prochandle *, lwpid_t, prfpregset_t *);
duke@435 290 extern int Plwp_setfpregs(struct ps_prochandle *, lwpid_t,
duke@435 291 const prfpregset_t *);
duke@435 292
duke@435 293 #if defined(sparc) || defined(__sparc)
duke@435 294
duke@435 295 extern int Plwp_getxregs(struct ps_prochandle *, lwpid_t, prxregset_t *);
duke@435 296 extern int Plwp_setxregs(struct ps_prochandle *, lwpid_t, const prxregset_t *);
duke@435 297
duke@435 298 #if defined(__sparcv9)
duke@435 299 extern int Plwp_getasrs(struct ps_prochandle *, lwpid_t, asrset_t);
duke@435 300 extern int Plwp_setasrs(struct ps_prochandle *, lwpid_t, const asrset_t);
duke@435 301 #endif /* __sparcv9 */
duke@435 302
duke@435 303 #endif /* __sparc */
duke@435 304
duke@435 305 extern int Plwp_getpsinfo(struct ps_prochandle *, lwpid_t, lwpsinfo_t *);
duke@435 306
duke@435 307 /*
duke@435 308 * LWP iteration interface.
duke@435 309 */
duke@435 310 typedef int proc_lwp_f(void *, const lwpstatus_t *);
duke@435 311 extern int Plwp_iter(struct ps_prochandle *, proc_lwp_f *, void *);
duke@435 312
duke@435 313 /*
duke@435 314 * Symbol table interfaces.
duke@435 315 */
duke@435 316
duke@435 317 /*
duke@435 318 * Pseudo-names passed to Plookup_by_name() for well-known load objects.
duke@435 319 * NOTE: It is required that PR_OBJ_EXEC and PR_OBJ_LDSO exactly match
duke@435 320 * the definitions of PS_OBJ_EXEC and PS_OBJ_LDSO from <proc_service.h>.
duke@435 321 */
duke@435 322 #define PR_OBJ_EXEC ((const char *)0) /* search the executable file */
duke@435 323 #define PR_OBJ_LDSO ((const char *)1) /* search ld.so.1 */
duke@435 324 #define PR_OBJ_EVERY ((const char *)-1) /* search every load object */
duke@435 325
duke@435 326 /*
duke@435 327 * 'object_name' is the name of a load object obtained from an
duke@435 328 * iteration over the process's address space mappings (Pmapping_iter),
duke@435 329 * or an iteration over the process's mapped objects (Pobject_iter),
duke@435 330 * or else it is one of the special PR_OBJ_* values above.
duke@435 331 */
duke@435 332 extern int Plookup_by_name(struct ps_prochandle *,
duke@435 333 const char *, const char *, GElf_Sym *);
duke@435 334
duke@435 335 extern int Plookup_by_addr(struct ps_prochandle *,
duke@435 336 uintptr_t, char *, size_t, GElf_Sym *);
duke@435 337
duke@435 338 typedef int proc_map_f(void *, const prmap_t *, const char *);
duke@435 339
duke@435 340 extern int Pmapping_iter(struct ps_prochandle *, proc_map_f *, void *);
duke@435 341 extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
duke@435 342
duke@435 343 extern const prmap_t *Paddr_to_map(struct ps_prochandle *, uintptr_t);
duke@435 344 extern const prmap_t *Paddr_to_text_map(struct ps_prochandle *, uintptr_t);
duke@435 345 extern const prmap_t *Pname_to_map(struct ps_prochandle *, const char *);
duke@435 346
duke@435 347 extern char *Pplatform(struct ps_prochandle *, char *, size_t);
duke@435 348 extern int Puname(struct ps_prochandle *, struct utsname *);
duke@435 349
duke@435 350 extern char *Pexecname(struct ps_prochandle *, char *, size_t);
duke@435 351 extern char *Pobjname(struct ps_prochandle *, uintptr_t, char *, size_t);
duke@435 352
duke@435 353 extern char *Pgetenv(struct ps_prochandle *, const char *, char *, size_t);
duke@435 354 extern long Pgetauxval(struct ps_prochandle *, int);
duke@435 355
duke@435 356 /*
duke@435 357 * Symbol table iteration interface.
duke@435 358 */
duke@435 359 typedef int proc_sym_f(void *, const GElf_Sym *, const char *);
duke@435 360
duke@435 361 extern int Psymbol_iter(struct ps_prochandle *,
duke@435 362 const char *, int, int, proc_sym_f *, void *);
duke@435 363
duke@435 364 /*
duke@435 365 * 'which' selects which symbol table and can be one of the following.
duke@435 366 */
duke@435 367 #define PR_SYMTAB 1
duke@435 368 #define PR_DYNSYM 2
duke@435 369 /*
duke@435 370 * 'type' selects the symbols of interest by binding and type. It is a bit-
duke@435 371 * mask of one or more of the following flags, whose order MUST match the
duke@435 372 * order of STB and STT constants in <sys/elf.h>.
duke@435 373 */
duke@435 374 #define BIND_LOCAL 0x0001
duke@435 375 #define BIND_GLOBAL 0x0002
duke@435 376 #define BIND_WEAK 0x0004
duke@435 377 #define BIND_ANY (BIND_LOCAL|BIND_GLOBAL|BIND_WEAK)
duke@435 378 #define TYPE_NOTYPE 0x0100
duke@435 379 #define TYPE_OBJECT 0x0200
duke@435 380 #define TYPE_FUNC 0x0400
duke@435 381 #define TYPE_SECTION 0x0800
duke@435 382 #define TYPE_FILE 0x1000
duke@435 383 #define TYPE_ANY (TYPE_NOTYPE|TYPE_OBJECT|TYPE_FUNC|TYPE_SECTION|TYPE_FILE)
duke@435 384
duke@435 385 /*
duke@435 386 * This returns the rtld_db agent handle for the process.
duke@435 387 * The handle will become invalid at the next successful exec() and
duke@435 388 * must not be used beyond that point (see Preset_maps(), below).
duke@435 389 */
duke@435 390 extern rd_agent_t *Prd_agent(struct ps_prochandle *);
duke@435 391
duke@435 392 /*
duke@435 393 * This should be called when an RD_DLACTIVITY event with the
duke@435 394 * RD_CONSISTENT state occurs via librtld_db's event mechanism.
duke@435 395 * This makes libproc's address space mappings and symbol tables current.
duke@435 396 */
duke@435 397 extern void Pupdate_maps(struct ps_prochandle *);
duke@435 398
duke@435 399 /*
duke@435 400 * This must be called after the victim process performs a successful
duke@435 401 * exec() if any of the symbol table interface functions have been called
duke@435 402 * prior to that point. This is essential because an exec() invalidates
duke@435 403 * all previous symbol table and address space mapping information.
duke@435 404 * It is always safe to call, but if it is called other than after an
duke@435 405 * exec() by the victim process it just causes unnecessary overhead.
duke@435 406 *
duke@435 407 * The rtld_db agent handle obtained from a previous call to Prd_agent() is
duke@435 408 * made invalid by Preset_maps() and Prd_agent() must be called again to get
duke@435 409 * the new handle.
duke@435 410 */
duke@435 411 extern void Preset_maps(struct ps_prochandle *);
duke@435 412
duke@435 413 /*
duke@435 414 * Given an address, Ppltdest() determines if this is part of a PLT, and if
duke@435 415 * so returns the target address of this PLT entry and a flag indicating
duke@435 416 * whether or not this PLT entry has been bound by the run-time linker.
duke@435 417 */
duke@435 418 extern uintptr_t Ppltdest(struct ps_prochandle *, uintptr_t, int *);
duke@435 419
duke@435 420 /*
duke@435 421 * Stack frame iteration interface.
duke@435 422 */
duke@435 423 typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
duke@435 424
duke@435 425 extern int Pstack_iter(struct ps_prochandle *,
duke@435 426 const prgregset_t, proc_stack_f *, void *);
duke@435 427
duke@435 428 /*
duke@435 429 * Compute the full pathname of a named directory without using chdir().
duke@435 430 * This is useful for dealing with /proc/<pid>/cwd.
duke@435 431 */
duke@435 432 extern char *proc_dirname(const char *, char *, size_t);
duke@435 433
duke@435 434 /*
duke@435 435 * Remove unprintable characters from psinfo.pr_psargs and replace with
duke@435 436 * whitespace characters so it is safe for printing.
duke@435 437 */
duke@435 438 extern void proc_unctrl_psinfo(psinfo_t *);
duke@435 439
duke@435 440 /*
duke@435 441 * Utility functions for processing arguments which should be /proc files,
duke@435 442 * pids, and/or core files. The returned error code can be passed to
duke@435 443 * Pgrab_error() in order to convert it to an error string.
duke@435 444 */
duke@435 445 #define PR_ARG_PIDS 0x1 /* Allow pid and /proc file arguments */
duke@435 446 #define PR_ARG_CORES 0x2 /* Allow core file arguments */
duke@435 447
duke@435 448 #define PR_ARG_ANY (PR_ARG_PIDS | PR_ARG_CORES)
duke@435 449
duke@435 450 extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *);
duke@435 451 extern pid_t proc_arg_psinfo(const char *, int, psinfo_t *, int *);
duke@435 452
duke@435 453 /*
duke@435 454 * Utility functions for obtaining information via /proc without actually
duke@435 455 * performing a Pcreate() or Pgrab():
duke@435 456 */
duke@435 457 extern int proc_get_auxv(pid_t, auxv_t *, int);
duke@435 458 extern int proc_get_cred(pid_t, prcred_t *, int);
duke@435 459 extern int proc_get_psinfo(pid_t, psinfo_t *);
duke@435 460 extern int proc_get_status(pid_t, pstatus_t *);
duke@435 461
duke@435 462 /*
duke@435 463 * Utility functions for debugging tools to convert numeric fault,
duke@435 464 * signal, and system call numbers to symbolic names:
duke@435 465 */
duke@435 466 extern char *proc_fltname(int, char *, size_t);
duke@435 467 extern char *proc_signame(int, char *, size_t);
duke@435 468 extern char *proc_sysname(int, char *, size_t);
duke@435 469
duke@435 470 #ifdef __cplusplus
duke@435 471 }
duke@435 472 #endif
duke@435 473
duke@435 474 #endif /* _LIBPROC_H */

mercurial