libproc.h revision 2a12f85ad140e332791b4bad1208a734c3f26bf3
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER START
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The contents of this file are subject to the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Common Development and Distribution License (the "License").
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You may not use this file except in compliance with the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * See the License for the specific language governing permissions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and limitations under the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * When distributing Covered Code, include this CDDL HEADER in each
199767f8919635c4928607450d9e0abb932109ceToomas Soome * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If applicable, add the following below this CDDL HEADER, with the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * fields enclosed by brackets "[]" replaced with your own identifying
199767f8919635c4928607450d9e0abb932109ceToomas Soome * information: Portions Copyright [yyyy] [name of copyright owner]
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER END
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Use is subject to license terms.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Portions Copyright 2007 Chad Mynhier
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2013, Joyent, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2013 by Delphix. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Interfaces available from the process control library, libproc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * libproc provides process control functions for the /proc tools
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (commands in /usr/proc/bin), /usr/bin/truss, and /usr/bin/gcore.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * libproc is a private support library for these commands only.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * It is _not_ a public interface, although it might become one
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in the fullness of time, when the interfaces settle down.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * In the meantime, be aware that any program linked with libproc in this
199767f8919635c4928607450d9e0abb932109ceToomas Soome * release of Solaris is almost guaranteed to break in the next release.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * In short, do not use this header file or libproc for any purpose.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Opaque structure tag reference to a process control structure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Clients of libproc cannot look inside the process control structure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The implementation of struct ps_prochandle can change w/o affecting clients.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Opaque structure tag reference to an lwp control structure.
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int _libproc_debug; /* set non-zero to enable debugging fprintfs */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int _libproc_no_qsort; /* set non-zero to inhibit sorting */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* of symbol tables */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int _libproc_incore_elf; /* only use in-core elf data */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL1 R_O0 /* register holding a function return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL2 R_O1 /* 32 more bits for a 64-bit return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __sparc */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL1 REG_RAX /* register holding a function return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL2 REG_RDX /* 32 more bits for a 64-bit return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL1 EAX /* register holding a function return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL2 EDX /* 32 more bits for a 64-bit return value */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __amd64 || __i386 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define R_RVAL R_RVAL1 /* simple function return value register */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* maximum sizes of things */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRMAXSIG (32 * sizeof (sigset_t) / sizeof (uint32_t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRMAXFAULT (32 * sizeof (fltset_t) / sizeof (uint32_t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRMAXSYS (32 * sizeof (sysset_t) / sizeof (uint32_t))
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* State values returned by Pstate() */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PS_LOST 3 /* process is lost to control (EAGAIN) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PS_UNDEAD 4 /* process is terminated (zombie) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PS_DEAD 5 /* process is terminated (core file) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PS_IDLE 6 /* process has not been run */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Flags accepted by Pgrab() */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PGRAB_RETAIN 0x01 /* Retain tracing flags, else clear flags */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PGRAB_FORCE 0x02 /* Open the process w/o O_EXCL */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PGRAB_RDONLY 0x04 /* Open the process or core w/ O_RDONLY */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PGRAB_NOSTOP 0x08 /* Open the process but do not stop it */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PGRAB_INCORE 0x10 /* Use in-core data to build symbol tables */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Error codes from Pcreate() */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define C_STRANGE -1 /* Unanticipated error, errno is meaningful */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define C_PERM 2 /* No permission (file set-id or unreadable) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define C_INTR 4 /* Interrupt received while creating */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define C_LP64 5 /* Program is _LP64, self is _ILP32 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define C_NOENT 6 /* Cannot find executable file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_STRANGE -1 /* Unanticipated error, errno is meaningful */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_NOPROCORCORE 3 /* No such proc or core (for proc_arg_grab) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_NOEXEC 4 /* Cannot locate executable file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_BUSY 7 /* Another process has control */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_INTR 10 /* Interrupt received while grabbing */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_LP64 11 /* Process is _LP64, self is ILP32 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_FORMAT 12 /* File is not an ELF format core file */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_ELF 13 /* Libelf error, elf_errno() is meaningful */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_ISAINVAL 15 /* Wrong ELF machine type */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_BADLWPS 16 /* Bad '/lwps' specification */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define G_NOFD 17 /* No more file descriptors */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Flags accepted by Prelease */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRELEASE_CLEAR 0x10 /* Clear all tracing flags */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRELEASE_RETAIN 0x20 /* Retain final tracing flags */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRELEASE_HANG 0x40 /* Leave the process stopped */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PRELEASE_KILL 0x80 /* Terminate the process */
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct { /* argument descriptor for system call (Psyscall) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome long arg_value; /* value of argument given to system call */
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *arg_object; /* pointer to object in controlling process */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char arg_inout; /* AI_INPUT, AI_OUTPUT, AI_INOUT */
199767f8919635c4928607450d9e0abb932109ceToomas Soome ushort_t arg_size; /* if AT_BYREF, size of object in bytes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* values for type */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* values for inout */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* maximum number of syscall arguments */
uintptr_t, void *);
uintptr_t, void *);
typedef struct ps_ops {
} ps_ops_t;
int *, char *, size_t);
char *const *, int *, char *, size_t);
extern const char *Pcreate_error(int);
extern const char *Pgrab_error(int);
extern const char *Lgrab_error(int);
void *, size_t, int, int);
int, struct itimerval *);
struct stat64 *);
struct stat64 *);
int flags);
int, struct rlimit *);
int, const struct rlimit *);
#if defined(_LARGEFILE64_SOURCE)
int, struct rlimit64 *);
int, const struct rlimit64 *);
const prfpregset_t *);
#if defined(__sparc)
#if defined(__sparcv9)
extern int proc_lwp_range_valid(const char *);
* the definitions of PS_OBJ_EXEC and PS_OBJ_LDSO from <proc_service.h>.
* special values LM_ID_BASE and LM_ID_LDSO from <link.h> may also be used.
const char *, const char *, GElf_Sym *);
typedef struct prsyminfo {
} prsyminfo_t;
Lmid_t, const char *);
Lmid_t, const char *);
size_t);
extern void Pset_procfs_path(const char *);
const prsyminfo_t *);
const char *, int, int, proc_sym_f *, void *);
const char *, int, int, proc_sym_f *, void *);
const char *, int, int, proc_sym_f *, void *);
* See comments for Pissyscall(), in Pisadep.h
extern int proc_str2flt(const char *, int *);
extern int proc_str2sig(const char *, int *);
extern int proc_str2sys(const char *, int *);
char *, size_t);
char *, size_t);
char *, size_t);
extern int proc_initstdio(void);
extern int proc_flushstdio(void);
extern int proc_finistdio(void);
#ifdef __cplusplus