libproc.h revision 179185
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 179185 2008-05-22 02:09:21Z jb $ 27179185Sjb */ 28179185Sjb 29179185Sjb#ifndef _LIBPROC_H_ 30179185Sjb#define _LIBPROC_H_ 31179185Sjb 32179185Sjb#include <gelf.h> 33179185Sjb 34179185Sjbstruct proc_handle; 35179185Sjb 36179185Sjb/* Values returned by proc_state(). */ 37179185Sjb#define PS_IDLE 1 38179185Sjb#define PS_STOP 2 39179185Sjb#define PS_RUN 3 40179185Sjb#define PS_UNDEAD 4 41179185Sjb#define PS_DEAD 5 42179185Sjb#define PS_LOST 6 43179185Sjb 44179185Sjbtypedef struct prmap { 45179185Sjb uintptr_t pr_vaddr; /* Virtual address. */ 46179185Sjb} prmap_t; 47179185Sjb 48179185Sjb/* Function prototype definitions. */ 49179185Sjb__BEGIN_DECLS 50179185Sjb 51179185Sjbconst prmap_t *proc_addr2map(struct proc_handle *, uintptr_t); 52179185Sjbconst prmap_t *proc_name2map(struct proc_handle *, const char *); 53179185Sjbchar *proc_objname(struct proc_handle *, uintptr_t, char *, size_t); 54179185Sjbint proc_addr2sym(struct proc_handle *, uintptr_t, char *, size_t, GElf_Sym *); 55179185Sjbint proc_attach(pid_t pid, int flags, struct proc_handle **pphdl); 56179185Sjbint proc_continue(struct proc_handle *); 57179185Sjbint proc_clearflags(struct proc_handle *, int); 58179185Sjbint proc_create(const char *, char * const *, struct proc_handle **); 59179185Sjbint proc_detach(struct proc_handle *); 60179185Sjbint proc_getflags(struct proc_handle *); 61179185Sjbint proc_name2sym(struct proc_handle *, const char *, const char *, GElf_Sym *); 62179185Sjbint proc_setflags(struct proc_handle *, int); 63179185Sjbint proc_state(struct proc_handle *); 64179185Sjbint proc_wait(struct proc_handle *); 65179185Sjbpid_t proc_getpid(struct proc_handle *); 66179185Sjbvoid proc_free(struct proc_handle *); 67179185Sjb 68179185Sjb__END_DECLS 69179185Sjb 70179185Sjb#endif /* !_LIBPROC_H_ */ 71