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 #include <sys/types.h> 302c633af4SJohn Birrell #include <sys/ptrace.h> 31700244a2SMark Johnston 328eb20f36SRui Paulo #include <rtld_db.h> 332c633af4SJohn Birrell 342c633af4SJohn Birrell #include "libproc.h" 352c633af4SJohn Birrell 36*4808a678SMark Johnston struct procstat; 37*4808a678SMark Johnston 382c633af4SJohn Birrell struct proc_handle { 392c633af4SJohn Birrell pid_t pid; /* Process ID. */ 402c633af4SJohn Birrell int flags; /* Process flags. */ 412c633af4SJohn Birrell int status; /* Process status (PS_*). */ 428eb20f36SRui Paulo int wstat; /* Process wait status. */ 43*4808a678SMark Johnston int model; /* Process data model. */ 448eb20f36SRui Paulo rd_agent_t *rdap; /* librtld_db agent */ 45700244a2SMark Johnston rd_loadobj_t *rdobjs; /* Array of loaded objects. */ 46700244a2SMark Johnston size_t rdobjsz; /* Array size. */ 47700244a2SMark Johnston size_t nobjs; /* Num. objects currently loaded. */ 48700244a2SMark Johnston rd_loadobj_t *rdexec; /* rdobj for program executable. */ 49700244a2SMark Johnston struct lwpstatus lwps; /* Process status. */ 50*4808a678SMark Johnston struct procstat *procstat; /* libprocstat handle. */ 51*4808a678SMark Johnston char execpath[MAXPATHLEN]; /* Path to program executable. */ 522c633af4SJohn Birrell }; 532c633af4SJohn Birrell 548eb20f36SRui Paulo #ifdef DEBUG 5525aecfbbSMark Johnston #define DPRINTF(...) warn(__VA_ARGS__) 5630e81f7eSMark Johnston #define DPRINTFX(...) warnx(__VA_ARGS__) 578eb20f36SRui Paulo #else 58fb15925cSMark Johnston #define DPRINTF(...) do { } while (0) 59fb15925cSMark Johnston #define DPRINTFX(...) do { } while (0) 608eb20f36SRui Paulo #endif 61