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