proc_service.h revision 132173
1/*
2 * Copyright (c) 2004 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by the University of
16 *	California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/include/proc_service.h 132173 2004-07-15 03:43:18Z davidxu $
34 */
35
36#ifndef _PROC_SERVICE_H_
37#define _PROC_SERVICE_H_
38
39#include <sys/types.h>
40#include <sys/procfs.h>
41
42struct ps_prochandle;
43
44typedef enum
45{
46    PS_OK,
47    PS_ERR,
48    PS_BADPID,
49    PS_BADLID,
50    PS_BADADDR,
51    PS_NOSYM,
52    PS_NOFREGS
53} ps_err_e;
54
55/*
56 * Every program that links libthread_db must provide a set of process control
57 * primitives to access memory and registers in the target process, to start
58 * and to stop the target process, and to look up symbols in the target process.
59 */
60
61#if 0
62ps_err_e ps_pdmodel(struct ps_prochandle *ph, int *data_model);
63#endif
64ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
65		const char *sym_name , psaddr_t *sym_addr);
66#if 0
67ps_err_e ps_pglobal_sym(struct ps_prochandle *ph, const char *object_name,
68		const char *sym_name , ps_sym_t *sym);
69ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
70		size_t size);
71ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
72		size_t size);
73#endif
74ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
75		size_t size);
76ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
77		size_t size);
78ps_err_e ps_ptread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
79		size_t size);
80ps_err_e ps_ptwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
81		size_t size);
82ps_err_e ps_pstop(struct ps_prochandle *ph);
83ps_err_e ps_pcontinue(struct ps_prochandle *ph);
84ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lwpid);
85ps_err_e ps_lcontinue(struct ps_prochandle *ph, lwpid_t lwpid);
86ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lwpid,
87		prgregset_t gregset);
88ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lwpid,
89		const prgregset_t gregset);
90ps_err_e ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lwpid,
91		prfpregset_t *fpregset);
92ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lwpid,
93		const prfpregset_t *fpregset);
94#if 0
95ps_err_e ps_pauxv(struct ps_prochandle *ph, const auxv_t **auxp);
96ps_err_e ps_kill(struct ps_prochandle *ph, int sig);
97ps_err_e ps_lrolltoaddr(struct ps_prochandle *ph, lwpid_t lwpid,
98		psaddr_t go_addr, psaddr_t stop_addr);
99#endif
100void ps_plog(const char *fmt, ...);
101pid_t ps_getpid (struct ps_prochandle *ph);
102
103#endif
104