📄 libproc.h
字号:
const prfpregset_t *);#if defined(__sparc)extern int Plwp_getxregs(struct ps_prochandle *, lwpid_t, prxregset_t *);extern int Plwp_setxregs(struct ps_prochandle *, lwpid_t, const prxregset_t *);extern int Plwp_getgwindows(struct ps_prochandle *, lwpid_t, gwindows_t *);#if defined(__sparcv9)extern int Plwp_getasrs(struct ps_prochandle *, lwpid_t, asrset_t);extern int Plwp_setasrs(struct ps_prochandle *, lwpid_t, const asrset_t);#endif /* __sparcv9 */#endif /* __sparc */#if defined(__i386) || defined(__amd64)extern int Pldt(struct ps_prochandle *, struct ssd *, int);extern int proc_get_ldt(pid_t, struct ssd *, int);#endif /* __i386 || __amd64 */extern int Plwp_getpsinfo(struct ps_prochandle *, lwpid_t, lwpsinfo_t *);extern int Plwp_stack(struct ps_prochandle *, lwpid_t, stack_t *);extern int Plwp_main_stack(struct ps_prochandle *, lwpid_t, stack_t *);extern int Plwp_alt_stack(struct ps_prochandle *, lwpid_t, stack_t *);/* * LWP iteration interface; iterate over all active LWPs. */typedef int proc_lwp_f(void *, const lwpstatus_t *);extern int Plwp_iter(struct ps_prochandle *, proc_lwp_f *, void *);/* * LWP iteration interface; iterate over all LWPs, active and zombie. */typedef int proc_lwp_all_f(void *, const lwpstatus_t *, const lwpsinfo_t *);extern int Plwp_iter_all(struct ps_prochandle *, proc_lwp_all_f *, void *);/* * Process iteration interface; iterate over all active processes. */typedef int proc_walk_f(psinfo_t *, lwpsinfo_t *, void *);extern int proc_walk(proc_walk_f *, void *, int);#define PR_WALK_PROC 0 /* walk processes only */#define PR_WALK_LWP 1 /* walk all lwps *//* * Determine if an lwp is in a set as returned from proc_arg_xgrab(). */extern int proc_lwp_in_set(const char *, lwpid_t);extern int proc_lwp_range_valid(const char *);/* * Symbol table interfaces. *//* * Pseudo-names passed to Plookup_by_name() for well-known load objects. * NOTE: It is required that PR_OBJ_EXEC and PR_OBJ_LDSO exactly match * the definitions of PS_OBJ_EXEC and PS_OBJ_LDSO from <proc_service.h>. */#define PR_OBJ_EXEC ((const char *)0) /* search the executable file */#define PR_OBJ_LDSO ((const char *)1) /* search ld.so.1 */#define PR_OBJ_EVERY ((const char *)-1) /* search every load object *//* * Special Lmid_t passed to Plookup_by_lmid() to search all link maps. The * special values LM_ID_BASE and LM_ID_LDSO from <link.h> may also be used. * If PR_OBJ_EXEC is used as the object name, the lmid must be PR_LMID_EVERY * or LM_ID_BASE in order to return a match. If PR_OBJ_LDSO is used as the * object name, the lmid must be PR_LMID_EVERY or LM_ID_LDSO to return a match. */#define PR_LMID_EVERY ((Lmid_t)-1UL) /* search every link map *//* * 'object_name' is the name of a load object obtained from an * iteration over the process's address space mappings (Pmapping_iter), * or an iteration over the process's mapped objects (Pobject_iter), * or else it is one of the special PR_OBJ_* values above. */extern int Plookup_by_name(struct ps_prochandle *, const char *, const char *, GElf_Sym *);extern int Plookup_by_addr(struct ps_prochandle *, uintptr_t, char *, size_t, GElf_Sym *);typedef struct prsyminfo { const char *prs_object; /* object name */ const char *prs_name; /* symbol name */ Lmid_t prs_lmid; /* link map id */ uint_t prs_id; /* symbol id */ uint_t prs_table; /* symbol table id */} prsyminfo_t;extern int Pxlookup_by_name(struct ps_prochandle *, Lmid_t, const char *, const char *, GElf_Sym *, prsyminfo_t *);extern int Pxlookup_by_addr(struct ps_prochandle *, uintptr_t, char *, size_t, GElf_Sym *, prsyminfo_t *);typedef int proc_map_f(void *, const prmap_t *, const char *);extern int Pmapping_iter(struct ps_prochandle *, proc_map_f *, void *);extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);extern const prmap_t *Paddr_to_map(struct ps_prochandle *, uintptr_t);extern const prmap_t *Paddr_to_text_map(struct ps_prochandle *, uintptr_t);extern const prmap_t *Pname_to_map(struct ps_prochandle *, const char *);extern const prmap_t *Plmid_to_map(struct ps_prochandle *, Lmid_t, const char *);extern const rd_loadobj_t *Paddr_to_loadobj(struct ps_prochandle *, uintptr_t);extern const rd_loadobj_t *Pname_to_loadobj(struct ps_prochandle *, const char *);extern const rd_loadobj_t *Plmid_to_loadobj(struct ps_prochandle *, Lmid_t, const char *);extern ctf_file_t *Paddr_to_ctf(struct ps_prochandle *, uintptr_t);extern ctf_file_t *Pname_to_ctf(struct ps_prochandle *, const char *);extern char *Pplatform(struct ps_prochandle *, char *, size_t);extern int Puname(struct ps_prochandle *, struct utsname *);extern char *Pzonename(struct ps_prochandle *, char *, size_t);extern char *Pexecname(struct ps_prochandle *, char *, size_t);extern char *Pobjname(struct ps_prochandle *, uintptr_t, char *, size_t);extern int Plmid(struct ps_prochandle *, uintptr_t, Lmid_t *);typedef int proc_env_f(void *, struct ps_prochandle *, uintptr_t, const char *);extern int Penv_iter(struct ps_prochandle *, proc_env_f *, void *);extern char *Pgetenv(struct ps_prochandle *, const char *, char *, size_t);extern long Pgetauxval(struct ps_prochandle *, int);extern const auxv_t *Pgetauxvec(struct ps_prochandle *);/* * Symbol table iteration interface. The special lmid constants LM_ID_BASE, * LM_ID_LDSO, and PR_LMID_EVERY may be used with Psymbol_iter_by_lmid. */typedef int proc_sym_f(void *, const GElf_Sym *, const char *);typedef int proc_xsym_f(void *, const GElf_Sym *, const char *, const prsyminfo_t *);extern int Psymbol_iter(struct ps_prochandle *, const char *, int, int, proc_sym_f *, void *);extern int Psymbol_iter_by_addr(struct ps_prochandle *, const char *, int, int, proc_sym_f *, void *);extern int Psymbol_iter_by_name(struct ps_prochandle *, const char *, int, int, proc_sym_f *, void *);extern int Psymbol_iter_by_lmid(struct ps_prochandle *, Lmid_t, const char *, int, int, proc_sym_f *, void *);extern int Pxsymbol_iter(struct ps_prochandle *, Lmid_t, const char *, int, int, proc_xsym_f *, void *);/* * 'which' selects which symbol table and can be one of the following. */#define PR_SYMTAB 1#define PR_DYNSYM 2/* * 'type' selects the symbols of interest by binding and type. It is a bit- * mask of one or more of the following flags, whose order MUST match the * order of STB and STT constants in <sys/elf.h>. */#define BIND_LOCAL 0x0001#define BIND_GLOBAL 0x0002#define BIND_WEAK 0x0004#define BIND_ANY (BIND_LOCAL|BIND_GLOBAL|BIND_WEAK)#define TYPE_NOTYPE 0x0100#define TYPE_OBJECT 0x0200#define TYPE_FUNC 0x0400#define TYPE_SECTION 0x0800#define TYPE_FILE 0x1000#define TYPE_ANY (TYPE_NOTYPE|TYPE_OBJECT|TYPE_FUNC|TYPE_SECTION|TYPE_FILE)/* * This returns the rtld_db agent handle for the process. * The handle will become invalid at the next successful exec() and * must not be used beyond that point (see Preset_maps(), below). */extern rd_agent_t *Prd_agent(struct ps_prochandle *);/* * This should be called when an RD_DLACTIVITY event with the * RD_CONSISTENT state occurs via librtld_db's event mechanism. * This makes libproc's address space mappings and symbol tables current. * The variant Pupdate_syms() can be used to preload all symbol tables as well. */extern void Pupdate_maps(struct ps_prochandle *);extern void Pupdate_syms(struct ps_prochandle *);/* * This must be called after the victim process performs a successful * exec() if any of the symbol table interface functions have been called * prior to that point. This is essential because an exec() invalidates * all previous symbol table and address space mapping information. * It is always safe to call, but if it is called other than after an * exec() by the victim process it just causes unnecessary overhead. * * The rtld_db agent handle obtained from a previous call to Prd_agent() is * made invalid by Preset_maps() and Prd_agent() must be called again to get * the new handle. */extern void Preset_maps(struct ps_prochandle *);/* * Given an address, Ppltdest() determines if this is part of a PLT, and if * so returns a pointer to the symbol name that will be used for resolution. * If the specified address is not part of a PLT, the function returns NULL. */extern const char *Ppltdest(struct ps_prochandle *, uintptr_t);/* * See comments for Pissyscall(), in Pisadep.h */extern int Pissyscall_prev(struct ps_prochandle *, uintptr_t, uintptr_t *);/* * Stack frame iteration interface. */typedef int proc_stack_f(void *, prgregset_t, uint_t, const long *);extern int Pstack_iter(struct ps_prochandle *, const prgregset_t, proc_stack_f *, void *);/* * The following functions define a set of passive interfaces: libproc provides * default, empty definitions that are called internally. If a client wishes * to override these definitions, it can simply provide its own version with * the same signature that interposes on the libproc definition. * * If the client program wishes to report additional error information, it * can provide its own version of Perror_printf. * * If the client program wishes to receive a callback after Pcreate forks * but before it execs, it can provide its own version of Pcreate_callback. */extern void Perror_printf(struct ps_prochandle *P, const char *format, ...);extern void Pcreate_callback(struct ps_prochandle *);/* * Remove unprintable characters from psinfo.pr_psargs and replace with * whitespace characters so it is safe for printing. */extern void proc_unctrl_psinfo(psinfo_t *);/* * Utility functions for processing arguments which should be /proc files, * pids, and/or core files. The returned error code can be passed to * Pgrab_error() in order to convert it to an error string. */#define PR_ARG_PIDS 0x1 /* Allow pid and /proc file arguments */#define PR_ARG_CORES 0x2 /* Allow core file arguments */#define PR_ARG_ANY (PR_ARG_PIDS | PR_ARG_CORES)extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *);extern struct ps_prochandle *proc_arg_xgrab(const char *, const char *, int, int, int *, const char **);extern pid_t proc_arg_psinfo(const char *, int, psinfo_t *, int *);extern pid_t proc_arg_xpsinfo(const char *, int, psinfo_t *, int *, const char **);/* * Utility functions for obtaining information via /proc without actually * performing a Pcreate() or Pgrab(): */extern int proc_get_auxv(pid_t, auxv_t *, int);extern int proc_get_cred(pid_t, prcred_t *, int);extern prpriv_t *proc_get_priv(pid_t);extern int proc_get_psinfo(pid_t, psinfo_t *);extern int proc_get_status(pid_t, pstatus_t *);/* * Utility functions for debugging tools to convert numeric fault, * signal, and system call numbers to symbolic names: */#define FLT2STR_MAX 32 /* max. string length of faults (like SIG2STR_MAX) */#define SYS2STR_MAX 32 /* max. string length of syscalls (like SIG2STR_MAX) */extern char *proc_fltname(int, char *, size_t);extern char *proc_signame(int, char *, size_t);extern char *proc_sysname(int, char *, size_t);/* * Utility functions for debugging tools to convert fault, signal, and system * call names back to the numeric constants: */extern int proc_str2flt(const char *, int *);extern int proc_str2sig(const char *, int *);extern int proc_str2sys(const char *, int *);/* * Utility functions for debugging tools to convert a fault, signal or system * call set to a string representation (e.g. "BUS,SEGV" or "open,close,read"). */#define PRSIGBUFSZ 1024 /* buffer size for proc_sigset2str() */extern char *proc_fltset2str(const fltset_t *, const char *, int, char *, size_t);extern char *proc_sigset2str(const sigset_t *, const char *, int, char *, size_t);extern char *proc_sysset2str(const sysset_t *, const char *, int, char *, size_t);extern int Pgcore(struct ps_prochandle *, const char *, core_content_t);extern int Pfgcore(struct ps_prochandle *, int, core_content_t);extern core_content_t Pcontent(struct ps_prochandle *);/* * Utility functions for debugging tools to convert a string representation of * a fault, signal or system call set back to the numeric value of the * corresponding set type. */extern char *proc_str2fltset(const char *, const char *, int, fltset_t *);extern char *proc_str2sigset(const char *, const char *, int, sigset_t *);extern char *proc_str2sysset(const char *, const char *, int, sysset_t *);/* * Utility functions for converting between strings and core_content_t. */#define PRCONTENTBUFSZ 80 /* buffer size for proc_content2str() */extern int proc_str2content(const char *, core_content_t *);extern int proc_content2str(core_content_t, char *, size_t);/* * Utility functions for buffering output to stdout, stderr while * process is grabbed. Prevents deadlocks due to pfiles `pgrep xterm` * and other varients. */extern int proc_initstdio(void);extern int proc_flushstdio(void);extern int proc_finistdio(void);#ifdef __cplusplus}#endif#endif /* _LIBPROC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -