libproc.h (184697) | libproc.h (210688) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2010 The FreeBSD Foundation |
|
2 * Copyright (c) 2008 John Birrell (jb@freebsd.org) 3 * All rights reserved. 4 * | 3 * Copyright (c) 2008 John Birrell (jb@freebsd.org) 4 * All rights reserved. 5 * |
6 * Portions of this software were developed by Rui Paulo under sponsorship 7 * from the FreeBSD Foundation. 8 * |
|
5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. --- 5 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. --- 5 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * |
26 * $FreeBSD: head/lib/libproc/libproc.h 184697 2008-11-05 19:35:43Z rodrigc $ | 30 * $FreeBSD: head/lib/libproc/libproc.h 210688 2010-07-31 16:10:20Z rpaulo $ |
27 */ 28 29#ifndef _LIBPROC_H_ 30#define _LIBPROC_H_ 31 32#include <gelf.h> | 31 */ 32 33#ifndef _LIBPROC_H_ 34#define _LIBPROC_H_ 35 36#include <gelf.h> |
37#include <rtld_db.h> 38#include <limits.h> |
|
33 34struct proc_handle; 35 36typedef void (*proc_child_func)(void *); 37 38/* Values returned by proc_state(). */ 39#define PS_IDLE 1 40#define PS_STOP 2 41#define PS_RUN 3 42#define PS_UNDEAD 4 43#define PS_DEAD 5 44#define PS_LOST 6 45 | 39 40struct proc_handle; 41 42typedef void (*proc_child_func)(void *); 43 44/* Values returned by proc_state(). */ 45#define PS_IDLE 1 46#define PS_STOP 2 47#define PS_RUN 3 48#define PS_UNDEAD 4 49#define PS_DEAD 5 50#define PS_LOST 6 51 |
52/* Reason values for proc_detach(). */ 53#define PRELEASE_HANG 1 54#define PRELEASE_KILL 2 55 |
|
46typedef struct prmap { 47 uintptr_t pr_vaddr; /* Virtual address. */ | 56typedef struct prmap { 57 uintptr_t pr_vaddr; /* Virtual address. */ |
58 size_t pr_size; /* Mapping size in bytes */ 59 size_t pr_offset; /* Mapping offset in object */ 60 char pr_mapname[PATH_MAX]; /* Mapping filename */ 61 uint8_t pr_mflags; /* Protection flags */ 62#define MA_READ 0x01 63#define MA_WRITE 0x02 64#define MA_EXEC 0x04 65#define MA_COW 0x08 66#define MA_NEEDS_COPY 0x10 67#define MA_NOCOREDUMP 0x20 |
|
48} prmap_t; 49 | 68} prmap_t; 69 |
70typedef int proc_map_f(void *, const prmap_t *, const char *); 71typedef int proc_sym_f(void *, const GElf_Sym *, const char *); 72 73/* Values for ELF sections */ 74#define PR_SYMTAB 1 75#define PR_DYNSYM 2 76 77/* Values for the 'mask' parameter in the iteration functions */ 78#define BIND_LOCAL 0x0001 79#define BIND_GLOBAL 0x0002 80#define BIND_WEAK 0x0004 81#define BIND_ANY (BIND_LOCAL|BIND_GLOBAL|BIND_WEAK) 82#define TYPE_NOTYPE 0x0100 83#define TYPE_OBJECT 0x0200 84#define TYPE_FUNC 0x0400 85#define TYPE_SECTION 0x0800 86#define TYPE_FILE 0x1000 87#define TYPE_ANY (TYPE_NOTYPE|TYPE_OBJECT|TYPE_FUNC|TYPE_SECTION|\ 88 TYPE_FILE) 89 90typedef enum { 91 REG_PC, 92 REG_SP, 93 REG_RVAL1, 94 REG_RVAL2 95} proc_reg_t; 96 97#define SIG2STR_MAX 8 98 99typedef struct lwpstatus { 100 int pr_why; 101#define PR_REQUESTED 1 102#define PR_FAULTED 2 103#define PR_SYSENTRY 3 104#define PR_SYSEXIT 4 105 int pr_what; 106#define FLTBPT -1 107} lwpstatus_t; 108 |
|
50/* Function prototype definitions. */ 51__BEGIN_DECLS 52 | 109/* Function prototype definitions. */ 110__BEGIN_DECLS 111 |
53const prmap_t *proc_addr2map(struct proc_handle *, uintptr_t); 54const prmap_t *proc_name2map(struct proc_handle *, const char *); | 112prmap_t *proc_addr2map(struct proc_handle *, uintptr_t); 113prmap_t *proc_name2map(struct proc_handle *, const char *); |
55char *proc_objname(struct proc_handle *, uintptr_t, char *, size_t); | 114char *proc_objname(struct proc_handle *, uintptr_t, char *, size_t); |
115prmap_t *proc_obj2map(struct proc_handle *, const char *); 116int proc_iter_objs(struct proc_handle *, proc_map_f *, void *); 117int proc_iter_symbyaddr(struct proc_handle *, const char *, int, 118 int, proc_sym_f *, void *); |
|
56int proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *); 57int proc_attach(pid_t pid, int flags, struct proc_handle **pphdl); 58int proc_continue(struct proc_handle *); 59int proc_clearflags(struct proc_handle *, int); 60int proc_create(const char *, char * const *, proc_child_func *, void *, 61 struct proc_handle **); | 119int proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *); 120int proc_attach(pid_t pid, int flags, struct proc_handle **pphdl); 121int proc_continue(struct proc_handle *); 122int proc_clearflags(struct proc_handle *, int); 123int proc_create(const char *, char * const *, proc_child_func *, void *, 124 struct proc_handle **); |
62int proc_detach(struct proc_handle *); | 125int proc_detach(struct proc_handle *, int); |
63int proc_getflags(struct proc_handle *); 64int proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); 65int proc_setflags(struct proc_handle *, int); 66int proc_state(struct proc_handle *); | 126int proc_getflags(struct proc_handle *); 127int proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); 128int proc_setflags(struct proc_handle *, int); 129int proc_state(struct proc_handle *); |
67int proc_wait(struct proc_handle *); | |
68pid_t proc_getpid(struct proc_handle *); | 130pid_t proc_getpid(struct proc_handle *); |
131int proc_wstatus(struct proc_handle *); 132int proc_getwstat(struct proc_handle *); 133char * proc_signame(int, char *, size_t); 134int proc_read(struct proc_handle *, char *, size_t, size_t); 135const lwpstatus_t * 136 proc_getlwpstatus(struct proc_handle *); |
|
69void proc_free(struct proc_handle *); | 137void proc_free(struct proc_handle *); |
138rd_agent_t *proc_rdagent(struct proc_handle *); 139void proc_updatesyms(struct proc_handle *); 140int proc_bkptset(struct proc_handle *, uintptr_t, unsigned long *); 141int proc_bkptdel(struct proc_handle *, uintptr_t, unsigned long); 142void proc_bkptregadj(unsigned long *); 143int proc_bkptexec(struct proc_handle *, unsigned long); 144int proc_regget(struct proc_handle *, proc_reg_t, unsigned long *); 145int proc_regset(struct proc_handle *, proc_reg_t, unsigned long); |
|
70 71__END_DECLS 72 73#endif /* !_LIBPROC_H_ */ | 146 147__END_DECLS 148 149#endif /* !_LIBPROC_H_ */ |