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