Add workaround from gdbserver's gdb_proc_service.h to GDB
[deliverable/binutils-gdb.git] / gdb / gdb_proc_service.h
CommitLineData
110be7c9 1/* <proc_service.h> replacement for systems that don't have it.
e2882c85 2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
110be7c9
MK
3
4 This file is part of GDB.
5
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
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
110be7c9
MK
9 (at your option) any later version.
10
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.
15
16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
110be7c9
MK
18
19#ifndef GDB_PROC_SERVICE_H
20#define GDB_PROC_SERVICE_H
21
22#include <sys/types.h>
23
31925464
MW
24#include "gregset.h"
25
00431a78
PA
26struct thread_info;
27
110be7c9 28#ifdef HAVE_PROC_SERVICE_H
749bab01
PA
29
30/* glibc's proc_service.h doesn't wrap itself with extern "C". Need
31 to do it ourselves. */
32EXTERN_C_PUSH
33
110be7c9 34#include <proc_service.h>
a298c5e8 35
749bab01
PA
36EXTERN_C_POP
37
a298c5e8
PA
38#else /* HAVE_PROC_SERVICE_H */
39
40/* The following fallback definitions have been imported and adjusted
41 from glibc's proc_service.h */
42
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.
46
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.
51
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.
56
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/>. */
60
61/* The definitions in this file must correspond to those in the debugger. */
110be7c9
MK
62
63#ifdef HAVE_SYS_PROCFS_H
64#include <sys/procfs.h>
65#endif
66
43b7e92b
GB
67/* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>. If
68 <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
69 headers also (but don't if we don't need to). */
70#ifndef HAVE_ELF_FPREGSET_T
71# ifdef HAVE_LINUX_ELF_H
72# include <linux/elf.h>
73# endif
74#endif
75
749bab01
PA
76EXTERN_C_PUSH
77
a298c5e8 78/* Functions in this interface return one of these status codes. */
110be7c9
MK
79typedef enum
80{
a298c5e8 81 PS_OK, /* Generic "call succeeded". */
3795e814 82 PS_ERR, /* Generic error. */
a298c5e8
PA
83 PS_BADPID, /* Bad process handle. */
84 PS_BADLID, /* Bad LWP identifier. */
85 PS_BADADDR, /* Bad address. */
86 PS_NOSYM, /* Could not find given symbol. */
87 PS_NOFREGS /* FPU register set not available for given LWP. */
110be7c9 88} ps_err_e;
ed9a39eb 89
83d37ec8 90#ifndef HAVE_LWPID_T
110be7c9 91typedef unsigned int lwpid_t;
83d37ec8
MK
92#endif
93
83d37ec8 94#ifndef HAVE_PSADDR_T
00f515da 95typedef void *psaddr_t;
83d37ec8 96#endif
ed9a39eb 97
83d37ec8 98#ifndef HAVE_PRGREGSET_T
110be7c9 99typedef gdb_gregset_t prgregset_t;
83d37ec8 100#endif
ed9a39eb 101
83d37ec8 102#ifndef HAVE_PRFPREGSET_T
110be7c9
MK
103typedef gdb_fpregset_t prfpregset_t;
104#endif
105
a298c5e8
PA
106/* This type is opaque in this interface. It's defined by the user of
107 libthread_db. GDB's version is defined below. */
108struct ps_prochandle;
109
110
111/* Read or write process memory at the given address. */
112extern ps_err_e ps_pdread (struct ps_prochandle *,
113 psaddr_t, void *, size_t);
114extern ps_err_e ps_pdwrite (struct ps_prochandle *,
115 psaddr_t, const void *, size_t);
116extern ps_err_e ps_ptread (struct ps_prochandle *,
117 psaddr_t, void *, size_t);
118extern ps_err_e ps_ptwrite (struct ps_prochandle *,
119 psaddr_t, const void *, size_t);
120
121
122/* Get and set the given LWP's general or FPU register set. */
123extern ps_err_e ps_lgetregs (struct ps_prochandle *,
124 lwpid_t, prgregset_t);
125extern ps_err_e ps_lsetregs (struct ps_prochandle *,
126 lwpid_t, const prgregset_t);
127extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
128 lwpid_t, prfpregset_t *);
129extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
130 lwpid_t, const prfpregset_t *);
131
132/* Return the PID of the process. */
133extern pid_t ps_getpid (struct ps_prochandle *);
134
135/* Fetch the special per-thread address associated with the given LWP.
136 This call is only used on a few platforms (most use a normal register).
137 The meaning of the `int' parameter is machine-dependent. */
754653a7 138extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
a298c5e8
PA
139 lwpid_t, int, psaddr_t *);
140
141
142/* Look up the named symbol in the named DSO in the symbol tables
143 associated with the process being debugged, filling in *SYM_ADDR
144 with the corresponding run-time address. */
145extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
146 const char *object_name,
147 const char *sym_name,
148 psaddr_t *sym_addr);
149
150
151/* Stop or continue the entire process. */
152extern ps_err_e ps_pstop (struct ps_prochandle *);
153extern ps_err_e ps_pcontinue (struct ps_prochandle *);
154
155/* Stop or continue the given LWP alone. */
156extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
157extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
158
159/* The following are only defined in/called by Solaris. */
160
161/* Get size of extra register set. */
162extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
163 lwpid_t lwpid, int *xregsize);
164/* Get extra register set. */
165extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
166 caddr_t xregset);
167extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
168 caddr_t xregset);
169
170/* Log a message (sends to gdb_stderr). */
171extern void ps_plog (const char *fmt, ...);
172
749bab01
PA
173EXTERN_C_POP
174
110be7c9
MK
175#endif /* HAVE_PROC_SERVICE_H */
176
177/* Fix-up some broken systems. */
178
179/* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
180 type. We let configure check for this lossage, and make
181 appropriate typedefs here. */
182
183#ifdef PRFPREGSET_T_BROKEN
184typedef gdb_fpregset_t gdb_prfpregset_t;
185#else
186typedef prfpregset_t gdb_prfpregset_t;
83d37ec8 187#endif
ed9a39eb 188
a298c5e8 189/* GDB specific structure that identifies the target process. */
110be7c9
MK
190struct ps_prochandle
191{
93a91755 192 /* The LWP we use for memory reads. */
00431a78 193 thread_info *thread;
110be7c9
MK
194};
195
196#endif /* gdb_proc_service.h */
This page took 1.395025 seconds and 4 git commands to generate.