1 /* <proc_service.h> replacement for systems that don't have it.
2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef GDB_PROC_SERVICE_H
20 #define GDB_PROC_SERVICE_H
22 #include <sys/types.h>
28 #ifdef HAVE_PROC_SERVICE_H
30 /* glibc's proc_service.h doesn't wrap itself with extern "C". Need
31 to do it ourselves. */
34 #include <proc_service.h>
38 #else /* HAVE_PROC_SERVICE_H */
40 /* The following fallback definitions have been imported and adjusted
41 from glibc's proc_service.h */
43 /* Callback interface for libthread_db, functions users must define.
44 Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
45 This file is part of the GNU C Library.
47 The GNU C Library is free software; you can redistribute it and/or
48 modify it under the terms of the GNU Lesser General Public
49 License as published by the Free Software Foundation; either
50 version 2.1 of the License, or (at your option) any later version.
52 The GNU C Library is distributed in the hope that it will be useful,
53 but WITHOUT ANY WARRANTY; without even the implied warranty of
54 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55 Lesser General Public License for more details.
57 You should have received a copy of the GNU Lesser General Public
58 License along with the GNU C Library; if not, see
59 <http://www.gnu.org/licenses/>. */
61 /* The definitions in this file must correspond to those in the debugger. */
63 #ifdef HAVE_SYS_PROCFS_H
64 #include <sys/procfs.h>
69 /* Functions in this interface return one of these status codes. */
72 PS_OK
, /* Generic "call succeeded". */
73 PS_ERR
, /* Generic error. */
74 PS_BADPID
, /* Bad process handle. */
75 PS_BADLID
, /* Bad LWP identifier. */
76 PS_BADADDR
, /* Bad address. */
77 PS_NOSYM
, /* Could not find given symbol. */
78 PS_NOFREGS
/* FPU register set not available for given LWP. */
82 typedef unsigned int lwpid_t
;
86 typedef void *psaddr_t
;
89 #ifndef HAVE_PRGREGSET_T
90 typedef gdb_gregset_t prgregset_t
;
93 #ifndef HAVE_PRFPREGSET_T
94 typedef gdb_fpregset_t prfpregset_t
;
97 /* This type is opaque in this interface. It's defined by the user of
98 libthread_db. GDB's version is defined below. */
102 /* Read or write process memory at the given address. */
103 extern ps_err_e
ps_pdread (struct ps_prochandle
*,
104 psaddr_t
, void *, size_t);
105 extern ps_err_e
ps_pdwrite (struct ps_prochandle
*,
106 psaddr_t
, const void *, size_t);
107 extern ps_err_e
ps_ptread (struct ps_prochandle
*,
108 psaddr_t
, void *, size_t);
109 extern ps_err_e
ps_ptwrite (struct ps_prochandle
*,
110 psaddr_t
, const void *, size_t);
113 /* Get and set the given LWP's general or FPU register set. */
114 extern ps_err_e
ps_lgetregs (struct ps_prochandle
*,
115 lwpid_t
, prgregset_t
);
116 extern ps_err_e
ps_lsetregs (struct ps_prochandle
*,
117 lwpid_t
, const prgregset_t
);
118 extern ps_err_e
ps_lgetfpregs (struct ps_prochandle
*,
119 lwpid_t
, prfpregset_t
*);
120 extern ps_err_e
ps_lsetfpregs (struct ps_prochandle
*,
121 lwpid_t
, const prfpregset_t
*);
123 /* Return the PID of the process. */
124 extern pid_t
ps_getpid (struct ps_prochandle
*);
126 /* Fetch the special per-thread address associated with the given LWP.
127 This call is only used on a few platforms (most use a normal register).
128 The meaning of the `int' parameter is machine-dependent. */
129 extern ps_err_e
ps_get_thread_area (struct ps_prochandle
*,
130 lwpid_t
, int, psaddr_t
*);
133 /* Look up the named symbol in the named DSO in the symbol tables
134 associated with the process being debugged, filling in *SYM_ADDR
135 with the corresponding run-time address. */
136 extern ps_err_e
ps_pglobal_lookup (struct ps_prochandle
*,
137 const char *object_name
,
138 const char *sym_name
,
142 /* Stop or continue the entire process. */
143 extern ps_err_e
ps_pstop (struct ps_prochandle
*);
144 extern ps_err_e
ps_pcontinue (struct ps_prochandle
*);
146 /* Stop or continue the given LWP alone. */
147 extern ps_err_e
ps_lstop (struct ps_prochandle
*, lwpid_t
);
148 extern ps_err_e
ps_lcontinue (struct ps_prochandle
*, lwpid_t
);
150 /* The following are only defined in/called by Solaris. */
152 /* Get size of extra register set. */
153 extern ps_err_e
ps_lgetxregsize (struct ps_prochandle
*ph
,
154 lwpid_t lwpid
, int *xregsize
);
155 /* Get extra register set. */
156 extern ps_err_e
ps_lgetxregs (struct ps_prochandle
*ph
, lwpid_t lwpid
,
158 extern ps_err_e
ps_lsetxregs (struct ps_prochandle
*ph
, lwpid_t lwpid
,
161 /* Log a message (sends to gdb_stderr). */
162 extern void ps_plog (const char *fmt
, ...);
166 #endif /* HAVE_PROC_SERVICE_H */
168 /* Fix-up some broken systems. */
170 /* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
171 type. We let configure check for this lossage, and make
172 appropriate typedefs here. */
174 #ifdef PRFPREGSET_T_BROKEN
175 typedef gdb_fpregset_t gdb_prfpregset_t
;
177 typedef prfpregset_t gdb_prfpregset_t
;
180 /* GDB specific structure that identifies the target process. */
183 /* The LWP we use for memory reads. */
187 #endif /* gdb_proc_service.h */