GDB (xrefs)
/tmp/gdb-7.10/gdb/gdb_proc_service.h
Go to the documentation of this file.
1 /* <proc_service.h> replacement for systems that don't have it.
2  Copyright (C) 2000-2015 Free Software Foundation, Inc.
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
8  the Free Software Foundation; either version 3 of the License, or
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
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef GDB_PROC_SERVICE_H
20 #define GDB_PROC_SERVICE_H
21 
22 #include <sys/types.h>
23 
24 #ifdef HAVE_PROC_SERVICE_H
25 
26 /* glibc's proc_service.h doesn't wrap itself with extern "C". Need
27  to do it ourselves. */
29 
30 #include <proc_service.h>
31 
33 
34 #else /* HAVE_PROC_SERVICE_H */
35 
36 /* The following fallback definitions have been imported and adjusted
37  from glibc's proc_service.h */
38 
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.
42 
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.
47 
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.
52 
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/>. */
56 
57 /* The definitions in this file must correspond to those in the debugger. */
58 
59 #ifdef HAVE_SYS_PROCFS_H
60 #include <sys/procfs.h>
61 #endif
62 
63 #include "gregset.h"
64 
66 
67 /* Functions in this interface return one of these status codes. */
68 typedef enum
69 {
70  PS_OK, /* Generic "call succeeded". */
71  PS_ERR, /* Generic error. */
72  PS_BADPID, /* Bad process handle. */
73  PS_BADLID, /* Bad LWP identifier. */
74  PS_BADADDR, /* Bad address. */
75  PS_NOSYM, /* Could not find given symbol. */
76  PS_NOFREGS /* FPU register set not available for given LWP. */
77 } ps_err_e;
78 
79 #ifndef HAVE_LWPID_T
80 typedef unsigned int lwpid_t;
81 #endif
82 
83 #ifndef HAVE_PSADDR_T
84 typedef void *psaddr_t;
85 #endif
86 
87 #ifndef HAVE_PRGREGSET_T
89 #endif
90 
91 #ifndef HAVE_PRFPREGSET_T
93 #endif
94 
95 /* This type is opaque in this interface. It's defined by the user of
96  libthread_db. GDB's version is defined below. */
97 struct ps_prochandle;
98 
99 
100 /* Read or write process memory at the given address. */
101 extern ps_err_e ps_pdread (struct ps_prochandle *,
102  psaddr_t, void *, size_t);
103 extern ps_err_e ps_pdwrite (struct ps_prochandle *,
104  psaddr_t, const void *, size_t);
105 extern ps_err_e ps_ptread (struct ps_prochandle *,
106  psaddr_t, void *, size_t);
107 extern ps_err_e ps_ptwrite (struct ps_prochandle *,
108  psaddr_t, const void *, size_t);
109 
110 
111 /* Get and set the given LWP's general or FPU register set. */
112 extern ps_err_e ps_lgetregs (struct ps_prochandle *,
114 extern ps_err_e ps_lsetregs (struct ps_prochandle *,
115  lwpid_t, const prgregset_t);
116 extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
117  lwpid_t, prfpregset_t *);
118 extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
119  lwpid_t, const prfpregset_t *);
120 
121 /* Return the PID of the process. */
122 extern pid_t ps_getpid (struct ps_prochandle *);
123 
124 /* Fetch the special per-thread address associated with the given LWP.
125  This call is only used on a few platforms (most use a normal register).
126  The meaning of the `int' parameter is machine-dependent. */
127 extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,
128  lwpid_t, int, psaddr_t *);
129 
130 
131 /* Look up the named symbol in the named DSO in the symbol tables
132  associated with the process being debugged, filling in *SYM_ADDR
133  with the corresponding run-time address. */
134 extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
135  const char *object_name,
136  const char *sym_name,
137  psaddr_t *sym_addr);
138 
139 
140 /* Stop or continue the entire process. */
141 extern ps_err_e ps_pstop (struct ps_prochandle *);
142 extern ps_err_e ps_pcontinue (struct ps_prochandle *);
143 
144 /* Stop or continue the given LWP alone. */
145 extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
146 extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
147 
148 /* The following are only defined in/called by Solaris. */
149 
150 /* Get size of extra register set. */
151 extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
152  lwpid_t lwpid, int *xregsize);
153 /* Get extra register set. */
154 extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
155  caddr_t xregset);
156 extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
157  caddr_t xregset);
158 
159 /* Log a message (sends to gdb_stderr). */
160 extern void ps_plog (const char *fmt, ...);
161 
163 
164 #endif /* HAVE_PROC_SERVICE_H */
165 
166 /* Fix-up some broken systems. */
167 
168 /* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
169  type. We let configure check for this lossage, and make
170  appropriate typedefs here. */
171 
172 #ifdef PRFPREGSET_T_BROKEN
174 #else
176 #endif
177 
178 /* GDB specific structure that identifies the target process. */
180 {
181  /* The LWP we use for memory reads. */
183 };
184 
185 #endif /* gdb_proc_service.h */
unsigned int lwpid_t
ps_err_e ps_lgetregs(struct ps_prochandle *, lwpid_t, prgregset_t)
ps_err_e ps_lgetfpregs(struct ps_prochandle *, lwpid_t, prfpregset_t *)
ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t)
ps_err_e ps_ptread(struct ps_prochandle *, psaddr_t, void *, size_t)
ps_err_e ps_pglobal_lookup(struct ps_prochandle *, const char *object_name, const char *sym_name, psaddr_t *sym_addr)
EXTERN_C_POP typedef prfpregset_t gdb_prfpregset_t
ps_err_e ps_lsetregs(struct ps_prochandle *, lwpid_t, const prgregset_t)
ps_err_e
ps_err_e ps_lsetfpregs(struct ps_prochandle *, lwpid_t, const prfpregset_t *)
ps_err_e ps_lgetxregs(struct ps_prochandle *ph, lwpid_t lwpid, caddr_t xregset)
Definition: ptid.h:35
gdb_fpregset_t prfpregset_t
ps_err_e ps_pdread(struct ps_prochandle *, psaddr_t, void *, size_t)
GDB_GREGSET_T gdb_gregset_t
Definition: gregset.h:34
GDB_FPREGSET_T gdb_fpregset_t
Definition: gregset.h:35
ps_err_e ps_lgetxregsize(struct ps_prochandle *ph, lwpid_t lwpid, int *xregsize)
#define EXTERN_C_PUSH
Definition: common-defs.h:59
pid_t ps_getpid(struct ps_prochandle *)
void * psaddr_t
void ps_plog(const char *fmt,...)
Definition: sol-thread.c:897
ps_err_e ps_ptwrite(struct ps_prochandle *, psaddr_t, const void *, size_t)
ps_err_e ps_lsetxregs(struct ps_prochandle *ph, lwpid_t lwpid, caddr_t xregset)
gdb_gregset_t prgregset_t
#define EXTERN_C_POP
Definition: common-defs.h:60
ps_err_e ps_pdwrite(struct ps_prochandle *, psaddr_t, const void *, size_t)
ps_err_e ps_pstop(struct ps_prochandle *)
ps_err_e ps_pcontinue(struct ps_prochandle *)
ps_err_e ps_get_thread_area(const struct ps_prochandle *, lwpid_t, int, psaddr_t *)
ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t)