testsuite: skip confirmation in 'gdb_reinitialize_dir'
[binutils-gdb.git] / gdbsupport / gdb_proc_service.h
blob52f77a8a5c500cfd68fec153b5914855053cbb59
1 /* <proc_service.h> replacement for systems that don't have it.
2 Copyright (C) 2000-2024 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 COMMON_GDB_PROC_SERVICE_H
20 #define COMMON_GDB_PROC_SERVICE_H
22 #include <sys/types.h>
24 #ifdef HAVE_PROC_SERVICE_H
26 /* glibc's proc_service.h doesn't wrap itself with extern "C". Need
27 to do it ourselves. */
28 extern "C" {
30 #include <proc_service.h>
34 #else /* HAVE_PROC_SERVICE_H */
36 /* The following fallback definitions have been imported and adjusted
37 from glibc's proc_service.h */
39 /* Callback interface for libthread_db, functions users must define.
40 Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
41 This file is part of the GNU C Library.
43 The GNU C Library is free software; you can redistribute it and/or
44 modify it under the terms of the GNU Lesser General Public
45 License as published by the Free Software Foundation; either
46 version 2.1 of the License, or (at your option) any later version.
48 The GNU C Library is distributed in the hope that it will be useful,
49 but WITHOUT ANY WARRANTY; without even the implied warranty of
50 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
51 Lesser General Public License for more details.
53 You should have received a copy of the GNU Lesser General Public
54 License along with the GNU C Library; if not, see
55 <http://www.gnu.org/licenses/>. */
57 /* The definitions in this file must correspond to those in the debugger. */
59 #ifdef HAVE_SYS_PROCFS_H
60 #include <sys/procfs.h>
61 #endif
63 /* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>. If
64 <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
65 headers also (but don't if we don't need to). */
66 #ifndef HAVE_ELF_FPREGSET_T
67 # ifdef HAVE_LINUX_ELF_H
68 # include <linux/elf.h>
69 # endif
70 #endif
72 extern "C" {
74 /* Functions in this interface return one of these status codes. */
75 typedef enum
77 PS_OK, /* Generic "call succeeded". */
78 PS_ERR, /* Generic error. */
79 PS_BADPID, /* Bad process handle. */
80 PS_BADLID, /* Bad LWP identifier. */
81 PS_BADADDR, /* Bad address. */
82 PS_NOSYM, /* Could not find given symbol. */
83 PS_NOFREGS /* FPU register set not available for given LWP. */
84 } ps_err_e;
86 #ifndef HAVE_LWPID_T
87 typedef unsigned int lwpid_t;
88 #endif
90 #ifndef HAVE_PSADDR_T
91 typedef void *psaddr_t;
92 #endif
94 #ifndef HAVE_PRGREGSET_T
95 typedef elf_gregset_t prgregset_t;
96 #endif
98 #ifndef HAVE_PRFPREGSET_T
99 typedef elf_fpregset_t prfpregset_t;
100 #endif
102 /* This type is opaque in this interface. It's defined by the user of
103 libthread_db. GDB's version is defined below. */
104 struct ps_prochandle;
107 /* Read or write process memory at the given address. */
108 extern ps_err_e ps_pdread (struct ps_prochandle *,
109 psaddr_t, void *, size_t);
110 extern ps_err_e ps_pdwrite (struct ps_prochandle *,
111 psaddr_t, const void *, size_t);
112 extern ps_err_e ps_ptread (struct ps_prochandle *,
113 psaddr_t, void *, size_t);
114 extern ps_err_e ps_ptwrite (struct ps_prochandle *,
115 psaddr_t, const void *, size_t);
118 /* Get and set the given LWP's general or FPU register set. */
119 extern ps_err_e ps_lgetregs (struct ps_prochandle *,
120 lwpid_t, prgregset_t);
121 extern ps_err_e ps_lsetregs (struct ps_prochandle *,
122 lwpid_t, const prgregset_t);
123 extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
124 lwpid_t, prfpregset_t *);
125 extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
126 lwpid_t, const prfpregset_t *);
128 /* Return the PID of the process. */
129 extern pid_t ps_getpid (struct ps_prochandle *);
131 /* Fetch the special per-thread address associated with the given LWP.
132 This call is only used on a few platforms (most use a normal register).
133 The meaning of the `int' parameter is machine-dependent. */
134 extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
135 lwpid_t, int, psaddr_t *);
138 /* Look up the named symbol in the named DSO in the symbol tables
139 associated with the process being debugged, filling in *SYM_ADDR
140 with the corresponding run-time address. */
141 extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
142 const char *object_name,
143 const char *sym_name,
144 psaddr_t *sym_addr);
147 /* Stop or continue the entire process. */
148 extern ps_err_e ps_pstop (struct ps_prochandle *);
149 extern ps_err_e ps_pcontinue (struct ps_prochandle *);
151 /* Stop or continue the given LWP alone. */
152 extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
153 extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
155 /* The following are only defined in/called by Solaris. */
157 /* Get size of extra register set. */
158 extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
159 lwpid_t lwpid, int *xregsize);
160 /* Get extra register set. */
161 extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
162 caddr_t xregset);
163 extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
164 caddr_t xregset);
166 /* Log a message (sends to gdb_stderr). */
167 extern void ps_plog (const char *fmt, ...);
171 #endif /* HAVE_PROC_SERVICE_H */
173 /* Make sure we export the needed symbols, in case GDB is built with
174 -fvisibility=hidden. */
176 #define PS_EXPORT(SYM) \
177 __attribute__((visibility ("default"))) decltype (SYM) SYM
179 PS_EXPORT (ps_get_thread_area);
180 PS_EXPORT (ps_getpid);
181 PS_EXPORT (ps_lcontinue);
182 PS_EXPORT (ps_lgetfpregs);
183 PS_EXPORT (ps_lgetregs);
184 PS_EXPORT (ps_lsetfpregs);
185 PS_EXPORT (ps_lsetregs);
186 PS_EXPORT (ps_lstop);
187 PS_EXPORT (ps_pcontinue);
188 PS_EXPORT (ps_pdread);
189 PS_EXPORT (ps_pdwrite);
190 PS_EXPORT (ps_pglobal_lookup);
191 PS_EXPORT (ps_pstop);
192 PS_EXPORT (ps_ptread);
193 PS_EXPORT (ps_ptwrite);
195 #ifdef __sun__
196 PS_EXPORT (ps_lgetxregs);
197 PS_EXPORT (ps_lgetxregsize);
198 PS_EXPORT (ps_lsetxregs);
199 PS_EXPORT (ps_plog);
200 #endif
202 #endif /* COMMON_GDB_PROC_SERVICE_H */