]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdbserver/target.h
* win32-nat.c (psapi_module_handle): Remove static.
[thirdparty/binutils-gdb.git] / gdb / gdbserver / target.h
CommitLineData
ce3a066d 1/* Target operations for the remote server for GDB.
6aba47ca 2 Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
ce3a066d
DJ
3
4 Contributed by MontaVista Software.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
ce3a066d
DJ
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
ce3a066d
DJ
20
21#ifndef TARGET_H
22#define TARGET_H
23
64386c31
DJ
24/* This structure describes how to resume a particular thread (or
25 all threads) based on the client's request. If thread is -1, then
26 this entry applies to all threads. These are generally passed around
27 as an array, and terminated by a thread == -1 entry. */
28
29struct thread_resume
30{
a1928bad 31 unsigned long thread;
64386c31
DJ
32
33 /* If non-zero, leave this thread stopped. */
34 int leave_stopped;
35
36 /* If non-zero, we want to single-step. */
37 int step;
38
39 /* If non-zero, send this signal when we resume. */
40 int sig;
41};
42
ce3a066d
DJ
43struct target_ops
44{
45 /* Start a new process.
46
47 PROGRAM is a path to the program to execute.
48 ARGS is a standard NULL-terminated array of arguments,
49 to be passed to the inferior as ``argv''.
50
a9fa9f7d 51 Returns the new PID on success, -1 on failure. Registers the new
ce3a066d
DJ
52 process with the process list. */
53
54 int (*create_inferior) (char *program, char **args);
55
56 /* Attach to a running process.
57
58 PID is the process ID to attach to, specified by the user
1d5315fe
PA
59 or a higher layer.
60
61 Returns -1 if attaching is unsupported, 0 on success, and calls
62 error() otherwise. */
ce3a066d 63
a1928bad 64 int (*attach) (unsigned long pid);
ce3a066d
DJ
65
66 /* Kill all inferiors. */
67
68 void (*kill) (void);
69
444d6139
PA
70 /* Detach from all inferiors.
71 Return -1 on failure, and 0 on success. */
6ad8ae5c 72
444d6139
PA
73 int (*detach) (void);
74
75 /* Wait for inferiors to end. */
76
77 void (*join) (void);
6ad8ae5c 78
ce3a066d
DJ
79 /* Return 1 iff the thread with process ID PID is alive. */
80
a1928bad 81 int (*thread_alive) (unsigned long pid);
ce3a066d 82
64386c31 83 /* Resume the inferior process. */
ce3a066d 84
64386c31 85 void (*resume) (struct thread_resume *resume_info);
ce3a066d
DJ
86
87 /* Wait for the inferior process to change state.
88
b80864fb 89 STATUS will be filled in with a response code to send to GDB.
ce3a066d 90
b80864fb
DJ
91 Returns the signal which caused the process to stop, in the
92 remote protocol numbering (e.g. TARGET_SIGNAL_STOP), or the
93 exit code as an integer if *STATUS is 'W'. */
ce3a066d
DJ
94
95 unsigned char (*wait) (char *status);
96
97 /* Fetch registers from the inferior process.
98
99 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
100
101 void (*fetch_registers) (int regno);
aa691b87 102
ce3a066d
DJ
103 /* Store registers to the inferior process.
104
105 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
106
107 void (*store_registers) (int regno);
108
611cb4a5
DJ
109 /* Read memory from the inferior process. This should generally be
110 called through read_inferior_memory, which handles breakpoint shadowing.
ce3a066d 111
c3e735a6
DJ
112 Read LEN bytes at MEMADDR into a buffer at MYADDR.
113
114 Returns 0 on success and errno on failure. */
ce3a066d 115
f450004a 116 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
ce3a066d 117
611cb4a5
DJ
118 /* Write memory to the inferior process. This should generally be
119 called through write_inferior_memory, which handles breakpoint shadowing.
ce3a066d
DJ
120
121 Write LEN bytes from the buffer at MYADDR to MEMADDR.
122
123 Returns 0 on success and errno on failure. */
124
f450004a
DJ
125 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
126 int len);
2f2893d9
DJ
127
128 /* Query GDB for the values of any symbols we're interested in.
129 This function is called whenever we receive a "qSymbols::"
130 query, which corresponds to every time more symbols (might)
611cb4a5
DJ
131 become available. NULL if we aren't interested in any
132 symbols. */
2f2893d9
DJ
133
134 void (*look_up_symbols) (void);
e5379b03 135
ef57601b
PA
136 /* Send an interrupt request to the inferior process,
137 however is appropriate. */
138
139 void (*request_interrupt) (void);
aa691b87
RM
140
141 /* Read auxiliary vector data from the inferior process.
142
143 Read LEN bytes at OFFSET into a buffer at MYADDR. */
144
f450004a
DJ
145 int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
146 unsigned int len);
e013ee27
OF
147
148 /* Insert and remove a hardware watchpoint.
149 Returns 0 on success, -1 on failure and 1 on unsupported.
150 The type is coded as follows:
151 2 = write watchpoint
152 3 = read watchpoint
153 4 = access watchpoint
154 */
155
156 int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
157 int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
158
159 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
160
161 int (*stopped_by_watchpoint) (void);
162
163 /* Returns the address associated with the watchpoint that hit, if any;
164 returns 0 otherwise. */
165
166 CORE_ADDR (*stopped_data_address) (void);
167
52fb6437
NS
168 /* Reports the text, data offsets of the executable. This is
169 needed for uclinux where the executable is relocated during load
170 time. */
171
172 int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
dae5f5cf
DJ
173
174 /* Fetch the address associated with a specific thread local storage
175 area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
176 Stores it in *ADDRESS and returns zero on success; otherwise returns
177 an error code. A return value of -1 means this system does not
178 support the operation. */
179
180 int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
181 CORE_ADDR load_module, CORE_ADDR *address);
23181151
DJ
182
183 /* Return a string identifying the current architecture, or NULL if
184 this operation is not supported. */
185 const char *(*arch_string) (void);
0e7f50da
UW
186
187 /* Read/Write from/to spufs using qXfer packets. */
188 int (*qxfer_spu) (const char *annex, unsigned char *readbuf,
189 unsigned const char *writebuf, CORE_ADDR offset, int len);
ce3a066d
DJ
190};
191
192extern struct target_ops *the_target;
193
194void set_target_ops (struct target_ops *);
195
196#define create_inferior(program, args) \
197 (*the_target->create_inferior) (program, args)
198
199#define myattach(pid) \
200 (*the_target->attach) (pid)
201
202#define kill_inferior() \
203 (*the_target->kill) ()
204
6ad8ae5c
DJ
205#define detach_inferior() \
206 (*the_target->detach) ()
207
ce3a066d
DJ
208#define mythread_alive(pid) \
209 (*the_target->thread_alive) (pid)
210
ce3a066d
DJ
211#define fetch_inferior_registers(regno) \
212 (*the_target->fetch_registers) (regno)
213
214#define store_inferior_registers(regno) \
215 (*the_target->store_registers) (regno)
216
444d6139
PA
217#define join_inferior() \
218 (*the_target->join) ()
219
0d62e5e8
DJ
220unsigned char mywait (char *statusp, int connected_wait);
221
f450004a 222int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
ce3a066d 223
f450004a
DJ
224int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
225 int len);
0d62e5e8
DJ
226
227void set_desired_inferior (int id);
ce3a066d
DJ
228
229#endif /* TARGET_H */