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 29fcf9fc10SMark Johnston #ifndef __LIBPROC_H_ 30fcf9fc10SMark Johnston #define __LIBPROC_H_ 31fcf9fc10SMark Johnston 322c633af4SJohn Birrell #include <sys/types.h> 332c633af4SJohn Birrell #include <sys/ptrace.h> 34700244a2SMark Johnston 35*07a9c2e6SMark Johnston #include <libelf.h> 368eb20f36SRui Paulo #include <rtld_db.h> 372c633af4SJohn Birrell 382c633af4SJohn Birrell #include "libproc.h" 392c633af4SJohn Birrell 404808a678SMark Johnston struct procstat; 414808a678SMark Johnston 42*07a9c2e6SMark Johnston struct file_info { 43*07a9c2e6SMark Johnston Elf *elf; 44*07a9c2e6SMark Johnston int fd; 45*07a9c2e6SMark Johnston u_int refs; 46*07a9c2e6SMark Johnston }; 47*07a9c2e6SMark Johnston 48*07a9c2e6SMark Johnston struct map_info { 49*07a9c2e6SMark Johnston prmap_t map; 50*07a9c2e6SMark Johnston struct file_info *file; 51*07a9c2e6SMark Johnston }; 52*07a9c2e6SMark Johnston 532c633af4SJohn Birrell struct proc_handle { 54b1bb30e5SMark Johnston struct proc_handle_public public; /* Public fields. */ 552c633af4SJohn Birrell int flags; /* Process flags. */ 562c633af4SJohn Birrell int status; /* Process status (PS_*). */ 578eb20f36SRui Paulo int wstat; /* Process wait status. */ 584808a678SMark Johnston int model; /* Process data model. */ 598eb20f36SRui Paulo rd_agent_t *rdap; /* librtld_db agent */ 60*07a9c2e6SMark Johnston struct map_info *mappings; /* File mappings for proc. */ 61*07a9c2e6SMark Johnston size_t maparrsz; /* Map array size. */ 62*07a9c2e6SMark Johnston size_t nmappings; /* Number of mappings. */ 63*07a9c2e6SMark Johnston prmap_t *exec_map; /* Executable text mapping. */ 64*07a9c2e6SMark Johnston lwpstatus_t lwps; /* Process status. */ 654808a678SMark Johnston struct procstat *procstat; /* libprocstat handle. */ 66*07a9c2e6SMark Johnston char execpath[PATH_MAX]; /* Path to program executable. */ 672c633af4SJohn Birrell }; 682c633af4SJohn Birrell 698eb20f36SRui Paulo #ifdef DEBUG 7025aecfbbSMark Johnston #define DPRINTF(...) warn(__VA_ARGS__) 7130e81f7eSMark Johnston #define DPRINTFX(...) warnx(__VA_ARGS__) 728eb20f36SRui Paulo #else 73fb15925cSMark Johnston #define DPRINTF(...) do { } while (0) 74fb15925cSMark Johnston #define DPRINTFX(...) do { } while (0) 758eb20f36SRui Paulo #endif 76fcf9fc10SMark Johnston 77fcf9fc10SMark Johnston #endif /* __LIBPROC_H_ */ 78