libproc.h revision 184697
1179185Sjb/*- 2179185Sjb * Copyright (c) 2008 John Birrell (jb@freebsd.org) 3179185Sjb * All rights reserved. 4179185Sjb * 5179185Sjb * Redistribution and use in source and binary forms, with or without 6179185Sjb * modification, are permitted provided that the following conditions 7179185Sjb * are met: 8179185Sjb * 1. Redistributions of source code must retain the above copyright 9179185Sjb * notice, this list of conditions and the following disclaimer. 10179185Sjb * 2. Redistributions in binary form must reproduce the above copyright 11179185Sjb * notice, this list of conditions and the following disclaimer in the 12179185Sjb * documentation and/or other materials provided with the distribution. 13179185Sjb * 14179185Sjb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15179185Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16179185Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17179185Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18179185Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19179185Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20179185Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21179185Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22179185Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23179185Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24179185Sjb * SUCH DAMAGE. 25179185Sjb * 26179185Sjb * $FreeBSD: head/lib/libproc/libproc.h 184697 2008-11-05 19:35:43Z rodrigc $ 27179185Sjb */ 28179185Sjb 29179185Sjb#ifndef _LIBPROC_H_ 30179185Sjb#define _LIBPROC_H_ 31179185Sjb 32179185Sjb#include <gelf.h> 33179185Sjb 34179185Sjbstruct proc_handle; 35179185Sjb 36184697Srodrigctypedef void (*proc_child_func)(void *); 37184697Srodrigc 38179185Sjb/* Values returned by proc_state(). */ 39179185Sjb#define PS_IDLE 1 40179185Sjb#define PS_STOP 2 41179185Sjb#define PS_RUN 3 42179185Sjb#define PS_UNDEAD 4 43179185Sjb#define PS_DEAD 5 44179185Sjb#define PS_LOST 6 45179185Sjb 46179185Sjbtypedef struct prmap { 47179185Sjb uintptr_t pr_vaddr; /* Virtual address. */ 48179185Sjb} prmap_t; 49179185Sjb 50179185Sjb/* Function prototype definitions. */ 51179185Sjb__BEGIN_DECLS 52179185Sjb 53179185Sjbconst prmap_t *proc_addr2map(struct proc_handle *, uintptr_t); 54179185Sjbconst prmap_t *proc_name2map(struct proc_handle *, const char *); 55179185Sjbchar *proc_objname(struct proc_handle *, uintptr_t, char *, size_t); 56179185Sjbint proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *); 57179185Sjbint proc_attach(pid_t pid, int flags, struct proc_handle **pphdl); 58179185Sjbint proc_continue(struct proc_handle *); 59179185Sjbint proc_clearflags(struct proc_handle *, int); 60184697Srodrigcint proc_create(const char *, char * const *, proc_child_func *, void *, 61184697Srodrigc struct proc_handle **); 62179185Sjbint proc_detach(struct proc_handle *); 63179185Sjbint proc_getflags(struct proc_handle *); 64179185Sjbint proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); 65179185Sjbint proc_setflags(struct proc_handle *, int); 66179185Sjbint proc_state(struct proc_handle *); 67179185Sjbint proc_wait(struct proc_handle *); 68179185Sjbpid_t proc_getpid(struct proc_handle *); 69179185Sjbvoid proc_free(struct proc_handle *); 70179185Sjb 71179185Sjb__END_DECLS 72179185Sjb 73179185Sjb#endif /* !_LIBPROC_H_ */ 74