* hppa-tdep.c: Remove all uses of use_unwind and `set use_unwind'
[deliverable/binutils-gdb.git] / gdb / target.h
CommitLineData
bd5635a1 1/* Interface between GDB and target environments, including files and processes
75af490b 2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
bd5635a1
RP
3 Contributed by Cygnus Support. Written by John Gilmore.
4
5This file is part of GDB.
6
75af490b 7This program is free software; you can redistribute it and/or modify
bd5635a1 8it under the terms of the GNU General Public License as published by
75af490b
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
bd5635a1 11
75af490b 12This program is distributed in the hope that it will be useful,
bd5635a1
RP
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
75af490b
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
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
45enum strata {
46 dummy_stratum, /* The lowest of the low */
47 file_stratum, /* Executable files, etc */
48 core_stratum, /* Core dump files */
75af490b 49 process_stratum /* Executing processes */
bd5635a1
RP
50};
51
75af490b
JG
52struct target_ops
53{
54 char *to_shortname; /* Name this target type */
55 char *to_longname; /* Name for printing */
56 char *to_doc; /* Documentation. Does not include trailing
57 newline, and starts with a one-line descrip-
58 tion (probably similar to to_longname). */
59 void (*to_open) PARAMS ((char *, int));
60 void (*to_close) PARAMS ((int));
61 void (*to_attach) PARAMS ((char *, int));
62 void (*to_detach) PARAMS ((char *, int));
63 void (*to_resume) PARAMS ((int, int));
64 int (*to_wait) PARAMS ((int *));
65 void (*to_fetch_registers) PARAMS ((int));
66 void (*to_store_registers) PARAMS ((int));
67 void (*to_prepare_to_store) PARAMS ((void));
75af490b
JG
68 int (*to_xfer_memory) PARAMS ((CORE_ADDR, char *, int, int,
69 struct target_ops *));
70 void (*to_files_info) PARAMS ((struct target_ops *));
71 int (*to_insert_breakpoint) PARAMS ((CORE_ADDR, char *));
72 int (*to_remove_breakpoint) PARAMS ((CORE_ADDR, char *));
73 void (*to_terminal_init) PARAMS ((void));
74 void (*to_terminal_inferior) PARAMS ((void));
75 void (*to_terminal_ours_for_output) PARAMS ((void));
76 void (*to_terminal_ours) PARAMS ((void));
77 void (*to_terminal_info) PARAMS ((char *, int));
78 void (*to_kill) PARAMS ((void));
79 void (*to_load) PARAMS ((char *, int));
80 int (*to_lookup_symbol) PARAMS ((char *, CORE_ADDR *));
81 void (*to_create_inferior) PARAMS ((char *, char *, char **));
82 void (*to_mourn_inferior) PARAMS ((void));
836e343b 83 int (*to_can_run) PARAMS ((void));
75af490b
JG
84 enum strata to_stratum;
85 struct target_ops
86 *to_next;
87 int to_has_all_memory;
88 int to_has_memory;
89 int to_has_stack;
90 int to_has_registers;
91 int to_has_execution;
92 struct section_table
93 *to_sections;
94 struct section_table
95 *to_sections_end;
96 int to_magic;
97 /* Need sub-structure for target machine related rather than comm related? */
bd5635a1
RP
98};
99
100/* Magic number for checking ops size. If a struct doesn't end with this
101 number, somebody changed the declaration but didn't change all the
102 places that initialize one. */
103
104#define OPS_MAGIC 3840
105
106/* The ops structure for our "current" target process. */
107
108extern struct target_ops *current_target;
109
110/* Define easy words for doing these operations on our current target. */
111
112#define target_shortname (current_target->to_shortname)
113#define target_longname (current_target->to_longname)
114
9136fe49
JK
115/* The open routine takes the rest of the parameters from the command,
116 and (if successful) pushes a new target onto the stack.
117 Targets should supply this routine, if only to provide an error message. */
bd5635a1
RP
118#define target_open(name, from_tty) \
119 (*current_target->to_open) (name, from_tty)
120
121/* Does whatever cleanup is required for a target that we are no longer
122 going to be calling. Argument says whether we are quitting gdb and
123 should not get hung in case of errors, or whether we want a clean
124 termination even if it takes a while. This routine is automatically
125 always called just before a routine is popped off the target stack.
126 Closing file descriptors and freeing memory are typical things it should
127 do. */
128
129#define target_close(quitting) \
130 (*current_target->to_close) (quitting)
131
836e343b
JG
132/* Attaches to a process on the target side. Arguments are as passed
133 to the `attach' command by the user. This routine can be called
134 when the target is not on the target-stack, if the target_can_run
135 routine returns 1; in that case, it must push itself onto the stack.
136 Upon exit, the target should be ready for normal operations, and
137 should be ready to deliver the status of the process immediately
138 (without waiting) to an upcoming target_wait call. */
bd5635a1
RP
139
140#define target_attach(args, from_tty) \
141 (*current_target->to_attach) (args, from_tty)
142
143/* Takes a program previously attached to and detaches it.
144 The program may resume execution (some targets do, some don't) and will
145 no longer stop on signals, etc. We better not have left any breakpoints
146 in the program or it'll die when it hits one. ARGS is arguments
147 typed by the user (e.g. a signal to send the process). FROM_TTY
148 says whether to be verbose or not. */
149
150#define target_detach(args, from_tty) \
151 (*current_target->to_detach) (args, from_tty)
152
153/* Resume execution of the target process. STEP says whether to single-step
154 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
155 to the target, or zero for no signal. */
156
157#define target_resume(step, siggnal) \
158 (*current_target->to_resume) (step, siggnal)
159
160/* Wait for inferior process to do something. Return pid of child,
161 or -1 in case of error; store status through argument pointer STATUS. */
162
163#define target_wait(status) \
164 (*current_target->to_wait) (status)
165
75af490b 166/* Fetch register REGNO, or all regs if regno == -1. No result. */
bd5635a1
RP
167
168#define target_fetch_registers(regno) \
169 (*current_target->to_fetch_registers) (regno)
170
171/* Store at least register REGNO, or all regs if REGNO == -1.
172 It can store as many registers as it wants to, so the entire registers
173 array must be valid. Result is 0 for success, -1 for problems. */
174
175#define target_store_registers(regs) \
176 (*current_target->to_store_registers) (regs)
177
178/* Get ready to modify the registers array. On machines which store
179 individual registers, this doesn't need to do anything. On machines
180 which store all the registers in one fell swoop, this makes sure
181 that REGISTERS contains all the registers from the program being
182 debugged. */
183
184#define target_prepare_to_store() \
185 (*current_target->to_prepare_to_store) ()
186
bd5635a1
RP
187/* Reading and writing memory actually happens through a glue
188 function which iterates across the various targets. Result is
189 0 for success, or an errno value. */
190
75af490b
JG
191extern int
192target_read_string PARAMS ((CORE_ADDR, char *, int));
193
194extern int
195target_read_memory PARAMS ((CORE_ADDR, char *, int));
196
197extern int
198target_write_memory PARAMS ((CORE_ADDR, char *, int));
199
200extern int
201xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
202
203extern int
204child_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
205
206extern int
207target_xfer_memory PARAMS ((CORE_ADDR, char *, int, int));
208
209/* From exec.c */
210
211extern void
212print_section_info PARAMS ((struct target_ops *, bfd *));
bd5635a1
RP
213
214/* Print a line about the current target. */
215
216#define target_files_info() \
75af490b 217 (*current_target->to_files_info) (current_target)
bd5635a1
RP
218
219/* Insert a breakpoint at address ADDR in the target machine.
220 SAVE is a pointer to memory allocated for saving the
221 target contents. It is guaranteed by the caller to be long enough
222 to save "sizeof BREAKPOINT" bytes. Result is 0 for success, or
223 an errno value. */
224
225#define target_insert_breakpoint(addr, save) \
226 (*current_target->to_insert_breakpoint) (addr, save)
227
228/* Remove a breakpoint at address ADDR in the target machine.
229 SAVE is a pointer to the same save area
230 that was previously passed to target_insert_breakpoint.
231 Result is 0 for success, or an errno value. */
232
233#define target_remove_breakpoint(addr, save) \
234 (*current_target->to_remove_breakpoint) (addr, save)
235
236/* Initialize the terminal settings we record for the inferior,
237 before we actually run the inferior. */
238
239#define target_terminal_init() \
240 (*current_target->to_terminal_init) ()
241
242/* Put the inferior's terminal settings into effect.
243 This is preparation for starting or resuming the inferior. */
244
245#define target_terminal_inferior() \
246 (*current_target->to_terminal_inferior) ()
247
248/* Put some of our terminal settings into effect,
249 enough to get proper results from our output,
250 but do not change into or out of RAW mode
251 so that no input is discarded.
252
253 After doing this, either terminal_ours or terminal_inferior
254 should be called to get back to a normal state of affairs. */
255
256#define target_terminal_ours_for_output() \
257 (*current_target->to_terminal_ours_for_output) ()
258
259/* Put our terminal settings into effect.
260 First record the inferior's terminal settings
261 so they can be restored properly later. */
262
263#define target_terminal_ours() \
264 (*current_target->to_terminal_ours) ()
265
266/* Print useful information about our terminal status, if such a thing
267 exists. */
268
269#define target_terminal_info(arg, from_tty) \
270 (*current_target->to_terminal_info) (arg, from_tty)
271
272/* Kill the inferior process. Make it go away. */
273
75af490b
JG
274#define target_kill() \
275 (*current_target->to_kill) ()
bd5635a1
RP
276
277/* Load an executable file into the target process. This is expected to
278 not only bring new code into the target process, but also to update
279 GDB's symbol tables to match. */
280
281#define target_load(arg, from_tty) \
282 (*current_target->to_load) (arg, from_tty)
283
bd5635a1
RP
284/* Look up a symbol in the target's symbol table. NAME is the symbol
285 name. ADDRP is a CORE_ADDR * pointing to where the value of the symbol
286 should be returned. The result is 0 if successful, nonzero if the
287 symbol does not exist in the target environment. This function should
288 not call error() if communication with the target is interrupted, since
289 it is called from symbol reading, but should return nonzero, possibly
290 doing a complain(). */
291
292#define target_lookup_symbol(name, addrp) \
293 (*current_target->to_lookup_symbol) (name, addrp)
294
295/* Start an inferior process and set inferior_pid to its pid.
296 EXEC_FILE is the file to run.
297 ALLARGS is a string containing the arguments to the program.
298 ENV is the environment vector to pass. Errors reported with error().
299 On VxWorks and various standalone systems, we ignore exec_file. */
300
301#define target_create_inferior(exec_file, args, env) \
302 (*current_target->to_create_inferior) (exec_file, args, env)
303
304/* The inferior process has died. Do what is right. */
305
306#define target_mourn_inferior() \
307 (*current_target->to_mourn_inferior) ()
308
836e343b
JG
309/* Does target have enough data to do a run or attach command? */
310
311#define target_can_run(t) \
312 ((t)->to_can_run) ()
313
bd5635a1
RP
314/* Pointer to next target in the chain, e.g. a core file and an exec file. */
315
316#define target_next \
317 (current_target->to_next)
318
319/* Does the target include all of memory, or only part of it? This
320 determines whether we look up the target chain for other parts of
321 memory if this target can't satisfy a request. */
322
323#define target_has_all_memory \
324 (current_target->to_has_all_memory)
325
326/* Does the target include memory? (Dummy targets don't.) */
327
328#define target_has_memory \
329 (current_target->to_has_memory)
330
331/* Does the target have a stack? (Exec files don't, VxWorks doesn't, until
332 we start a process.) */
333
334#define target_has_stack \
335 (current_target->to_has_stack)
336
337/* Does the target have registers? (Exec files don't.) */
338
339#define target_has_registers \
340 (current_target->to_has_registers)
341
342/* Does the target have execution? Can we make it jump (through hoops),
75af490b 343 or pop its stack a few times? */
bd5635a1
RP
344
345#define target_has_execution \
346 (current_target->to_has_execution)
347
348/* Routines for maintenance of the target structures...
349
350 add_target: Add a target to the list of all possible targets.
351
352 push_target: Make this target the top of the stack of currently used
353 targets, within its particular stratum of the stack. Result
354 is 0 if now atop the stack, nonzero if not on top (maybe
355 should warn user).
356
357 unpush_target: Remove this from the stack of currently used targets,
358 no matter where it is on the list. Returns 0 if no
359 change, 1 if removed from stack.
360
361 pop_target: Remove the top thing on the stack of current targets. */
362
75af490b
JG
363extern void
364add_target PARAMS ((struct target_ops *));
365
366extern int
367push_target PARAMS ((struct target_ops *));
368
369extern int
370unpush_target PARAMS ((struct target_ops *));
371
372extern void
373target_preopen PARAMS ((int));
374
375extern void
376pop_target PARAMS ((void));
377
378/* Struct section_table maps address ranges to file sections. It is
379 mostly used with BFD files, but can be used without (e.g. for handling
380 raw disks, or files not in formats handled by BFD). */
381
382struct section_table {
383 CORE_ADDR addr; /* Lowest address in section */
384 CORE_ADDR endaddr; /* 1+highest address in section */
385 sec_ptr sec_ptr; /* BFD section pointer */
386 bfd *bfd; /* BFD file pointer */
387};
388
389/* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
390 Returns 0 if OK, 1 on error. */
391
392extern int
393build_section_table PARAMS ((bfd *, struct section_table **,
394 struct section_table **));
395
75af490b
JG
396/* From mem-break.c */
397
398extern int
399memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
400
401extern int
402memory_insert_breakpoint PARAMS ((CORE_ADDR, char *));
403
dcc8abce
JG
404/* From target.c */
405
406void
407noprocess PARAMS ((void));
408
836e343b
JG
409void
410find_default_attach PARAMS ((char *, int));
411
412void
413find_default_create_inferior PARAMS ((char *, char *, char **));
414
75af490b 415#endif /* !defined (TARGET_H) */
This page took 0.132603 seconds and 4 git commands to generate.