1 /* Callback interface for libthread_db, functions users must define.
2    Copyright (C) 1999-2022 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef _PROC_SERVICE_H
20 #define _PROC_SERVICE_H 1
21 
22 /* The definitions in this file must correspond to those in the debugger.  */
23 #include <sys/procfs.h>
24 
25 __BEGIN_DECLS
26 
27 /* Functions in this interface return one of these status codes.  */
28 typedef enum
29 {
30   PS_OK,		/* Generic "call succeeded".  */
31   PS_ERR,		/* Generic error. */
32   PS_BADPID,		/* Bad process handle.  */
33   PS_BADLID,		/* Bad LWP identifier.  */
34   PS_BADADDR,		/* Bad address.  */
35   PS_NOSYM,		/* Could not find given symbol.  */
36   PS_NOFREGS		/* FPU register set not available for given LWP.  */
37 } ps_err_e;
38 
39 
40 /* This type is opaque in this interface.
41    It's defined by the user of libthread_db.  */
42 struct ps_prochandle;
43 
44 
45 /* Read or write process memory at the given address.  */
46 extern ps_err_e ps_pdread (struct ps_prochandle *,
47 			   psaddr_t, void *, size_t);
48 extern ps_err_e ps_pdwrite (struct ps_prochandle *,
49 			    psaddr_t, const void *, size_t);
50 extern ps_err_e ps_ptread (struct ps_prochandle *,
51 			   psaddr_t, void *, size_t);
52 extern ps_err_e ps_ptwrite (struct ps_prochandle *,
53 			    psaddr_t, const void *, size_t);
54 
55 
56 /* Get and set the given LWP's general or FPU register set.  */
57 extern ps_err_e ps_lgetregs (struct ps_prochandle *,
58 			     lwpid_t, prgregset_t);
59 extern ps_err_e ps_lsetregs (struct ps_prochandle *,
60 			     lwpid_t, const prgregset_t);
61 extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
62 			       lwpid_t, prfpregset_t *);
63 extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
64 			       lwpid_t, const prfpregset_t *);
65 
66 /* Return the PID of the process.  */
67 extern pid_t ps_getpid (struct ps_prochandle *);
68 
69 /* Fetch the special per-thread address associated with the given LWP.
70    This call is only used on a few platforms (most use a normal register).
71    The meaning of the `int' parameter is machine-dependent.  */
72 extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
73 				    lwpid_t, int, psaddr_t *);
74 
75 
76 /* Look up the named symbol in the named DSO in the symbol tables
77    associated with the process being debugged, filling in *SYM_ADDR
78    with the corresponding run-time address.  */
79 extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
80 				   const char *object_name,
81 				   const char *sym_name,
82 				   psaddr_t *sym_addr);
83 
84 
85 /* Stop or continue the entire process.  */
86 extern ps_err_e ps_pstop (struct ps_prochandle *);
87 extern ps_err_e ps_pcontinue (struct ps_prochandle *);
88 
89 /* Stop or continue the given LWP alone.  */
90 extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
91 extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
92 
93 __END_DECLS
94 
95 #endif /* proc_service.h */
96