GDBserver
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
35 
36 #ifdef HAVE_SYS_PROCFS_H
37 #include <sys/procfs.h>
38 #endif
39 
40 /* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>. If
41  <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
42  headers also (but don't if we don't need to). */
43 #ifndef HAVE_ELF_FPREGSET_T
44 # ifdef HAVE_LINUX_ELF_H
45 # include <linux/elf.h>
46 # endif
47 #endif
48 
50 
51 typedef enum
52 {
53  PS_OK, /* Success. */
54  PS_ERR, /* Generic error. */
55  PS_BADPID, /* Bad process handle. */
56  PS_BADLID, /* Bad LWP id. */
57  PS_BADADDR, /* Bad address. */
58  PS_NOSYM, /* Symbol not found. */
59  PS_NOFREGS /* FPU register set not available. */
60 } ps_err_e;
61 
62 #ifndef HAVE_LWPID_T
63 typedef unsigned int lwpid_t;
64 #endif
65 
66 #ifndef HAVE_PSADDR_T
67 typedef void *psaddr_t;
68 #endif
69 
70 #ifndef HAVE_PRGREGSET_T
71 typedef elf_gregset_t prgregset_t;
72 #endif
73 
74 #ifndef HAVE_PRFPREGSET_T
75 typedef elf_fpregset_t prfpregset_t;
76 #endif
77 
78 /* This type is opaque in this interface. It's defined by the user of
79  libthread_db. GDB's version is defined below. */
80 struct ps_prochandle;
81 
82 
83 /* Read or write process memory at the given address. */
84 extern ps_err_e ps_pdread (struct ps_prochandle *,
85  psaddr_t, void *, size_t);
86 extern ps_err_e ps_pdwrite (struct ps_prochandle *,
87  psaddr_t, const void *, size_t);
88 extern ps_err_e ps_ptread (struct ps_prochandle *,
89  psaddr_t, void *, size_t);
90 extern ps_err_e ps_ptwrite (struct ps_prochandle *,
91  psaddr_t, const void *, size_t);
92 
93 
94 /* Get and set the given LWP's general or FPU register set. */
95 extern ps_err_e ps_lgetregs (struct ps_prochandle *,
97 extern ps_err_e ps_lsetregs (struct ps_prochandle *,
98  lwpid_t, const prgregset_t);
99 extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
100  lwpid_t, prfpregset_t *);
101 extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
102  lwpid_t, const prfpregset_t *);
103 
104 /* Return the PID of the process. */
105 extern pid_t ps_getpid (struct ps_prochandle *);
106 
107 /* Fetch the special per-thread address associated with the given LWP.
108  This call is only used on a few platforms (most use a normal register).
109  The meaning of the `int' parameter is machine-dependent. */
110 extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,
111  lwpid_t, int, psaddr_t *);
112 
113 
114 /* Look up the named symbol in the named DSO in the symbol tables
115  associated with the process being debugged, filling in *SYM_ADDR
116  with the corresponding run-time address. */
117 extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
118  const char *object_name,
119  const char *sym_name,
120  psaddr_t *sym_addr);
121 
122 
123 /* Stop or continue the entire process. */
124 extern ps_err_e ps_pstop (struct ps_prochandle *);
125 extern ps_err_e ps_pcontinue (struct ps_prochandle *);
126 
127 /* Stop or continue the given LWP alone. */
128 extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
129 extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
130 
131 /* The following are only defined in/called by Solaris. */
132 
133 /* Get size of extra register set. */
134 extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
135  lwpid_t lwpid, int *xregsize);
136 /* Get extra register set. */
137 extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
138  caddr_t xregset);
139 extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
140  caddr_t xregset);
141 
142 /* Log a message (sends to gdb_stderr). */
143 extern void ps_plog (const char *fmt, ...);
144 
146 
147 #endif /* HAVE_PROC_SERVICE_H */
148 
149 /* Structure that identifies the target process. */
151 {
152  /* We don't need to track anything. All context is served from the
153  current inferior. */
154 };
155 
156 #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)
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)
ps_err_e ps_pdread(struct ps_prochandle *, psaddr_t, void *, size_t)
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,...)
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)
#define EXTERN_C_POP
Definition: common-defs.h:60
elf_fpregset_t prfpregset_t
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 *)
elf_gregset_t prgregset_t
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)