12c633af4SJohn Birrell /*- 22c633af4SJohn Birrell * Copyright (c) 2008 John Birrell (jb@freebsd.org) 32c633af4SJohn Birrell * All rights reserved. 42c633af4SJohn Birrell * 52c633af4SJohn Birrell * Redistribution and use in source and binary forms, with or without 62c633af4SJohn Birrell * modification, are permitted provided that the following conditions 72c633af4SJohn Birrell * are met: 82c633af4SJohn Birrell * 1. Redistributions of source code must retain the above copyright 92c633af4SJohn Birrell * notice, this list of conditions and the following disclaimer. 102c633af4SJohn Birrell * 2. Redistributions in binary form must reproduce the above copyright 112c633af4SJohn Birrell * notice, this list of conditions and the following disclaimer in the 122c633af4SJohn Birrell * documentation and/or other materials provided with the distribution. 132c633af4SJohn Birrell * 142c633af4SJohn Birrell * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 152c633af4SJohn Birrell * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 162c633af4SJohn Birrell * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172c633af4SJohn Birrell * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 182c633af4SJohn Birrell * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 192c633af4SJohn Birrell * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 202c633af4SJohn Birrell * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 212c633af4SJohn Birrell * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 222c633af4SJohn Birrell * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 232c633af4SJohn Birrell * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 242c633af4SJohn Birrell * SUCH DAMAGE. 252c633af4SJohn Birrell * 262c633af4SJohn Birrell * $FreeBSD$ 272c633af4SJohn Birrell */ 282c633af4SJohn Birrell 292c633af4SJohn Birrell #ifndef _LIBPROC_H_ 302c633af4SJohn Birrell #define _LIBPROC_H_ 312c633af4SJohn Birrell 322c633af4SJohn Birrell #include <gelf.h> 332c633af4SJohn Birrell 342c633af4SJohn Birrell struct proc_handle; 352c633af4SJohn Birrell 362c633af4SJohn Birrell /* Values returned by proc_state(). */ 372c633af4SJohn Birrell #define PS_IDLE 1 382c633af4SJohn Birrell #define PS_STOP 2 392c633af4SJohn Birrell #define PS_RUN 3 402c633af4SJohn Birrell #define PS_UNDEAD 4 412c633af4SJohn Birrell #define PS_DEAD 5 422c633af4SJohn Birrell #define PS_LOST 6 432c633af4SJohn Birrell 442c633af4SJohn Birrell typedef struct prmap { 452c633af4SJohn Birrell uintptr_t pr_vaddr; /* Virtual address. */ 462c633af4SJohn Birrell } prmap_t; 472c633af4SJohn Birrell 482c633af4SJohn Birrell /* Function prototype definitions. */ 492c633af4SJohn Birrell __BEGIN_DECLS 502c633af4SJohn Birrell 512c633af4SJohn Birrell const prmap_t *proc_addr2map(struct proc_handle *, uintptr_t); 522c633af4SJohn Birrell const prmap_t *proc_name2map(struct proc_handle *, const char *); 532c633af4SJohn Birrell char *proc_objname(struct proc_handle *, uintptr_t, char *, size_t); 542c633af4SJohn Birrell int proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *); 552c633af4SJohn Birrell int proc_attach(pid_t pid, int flags, struct proc_handle **pphdl); 562c633af4SJohn Birrell int proc_continue(struct proc_handle *); 572c633af4SJohn Birrell int proc_clearflags(struct proc_handle *, int); 582c633af4SJohn Birrell int proc_create(const char *, char * const *, struct proc_handle **); 592c633af4SJohn Birrell int proc_detach(struct proc_handle *); 602c633af4SJohn Birrell int proc_getflags(struct proc_handle *); 612c633af4SJohn Birrell int proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); 622c633af4SJohn Birrell int proc_setflags(struct proc_handle *, int); 632c633af4SJohn Birrell int proc_state(struct proc_handle *); 642c633af4SJohn Birrell int proc_wait(struct proc_handle *); 652c633af4SJohn Birrell pid_t proc_getpid(struct proc_handle *); 662c633af4SJohn Birrell void proc_free(struct proc_handle *); 672c633af4SJohn Birrell 682c633af4SJohn Birrell __END_DECLS 692c633af4SJohn Birrell 702c633af4SJohn Birrell #endif /* !_LIBPROC_H_ */ 71