Commit | Line | Data |
---|---|---|
bd5635a1 | 1 | /* Interface between GDB and target environments, including files and processes |
fcbc95a7 | 2 | Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
bd5635a1 RP |
3 | Contributed by Cygnus Support. Written by John Gilmore. |
4 | ||
5 | This file is part of GDB. | |
6 | ||
75af490b | 7 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 8 | it under the terms of the GNU General Public License as published by |
75af490b JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
bd5635a1 | 11 | |
75af490b | 12 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
75af490b | 18 | along with this program; if not, write to the Free Software |
cb1709ae | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
75af490b JG |
20 | |
21 | #if !defined (TARGET_H) | |
22 | #define TARGET_H | |
bd5635a1 RP |
23 | |
24 | /* This include file defines the interface between the main part | |
25 | of the debugger, and the part which is target-specific, or | |
26 | specific to the communications interface between us and the | |
27 | target. | |
28 | ||
29 | A TARGET is an interface between the debugger and a particular | |
30 | kind of file or process. Targets can be STACKED in STRATA, | |
31 | so that more than one target can potentially respond to a request. | |
32 | In particular, memory accesses will walk down the stack of targets | |
33 | until they find a target that is interested in handling that particular | |
34 | address. STRATA are artificial boundaries on the stack, within | |
35 | which particular kinds of targets live. Strata exist so that | |
36 | people don't get confused by pushing e.g. a process target and then | |
37 | a file target, and wondering why they can't see the current values | |
38 | of variables any more (the file target is handling them and they | |
39 | never get to the process target). So when you push a file target, | |
40 | it goes into the file stratum, which is always below the process | |
41 | stratum. */ | |
42 | ||
75af490b JG |
43 | #include "bfd.h" |
44 | ||
bd5635a1 RP |
45 | enum strata { |
46 | dummy_stratum, /* The lowest of the low */ | |
47 | file_stratum, /* Executable files, etc */ | |
48 | core_stratum, /* Core dump files */ | |
e8bf33c4 | 49 | download_stratum, /* Downloading of remote targets */ |
75af490b | 50 | process_stratum /* Executing processes */ |
bd5635a1 RP |
51 | }; |
52 | ||
67ac9759 JK |
53 | /* Stuff for target_wait. */ |
54 | ||
55 | /* Generally, what has the program done? */ | |
56 | enum target_waitkind { | |
57 | /* The program has exited. The exit status is in value.integer. */ | |
58 | TARGET_WAITKIND_EXITED, | |
59 | ||
60 | /* The program has stopped with a signal. Which signal is in value.sig. */ | |
61 | TARGET_WAITKIND_STOPPED, | |
62 | ||
63 | /* The program has terminated with a signal. Which signal is in | |
64 | value.sig. */ | |
fcbc95a7 JK |
65 | TARGET_WAITKIND_SIGNALLED, |
66 | ||
67 | /* The program is letting us know that it dynamically loaded something | |
68 | (e.g. it called load(2) on AIX). */ | |
69 | TARGET_WAITKIND_LOADED, | |
70 | ||
71 | /* Nothing happened, but we stopped anyway. This perhaps should be handled | |
72 | within target_wait, but I'm not sure target_wait should be resuming the | |
73 | inferior. */ | |
74 | TARGET_WAITKIND_SPURIOUS | |
67ac9759 JK |
75 | }; |
76 | ||
77 | /* The numbering of these signals is chosen to match traditional unix | |
78 | signals (insofar as various unices use the same numbers, anyway). | |
79 | It is also the numbering of the GDB remote protocol. Other remote | |
80 | protocols, if they use a different numbering, should make sure to | |
81 | translate appropriately. */ | |
82 | ||
83 | /* This is based strongly on Unix/POSIX signals for several reasons: | |
84 | (1) This set of signals represents a widely-accepted attempt to | |
85 | represent events of this sort in a portable fashion, (2) we want a | |
86 | signal to make it from wait to child_wait to the user intact, (3) many | |
87 | remote protocols use a similar encoding. However, it is | |
88 | recognized that this set of signals has limitations (such as not | |
89 | distinguishing between various kinds of SIGSEGV, or not | |
90 | distinguishing hitting a breakpoint from finishing a single step). | |
91 | So in the future we may get around this either by adding additional | |
92 | signals for breakpoint, single-step, etc., or by adding signal | |
93 | codes; the latter seems more in the spirit of what BSD, System V, | |
94 | etc. are doing to address these issues. */ | |
95 | ||
96 | /* For an explanation of what each signal means, see | |
97 | target_signal_to_string. */ | |
98 | ||
99 | enum target_signal { | |
100 | /* Used some places (e.g. stop_signal) to record the concept that | |
101 | there is no signal. */ | |
102 | TARGET_SIGNAL_0 = 0, | |
1c95d7ab | 103 | TARGET_SIGNAL_FIRST = 0, |
67ac9759 JK |
104 | TARGET_SIGNAL_HUP = 1, |
105 | TARGET_SIGNAL_INT = 2, | |
106 | TARGET_SIGNAL_QUIT = 3, | |
107 | TARGET_SIGNAL_ILL = 4, | |
108 | TARGET_SIGNAL_TRAP = 5, | |
109 | TARGET_SIGNAL_ABRT = 6, | |
110 | TARGET_SIGNAL_EMT = 7, | |
111 | TARGET_SIGNAL_FPE = 8, | |
112 | TARGET_SIGNAL_KILL = 9, | |
113 | TARGET_SIGNAL_BUS = 10, | |
114 | TARGET_SIGNAL_SEGV = 11, | |
115 | TARGET_SIGNAL_SYS = 12, | |
116 | TARGET_SIGNAL_PIPE = 13, | |
117 | TARGET_SIGNAL_ALRM = 14, | |
118 | TARGET_SIGNAL_TERM = 15, | |
119 | TARGET_SIGNAL_URG = 16, | |
120 | TARGET_SIGNAL_STOP = 17, | |
121 | TARGET_SIGNAL_TSTP = 18, | |
122 | TARGET_SIGNAL_CONT = 19, | |
123 | TARGET_SIGNAL_CHLD = 20, | |
124 | TARGET_SIGNAL_TTIN = 21, | |
125 | TARGET_SIGNAL_TTOU = 22, | |
126 | TARGET_SIGNAL_IO = 23, | |
127 | TARGET_SIGNAL_XCPU = 24, | |
128 | TARGET_SIGNAL_XFSZ = 25, | |
129 | TARGET_SIGNAL_VTALRM = 26, | |
130 | TARGET_SIGNAL_PROF = 27, | |
131 | TARGET_SIGNAL_WINCH = 28, | |
132 | TARGET_SIGNAL_LOST = 29, | |
133 | TARGET_SIGNAL_USR1 = 30, | |
134 | TARGET_SIGNAL_USR2 = 31, | |
135 | TARGET_SIGNAL_PWR = 32, | |
136 | /* Similar to SIGIO. Perhaps they should have the same number. */ | |
137 | TARGET_SIGNAL_POLL = 33, | |
138 | TARGET_SIGNAL_WIND = 34, | |
139 | TARGET_SIGNAL_PHONE = 35, | |
140 | TARGET_SIGNAL_WAITING = 36, | |
141 | TARGET_SIGNAL_LWP = 37, | |
142 | TARGET_SIGNAL_DANGER = 38, | |
143 | TARGET_SIGNAL_GRANT = 39, | |
144 | TARGET_SIGNAL_RETRACT = 40, | |
145 | TARGET_SIGNAL_MSG = 41, | |
146 | TARGET_SIGNAL_SOUND = 42, | |
147 | TARGET_SIGNAL_SAK = 43, | |
e8bf33c4 JK |
148 | TARGET_SIGNAL_PRIO = 44, |
149 | TARGET_SIGNAL_REALTIME_33 = 45, | |
150 | TARGET_SIGNAL_REALTIME_34 = 46, | |
151 | TARGET_SIGNAL_REALTIME_35 = 47, | |
152 | TARGET_SIGNAL_REALTIME_36 = 48, | |
153 | TARGET_SIGNAL_REALTIME_37 = 49, | |
154 | TARGET_SIGNAL_REALTIME_38 = 50, | |
155 | TARGET_SIGNAL_REALTIME_39 = 51, | |
156 | TARGET_SIGNAL_REALTIME_40 = 52, | |
157 | TARGET_SIGNAL_REALTIME_41 = 53, | |
158 | TARGET_SIGNAL_REALTIME_42 = 54, | |
159 | TARGET_SIGNAL_REALTIME_43 = 55, | |
160 | TARGET_SIGNAL_REALTIME_44 = 56, | |
161 | TARGET_SIGNAL_REALTIME_45 = 57, | |
162 | TARGET_SIGNAL_REALTIME_46 = 58, | |
163 | TARGET_SIGNAL_REALTIME_47 = 59, | |
164 | TARGET_SIGNAL_REALTIME_48 = 60, | |
165 | TARGET_SIGNAL_REALTIME_49 = 61, | |
166 | TARGET_SIGNAL_REALTIME_50 = 62, | |
167 | TARGET_SIGNAL_REALTIME_51 = 63, | |
168 | TARGET_SIGNAL_REALTIME_52 = 64, | |
169 | TARGET_SIGNAL_REALTIME_53 = 65, | |
170 | TARGET_SIGNAL_REALTIME_54 = 66, | |
171 | TARGET_SIGNAL_REALTIME_55 = 67, | |
172 | TARGET_SIGNAL_REALTIME_56 = 68, | |
173 | TARGET_SIGNAL_REALTIME_57 = 69, | |
174 | TARGET_SIGNAL_REALTIME_58 = 70, | |
175 | TARGET_SIGNAL_REALTIME_59 = 71, | |
176 | TARGET_SIGNAL_REALTIME_60 = 72, | |
177 | TARGET_SIGNAL_REALTIME_61 = 73, | |
178 | TARGET_SIGNAL_REALTIME_62 = 74, | |
179 | TARGET_SIGNAL_REALTIME_63 = 75, | |
67ac9759 JK |
180 | |
181 | /* Some signal we don't know about. */ | |
182 | TARGET_SIGNAL_UNKNOWN, | |
183 | ||
fcbc95a7 JK |
184 | /* Use whatever signal we use when one is not specifically specified |
185 | (for passing to proceed and so on). */ | |
186 | TARGET_SIGNAL_DEFAULT, | |
187 | ||
67ac9759 JK |
188 | /* Last and unused enum value, for sizing arrays, etc. */ |
189 | TARGET_SIGNAL_LAST | |
190 | }; | |
191 | ||
192 | struct target_waitstatus { | |
193 | enum target_waitkind kind; | |
194 | ||
195 | /* Exit status or signal number. */ | |
196 | union { | |
197 | int integer; | |
198 | enum target_signal sig; | |
199 | } value; | |
200 | }; | |
201 | ||
202 | /* Return the string for a signal. */ | |
203 | extern char *target_signal_to_string PARAMS ((enum target_signal)); | |
204 | ||
205 | /* Return the name (SIGHUP, etc.) for a signal. */ | |
206 | extern char *target_signal_to_name PARAMS ((enum target_signal)); | |
207 | ||
208 | /* Given a name (SIGHUP, etc.), return its signal. */ | |
209 | enum target_signal target_signal_from_name PARAMS ((char *)); | |
210 | \f | |
e8bf33c4 JK |
211 | /* If certain kinds of activity happen, target_wait should perform |
212 | callbacks. */ | |
213 | /* Right now we just call (*TARGET_ACTIVITY_FUNCTION) if I/O is possible | |
214 | on TARGET_ACTIVITY_FD. */ | |
215 | extern int target_activity_fd; | |
216 | /* Returns zero to leave the inferior alone, one to interrupt it. */ | |
217 | extern int (*target_activity_function) PARAMS ((void)); | |
218 | \f | |
75af490b JG |
219 | struct target_ops |
220 | { | |
221 | char *to_shortname; /* Name this target type */ | |
222 | char *to_longname; /* Name for printing */ | |
223 | char *to_doc; /* Documentation. Does not include trailing | |
224 | newline, and starts with a one-line descrip- | |
225 | tion (probably similar to to_longname). */ | |
226 | void (*to_open) PARAMS ((char *, int)); | |
227 | void (*to_close) PARAMS ((int)); | |
228 | void (*to_attach) PARAMS ((char *, int)); | |
229 | void (*to_detach) PARAMS ((char *, int)); | |
67ac9759 JK |
230 | void (*to_resume) PARAMS ((int, int, enum target_signal)); |
231 | int (*to_wait) PARAMS ((int, struct target_waitstatus *)); | |
75af490b JG |
232 | void (*to_fetch_registers) PARAMS ((int)); |
233 | void (*to_store_registers) PARAMS ((int)); | |
234 | void (*to_prepare_to_store) PARAMS ((void)); | |
f1e7bafc JK |
235 | |
236 | /* Transfer LEN bytes of memory between GDB address MYADDR and | |
237 | target address MEMADDR. If WRITE, transfer them to the target, else | |
238 | transfer them from the target. TARGET is the target from which we | |
239 | get this function. | |
240 | ||
241 | Return value, N, is one of the following: | |
242 | ||
243 | 0 means that we can't handle this. If errno has been set, it is the | |
244 | error which prevented us from doing it (FIXME: What about bfd_error?). | |
245 | ||
246 | positive (call it N) means that we have transferred N bytes | |
247 | starting at MEMADDR. We might be able to handle more bytes | |
248 | beyond this length, but no promises. | |
249 | ||
250 | negative (call its absolute value N) means that we cannot | |
251 | transfer right at MEMADDR, but we could transfer at least | |
252 | something at MEMADDR + N. */ | |
253 | ||
254 | int (*to_xfer_memory) PARAMS ((CORE_ADDR memaddr, char *myaddr, | |
255 | int len, int write, | |
256 | struct target_ops * target)); | |
257 | ||
c20c1bdf JK |
258 | #if 0 |
259 | /* Enable this after 4.12. */ | |
260 | ||
261 | /* Search target memory. Start at STARTADDR and take LEN bytes of | |
262 | target memory, and them with MASK, and compare to DATA. If they | |
263 | match, set *ADDR_FOUND to the address we found it at, store the data | |
264 | we found at LEN bytes starting at DATA_FOUND, and return. If | |
265 | not, add INCREMENT to the search address and keep trying until | |
266 | the search address is outside of the range [LORANGE,HIRANGE). | |
267 | ||
268 | If we don't find anything, set *ADDR_FOUND to (CORE_ADDR)0 and return. */ | |
269 | void (*to_search) PARAMS ((int len, char *data, char *mask, | |
270 | CORE_ADDR startaddr, int increment, | |
271 | CORE_ADDR lorange, CORE_ADDR hirange, | |
272 | CORE_ADDR *addr_found, char *data_found)); | |
273 | ||
274 | #define target_search(len, data, mask, startaddr, increment, lorange, hirange, addr_found, data_found) \ | |
e8bf33c4 | 275 | (*current_target.to_search) (len, data, mask, startaddr, increment, \ |
c20c1bdf JK |
276 | lorange, hirange, addr_found, data_found) |
277 | #endif /* 0 */ | |
278 | ||
75af490b JG |
279 | void (*to_files_info) PARAMS ((struct target_ops *)); |
280 | int (*to_insert_breakpoint) PARAMS ((CORE_ADDR, char *)); | |
281 | int (*to_remove_breakpoint) PARAMS ((CORE_ADDR, char *)); | |
282 | void (*to_terminal_init) PARAMS ((void)); | |
283 | void (*to_terminal_inferior) PARAMS ((void)); | |
284 | void (*to_terminal_ours_for_output) PARAMS ((void)); | |
285 | void (*to_terminal_ours) PARAMS ((void)); | |
286 | void (*to_terminal_info) PARAMS ((char *, int)); | |
287 | void (*to_kill) PARAMS ((void)); | |
288 | void (*to_load) PARAMS ((char *, int)); | |
289 | int (*to_lookup_symbol) PARAMS ((char *, CORE_ADDR *)); | |
290 | void (*to_create_inferior) PARAMS ((char *, char *, char **)); | |
291 | void (*to_mourn_inferior) PARAMS ((void)); | |
836e343b | 292 | int (*to_can_run) PARAMS ((void)); |
67ac9759 | 293 | void (*to_notice_signals) PARAMS ((int pid)); |
cb1709ae | 294 | int (*to_thread_alive) PARAMS ((int pid)); |
e8bf33c4 | 295 | void (*to_stop) PARAMS ((void)); |
75af490b JG |
296 | enum strata to_stratum; |
297 | struct target_ops | |
e8bf33c4 | 298 | *DONT_USE; /* formerly to_next */ |
75af490b JG |
299 | int to_has_all_memory; |
300 | int to_has_memory; | |
301 | int to_has_stack; | |
302 | int to_has_registers; | |
303 | int to_has_execution; | |
304 | struct section_table | |
305 | *to_sections; | |
306 | struct section_table | |
307 | *to_sections_end; | |
308 | int to_magic; | |
309 | /* Need sub-structure for target machine related rather than comm related? */ | |
bd5635a1 RP |
310 | }; |
311 | ||
312 | /* Magic number for checking ops size. If a struct doesn't end with this | |
313 | number, somebody changed the declaration but didn't change all the | |
314 | places that initialize one. */ | |
315 | ||
316 | #define OPS_MAGIC 3840 | |
317 | ||
f1e7bafc JK |
318 | /* The ops structure for our "current" target process. This should |
319 | never be NULL. If there is no target, it points to the dummy_target. */ | |
bd5635a1 | 320 | |
e8bf33c4 JK |
321 | extern struct target_ops current_target; |
322 | ||
323 | /* An item on the target stack. */ | |
324 | ||
325 | struct target_stack_item | |
326 | { | |
327 | struct target_stack_item *next; | |
328 | struct target_ops *target_ops; | |
329 | }; | |
330 | ||
331 | /* The target stack. */ | |
332 | ||
333 | extern struct target_stack_item *target_stack; | |
bd5635a1 RP |
334 | |
335 | /* Define easy words for doing these operations on our current target. */ | |
336 | ||
e8bf33c4 JK |
337 | #define target_shortname (current_target.to_shortname) |
338 | #define target_longname (current_target.to_longname) | |
bd5635a1 | 339 | |
9136fe49 JK |
340 | /* The open routine takes the rest of the parameters from the command, |
341 | and (if successful) pushes a new target onto the stack. | |
342 | Targets should supply this routine, if only to provide an error message. */ | |
bd5635a1 | 343 | #define target_open(name, from_tty) \ |
e8bf33c4 | 344 | (*current_target.to_open) (name, from_tty) |
bd5635a1 RP |
345 | |
346 | /* Does whatever cleanup is required for a target that we are no longer | |
347 | going to be calling. Argument says whether we are quitting gdb and | |
348 | should not get hung in case of errors, or whether we want a clean | |
349 | termination even if it takes a while. This routine is automatically | |
350 | always called just before a routine is popped off the target stack. | |
351 | Closing file descriptors and freeing memory are typical things it should | |
352 | do. */ | |
353 | ||
354 | #define target_close(quitting) \ | |
e8bf33c4 | 355 | (*current_target.to_close) (quitting) |
bd5635a1 | 356 | |
836e343b JG |
357 | /* Attaches to a process on the target side. Arguments are as passed |
358 | to the `attach' command by the user. This routine can be called | |
359 | when the target is not on the target-stack, if the target_can_run | |
360 | routine returns 1; in that case, it must push itself onto the stack. | |
361 | Upon exit, the target should be ready for normal operations, and | |
362 | should be ready to deliver the status of the process immediately | |
363 | (without waiting) to an upcoming target_wait call. */ | |
bd5635a1 RP |
364 | |
365 | #define target_attach(args, from_tty) \ | |
e8bf33c4 | 366 | (*current_target.to_attach) (args, from_tty) |
bd5635a1 RP |
367 | |
368 | /* Takes a program previously attached to and detaches it. | |
369 | The program may resume execution (some targets do, some don't) and will | |
370 | no longer stop on signals, etc. We better not have left any breakpoints | |
371 | in the program or it'll die when it hits one. ARGS is arguments | |
372 | typed by the user (e.g. a signal to send the process). FROM_TTY | |
373 | says whether to be verbose or not. */ | |
374 | ||
f1e7bafc JK |
375 | extern void |
376 | target_detach PARAMS ((char *, int)); | |
bd5635a1 | 377 | |
f1e7bafc | 378 | /* Resume execution of the target process PID. STEP says whether to |
fcbc95a7 JK |
379 | single-step or to run free; SIGGNAL is the signal to be given to |
380 | the target, or TARGET_SIGNAL_0 for no signal. The caller may not | |
381 | pass TARGET_SIGNAL_DEFAULT. */ | |
bd5635a1 | 382 | |
f1e7bafc | 383 | #define target_resume(pid, step, siggnal) \ |
e8bf33c4 | 384 | (*current_target.to_resume) (pid, step, siggnal) |
bd5635a1 | 385 | |
c20c1bdf JK |
386 | /* Wait for process pid to do something. Pid = -1 to wait for any pid |
387 | to do something. Return pid of child, or -1 in case of error; | |
388 | store status through argument pointer STATUS. Note that it is | |
389 | *not* OK to return_to_top_level out of target_wait without popping | |
390 | the debugging target from the stack; GDB isn't prepared to get back | |
391 | to the prompt with a debugging target but without the frame cache, | |
392 | stop_pc, etc., set up. */ | |
bd5635a1 | 393 | |
67ac9759 | 394 | #define target_wait(pid, status) \ |
e8bf33c4 | 395 | (*current_target.to_wait) (pid, status) |
bd5635a1 | 396 | |
75af490b | 397 | /* Fetch register REGNO, or all regs if regno == -1. No result. */ |
bd5635a1 RP |
398 | |
399 | #define target_fetch_registers(regno) \ | |
e8bf33c4 | 400 | (*current_target.to_fetch_registers) (regno) |
bd5635a1 RP |
401 | |
402 | /* Store at least register REGNO, or all regs if REGNO == -1. | |
f1e7bafc JK |
403 | It can store as many registers as it wants to, so target_prepare_to_store |
404 | must have been previously called. Calls error() if there are problems. */ | |
bd5635a1 RP |
405 | |
406 | #define target_store_registers(regs) \ | |
e8bf33c4 | 407 | (*current_target.to_store_registers) (regs) |
bd5635a1 RP |
408 | |
409 | /* Get ready to modify the registers array. On machines which store | |
410 | individual registers, this doesn't need to do anything. On machines | |
411 | which store all the registers in one fell swoop, this makes sure | |
412 | that REGISTERS contains all the registers from the program being | |
413 | debugged. */ | |
414 | ||
415 | #define target_prepare_to_store() \ | |
e8bf33c4 | 416 | (*current_target.to_prepare_to_store) () |
bd5635a1 | 417 | |
4ad0021e | 418 | extern int target_read_string PARAMS ((CORE_ADDR, char **, int, int *)); |
75af490b JG |
419 | |
420 | extern int | |
421 | target_read_memory PARAMS ((CORE_ADDR, char *, int)); | |
422 | ||
f1e7bafc JK |
423 | extern int |
424 | target_read_memory_partial PARAMS ((CORE_ADDR, char *, int, int *)); | |
425 | ||
75af490b JG |
426 | extern int |
427 | target_write_memory PARAMS ((CORE_ADDR, char *, int)); | |
428 | ||
429 | extern int | |
430 | xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *)); | |
431 | ||
432 | extern int | |
433 | child_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *)); | |
434 | ||
f1e7bafc JK |
435 | /* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR. |
436 | Returns 0 for success, errno code for failure (which includes partial | |
437 | transfers--if you want a more useful response to partial transfers, try | |
438 | target_read_memory_partial). */ | |
439 | ||
440 | extern int target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, | |
441 | int len, int write)); | |
75af490b JG |
442 | |
443 | /* From exec.c */ | |
444 | ||
445 | extern void | |
446 | print_section_info PARAMS ((struct target_ops *, bfd *)); | |
bd5635a1 RP |
447 | |
448 | /* Print a line about the current target. */ | |
449 | ||
450 | #define target_files_info() \ | |
e8bf33c4 | 451 | (*current_target.to_files_info) (¤t_target) |
bd5635a1 RP |
452 | |
453 | /* Insert a breakpoint at address ADDR in the target machine. | |
454 | SAVE is a pointer to memory allocated for saving the | |
455 | target contents. It is guaranteed by the caller to be long enough | |
456 | to save "sizeof BREAKPOINT" bytes. Result is 0 for success, or | |
457 | an errno value. */ | |
458 | ||
459 | #define target_insert_breakpoint(addr, save) \ | |
e8bf33c4 | 460 | (*current_target.to_insert_breakpoint) (addr, save) |
bd5635a1 RP |
461 | |
462 | /* Remove a breakpoint at address ADDR in the target machine. | |
463 | SAVE is a pointer to the same save area | |
464 | that was previously passed to target_insert_breakpoint. | |
465 | Result is 0 for success, or an errno value. */ | |
466 | ||
467 | #define target_remove_breakpoint(addr, save) \ | |
e8bf33c4 | 468 | (*current_target.to_remove_breakpoint) (addr, save) |
bd5635a1 RP |
469 | |
470 | /* Initialize the terminal settings we record for the inferior, | |
471 | before we actually run the inferior. */ | |
472 | ||
473 | #define target_terminal_init() \ | |
e8bf33c4 | 474 | (*current_target.to_terminal_init) () |
f1e7bafc | 475 | |
bd5635a1 RP |
476 | /* Put the inferior's terminal settings into effect. |
477 | This is preparation for starting or resuming the inferior. */ | |
478 | ||
479 | #define target_terminal_inferior() \ | |
e8bf33c4 | 480 | (*current_target.to_terminal_inferior) () |
bd5635a1 RP |
481 | |
482 | /* Put some of our terminal settings into effect, | |
483 | enough to get proper results from our output, | |
484 | but do not change into or out of RAW mode | |
485 | so that no input is discarded. | |
486 | ||
487 | After doing this, either terminal_ours or terminal_inferior | |
488 | should be called to get back to a normal state of affairs. */ | |
489 | ||
490 | #define target_terminal_ours_for_output() \ | |
e8bf33c4 | 491 | (*current_target.to_terminal_ours_for_output) () |
bd5635a1 RP |
492 | |
493 | /* Put our terminal settings into effect. | |
494 | First record the inferior's terminal settings | |
495 | so they can be restored properly later. */ | |
496 | ||
497 | #define target_terminal_ours() \ | |
e8bf33c4 | 498 | (*current_target.to_terminal_ours) () |
bd5635a1 RP |
499 | |
500 | /* Print useful information about our terminal status, if such a thing | |
501 | exists. */ | |
502 | ||
503 | #define target_terminal_info(arg, from_tty) \ | |
e8bf33c4 | 504 | (*current_target.to_terminal_info) (arg, from_tty) |
bd5635a1 RP |
505 | |
506 | /* Kill the inferior process. Make it go away. */ | |
507 | ||
75af490b | 508 | #define target_kill() \ |
e8bf33c4 | 509 | (*current_target.to_kill) () |
bd5635a1 RP |
510 | |
511 | /* Load an executable file into the target process. This is expected to | |
512 | not only bring new code into the target process, but also to update | |
513 | GDB's symbol tables to match. */ | |
514 | ||
515 | #define target_load(arg, from_tty) \ | |
e8bf33c4 | 516 | (*current_target.to_load) (arg, from_tty) |
bd5635a1 | 517 | |
bd5635a1 RP |
518 | /* Look up a symbol in the target's symbol table. NAME is the symbol |
519 | name. ADDRP is a CORE_ADDR * pointing to where the value of the symbol | |
520 | should be returned. The result is 0 if successful, nonzero if the | |
521 | symbol does not exist in the target environment. This function should | |
522 | not call error() if communication with the target is interrupted, since | |
523 | it is called from symbol reading, but should return nonzero, possibly | |
524 | doing a complain(). */ | |
525 | ||
526 | #define target_lookup_symbol(name, addrp) \ | |
e8bf33c4 | 527 | (*current_target.to_lookup_symbol) (name, addrp) |
bd5635a1 RP |
528 | |
529 | /* Start an inferior process and set inferior_pid to its pid. | |
530 | EXEC_FILE is the file to run. | |
531 | ALLARGS is a string containing the arguments to the program. | |
532 | ENV is the environment vector to pass. Errors reported with error(). | |
533 | On VxWorks and various standalone systems, we ignore exec_file. */ | |
534 | ||
535 | #define target_create_inferior(exec_file, args, env) \ | |
e8bf33c4 | 536 | (*current_target.to_create_inferior) (exec_file, args, env) |
bd5635a1 RP |
537 | |
538 | /* The inferior process has died. Do what is right. */ | |
539 | ||
540 | #define target_mourn_inferior() \ | |
e8bf33c4 | 541 | (*current_target.to_mourn_inferior) () |
bd5635a1 | 542 | |
836e343b JG |
543 | /* Does target have enough data to do a run or attach command? */ |
544 | ||
545 | #define target_can_run(t) \ | |
546 | ((t)->to_can_run) () | |
547 | ||
f1e7bafc JK |
548 | /* post process changes to signal handling in the inferior. */ |
549 | ||
67ac9759 | 550 | #define target_notice_signals(pid) \ |
e8bf33c4 JK |
551 | (*current_target.to_notice_signals) (pid) |
552 | ||
cb1709ae DP |
553 | /* Check to see if a thread is still alive. */ |
554 | ||
555 | #define target_thread_alive(pid) \ | |
556 | (*current_target.to_thread_alive) (pid) | |
557 | ||
e8bf33c4 JK |
558 | /* Make target stop in a continuable fashion. (For instance, under Unix, this |
559 | should act like SIGSTOP). This function is normally used by GUIs to | |
560 | implement a stop button. */ | |
561 | ||
562 | #define target_stop() current_target.to_stop () | |
f1e7bafc | 563 | |
bd5635a1 RP |
564 | /* Pointer to next target in the chain, e.g. a core file and an exec file. */ |
565 | ||
566 | #define target_next \ | |
e8bf33c4 | 567 | (current_target.to_next) |
bd5635a1 RP |
568 | |
569 | /* Does the target include all of memory, or only part of it? This | |
570 | determines whether we look up the target chain for other parts of | |
571 | memory if this target can't satisfy a request. */ | |
572 | ||
573 | #define target_has_all_memory \ | |
e8bf33c4 | 574 | (current_target.to_has_all_memory) |
bd5635a1 RP |
575 | |
576 | /* Does the target include memory? (Dummy targets don't.) */ | |
577 | ||
578 | #define target_has_memory \ | |
e8bf33c4 | 579 | (current_target.to_has_memory) |
bd5635a1 RP |
580 | |
581 | /* Does the target have a stack? (Exec files don't, VxWorks doesn't, until | |
582 | we start a process.) */ | |
583 | ||
584 | #define target_has_stack \ | |
e8bf33c4 | 585 | (current_target.to_has_stack) |
bd5635a1 RP |
586 | |
587 | /* Does the target have registers? (Exec files don't.) */ | |
588 | ||
589 | #define target_has_registers \ | |
e8bf33c4 | 590 | (current_target.to_has_registers) |
bd5635a1 | 591 | |
f1e7bafc JK |
592 | /* Does the target have execution? Can we make it jump (through |
593 | hoops), or pop its stack a few times? FIXME: If this is to work that | |
594 | way, it needs to check whether an inferior actually exists. | |
595 | remote-udi.c and probably other targets can be the current target | |
596 | when the inferior doesn't actually exist at the moment. Right now | |
597 | this just tells us whether this target is *capable* of execution. */ | |
bd5635a1 RP |
598 | |
599 | #define target_has_execution \ | |
e8bf33c4 | 600 | (current_target.to_has_execution) |
bd5635a1 | 601 | |
1c95d7ab JK |
602 | extern void target_link PARAMS ((char *, CORE_ADDR *)); |
603 | ||
f1e7bafc JK |
604 | /* Converts a process id to a string. Usually, the string just contains |
605 | `process xyz', but on some systems it may contain | |
606 | `process xyz thread abc'. */ | |
607 | ||
608 | #ifndef target_pid_to_str | |
609 | #define target_pid_to_str(PID) \ | |
610 | normal_pid_to_str (PID) | |
611 | extern char *normal_pid_to_str PARAMS ((int pid)); | |
612 | #endif | |
613 | ||
cb1709ae DP |
614 | #ifndef target_new_objfile |
615 | #define target_new_objfile(OBJFILE) | |
616 | #endif | |
617 | ||
618 | /* Hook to call target-dependant code after reading in a new symbol table. */ | |
619 | ||
620 | #ifndef TARGET_SYMFILE_POSTREAD | |
621 | #define TARGET_SYMFILE_POSTREAD(OBJFILE) | |
622 | #endif | |
623 | ||
624 | /* Hook to call target dependant code just after inferior target process has | |
625 | started. */ | |
626 | ||
627 | #ifndef TARGET_CREATE_INFERIOR_HOOK | |
628 | #define TARGET_CREATE_INFERIOR_HOOK(PID) | |
629 | #endif | |
630 | ||
e8bf33c4 JK |
631 | /* Hardware watchpoint interfaces. */ |
632 | ||
633 | /* Returns non-zero if we were stopped by a hardware watchpoint (memory read or | |
634 | write). */ | |
635 | ||
636 | #ifndef STOPPED_BY_WATCHPOINT | |
637 | #define STOPPED_BY_WATCHPOINT(w) 0 | |
638 | #endif | |
639 | ||
cb1709ae DP |
640 | /* Provide defaults for systems that don't support hardware watchpoints. */ |
641 | ||
642 | #ifndef TARGET_HAS_HARDWARE_WATCHPOINTS | |
643 | ||
644 | /* Returns non-zero if we can set a hardware watchpoint of type TYPE. TYPE is | |
645 | one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint, or | |
646 | bp_hardware_breakpoint. CNT is the number of such watchpoints used so far | |
647 | (including this one?). OTHERTYPE is who knows what... */ | |
648 | ||
649 | #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0 | |
650 | ||
651 | /* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 1 | |
652 | for read and 2 for read/write accesses. Returns 0 for success, non-zero for | |
653 | failure. */ | |
654 | ||
655 | #define target_remove_watchpoint(ADDR,LEN,TYPE) -1 | |
656 | #define target_insert_watchpoint(ADDR,LEN,TYPE) -1 | |
657 | ||
658 | #endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */ | |
659 | ||
660 | #ifndef target_insert_hw_breakpoint | |
661 | #define target_remove_hw_breakpoint(ADDR,SHADOW) -1 | |
662 | #define target_insert_hw_breakpoint(ADDR,SHADOW) -1 | |
663 | #endif | |
664 | ||
665 | #ifndef target_stopped_data_address | |
666 | #define target_stopped_data_address() 0 | |
667 | #endif | |
668 | ||
669 | /* If defined, then we need to decr pc by this much after a hardware break- | |
670 | point. Presumably this overrides DECR_PC_AFTER_BREAK... */ | |
671 | ||
672 | #ifndef DECR_PC_AFTER_HW_BREAK | |
673 | #define DECR_PC_AFTER_HW_BREAK 0 | |
674 | #endif | |
675 | ||
bd5635a1 RP |
676 | /* Routines for maintenance of the target structures... |
677 | ||
678 | add_target: Add a target to the list of all possible targets. | |
679 | ||
680 | push_target: Make this target the top of the stack of currently used | |
681 | targets, within its particular stratum of the stack. Result | |
682 | is 0 if now atop the stack, nonzero if not on top (maybe | |
683 | should warn user). | |
684 | ||
685 | unpush_target: Remove this from the stack of currently used targets, | |
686 | no matter where it is on the list. Returns 0 if no | |
687 | change, 1 if removed from stack. | |
688 | ||
689 | pop_target: Remove the top thing on the stack of current targets. */ | |
690 | ||
75af490b JG |
691 | extern void |
692 | add_target PARAMS ((struct target_ops *)); | |
693 | ||
694 | extern int | |
695 | push_target PARAMS ((struct target_ops *)); | |
696 | ||
697 | extern int | |
698 | unpush_target PARAMS ((struct target_ops *)); | |
699 | ||
700 | extern void | |
701 | target_preopen PARAMS ((int)); | |
702 | ||
703 | extern void | |
704 | pop_target PARAMS ((void)); | |
705 | ||
706 | /* Struct section_table maps address ranges to file sections. It is | |
707 | mostly used with BFD files, but can be used without (e.g. for handling | |
708 | raw disks, or files not in formats handled by BFD). */ | |
709 | ||
710 | struct section_table { | |
711 | CORE_ADDR addr; /* Lowest address in section */ | |
712 | CORE_ADDR endaddr; /* 1+highest address in section */ | |
82a2edfb | 713 | |
1c95d7ab | 714 | sec_ptr the_bfd_section; |
82a2edfb | 715 | |
75af490b JG |
716 | bfd *bfd; /* BFD file pointer */ |
717 | }; | |
718 | ||
719 | /* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR. | |
720 | Returns 0 if OK, 1 on error. */ | |
721 | ||
722 | extern int | |
723 | build_section_table PARAMS ((bfd *, struct section_table **, | |
724 | struct section_table **)); | |
725 | ||
75af490b JG |
726 | /* From mem-break.c */ |
727 | ||
728 | extern int | |
729 | memory_remove_breakpoint PARAMS ((CORE_ADDR, char *)); | |
730 | ||
731 | extern int | |
732 | memory_insert_breakpoint PARAMS ((CORE_ADDR, char *)); | |
733 | ||
dcc8abce JG |
734 | /* From target.c */ |
735 | ||
736 | void | |
737 | noprocess PARAMS ((void)); | |
738 | ||
836e343b JG |
739 | void |
740 | find_default_attach PARAMS ((char *, int)); | |
741 | ||
742 | void | |
743 | find_default_create_inferior PARAMS ((char *, char *, char **)); | |
744 | ||
f1e7bafc JK |
745 | struct target_ops * |
746 | find_core_target PARAMS ((void)); | |
747 | \f | |
67ac9759 JK |
748 | /* Stuff that should be shared among the various remote targets. */ |
749 | ||
750 | /* Debugging level. 0 is off, and non-zero values mean to print some debug | |
751 | information (higher values, more information). */ | |
752 | extern int remote_debug; | |
753 | ||
c20c1bdf | 754 | /* Speed in bits per second, or -1 which means don't mess with the speed. */ |
67ac9759 | 755 | extern int baud_rate; |
cb1709ae DP |
756 | /* Timeout limit for response from target. */ |
757 | extern int remote_timeout; | |
67ac9759 JK |
758 | \f |
759 | /* Functions for helping to write a native target. */ | |
760 | ||
761 | /* This is for native targets which use a unix/POSIX-style waitstatus. */ | |
762 | extern void store_waitstatus PARAMS ((struct target_waitstatus *, int)); | |
763 | ||
764 | /* Convert between host signal numbers and enum target_signal's. */ | |
765 | extern enum target_signal target_signal_from_host PARAMS ((int)); | |
766 | extern int target_signal_to_host PARAMS ((enum target_signal)); | |
767 | ||
e8bf33c4 JK |
768 | /* Convert from a number used in a GDB command to an enum target_signal. */ |
769 | extern enum target_signal target_signal_from_command PARAMS ((int)); | |
770 | ||
75af490b | 771 | #endif /* !defined (TARGET_H) */ |