Various cleanups in target read/write code
[deliverable/binutils-gdb.git] / gdb / target.h
CommitLineData
c906108c 1/* Interface between GDB and target environments, including files and processes
0088c768 2
32d0add0 3 Copyright (C) 1990-2015 Free Software Foundation, Inc.
0088c768 4
c906108c
SS
5 Contributed by Cygnus Support. Written by John Gilmore.
6
c5aa993b 7 This file is part of GDB.
c906108c 8
c5aa993b
JM
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
c5aa993b 12 (at your option) any later version.
c906108c 13
c5aa993b
JM
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.
c906108c 18
c5aa993b 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/>. */
c906108c
SS
21
22#if !defined (TARGET_H)
23#define TARGET_H
24
da3331ec
AC
25struct objfile;
26struct ui_file;
27struct mem_attrib;
1e3ff5ad 28struct target_ops;
d248b706 29struct bp_location;
8181d85f 30struct bp_target_info;
56be3814 31struct regcache;
07b82ea5 32struct target_section_table;
35b1e5cc 33struct trace_state_variable;
00bf0b85
SS
34struct trace_status;
35struct uploaded_tsv;
36struct uploaded_tp;
0fb4aa4b 37struct static_tracepoint_marker;
b3b9301e 38struct traceframe_info;
0cf6dd15 39struct expression;
2a2f9fe4 40struct dcache_struct;
07c138c8 41struct inferior;
0cf6dd15 42
68c14faa
PA
43#include "infrun.h" /* For enum exec_direction_kind. */
44
c906108c
SS
45/* This include file defines the interface between the main part
46 of the debugger, and the part which is target-specific, or
47 specific to the communications interface between us and the
48 target.
49
2146d243
RM
50 A TARGET is an interface between the debugger and a particular
51 kind of file or process. Targets can be STACKED in STRATA,
c906108c
SS
52 so that more than one target can potentially respond to a request.
53 In particular, memory accesses will walk down the stack of targets
54 until they find a target that is interested in handling that particular
55 address. STRATA are artificial boundaries on the stack, within
56 which particular kinds of targets live. Strata exist so that
57 people don't get confused by pushing e.g. a process target and then
58 a file target, and wondering why they can't see the current values
59 of variables any more (the file target is handling them and they
60 never get to the process target). So when you push a file target,
61 it goes into the file stratum, which is always below the process
62 stratum. */
63
721ec300 64#include "target/target.h"
33b60d58
LM
65#include "target/resume.h"
66#include "target/wait.h"
67#include "target/waitstatus.h"
c906108c
SS
68#include "bfd.h"
69#include "symtab.h"
29e57380 70#include "memattr.h"
fd79ecee 71#include "vec.h"
2aecd87f 72#include "gdb_signals.h"
02d27625 73#include "btrace.h"
9852c492 74#include "command.h"
c906108c 75
c5aa993b
JM
76enum strata
77 {
78 dummy_stratum, /* The lowest of the low */
79 file_stratum, /* Executable files, etc */
c0edd9ed 80 process_stratum, /* Executing processes or core dump files */
81e64f55 81 thread_stratum, /* Executing threads */
85e747d2
UW
82 record_stratum, /* Support record debugging */
83 arch_stratum /* Architecture overrides */
c5aa993b 84 };
c906108c 85
c5aa993b
JM
86enum thread_control_capabilities
87 {
0d06e24b
JM
88 tc_none = 0, /* Default: can't control thread execution. */
89 tc_schedlock = 1, /* Can lock the thread scheduler. */
c5aa993b 90 };
c906108c 91
a96d9b2e
SDJ
92/* The structure below stores information about a system call.
93 It is basically used in the "catch syscall" command, and in
94 every function that gives information about a system call.
95
96 It's also good to mention that its fields represent everything
97 that we currently know about a syscall in GDB. */
98struct syscall
99 {
100 /* The syscall number. */
101 int number;
102
103 /* The syscall name. */
104 const char *name;
105 };
106
f00150c9
DE
107/* Return a pretty printed form of target_waitstatus.
108 Space for the result is malloc'd, caller must free. */
109extern char *target_waitstatus_to_string (const struct target_waitstatus *);
110
09826ec5
PA
111/* Return a pretty printed form of TARGET_OPTIONS.
112 Space for the result is malloc'd, caller must free. */
113extern char *target_options_to_string (int target_options);
114
2acceee2 115/* Possible types of events that the inferior handler will have to
0d06e24b 116 deal with. */
2acceee2
JM
117enum inferior_event_type
118 {
2acceee2 119 /* Process a normal inferior event which will result in target_wait
0d06e24b 120 being called. */
2146d243 121 INF_REG_EVENT,
0d06e24b 122 /* We are called because a timer went off. */
2acceee2 123 INF_TIMER,
0d06e24b 124 /* We are called to do stuff after the inferior stops. */
c2d11a7d
JM
125 INF_EXEC_COMPLETE,
126 /* We are called to do some stuff after the inferior stops, but we
127 are expected to reenter the proceed() and
c378eb4e 128 handle_inferior_event() functions. This is used only in case of
0d06e24b 129 'step n' like commands. */
c2d11a7d 130 INF_EXEC_CONTINUE
2acceee2 131 };
c906108c 132\f
13547ab6
DJ
133/* Target objects which can be transfered using target_read,
134 target_write, et cetera. */
1e3ff5ad
AC
135
136enum target_object
137{
1e3ff5ad
AC
138 /* AVR target specific transfer. See "avr-tdep.c" and "remote.c". */
139 TARGET_OBJECT_AVR,
23d964e7
UW
140 /* SPU target specific transfer. See "spu-tdep.c". */
141 TARGET_OBJECT_SPU,
1e3ff5ad 142 /* Transfer up-to LEN bytes of memory starting at OFFSET. */
287a334e 143 TARGET_OBJECT_MEMORY,
cf7a04e8
DJ
144 /* Memory, avoiding GDB's data cache and trusting the executable.
145 Target implementations of to_xfer_partial never need to handle
146 this object, and most callers should not use it. */
147 TARGET_OBJECT_RAW_MEMORY,
4e5d721f
DE
148 /* Memory known to be part of the target's stack. This is cached even
149 if it is not in a region marked as such, since it is known to be
150 "normal" RAM. */
151 TARGET_OBJECT_STACK_MEMORY,
29453a14
YQ
152 /* Memory known to be part of the target code. This is cached even
153 if it is not in a region marked as such. */
154 TARGET_OBJECT_CODE_MEMORY,
287a334e
JJ
155 /* Kernel Unwind Table. See "ia64-tdep.c". */
156 TARGET_OBJECT_UNWIND_TABLE,
2146d243
RM
157 /* Transfer auxilliary vector. */
158 TARGET_OBJECT_AUXV,
baf92889 159 /* StackGhost cookie. See "sparc-tdep.c". */
fd79ecee
DJ
160 TARGET_OBJECT_WCOOKIE,
161 /* Target memory map in XML format. */
162 TARGET_OBJECT_MEMORY_MAP,
a76d924d
DJ
163 /* Flash memory. This object can be used to write contents to
164 a previously erased flash memory. Using it without erasing
165 flash can have unexpected results. Addresses are physical
166 address on target, and not relative to flash start. */
23181151
DJ
167 TARGET_OBJECT_FLASH,
168 /* Available target-specific features, e.g. registers and coprocessors.
169 See "target-descriptions.c". ANNEX should never be empty. */
cfa9d6d9
DJ
170 TARGET_OBJECT_AVAILABLE_FEATURES,
171 /* Currently loaded libraries, in XML format. */
07e059b5 172 TARGET_OBJECT_LIBRARIES,
2268b414
JK
173 /* Currently loaded libraries specific for SVR4 systems, in XML format. */
174 TARGET_OBJECT_LIBRARIES_SVR4,
4d1eb6b4 175 /* Currently loaded libraries specific to AIX systems, in XML format. */
ff99b71b 176 TARGET_OBJECT_LIBRARIES_AIX,
07e059b5 177 /* Get OS specific data. The ANNEX specifies the type (running
113a6f1e
JB
178 processes, etc.). The data being transfered is expected to follow
179 the DTD specified in features/osdata.dtd. */
4aa995e1
PA
180 TARGET_OBJECT_OSDATA,
181 /* Extra signal info. Usually the contents of `siginfo_t' on unix
182 platforms. */
183 TARGET_OBJECT_SIGNAL_INFO,
dc146f7c
VP
184 /* The list of threads that are being debugged. */
185 TARGET_OBJECT_THREADS,
0fb4aa4b
PA
186 /* Collected static trace data. */
187 TARGET_OBJECT_STATIC_TRACE_DATA,
77ca787b
JB
188 /* The HP-UX registers (those that can be obtained or modified by using
189 the TT_LWP_RUREGS/TT_LWP_WUREGS ttrace requests). */
190 TARGET_OBJECT_HPUX_UREGS,
c4de7027
JB
191 /* The HP-UX shared library linkage pointer. ANNEX should be a string
192 image of the code address whose linkage pointer we are looking for.
193
194 The size of the data transfered is always 8 bytes (the size of an
195 address on ia64). */
196 TARGET_OBJECT_HPUX_SOLIB_GOT,
b3b9301e
PA
197 /* Traceframe info, in XML format. */
198 TARGET_OBJECT_TRACEFRAME_INFO,
78d85199
YQ
199 /* Load maps for FDPIC systems. */
200 TARGET_OBJECT_FDPIC,
f00c55f8 201 /* Darwin dynamic linker info data. */
169081d0
TG
202 TARGET_OBJECT_DARWIN_DYLD_INFO,
203 /* OpenVMS Unwind Information Block. */
02d27625 204 TARGET_OBJECT_OPENVMS_UIB,
9accd112 205 /* Branch trace data, in XML format. */
f4abbc16
MM
206 TARGET_OBJECT_BTRACE,
207 /* Branch trace configuration, in XML format. */
c78fa86a
GB
208 TARGET_OBJECT_BTRACE_CONF,
209 /* The pathname of the executable file that was run to create
210 a specified process. ANNEX should be a string representation
211 of the process ID of the process in question, in hexadecimal
212 format. */
213 TARGET_OBJECT_EXEC_FILE,
c378eb4e 214 /* Possible future objects: TARGET_OBJECT_FILE, ... */
1e3ff5ad
AC
215};
216
9b409511 217/* Possible values returned by target_xfer_partial, etc. */
6be7b56e 218
9b409511 219enum target_xfer_status
6be7b56e 220{
9b409511
YQ
221 /* Some bytes are transferred. */
222 TARGET_XFER_OK = 1,
223
224 /* No further transfer is possible. */
225 TARGET_XFER_EOF = 0,
226
bc113b4e
YQ
227 /* The piece of the object requested is unavailable. */
228 TARGET_XFER_UNAVAILABLE = 2,
229
6be7b56e
PA
230 /* Generic I/O error. Note that it's important that this is '-1',
231 as we still have target_xfer-related code returning hardcoded
232 '-1' on error. */
233 TARGET_XFER_E_IO = -1,
234
01cb8804 235 /* Keep list in sync with target_xfer_status_to_string. */
6be7b56e
PA
236};
237
01cb8804 238/* Return the string form of STATUS. */
6be7b56e 239
01cb8804
YQ
240extern const char *
241 target_xfer_status_to_string (enum target_xfer_status status);
6be7b56e 242
35b1e5cc
SS
243/* Enumeration of the kinds of traceframe searches that a target may
244 be able to perform. */
245
246enum trace_find_type
247 {
248 tfind_number,
249 tfind_pc,
250 tfind_tp,
251 tfind_range,
252 tfind_outside,
253 };
254
0fb4aa4b
PA
255typedef struct static_tracepoint_marker *static_tracepoint_marker_p;
256DEF_VEC_P(static_tracepoint_marker_p);
257
9b409511 258typedef enum target_xfer_status
4ac248ca
YQ
259 target_xfer_partial_ftype (struct target_ops *ops,
260 enum target_object object,
261 const char *annex,
262 gdb_byte *readbuf,
263 const gdb_byte *writebuf,
264 ULONGEST offset,
9b409511
YQ
265 ULONGEST len,
266 ULONGEST *xfered_len);
4ac248ca 267
13547ab6
DJ
268/* Request that OPS transfer up to LEN 8-bit bytes of the target's
269 OBJECT. The OFFSET, for a seekable object, specifies the
270 starting point. The ANNEX can be used to provide additional
271 data-specific information to the target.
1e3ff5ad 272
578d3588
PA
273 Return the number of bytes actually transfered, or a negative error
274 code (an 'enum target_xfer_error' value) if the transfer is not
275 supported or otherwise fails. Return of a positive value less than
276 LEN indicates that no further transfer is possible. Unlike the raw
277 to_xfer_partial interface, callers of these functions do not need
278 to retry partial transfers. */
1e3ff5ad 279
1e3ff5ad
AC
280extern LONGEST target_read (struct target_ops *ops,
281 enum target_object object,
1b0ba102 282 const char *annex, gdb_byte *buf,
1e3ff5ad
AC
283 ULONGEST offset, LONGEST len);
284
8dedea02
VP
285struct memory_read_result
286 {
c378eb4e 287 /* First address that was read. */
8dedea02
VP
288 ULONGEST begin;
289 /* Past-the-end address. */
290 ULONGEST end;
291 /* The data. */
292 gdb_byte *data;
293};
294typedef struct memory_read_result memory_read_result_s;
295DEF_VEC_O(memory_read_result_s);
296
297extern void free_memory_read_result_vector (void *);
298
299extern VEC(memory_read_result_s)* read_memory_robust (struct target_ops *ops,
279a6fed
SM
300 const ULONGEST offset,
301 const LONGEST len);
302
1e3ff5ad
AC
303extern LONGEST target_write (struct target_ops *ops,
304 enum target_object object,
1b0ba102 305 const char *annex, const gdb_byte *buf,
1e3ff5ad 306 ULONGEST offset, LONGEST len);
b6591e8b 307
a76d924d
DJ
308/* Similar to target_write, except that it also calls PROGRESS with
309 the number of bytes written and the opaque BATON after every
310 successful partial write (and before the first write). This is
311 useful for progress reporting and user interaction while writing
312 data. To abort the transfer, the progress callback can throw an
313 exception. */
314
cf7a04e8
DJ
315LONGEST target_write_with_progress (struct target_ops *ops,
316 enum target_object object,
317 const char *annex, const gdb_byte *buf,
318 ULONGEST offset, LONGEST len,
319 void (*progress) (ULONGEST, void *),
320 void *baton);
321
13547ab6
DJ
322/* Wrapper to perform a full read of unknown size. OBJECT/ANNEX will
323 be read using OPS. The return value will be -1 if the transfer
324 fails or is not supported; 0 if the object is empty; or the length
325 of the object otherwise. If a positive value is returned, a
326 sufficiently large buffer will be allocated using xmalloc and
327 returned in *BUF_P containing the contents of the object.
328
329 This method should be used for objects sufficiently small to store
330 in a single xmalloc'd buffer, when no fixed bound on the object's
331 size is known in advance. Don't try to read TARGET_OBJECT_MEMORY
332 through this function. */
333
334extern LONGEST target_read_alloc (struct target_ops *ops,
335 enum target_object object,
336 const char *annex, gdb_byte **buf_p);
337
159f81f3
DJ
338/* Read OBJECT/ANNEX using OPS. The result is NUL-terminated and
339 returned as a string, allocated using xmalloc. If an error occurs
340 or the transfer is unsupported, NULL is returned. Empty objects
341 are returned as allocated but empty strings. A warning is issued
342 if the result contains any embedded NUL bytes. */
343
344extern char *target_read_stralloc (struct target_ops *ops,
345 enum target_object object,
346 const char *annex);
347
6be7b56e 348/* See target_ops->to_xfer_partial. */
4ac248ca 349extern target_xfer_partial_ftype target_xfer_partial;
6be7b56e 350
b6591e8b
AC
351/* Wrappers to target read/write that perform memory transfers. They
352 throw an error if the memory transfer fails.
353
354 NOTE: cagney/2003-10-23: The naming schema is lifted from
355 "frame.h". The parameter order is lifted from get_frame_memory,
356 which in turn lifted it from read_memory. */
357
358extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
1b0ba102 359 gdb_byte *buf, LONGEST len);
b6591e8b 360extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
e17a4113
UW
361 CORE_ADDR addr, int len,
362 enum bfd_endian byte_order);
1e3ff5ad 363\f
0d06e24b
JM
364struct thread_info; /* fwd decl for parameter list below: */
365
b0a16e66
TT
366/* The type of the callback to the to_async method. */
367
368typedef void async_callback_ftype (enum inferior_event_type event_type,
369 void *context);
370
a7068b60
TT
371/* Normally target debug printing is purely type-based. However,
372 sometimes it is necessary to override the debug printing on a
373 per-argument basis. This macro can be used, attribute-style, to
374 name the target debug printing function for a particular method
375 argument. FUNC is the name of the function. The macro's
376 definition is empty because it is only used by the
377 make-target-delegates script. */
378
379#define TARGET_DEBUG_PRINTER(FUNC)
380
1101cb7b
TT
381/* These defines are used to mark target_ops methods. The script
382 make-target-delegates scans these and auto-generates the base
383 method implementations. There are four macros that can be used:
384
385 1. TARGET_DEFAULT_IGNORE. There is no argument. The base method
386 does nothing. This is only valid if the method return type is
387 'void'.
388
389 2. TARGET_DEFAULT_NORETURN. The argument is a function call, like
390 'tcomplain ()'. The base method simply makes this call, which is
391 assumed not to return.
392
393 3. TARGET_DEFAULT_RETURN. The argument is a C expression. The
394 base method returns this expression's value.
395
396 4. TARGET_DEFAULT_FUNC. The argument is the name of a function.
397 make-target-delegates does not generate a base method in this case,
398 but instead uses the argument function as the base method. */
399
400#define TARGET_DEFAULT_IGNORE()
401#define TARGET_DEFAULT_NORETURN(ARG)
402#define TARGET_DEFAULT_RETURN(ARG)
403#define TARGET_DEFAULT_FUNC(ARG)
404
c906108c 405struct target_ops
c5aa993b 406 {
258b763a 407 struct target_ops *beneath; /* To the target under this one. */
e9e7f724
TT
408 const char *to_shortname; /* Name this target type */
409 const char *to_longname; /* Name for printing */
410 const char *to_doc; /* Documentation. Does not include trailing
c906108c 411 newline, and starts with a one-line descrip-
0d06e24b 412 tion (probably similar to to_longname). */
bba2d28d
AC
413 /* Per-target scratch pad. */
414 void *to_data;
f1c07ab0
AC
415 /* The open routine takes the rest of the parameters from the
416 command, and (if successful) pushes a new target onto the
417 stack. Targets should supply this routine, if only to provide
418 an error message. */
014f9477 419 void (*to_open) (const char *, int);
f1c07ab0
AC
420 /* Old targets with a static target vector provide "to_close".
421 New re-entrant targets provide "to_xclose" and that is expected
422 to xfree everything (including the "struct target_ops"). */
460014f5 423 void (*to_xclose) (struct target_ops *targ);
de90e03d 424 void (*to_close) (struct target_ops *);
b3ccfe11
TT
425 /* Attaches to a process on the target side. Arguments are as
426 passed to the `attach' command by the user. This routine can
427 be called when the target is not on the target-stack, if the
428 target_can_run routine returns 1; in that case, it must push
429 itself onto the stack. Upon exit, the target should be ready
430 for normal operations, and should be ready to deliver the
431 status of the process immediately (without waiting) to an
432 upcoming target_wait call. */
c0939df1 433 void (*to_attach) (struct target_ops *ops, const char *, int);
bebd3233
TT
434 void (*to_post_attach) (struct target_ops *, int)
435 TARGET_DEFAULT_IGNORE ();
09da0d0a
TT
436 void (*to_detach) (struct target_ops *ops, const char *, int)
437 TARGET_DEFAULT_IGNORE ();
fee354ee 438 void (*to_disconnect) (struct target_ops *, const char *, int)
86a0854a 439 TARGET_DEFAULT_NORETURN (tcomplain ());
a7068b60
TT
440 void (*to_resume) (struct target_ops *, ptid_t,
441 int TARGET_DEBUG_PRINTER (target_debug_print_step),
442 enum gdb_signal)
6b84065d 443 TARGET_DEFAULT_NORETURN (noprocess ());
117de6a9 444 ptid_t (*to_wait) (struct target_ops *,
a7068b60
TT
445 ptid_t, struct target_waitstatus *,
446 int TARGET_DEBUG_PRINTER (target_debug_print_options))
6b84065d 447 TARGET_DEFAULT_NORETURN (noprocess ());
ad5989bd
TT
448 void (*to_fetch_registers) (struct target_ops *, struct regcache *, int)
449 TARGET_DEFAULT_IGNORE ();
6b84065d
TT
450 void (*to_store_registers) (struct target_ops *, struct regcache *, int)
451 TARGET_DEFAULT_NORETURN (noprocess ());
6c628163
TT
452 void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
453 TARGET_DEFAULT_NORETURN (noprocess ());
c5aa993b 454
f86e59b2
TT
455 void (*to_files_info) (struct target_ops *)
456 TARGET_DEFAULT_IGNORE ();
3db08215 457 int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
6b84065d
TT
458 struct bp_target_info *)
459 TARGET_DEFAULT_FUNC (memory_insert_breakpoint);
3db08215 460 int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
6b84065d
TT
461 struct bp_target_info *)
462 TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
1cf4d951
PA
463
464 /* Returns true if the target stopped because it executed a
465 software breakpoint. This is necessary for correct background
466 execution / non-stop mode operation, and for correct PC
467 adjustment on targets where the PC needs to be adjusted when a
468 software breakpoint triggers. In these modes, by the time GDB
469 processes a breakpoint event, the breakpoint may already be
470 done from the target, so GDB needs to be able to tell whether
471 it should ignore the event and whether it should adjust the PC.
472 See adjust_pc_after_break. */
473 int (*to_stopped_by_sw_breakpoint) (struct target_ops *)
474 TARGET_DEFAULT_RETURN (0);
475 /* Returns true if the above method is supported. */
476 int (*to_supports_stopped_by_sw_breakpoint) (struct target_ops *)
477 TARGET_DEFAULT_RETURN (0);
478
479 /* Returns true if the target stopped for a hardware breakpoint.
480 Likewise, if the target supports hardware breakpoints, this
481 method is necessary for correct background execution / non-stop
482 mode operation. Even though hardware breakpoints do not
483 require PC adjustment, GDB needs to be able to tell whether the
484 hardware breakpoint event is a delayed event for a breakpoint
485 that is already gone and should thus be ignored. */
486 int (*to_stopped_by_hw_breakpoint) (struct target_ops *)
487 TARGET_DEFAULT_RETURN (0);
488 /* Returns true if the above method is supported. */
489 int (*to_supports_stopped_by_hw_breakpoint) (struct target_ops *)
490 TARGET_DEFAULT_RETURN (0);
491
52b51d06
TT
492 int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int)
493 TARGET_DEFAULT_RETURN (0);
a134316b
TT
494 int (*to_ranged_break_num_registers) (struct target_ops *)
495 TARGET_DEFAULT_RETURN (-1);
23a26771 496 int (*to_insert_hw_breakpoint) (struct target_ops *,
61b371f9
TT
497 struct gdbarch *, struct bp_target_info *)
498 TARGET_DEFAULT_RETURN (-1);
a64dc96c 499 int (*to_remove_hw_breakpoint) (struct target_ops *,
418dabac
TT
500 struct gdbarch *, struct bp_target_info *)
501 TARGET_DEFAULT_RETURN (-1);
0cf6dd15
TJB
502
503 /* Documentation of what the two routines below are expected to do is
504 provided with the corresponding target_* macros. */
11b5219a 505 int (*to_remove_watchpoint) (struct target_ops *,
61dd109f
TT
506 CORE_ADDR, int, int, struct expression *)
507 TARGET_DEFAULT_RETURN (-1);
7bb99c53 508 int (*to_insert_watchpoint) (struct target_ops *,
016facd4
TT
509 CORE_ADDR, int, int, struct expression *)
510 TARGET_DEFAULT_RETURN (-1);
0cf6dd15 511
9c06b0b4 512 int (*to_insert_mask_watchpoint) (struct target_ops *,
cd4ae029
TT
513 CORE_ADDR, CORE_ADDR, int)
514 TARGET_DEFAULT_RETURN (1);
9c06b0b4 515 int (*to_remove_mask_watchpoint) (struct target_ops *,
8b1c364c
TT
516 CORE_ADDR, CORE_ADDR, int)
517 TARGET_DEFAULT_RETURN (1);
6b84065d
TT
518 int (*to_stopped_by_watchpoint) (struct target_ops *)
519 TARGET_DEFAULT_RETURN (0);
74174d2e 520 int to_have_steppable_watchpoint;
7df1a324 521 int to_have_continuable_watchpoint;
6b84065d
TT
522 int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *)
523 TARGET_DEFAULT_RETURN (0);
5009afc5 524 int (*to_watchpoint_addr_within_range) (struct target_ops *,
65f160a9
TT
525 CORE_ADDR, CORE_ADDR, int)
526 TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range);
e09342b5
TJB
527
528 /* Documentation of this routine is provided with the corresponding
529 target_* macro. */
31568a15 530 int (*to_region_ok_for_hw_watchpoint) (struct target_ops *,
d03655e4
TT
531 CORE_ADDR, int)
532 TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint);
e09342b5 533
c3a5ff89
TT
534 int (*to_can_accel_watchpoint_condition) (struct target_ops *,
535 CORE_ADDR, int, int,
77cdffe9
TT
536 struct expression *)
537 TARGET_DEFAULT_RETURN (0);
9c06b0b4 538 int (*to_masked_watch_num_registers) (struct target_ops *,
6c7e5e5c
TT
539 CORE_ADDR, CORE_ADDR)
540 TARGET_DEFAULT_RETURN (-1);
0343661d
TT
541 void (*to_terminal_init) (struct target_ops *)
542 TARGET_DEFAULT_IGNORE ();
ddeaacc9
TT
543 void (*to_terminal_inferior) (struct target_ops *)
544 TARGET_DEFAULT_IGNORE ();
74fcbef9
TT
545 void (*to_terminal_ours_for_output) (struct target_ops *)
546 TARGET_DEFAULT_IGNORE ();
e4a733f1
TT
547 void (*to_terminal_ours) (struct target_ops *)
548 TARGET_DEFAULT_IGNORE ();
e19e919f
TT
549 void (*to_terminal_info) (struct target_ops *, const char *, int)
550 TARGET_DEFAULT_FUNC (default_terminal_info);
423a4807
TT
551 void (*to_kill) (struct target_ops *)
552 TARGET_DEFAULT_NORETURN (noprocess ());
9cbe5fff 553 void (*to_load) (struct target_ops *, const char *, int)
7634da87 554 TARGET_DEFAULT_NORETURN (tcomplain ());
b3ccfe11
TT
555 /* Start an inferior process and set inferior_ptid to its pid.
556 EXEC_FILE is the file to run.
557 ALLARGS is a string containing the arguments to the program.
558 ENV is the environment vector to pass. Errors reported with error().
559 On VxWorks and various standalone systems, we ignore exec_file. */
136d6dae
VP
560 void (*to_create_inferior) (struct target_ops *,
561 char *, char *, char **, int);
340ba4bf
TT
562 void (*to_post_startup_inferior) (struct target_ops *, ptid_t)
563 TARGET_DEFAULT_IGNORE ();
5958ebeb
TT
564 int (*to_insert_fork_catchpoint) (struct target_ops *, int)
565 TARGET_DEFAULT_RETURN (1);
e1a21fb7
TT
566 int (*to_remove_fork_catchpoint) (struct target_ops *, int)
567 TARGET_DEFAULT_RETURN (1);
7e18a8dc
TT
568 int (*to_insert_vfork_catchpoint) (struct target_ops *, int)
569 TARGET_DEFAULT_RETURN (1);
95c3375e
TT
570 int (*to_remove_vfork_catchpoint) (struct target_ops *, int)
571 TARGET_DEFAULT_RETURN (1);
098dba18
TT
572 int (*to_follow_fork) (struct target_ops *, int, int)
573 TARGET_DEFAULT_FUNC (default_follow_fork);
62f64d7a
TT
574 int (*to_insert_exec_catchpoint) (struct target_ops *, int)
575 TARGET_DEFAULT_RETURN (1);
cda0f38c
TT
576 int (*to_remove_exec_catchpoint) (struct target_ops *, int)
577 TARGET_DEFAULT_RETURN (1);
ff214e67 578 int (*to_set_syscall_catchpoint) (struct target_ops *,
6a9fa051
TT
579 int, int, int, int, int *)
580 TARGET_DEFAULT_RETURN (1);
0db88c1d
TT
581 int (*to_has_exited) (struct target_ops *, int, int, int *)
582 TARGET_DEFAULT_RETURN (0);
8d657035
TT
583 void (*to_mourn_inferior) (struct target_ops *)
584 TARGET_DEFAULT_FUNC (default_mourn_inferior);
b3ccfe11
TT
585 /* Note that to_can_run is special and can be invoked on an
586 unpushed target. Targets defining this method must also define
587 to_can_async_p and to_supports_non_stop. */
e88ef65c
TT
588 int (*to_can_run) (struct target_ops *)
589 TARGET_DEFAULT_RETURN (0);
2455069d
UW
590
591 /* Documentation of this routine is provided with the corresponding
592 target_* macro. */
a7068b60
TT
593 void (*to_pass_signals) (struct target_ops *, int,
594 unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
035cad7f 595 TARGET_DEFAULT_IGNORE ();
2455069d 596
9b224c5e
PA
597 /* Documentation of this routine is provided with the
598 corresponding target_* function. */
a7068b60
TT
599 void (*to_program_signals) (struct target_ops *, int,
600 unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
7d4f8efa 601 TARGET_DEFAULT_IGNORE ();
9b224c5e 602
cbffc065
TT
603 int (*to_thread_alive) (struct target_ops *, ptid_t ptid)
604 TARGET_DEFAULT_RETURN (0);
e8032dde 605 void (*to_update_thread_list) (struct target_ops *)
09b0dc2b 606 TARGET_DEFAULT_IGNORE ();
770234d3
TT
607 char *(*to_pid_to_str) (struct target_ops *, ptid_t)
608 TARGET_DEFAULT_FUNC (default_pid_to_str);
4a7e6dda 609 char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *)
9b144037 610 TARGET_DEFAULT_RETURN (NULL);
825828fc 611 char *(*to_thread_name) (struct target_ops *, struct thread_info *)
9b144037 612 TARGET_DEFAULT_RETURN (NULL);
46ee7e8d
TT
613 void (*to_stop) (struct target_ops *, ptid_t)
614 TARGET_DEFAULT_IGNORE ();
1aac633b 615 void (*to_rcmd) (struct target_ops *,
a30bf1f1 616 const char *command, struct ui_file *output)
a53f3625 617 TARGET_DEFAULT_FUNC (default_rcmd);
830ca330 618 char *(*to_pid_to_exec_file) (struct target_ops *, int pid)
9b144037 619 TARGET_DEFAULT_RETURN (NULL);
d9cb0195
TT
620 void (*to_log_command) (struct target_ops *, const char *)
621 TARGET_DEFAULT_IGNORE ();
7e35c012 622 struct target_section_table *(*to_get_section_table) (struct target_ops *)
9b144037 623 TARGET_DEFAULT_RETURN (NULL);
c5aa993b 624 enum strata to_stratum;
c35b1492
PA
625 int (*to_has_all_memory) (struct target_ops *);
626 int (*to_has_memory) (struct target_ops *);
627 int (*to_has_stack) (struct target_ops *);
628 int (*to_has_registers) (struct target_ops *);
aeaec162 629 int (*to_has_execution) (struct target_ops *, ptid_t);
c5aa993b 630 int to_has_thread_control; /* control thread execution */
dc177b7a 631 int to_attach_no_wait;
b3ccfe11
TT
632 /* This method must be implemented in some situations. See the
633 comment on 'to_can_run'. */
6b84065d 634 int (*to_can_async_p) (struct target_ops *)
b3ccfe11 635 TARGET_DEFAULT_RETURN (0);
6b84065d 636 int (*to_is_async_p) (struct target_ops *)
b3ccfe11 637 TARGET_DEFAULT_RETURN (0);
6a3753b3 638 void (*to_async) (struct target_ops *, int)
6b84065d 639 TARGET_DEFAULT_NORETURN (tcomplain ());
b3ccfe11
TT
640 /* This method must be implemented in some situations. See the
641 comment on 'to_can_run'. */
642 int (*to_supports_non_stop) (struct target_ops *)
643 TARGET_DEFAULT_RETURN (0);
6b04bdb7 644 /* find_memory_regions support method for gcore */
2e73927c 645 int (*to_find_memory_regions) (struct target_ops *,
0b5a2719
TT
646 find_memory_region_ftype func, void *data)
647 TARGET_DEFAULT_FUNC (dummy_find_memory_regions);
6b04bdb7 648 /* make_corefile_notes support method for gcore */
16f796b1
TT
649 char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *)
650 TARGET_DEFAULT_FUNC (dummy_make_corefile_notes);
6b04bdb7 651 /* get_bookmark support method for bookmarks */
c2bcbb1d 652 gdb_byte * (*to_get_bookmark) (struct target_ops *, const char *, int)
3dbafbbb 653 TARGET_DEFAULT_NORETURN (tcomplain ());
6b04bdb7 654 /* goto_bookmark support method for bookmarks */
c2bcbb1d 655 void (*to_goto_bookmark) (struct target_ops *, const gdb_byte *, int)
9bb9d61d 656 TARGET_DEFAULT_NORETURN (tcomplain ());
3f47be5c
EZ
657 /* Return the thread-local address at OFFSET in the
658 thread-local storage for the thread PTID and the shared library
659 or executable file given by OBJFILE. If that block of
660 thread-local storage hasn't been allocated yet, this function
5876f503
JK
661 may return an error. LOAD_MODULE_ADDR may be zero for statically
662 linked multithreaded inferiors. */
117de6a9
PA
663 CORE_ADDR (*to_get_thread_local_address) (struct target_ops *ops,
664 ptid_t ptid,
b2756930 665 CORE_ADDR load_module_addr,
f0f9ff95
TT
666 CORE_ADDR offset)
667 TARGET_DEFAULT_NORETURN (generic_tls_error ());
3f47be5c 668
13547ab6
DJ
669 /* Request that OPS transfer up to LEN 8-bit bytes of the target's
670 OBJECT. The OFFSET, for a seekable object, specifies the
671 starting point. The ANNEX can be used to provide additional
672 data-specific information to the target.
673
9b409511
YQ
674 Return the transferred status, error or OK (an
675 'enum target_xfer_status' value). Save the number of bytes
676 actually transferred in *XFERED_LEN if transfer is successful
677 (TARGET_XFER_OK) or the number unavailable bytes if the requested
bc113b4e 678 data is unavailable (TARGET_XFER_UNAVAILABLE). *XFERED_LEN
9b409511
YQ
679 smaller than LEN does not indicate the end of the object, only
680 the end of the transfer; higher level code should continue
681 transferring if desired. This is handled in target.c.
13547ab6
DJ
682
683 The interface does not support a "retry" mechanism. Instead it
684 assumes that at least one byte will be transfered on each
685 successful call.
686
687 NOTE: cagney/2003-10-17: The current interface can lead to
688 fragmented transfers. Lower target levels should not implement
689 hacks, such as enlarging the transfer, in an attempt to
690 compensate for this. Instead, the target stack should be
691 extended so that it implements supply/collect methods and a
692 look-aside object cache. With that available, the lowest
693 target can safely and freely "push" data up the stack.
694
695 See target_read and target_write for more information. One,
696 and only one, of readbuf or writebuf must be non-NULL. */
697
9b409511
YQ
698 enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops,
699 enum target_object object,
700 const char *annex,
701 gdb_byte *readbuf,
702 const gdb_byte *writebuf,
703 ULONGEST offset, ULONGEST len,
6b84065d
TT
704 ULONGEST *xfered_len)
705 TARGET_DEFAULT_RETURN (TARGET_XFER_E_IO);
1e3ff5ad 706
fd79ecee
DJ
707 /* Returns the memory map for the target. A return value of NULL
708 means that no memory map is available. If a memory address
709 does not fall within any returned regions, it's assumed to be
710 RAM. The returned memory regions should not overlap.
711
712 The order of regions does not matter; target_memory_map will
c378eb4e 713 sort regions by starting address. For that reason, this
fd79ecee
DJ
714 function should not be called directly except via
715 target_memory_map.
716
717 This method should not cache data; if the memory map could
718 change unexpectedly, it should be invalidated, and higher
719 layers will re-fetch it. */
6b2c5a57 720 VEC(mem_region_s) *(*to_memory_map) (struct target_ops *)
9b144037 721 TARGET_DEFAULT_RETURN (NULL);
fd79ecee 722
a76d924d
DJ
723 /* Erases the region of flash memory starting at ADDRESS, of
724 length LENGTH.
725
726 Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
727 on flash block boundaries, as reported by 'to_memory_map'. */
728 void (*to_flash_erase) (struct target_ops *,
e8a6c6ac
TT
729 ULONGEST address, LONGEST length)
730 TARGET_DEFAULT_NORETURN (tcomplain ());
a76d924d
DJ
731
732 /* Finishes a flash memory write sequence. After this operation
733 all flash memory should be available for writing and the result
734 of reading from areas written by 'to_flash_write' should be
735 equal to what was written. */
f6fb2925
TT
736 void (*to_flash_done) (struct target_ops *)
737 TARGET_DEFAULT_NORETURN (tcomplain ());
a76d924d 738
2117c711
TT
739 /* Describe the architecture-specific features of this target. If
740 OPS doesn't have a description, this should delegate to the
741 "beneath" target. Returns the description found, or NULL if no
742 description was available. */
743 const struct target_desc *(*to_read_description) (struct target_ops *ops)
9b144037 744 TARGET_DEFAULT_RETURN (NULL);
424163ea 745
0ef643c8
JB
746 /* Build the PTID of the thread on which a given task is running,
747 based on LWP and THREAD. These values are extracted from the
748 task Private_Data section of the Ada Task Control Block, and
749 their interpretation depends on the target. */
1e6b91a4 750 ptid_t (*to_get_ada_task_ptid) (struct target_ops *,
4229b31d
TT
751 long lwp, long thread)
752 TARGET_DEFAULT_FUNC (default_get_ada_task_ptid);
0ef643c8 753
c47ffbe3
VP
754 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
755 Return 0 if *READPTR is already at the end of the buffer.
756 Return -1 if there is insufficient buffer for a whole entry.
757 Return 1 if an entry was read into *TYPEP and *VALP. */
758 int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr,
8de71aab
TT
759 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
760 TARGET_DEFAULT_FUNC (default_auxv_parse);
c47ffbe3 761
08388c79
DE
762 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
763 sequence of bytes in PATTERN with length PATTERN_LEN.
764
765 The result is 1 if found, 0 if not found, and -1 if there was an error
766 requiring halting of the search (e.g. memory read error).
767 If the pattern is found the address is recorded in FOUND_ADDRP. */
768 int (*to_search_memory) (struct target_ops *ops,
769 CORE_ADDR start_addr, ULONGEST search_space_len,
770 const gdb_byte *pattern, ULONGEST pattern_len,
58a5184e
TT
771 CORE_ADDR *found_addrp)
772 TARGET_DEFAULT_FUNC (default_search_memory);
08388c79 773
b2175913 774 /* Can target execute in reverse? */
53e1cfc7
TT
775 int (*to_can_execute_reverse) (struct target_ops *)
776 TARGET_DEFAULT_RETURN (0);
b2175913 777
32231432
PA
778 /* The direction the target is currently executing. Must be
779 implemented on targets that support reverse execution and async
780 mode. The default simply returns forward execution. */
fe31bf5b
TT
781 enum exec_direction_kind (*to_execution_direction) (struct target_ops *)
782 TARGET_DEFAULT_FUNC (default_execution_direction);
32231432 783
8a305172
PA
784 /* Does this target support debugging multiple processes
785 simultaneously? */
a7304748
TT
786 int (*to_supports_multi_process) (struct target_ops *)
787 TARGET_DEFAULT_RETURN (0);
8a305172 788
d248b706
KY
789 /* Does this target support enabling and disabling tracepoints while a trace
790 experiment is running? */
aab1b22d
TT
791 int (*to_supports_enable_disable_tracepoint) (struct target_ops *)
792 TARGET_DEFAULT_RETURN (0);
d248b706 793
03583c20 794 /* Does this target support disabling address space randomization? */
2bfc0540 795 int (*to_supports_disable_randomization) (struct target_ops *);
03583c20 796
3065dfb6 797 /* Does this target support the tracenz bytecode for string collection? */
9409d39e
TT
798 int (*to_supports_string_tracing) (struct target_ops *)
799 TARGET_DEFAULT_RETURN (0);
3065dfb6 800
b775012e
LM
801 /* Does this target support evaluation of breakpoint conditions on its
802 end? */
ccfde2a0
TT
803 int (*to_supports_evaluation_of_breakpoint_conditions) (struct target_ops *)
804 TARGET_DEFAULT_RETURN (0);
b775012e 805
d3ce09f5
SS
806 /* Does this target support evaluation of breakpoint commands on its
807 end? */
843f59ed
TT
808 int (*to_can_run_breakpoint_commands) (struct target_ops *)
809 TARGET_DEFAULT_RETURN (0);
d3ce09f5 810
3a8f7b07
JK
811 /* Determine current architecture of thread PTID.
812
813 The target is supposed to determine the architecture of the code where
814 the target is currently stopped at (on Cell, if a target is in spu_run,
815 to_thread_architecture would return SPU, otherwise PPC32 or PPC64).
816 This is architecture used to perform decr_pc_after_break adjustment,
817 and also determines the frame architecture of the innermost frame.
f5656ead 818 ptrace operations need to operate according to target_gdbarch ().
3a8f7b07 819
f5656ead 820 The default implementation always returns target_gdbarch (). */
43eba180
TT
821 struct gdbarch *(*to_thread_architecture) (struct target_ops *, ptid_t)
822 TARGET_DEFAULT_FUNC (default_thread_architecture);
c2250ad1 823
c0694254
PA
824 /* Determine current address space of thread PTID.
825
826 The default implementation always returns the inferior's
827 address space. */
828 struct address_space *(*to_thread_address_space) (struct target_ops *,
8eaff7cd
TT
829 ptid_t)
830 TARGET_DEFAULT_FUNC (default_thread_address_space);
c0694254 831
7313baad
UW
832 /* Target file operations. */
833
07c138c8
GB
834 /* Return nonzero if the filesystem seen by the current inferior
835 is the local filesystem, zero otherwise. */
4bd7dc42
GB
836 int (*to_filesystem_is_local) (struct target_ops *)
837 TARGET_DEFAULT_RETURN (1);
838
07c138c8
GB
839 /* Open FILENAME on the target, in the filesystem as seen by INF,
840 using FLAGS and MODE. If INF is NULL, use the filesystem seen
841 by the debugger (GDB or, for remote targets, the remote stub).
842 Return a target file descriptor, or -1 if an error occurs (and
843 set *TARGET_ERRNO). */
cd897586 844 int (*to_fileio_open) (struct target_ops *,
07c138c8
GB
845 struct inferior *inf, const char *filename,
846 int flags, int mode, int *target_errno);
7313baad
UW
847
848 /* Write up to LEN bytes from WRITE_BUF to FD on the target.
849 Return the number of bytes written, or -1 if an error occurs
850 (and set *TARGET_ERRNO). */
0d866f62
TT
851 int (*to_fileio_pwrite) (struct target_ops *,
852 int fd, const gdb_byte *write_buf, int len,
7313baad
UW
853 ULONGEST offset, int *target_errno);
854
855 /* Read up to LEN bytes FD on the target into READ_BUF.
856 Return the number of bytes read, or -1 if an error occurs
857 (and set *TARGET_ERRNO). */
a3be983c
TT
858 int (*to_fileio_pread) (struct target_ops *,
859 int fd, gdb_byte *read_buf, int len,
7313baad
UW
860 ULONGEST offset, int *target_errno);
861
9b15c1f0
GB
862 /* Get information about the file opened as FD and put it in
863 SB. Return 0 on success, or -1 if an error occurs (and set
864 *TARGET_ERRNO). */
865 int (*to_fileio_fstat) (struct target_ops *,
866 int fd, struct stat *sb, int *target_errno);
867
7313baad
UW
868 /* Close FD on the target. Return 0, or -1 if an error occurs
869 (and set *TARGET_ERRNO). */
df39ea25 870 int (*to_fileio_close) (struct target_ops *, int fd, int *target_errno);
7313baad 871
07c138c8
GB
872 /* Unlink FILENAME on the target, in the filesystem as seen by
873 INF. If INF is NULL, use the filesystem seen by the debugger
874 (GDB or, for remote targets, the remote stub). Return 0, or
875 -1 if an error occurs (and set *TARGET_ERRNO). */
dbbca37d 876 int (*to_fileio_unlink) (struct target_ops *,
07c138c8
GB
877 struct inferior *inf,
878 const char *filename,
879 int *target_errno);
880
881 /* Read value of symbolic link FILENAME on the target, in the
882 filesystem as seen by INF. If INF is NULL, use the filesystem
883 seen by the debugger (GDB or, for remote targets, the remote
884 stub). Return a null-terminated string allocated via xmalloc,
885 or NULL if an error occurs (and set *TARGET_ERRNO). */
fab5aa7c 886 char *(*to_fileio_readlink) (struct target_ops *,
07c138c8
GB
887 struct inferior *inf,
888 const char *filename,
889 int *target_errno);
b9e7b9c3 890
7313baad 891
145b16a9 892 /* Implement the "info proc" command. */
7bc112c1
TT
893 void (*to_info_proc) (struct target_ops *, const char *,
894 enum info_proc_what);
145b16a9 895
35b1e5cc
SS
896 /* Tracepoint-related operations. */
897
898 /* Prepare the target for a tracing run. */
5536135b
TT
899 void (*to_trace_init) (struct target_ops *)
900 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 901
e8ba3115 902 /* Send full details of a tracepoint location to the target. */
548f7808 903 void (*to_download_tracepoint) (struct target_ops *,
9a980a22
TT
904 struct bp_location *location)
905 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 906
1e4d1764
YQ
907 /* Is the target able to download tracepoint locations in current
908 state? */
719acc4a
TT
909 int (*to_can_download_tracepoint) (struct target_ops *)
910 TARGET_DEFAULT_RETURN (0);
1e4d1764 911
35b1e5cc 912 /* Send full details of a trace state variable to the target. */
559d2b81 913 void (*to_download_trace_state_variable) (struct target_ops *,
94eb98b9
TT
914 struct trace_state_variable *tsv)
915 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 916
d248b706 917 /* Enable a tracepoint on the target. */
46670d57 918 void (*to_enable_tracepoint) (struct target_ops *,
151f70f1
TT
919 struct bp_location *location)
920 TARGET_DEFAULT_NORETURN (tcomplain ());
d248b706
KY
921
922 /* Disable a tracepoint on the target. */
780b049c 923 void (*to_disable_tracepoint) (struct target_ops *,
05c41993
TT
924 struct bp_location *location)
925 TARGET_DEFAULT_NORETURN (tcomplain ());
d248b706 926
35b1e5cc
SS
927 /* Inform the target info of memory regions that are readonly
928 (such as text sections), and so it should return data from
929 those rather than look in the trace buffer. */
86dd181d
TT
930 void (*to_trace_set_readonly_regions) (struct target_ops *)
931 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
932
933 /* Start a trace run. */
25da2e80
TT
934 void (*to_trace_start) (struct target_ops *)
935 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
936
937 /* Get the current status of a tracing run. */
4072d4ff
TT
938 int (*to_get_trace_status) (struct target_ops *, struct trace_status *ts)
939 TARGET_DEFAULT_RETURN (-1);
35b1e5cc 940
db90e85c
TT
941 void (*to_get_tracepoint_status) (struct target_ops *,
942 struct breakpoint *tp,
6fea14cd
TT
943 struct uploaded_tp *utp)
944 TARGET_DEFAULT_NORETURN (tcomplain ());
f196051f 945
35b1e5cc 946 /* Stop a trace run. */
e51c07ea
TT
947 void (*to_trace_stop) (struct target_ops *)
948 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
949
950 /* Ask the target to find a trace frame of the given type TYPE,
951 using NUM, ADDR1, and ADDR2 as search parameters. Returns the
952 number of the trace frame, and also the tracepoint number at
c378eb4e 953 TPP. If no trace frame matches, return -1. May throw if the
f197e0f1 954 operation fails. */
bd4c6793
TT
955 int (*to_trace_find) (struct target_ops *,
956 enum trace_find_type type, int num,
afc94e66
TT
957 CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
958 TARGET_DEFAULT_RETURN (-1);
35b1e5cc
SS
959
960 /* Get the value of the trace state variable number TSV, returning
961 1 if the value is known and writing the value itself into the
962 location pointed to by VAL, else returning 0. */
4011015b 963 int (*to_get_trace_state_variable_value) (struct target_ops *,
959bcd0b
TT
964 int tsv, LONGEST *val)
965 TARGET_DEFAULT_RETURN (0);
35b1e5cc 966
a2e6c147
TT
967 int (*to_save_trace_data) (struct target_ops *, const char *filename)
968 TARGET_DEFAULT_NORETURN (tcomplain ());
00bf0b85 969
ab6617cc 970 int (*to_upload_tracepoints) (struct target_ops *,
1e949b00
TT
971 struct uploaded_tp **utpp)
972 TARGET_DEFAULT_RETURN (0);
00bf0b85 973
181e3713 974 int (*to_upload_trace_state_variables) (struct target_ops *,
08120467
TT
975 struct uploaded_tsv **utsvp)
976 TARGET_DEFAULT_RETURN (0);
00bf0b85 977
88ee6f45 978 LONGEST (*to_get_raw_trace_data) (struct target_ops *, gdb_byte *buf,
ace92e7d
TT
979 ULONGEST offset, LONGEST len)
980 TARGET_DEFAULT_NORETURN (tcomplain ());
00bf0b85 981
405f8e94
SS
982 /* Get the minimum length of instruction on which a fast tracepoint
983 may be set on the target. If this operation is unsupported,
984 return -1. If for some reason the minimum length cannot be
985 determined, return 0. */
9249843f
TT
986 int (*to_get_min_fast_tracepoint_insn_len) (struct target_ops *)
987 TARGET_DEFAULT_RETURN (-1);
405f8e94 988
35b1e5cc
SS
989 /* Set the target's tracing behavior in response to unexpected
990 disconnection - set VAL to 1 to keep tracing, 0 to stop. */
0bcfeddf
TT
991 void (*to_set_disconnected_tracing) (struct target_ops *, int val)
992 TARGET_DEFAULT_IGNORE ();
8d526939
TT
993 void (*to_set_circular_trace_buffer) (struct target_ops *, int val)
994 TARGET_DEFAULT_IGNORE ();
f6f899bf 995 /* Set the size of trace buffer in the target. */
91df8d1d
TT
996 void (*to_set_trace_buffer_size) (struct target_ops *, LONGEST val)
997 TARGET_DEFAULT_IGNORE ();
35b1e5cc 998
f196051f
SS
999 /* Add/change textual notes about the trace run, returning 1 if
1000 successful, 0 otherwise. */
d9e68a2c
TT
1001 int (*to_set_trace_notes) (struct target_ops *,
1002 const char *user, const char *notes,
8586ccaa
TT
1003 const char *stopnotes)
1004 TARGET_DEFAULT_RETURN (0);
f196051f 1005
dc146f7c
VP
1006 /* Return the processor core that thread PTID was last seen on.
1007 This information is updated only when:
1008 - update_thread_list is called
1009 - thread stops
3e43a32a
MS
1010 If the core cannot be determined -- either for the specified
1011 thread, or right now, or in this debug session, or for this
1012 target -- return -1. */
9e538d0d
TT
1013 int (*to_core_of_thread) (struct target_ops *, ptid_t ptid)
1014 TARGET_DEFAULT_RETURN (-1);
dc146f7c 1015
4a5e7a5b
PA
1016 /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
1017 matches the contents of [DATA,DATA+SIZE). Returns 1 if there's
1018 a match, 0 if there's a mismatch, and -1 if an error is
1019 encountered while reading memory. */
1020 int (*to_verify_memory) (struct target_ops *, const gdb_byte *data,
eb276a6b 1021 CORE_ADDR memaddr, ULONGEST size)
936d2992 1022 TARGET_DEFAULT_FUNC (default_verify_memory);
4a5e7a5b 1023
711e434b
PM
1024 /* Return the address of the start of the Thread Information Block
1025 a Windows OS specific feature. */
bd7ae0f5 1026 int (*to_get_tib_address) (struct target_ops *,
22bcceee
TT
1027 ptid_t ptid, CORE_ADDR *addr)
1028 TARGET_DEFAULT_NORETURN (tcomplain ());
711e434b 1029
d914c394 1030 /* Send the new settings of write permission variables. */
dcd6917f
TT
1031 void (*to_set_permissions) (struct target_ops *)
1032 TARGET_DEFAULT_IGNORE ();
d914c394 1033
0fb4aa4b
PA
1034 /* Look for a static tracepoint marker at ADDR, and fill in MARKER
1035 with its details. Return 1 on success, 0 on failure. */
61fc905d 1036 int (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
4c3e4425
TT
1037 struct static_tracepoint_marker *marker)
1038 TARGET_DEFAULT_RETURN (0);
0fb4aa4b
PA
1039
1040 /* Return a vector of all tracepoints markers string id ID, or all
1041 markers if ID is NULL. */
d6522a22
TT
1042 VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid) (struct target_ops *, const char *id)
1043 TARGET_DEFAULT_NORETURN (tcomplain ());
0fb4aa4b 1044
b3b9301e 1045 /* Return a traceframe info object describing the current
f73023dd
YQ
1046 traceframe's contents. This method should not cache data;
1047 higher layers take care of caching, invalidating, and
1048 re-fetching when necessary. */
92155eeb 1049 struct traceframe_info *(*to_traceframe_info) (struct target_ops *)
6a5f844b 1050 TARGET_DEFAULT_NORETURN (tcomplain ());
b3b9301e 1051
d1feda86
YQ
1052 /* Ask the target to use or not to use agent according to USE. Return 1
1053 successful, 0 otherwise. */
d9db5b21
TT
1054 int (*to_use_agent) (struct target_ops *, int use)
1055 TARGET_DEFAULT_NORETURN (tcomplain ());
d1feda86
YQ
1056
1057 /* Is the target able to use agent in current state? */
9a7d8b48
TT
1058 int (*to_can_use_agent) (struct target_ops *)
1059 TARGET_DEFAULT_RETURN (0);
d1feda86 1060
02d27625 1061 /* Check whether the target supports branch tracing. */
043c3577 1062 int (*to_supports_btrace) (struct target_ops *, enum btrace_format)
46917d26 1063 TARGET_DEFAULT_RETURN (0);
02d27625 1064
f4abbc16
MM
1065 /* Enable branch tracing for PTID using CONF configuration.
1066 Return a branch trace target information struct for reading and for
1067 disabling branch trace. */
e3c49f88 1068 struct btrace_target_info *(*to_enable_btrace) (struct target_ops *,
f4abbc16
MM
1069 ptid_t ptid,
1070 const struct btrace_config *conf)
6dc7fcf4 1071 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625
MM
1072
1073 /* Disable branch tracing and deallocate TINFO. */
25e95349 1074 void (*to_disable_btrace) (struct target_ops *,
8dc292d3
TT
1075 struct btrace_target_info *tinfo)
1076 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625
MM
1077
1078 /* Disable branch tracing and deallocate TINFO. This function is similar
1079 to to_disable_btrace, except that it is called during teardown and is
1080 only allowed to perform actions that are safe. A counter-example would
1081 be attempting to talk to a remote target. */
1777056d 1082 void (*to_teardown_btrace) (struct target_ops *,
9ace480d
TT
1083 struct btrace_target_info *tinfo)
1084 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625 1085
969c39fb 1086 /* Read branch trace data for the thread indicated by BTINFO into DATA.
734b0e4b 1087 DATA is cleared before new trace is added. */
39c49f83 1088 enum btrace_error (*to_read_btrace) (struct target_ops *self,
734b0e4b 1089 struct btrace_data *data,
969c39fb 1090 struct btrace_target_info *btinfo,
eb5b20d4
TT
1091 enum btrace_read_type type)
1092 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625 1093
f4abbc16
MM
1094 /* Get the branch trace configuration. */
1095 const struct btrace_config *(*to_btrace_conf) (struct target_ops *self,
1096 const struct btrace_target_info *)
1097 TARGET_DEFAULT_RETURN (NULL);
1098
7c1687a9 1099 /* Stop trace recording. */
ee97f592
TT
1100 void (*to_stop_recording) (struct target_ops *)
1101 TARGET_DEFAULT_IGNORE ();
7c1687a9 1102
d02ed0bb 1103 /* Print information about the recording. */
38e229b2
TT
1104 void (*to_info_record) (struct target_ops *)
1105 TARGET_DEFAULT_IGNORE ();
d02ed0bb
MM
1106
1107 /* Save the recorded execution trace into a file. */
f09e2107
TT
1108 void (*to_save_record) (struct target_ops *, const char *filename)
1109 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb 1110
252db1b5
TT
1111 /* Delete the recorded execution trace from the current position
1112 onwards. */
07366925
TT
1113 void (*to_delete_record) (struct target_ops *)
1114 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb
MM
1115
1116 /* Query if the record target is currently replaying. */
dd2e9d25
TT
1117 int (*to_record_is_replaying) (struct target_ops *)
1118 TARGET_DEFAULT_RETURN (0);
d02ed0bb
MM
1119
1120 /* Go to the begin of the execution trace. */
671e76cc
TT
1121 void (*to_goto_record_begin) (struct target_ops *)
1122 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb
MM
1123
1124 /* Go to the end of the execution trace. */
e9179bb3
TT
1125 void (*to_goto_record_end) (struct target_ops *)
1126 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb
MM
1127
1128 /* Go to a specific location in the recorded execution trace. */
05969c84
TT
1129 void (*to_goto_record) (struct target_ops *, ULONGEST insn)
1130 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb 1131
67c86d06
MM
1132 /* Disassemble SIZE instructions in the recorded execution trace from
1133 the current position.
1134 If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
1135 disassemble SIZE succeeding instructions. */
3679abfa
TT
1136 void (*to_insn_history) (struct target_ops *, int size, int flags)
1137 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06
MM
1138
1139 /* Disassemble SIZE instructions in the recorded execution trace around
1140 FROM.
1141 If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
1142 disassemble SIZE instructions after FROM. */
9abc3ff3 1143 void (*to_insn_history_from) (struct target_ops *,
8444ab58
TT
1144 ULONGEST from, int size, int flags)
1145 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06
MM
1146
1147 /* Disassemble a section of the recorded execution trace from instruction
0688d04e 1148 BEGIN (inclusive) to instruction END (inclusive). */
4e99c6b7 1149 void (*to_insn_history_range) (struct target_ops *,
c29302cc
TT
1150 ULONGEST begin, ULONGEST end, int flags)
1151 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06 1152
15984c13
MM
1153 /* Print a function trace of the recorded execution trace.
1154 If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
1155 succeeding functions. */
170049d4
TT
1156 void (*to_call_history) (struct target_ops *, int size, int flags)
1157 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13
MM
1158
1159 /* Print a function trace of the recorded execution trace starting
1160 at function FROM.
1161 If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
1162 SIZE functions after FROM. */
ec0aea04 1163 void (*to_call_history_from) (struct target_ops *,
16fc27d6
TT
1164 ULONGEST begin, int size, int flags)
1165 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13
MM
1166
1167 /* Print a function trace of an execution trace section from function BEGIN
0688d04e 1168 (inclusive) to function END (inclusive). */
f0d960ea 1169 void (*to_call_history_range) (struct target_ops *,
115d9817
TT
1170 ULONGEST begin, ULONGEST end, int flags)
1171 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13 1172
ced63ec0
GB
1173 /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
1174 non-empty annex. */
0de91722
TT
1175 int (*to_augmented_libraries_svr4_read) (struct target_ops *)
1176 TARGET_DEFAULT_RETURN (0);
ced63ec0 1177
ac01945b
TT
1178 /* Those unwinders are tried before any other arch unwinders. If
1179 SELF doesn't have unwinders, it should delegate to the
1180 "beneath" target. */
1181 const struct frame_unwind *(*to_get_unwinder) (struct target_ops *self)
1182 TARGET_DEFAULT_RETURN (NULL);
1183
1184 const struct frame_unwind *(*to_get_tailcall_unwinder) (struct target_ops *self)
1185 TARGET_DEFAULT_RETURN (NULL);
ea001bdc 1186
5fff78c4
MM
1187 /* Prepare to generate a core file. */
1188 void (*to_prepare_to_generate_core) (struct target_ops *)
1189 TARGET_DEFAULT_IGNORE ();
1190
1191 /* Cleanup after generating a core file. */
1192 void (*to_done_generating_core) (struct target_ops *)
1193 TARGET_DEFAULT_IGNORE ();
1194
c5aa993b 1195 int to_magic;
0d06e24b
JM
1196 /* Need sub-structure for target machine related rather than comm related?
1197 */
c5aa993b 1198 };
c906108c
SS
1199
1200/* Magic number for checking ops size. If a struct doesn't end with this
1201 number, somebody changed the declaration but didn't change all the
1202 places that initialize one. */
1203
1204#define OPS_MAGIC 3840
1205
1206/* The ops structure for our "current" target process. This should
1207 never be NULL. If there is no target, it points to the dummy_target. */
1208
c5aa993b 1209extern struct target_ops current_target;
c906108c 1210
c906108c
SS
1211/* Define easy words for doing these operations on our current target. */
1212
1213#define target_shortname (current_target.to_shortname)
1214#define target_longname (current_target.to_longname)
1215
f1c07ab0 1216/* Does whatever cleanup is required for a target that we are no
460014f5
JK
1217 longer going to be calling. This routine is automatically always
1218 called after popping the target off the target stack - the target's
1219 own methods are no longer available through the target vector.
1220 Closing file descriptors and freeing all memory allocated memory are
1221 typical things it should do. */
f1c07ab0 1222
460014f5 1223void target_close (struct target_ops *targ);
c906108c 1224
b3ccfe11
TT
1225/* Find the correct target to use for "attach". If a target on the
1226 current stack supports attaching, then it is returned. Otherwise,
1227 the default run target is returned. */
1228
1229extern struct target_ops *find_attach_target (void);
c906108c 1230
b3ccfe11
TT
1231/* Find the correct target to use for "run". If a target on the
1232 current stack supports creating a new inferior, then it is
1233 returned. Otherwise, the default run target is returned. */
1234
1235extern struct target_ops *find_run_target (void);
c906108c 1236
dc177b7a
PA
1237/* Some targets don't generate traps when attaching to the inferior,
1238 or their target_attach implementation takes care of the waiting.
1239 These targets must set to_attach_no_wait. */
1240
1241#define target_attach_no_wait \
1242 (current_target.to_attach_no_wait)
1243
c906108c
SS
1244/* The target_attach operation places a process under debugger control,
1245 and stops the process.
1246
1247 This operation provides a target-specific hook that allows the
0d06e24b 1248 necessary bookkeeping to be performed after an attach completes. */
c906108c 1249#define target_post_attach(pid) \
f045800c 1250 (*current_target.to_post_attach) (&current_target, pid)
c906108c 1251
c906108c
SS
1252/* Takes a program previously attached to and detaches it.
1253 The program may resume execution (some targets do, some don't) and will
1254 no longer stop on signals, etc. We better not have left any breakpoints
1255 in the program or it'll die when it hits one. ARGS is arguments
1256 typed by the user (e.g. a signal to send the process). FROM_TTY
1257 says whether to be verbose or not. */
1258
52554a0e 1259extern void target_detach (const char *, int);
c906108c 1260
6ad8ae5c
DJ
1261/* Disconnect from the current target without resuming it (leaving it
1262 waiting for a debugger). */
1263
fee354ee 1264extern void target_disconnect (const char *, int);
6ad8ae5c 1265
e5ef252a
PA
1266/* Resume execution of the target process PTID (or a group of
1267 threads). STEP says whether to single-step or to run free; SIGGNAL
1268 is the signal to be given to the target, or GDB_SIGNAL_0 for no
1269 signal. The caller may not pass GDB_SIGNAL_DEFAULT. A specific
1270 PTID means `step/resume only this process id'. A wildcard PTID
1271 (all threads, or all threads of process) means `step/resume
1272 INFERIOR_PTID, and let other threads (for which the wildcard PTID
1273 matches) resume with their 'thread->suspend.stop_signal' signal
1274 (usually GDB_SIGNAL_0) if it is in "pass" state, or with no signal
1275 if in "no pass" state. */
c906108c 1276
2ea28649 1277extern void target_resume (ptid_t ptid, int step, enum gdb_signal signal);
c906108c 1278
b5a2688f
AC
1279/* Wait for process pid to do something. PTID = -1 to wait for any
1280 pid to do something. Return pid of child, or -1 in case of error;
c906108c 1281 store status through argument pointer STATUS. Note that it is
b5a2688f 1282 _NOT_ OK to throw_exception() out of target_wait() without popping
c906108c
SS
1283 the debugging target from the stack; GDB isn't prepared to get back
1284 to the prompt with a debugging target but without the frame cache,
47608cb1
PA
1285 stop_pc, etc., set up. OPTIONS is a bitwise OR of TARGET_W*
1286 options. */
c906108c 1287
47608cb1
PA
1288extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
1289 int options);
c906108c 1290
17dee195 1291/* Fetch at least register REGNO, or all regs if regno == -1. No result. */
c906108c 1292
28439f5e 1293extern void target_fetch_registers (struct regcache *regcache, int regno);
c906108c
SS
1294
1295/* Store at least register REGNO, or all regs if REGNO == -1.
1296 It can store as many registers as it wants to, so target_prepare_to_store
1297 must have been previously called. Calls error() if there are problems. */
1298
28439f5e 1299extern void target_store_registers (struct regcache *regcache, int regs);
c906108c
SS
1300
1301/* Get ready to modify the registers array. On machines which store
1302 individual registers, this doesn't need to do anything. On machines
1303 which store all the registers in one fell swoop, this makes sure
1304 that REGISTERS contains all the registers from the program being
1305 debugged. */
1306
316f2060 1307#define target_prepare_to_store(regcache) \
f32dbf8c 1308 (*current_target.to_prepare_to_store) (&current_target, regcache)
c906108c 1309
6c95b8df
PA
1310/* Determine current address space of thread PTID. */
1311
1312struct address_space *target_thread_address_space (ptid_t);
1313
451b7c33
TT
1314/* Implement the "info proc" command. This returns one if the request
1315 was handled, and zero otherwise. It can also throw an exception if
1316 an error was encountered while attempting to handle the
1317 request. */
145b16a9 1318
7bc112c1 1319int target_info_proc (const char *, enum info_proc_what);
145b16a9 1320
8a305172
PA
1321/* Returns true if this target can debug multiple processes
1322 simultaneously. */
1323
1324#define target_supports_multi_process() \
86ce2668 1325 (*current_target.to_supports_multi_process) (&current_target)
8a305172 1326
03583c20
UW
1327/* Returns true if this target can disable address space randomization. */
1328
1329int target_supports_disable_randomization (void);
1330
d248b706
KY
1331/* Returns true if this target can enable and disable tracepoints
1332 while a trace experiment is running. */
1333
1334#define target_supports_enable_disable_tracepoint() \
7d178d6a 1335 (*current_target.to_supports_enable_disable_tracepoint) (&current_target)
d248b706 1336
3065dfb6 1337#define target_supports_string_tracing() \
6de37a3a 1338 (*current_target.to_supports_string_tracing) (&current_target)
3065dfb6 1339
b775012e
LM
1340/* Returns true if this target can handle breakpoint conditions
1341 on its end. */
1342
1343#define target_supports_evaluation_of_breakpoint_conditions() \
efcc2da7 1344 (*current_target.to_supports_evaluation_of_breakpoint_conditions) (&current_target)
b775012e 1345
d3ce09f5
SS
1346/* Returns true if this target can handle breakpoint commands
1347 on its end. */
1348
1349#define target_can_run_breakpoint_commands() \
78eff0ec 1350 (*current_target.to_can_run_breakpoint_commands) (&current_target)
d3ce09f5 1351
a14ed312 1352extern int target_read_string (CORE_ADDR, char **, int, int *);
c906108c 1353
721ec300 1354/* For target_read_memory see target/target.h. */
c906108c 1355
aee4bf85
PA
1356extern int target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
1357 ssize_t len);
1358
45aa4659 1359extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
4e5d721f 1360
29453a14
YQ
1361extern int target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
1362
721ec300 1363/* For target_write_memory see target/target.h. */
c906108c 1364
f0ba3972 1365extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
45aa4659 1366 ssize_t len);
f0ba3972 1367
fd79ecee
DJ
1368/* Fetches the target's memory map. If one is found it is sorted
1369 and returned, after some consistency checking. Otherwise, NULL
1370 is returned. */
1371VEC(mem_region_s) *target_memory_map (void);
1372
a76d924d
DJ
1373/* Erase the specified flash region. */
1374void target_flash_erase (ULONGEST address, LONGEST length);
1375
1376/* Finish a sequence of flash operations. */
1377void target_flash_done (void);
1378
1379/* Describes a request for a memory write operation. */
1380struct memory_write_request
1381 {
c378eb4e 1382 /* Begining address that must be written. */
a76d924d 1383 ULONGEST begin;
c378eb4e 1384 /* Past-the-end address. */
a76d924d 1385 ULONGEST end;
c378eb4e 1386 /* The data to write. */
a76d924d
DJ
1387 gdb_byte *data;
1388 /* A callback baton for progress reporting for this request. */
1389 void *baton;
1390 };
1391typedef struct memory_write_request memory_write_request_s;
1392DEF_VEC_O(memory_write_request_s);
1393
1394/* Enumeration specifying different flash preservation behaviour. */
1395enum flash_preserve_mode
1396 {
1397 flash_preserve,
1398 flash_discard
1399 };
1400
1401/* Write several memory blocks at once. This version can be more
1402 efficient than making several calls to target_write_memory, in
1403 particular because it can optimize accesses to flash memory.
1404
1405 Moreover, this is currently the only memory access function in gdb
1406 that supports writing to flash memory, and it should be used for
1407 all cases where access to flash memory is desirable.
1408
1409 REQUESTS is the vector (see vec.h) of memory_write_request.
1410 PRESERVE_FLASH_P indicates what to do with blocks which must be
1411 erased, but not completely rewritten.
1412 PROGRESS_CB is a function that will be periodically called to provide
1413 feedback to user. It will be called with the baton corresponding
1414 to the request currently being written. It may also be called
1415 with a NULL baton, when preserved flash sectors are being rewritten.
1416
1417 The function returns 0 on success, and error otherwise. */
1418int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
1419 enum flash_preserve_mode preserve_flash_p,
1420 void (*progress_cb) (ULONGEST, void *));
1421
c906108c
SS
1422/* Print a line about the current target. */
1423
1424#define target_files_info() \
0d06e24b 1425 (*current_target.to_files_info) (&current_target)
c906108c 1426
7d03f2eb 1427/* Insert a breakpoint at address BP_TGT->placed_address in
0000e5cc
PA
1428 the target machine. Returns 0 for success, and returns non-zero or
1429 throws an error (with a detailed failure reason error code and
1430 message) otherwise. */
c906108c 1431
d914c394
SS
1432extern int target_insert_breakpoint (struct gdbarch *gdbarch,
1433 struct bp_target_info *bp_tgt);
c906108c 1434
8181d85f 1435/* Remove a breakpoint at address BP_TGT->placed_address in the target
578d3588 1436 machine. Result is 0 for success, non-zero for error. */
c906108c 1437
d914c394
SS
1438extern int target_remove_breakpoint (struct gdbarch *gdbarch,
1439 struct bp_target_info *bp_tgt);
c906108c 1440
6fdebc3d
PA
1441/* Returns true if the terminal settings of the inferior are in
1442 effect. */
1443
1444extern int target_terminal_is_inferior (void);
1445
c906108c
SS
1446/* Initialize the terminal settings we record for the inferior,
1447 before we actually run the inferior. */
1448
5842f62a 1449extern void target_terminal_init (void);
c906108c
SS
1450
1451/* Put the inferior's terminal settings into effect.
1452 This is preparation for starting or resuming the inferior. */
1453
d9d2d8b6 1454extern void target_terminal_inferior (void);
c906108c 1455
5842f62a
PA
1456/* Put some of our terminal settings into effect, enough to get proper
1457 results from our output, but do not change into or out of RAW mode
1458 so that no input is discarded. This is a no-op if terminal_ours
1459 was most recently called. */
c906108c 1460
5842f62a 1461extern void target_terminal_ours_for_output (void);
c906108c
SS
1462
1463/* Put our terminal settings into effect.
1464 First record the inferior's terminal settings
1465 so they can be restored properly later. */
1466
5842f62a 1467extern void target_terminal_ours (void);
c906108c 1468
b0ed115f
TT
1469/* Return true if the target stack has a non-default
1470 "to_terminal_ours" method. */
1471
1472extern int target_supports_terminal_ours (void);
1473
1abf3a14
SM
1474/* Make a cleanup that restores the state of the terminal to the current
1475 state. */
1476extern struct cleanup *make_cleanup_restore_target_terminal (void);
1477
c906108c
SS
1478/* Print useful information about our terminal status, if such a thing
1479 exists. */
1480
1481#define target_terminal_info(arg, from_tty) \
0a4f40a2 1482 (*current_target.to_terminal_info) (&current_target, arg, from_tty)
c906108c
SS
1483
1484/* Kill the inferior process. Make it go away. */
1485
7d85a9c0 1486extern void target_kill (void);
c906108c 1487
0d06e24b
JM
1488/* Load an executable file into the target process. This is expected
1489 to not only bring new code into the target process, but also to
1986bccd
AS
1490 update GDB's symbol tables to match.
1491
1492 ARG contains command-line arguments, to be broken down with
1493 buildargv (). The first non-switch argument is the filename to
1494 load, FILE; the second is a number (as parsed by strtoul (..., ...,
1495 0)), which is an offset to apply to the load addresses of FILE's
1496 sections. The target may define switches, or other non-switch
1497 arguments, as it pleases. */
c906108c 1498
9cbe5fff 1499extern void target_load (const char *arg, int from_tty);
c906108c 1500
c906108c
SS
1501/* Some targets (such as ttrace-based HPUX) don't allow us to request
1502 notification of inferior events such as fork and vork immediately
1503 after the inferior is created. (This because of how gdb gets an
1504 inferior created via invoking a shell to do it. In such a scenario,
1505 if the shell init file has commands in it, the shell will fork and
1506 exec for each of those commands, and we will see each such fork
1507 event. Very bad.)
c5aa993b 1508
0d06e24b
JM
1509 Such targets will supply an appropriate definition for this function. */
1510
39f77062 1511#define target_post_startup_inferior(ptid) \
2e97a79e 1512 (*current_target.to_post_startup_inferior) (&current_target, ptid)
c906108c 1513
0d06e24b
JM
1514/* On some targets, we can catch an inferior fork or vfork event when
1515 it occurs. These functions insert/remove an already-created
77b06cd7
TJB
1516 catchpoint for such events. They return 0 for success, 1 if the
1517 catchpoint type is not supported and -1 for failure. */
c906108c 1518
c906108c 1519#define target_insert_fork_catchpoint(pid) \
a863b201 1520 (*current_target.to_insert_fork_catchpoint) (&current_target, pid)
c906108c
SS
1521
1522#define target_remove_fork_catchpoint(pid) \
973fc227 1523 (*current_target.to_remove_fork_catchpoint) (&current_target, pid)
c906108c
SS
1524
1525#define target_insert_vfork_catchpoint(pid) \
3ecc7da0 1526 (*current_target.to_insert_vfork_catchpoint) (&current_target, pid)
c906108c
SS
1527
1528#define target_remove_vfork_catchpoint(pid) \
e98cf0cd 1529 (*current_target.to_remove_vfork_catchpoint) (&current_target, pid)
c906108c 1530
6604731b
DJ
1531/* If the inferior forks or vforks, this function will be called at
1532 the next resume in order to perform any bookkeeping and fiddling
1533 necessary to continue debugging either the parent or child, as
1534 requested, and releasing the other. Information about the fork
1535 or vfork event is available via get_last_target_status ().
1536 This function returns 1 if the inferior should not be resumed
1537 (i.e. there is another event pending). */
0d06e24b 1538
07107ca6 1539int target_follow_fork (int follow_child, int detach_fork);
c906108c
SS
1540
1541/* On some targets, we can catch an inferior exec event when it
0d06e24b 1542 occurs. These functions insert/remove an already-created
77b06cd7
TJB
1543 catchpoint for such events. They return 0 for success, 1 if the
1544 catchpoint type is not supported and -1 for failure. */
0d06e24b 1545
c906108c 1546#define target_insert_exec_catchpoint(pid) \
ba025e51 1547 (*current_target.to_insert_exec_catchpoint) (&current_target, pid)
c5aa993b 1548
c906108c 1549#define target_remove_exec_catchpoint(pid) \
758e29d2 1550 (*current_target.to_remove_exec_catchpoint) (&current_target, pid)
c906108c 1551
a96d9b2e
SDJ
1552/* Syscall catch.
1553
1554 NEEDED is nonzero if any syscall catch (of any kind) is requested.
1555 If NEEDED is zero, it means the target can disable the mechanism to
1556 catch system calls because there are no more catchpoints of this type.
1557
1558 ANY_COUNT is nonzero if a generic (filter-less) syscall catch is
1559 being requested. In this case, both TABLE_SIZE and TABLE should
1560 be ignored.
1561
1562 TABLE_SIZE is the number of elements in TABLE. It only matters if
1563 ANY_COUNT is zero.
1564
1565 TABLE is an array of ints, indexed by syscall number. An element in
1566 this array is nonzero if that syscall should be caught. This argument
77b06cd7
TJB
1567 only matters if ANY_COUNT is zero.
1568
1569 Return 0 for success, 1 if syscall catchpoints are not supported or -1
1570 for failure. */
a96d9b2e
SDJ
1571
1572#define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table) \
ff214e67
TT
1573 (*current_target.to_set_syscall_catchpoint) (&current_target, \
1574 pid, needed, any_count, \
a96d9b2e
SDJ
1575 table_size, table)
1576
c906108c 1577/* Returns TRUE if PID has exited. And, also sets EXIT_STATUS to the
0d06e24b
JM
1578 exit code of PID, if any. */
1579
c906108c 1580#define target_has_exited(pid,wait_status,exit_status) \
d796e1d6
TT
1581 (*current_target.to_has_exited) (&current_target, \
1582 pid,wait_status,exit_status)
c906108c
SS
1583
1584/* The debugger has completed a blocking wait() call. There is now
2146d243 1585 some process event that must be processed. This function should
c906108c 1586 be defined by those targets that require the debugger to perform
0d06e24b 1587 cleanup or internal state changes in response to the process event. */
c906108c
SS
1588
1589/* The inferior process has died. Do what is right. */
1590
136d6dae 1591void target_mourn_inferior (void);
c906108c
SS
1592
1593/* Does target have enough data to do a run or attach command? */
1594
1595#define target_can_run(t) \
da82bd6b 1596 ((t)->to_can_run) (t)
c906108c 1597
2455069d
UW
1598/* Set list of signals to be handled in the target.
1599
1600 PASS_SIGNALS is an array of size NSIG, indexed by target signal number
2ea28649 1601 (enum gdb_signal). For every signal whose entry in this array is
2455069d
UW
1602 non-zero, the target is allowed -but not required- to skip reporting
1603 arrival of the signal to the GDB core by returning from target_wait,
1604 and to pass the signal directly to the inferior instead.
1605
1606 However, if the target is hardware single-stepping a thread that is
1607 about to receive a signal, it needs to be reported in any case, even
1608 if mentioned in a previous target_pass_signals call. */
c906108c 1609
2455069d 1610extern void target_pass_signals (int nsig, unsigned char *pass_signals);
c906108c 1611
9b224c5e
PA
1612/* Set list of signals the target may pass to the inferior. This
1613 directly maps to the "handle SIGNAL pass/nopass" setting.
1614
1615 PROGRAM_SIGNALS is an array of size NSIG, indexed by target signal
2ea28649 1616 number (enum gdb_signal). For every signal whose entry in this
9b224c5e
PA
1617 array is non-zero, the target is allowed to pass the signal to the
1618 inferior. Signals not present in the array shall be silently
1619 discarded. This does not influence whether to pass signals to the
1620 inferior as a result of a target_resume call. This is useful in
1621 scenarios where the target needs to decide whether to pass or not a
1622 signal to the inferior without GDB core involvement, such as for
1623 example, when detaching (as threads may have been suspended with
1624 pending signals not reported to GDB). */
1625
1626extern void target_program_signals (int nsig, unsigned char *program_signals);
1627
c906108c
SS
1628/* Check to see if a thread is still alive. */
1629
28439f5e 1630extern int target_thread_alive (ptid_t ptid);
c906108c 1631
e8032dde 1632/* Sync the target's threads with GDB's thread list. */
b83266a0 1633
e8032dde 1634extern void target_update_thread_list (void);
b83266a0 1635
0d06e24b 1636/* Make target stop in a continuable fashion. (For instance, under
9a6cf368
GB
1637 Unix, this should act like SIGSTOP). Note that this function is
1638 asynchronous: it does not wait for the target to become stopped
1639 before returning. If this is the behavior you want please use
1640 target_stop_and_wait. */
c906108c 1641
d914c394 1642extern void target_stop (ptid_t ptid);
c906108c 1643
96baa820
JM
1644/* Send the specified COMMAND to the target's monitor
1645 (shell,interpreter) for execution. The result of the query is
0d06e24b 1646 placed in OUTBUF. */
96baa820
JM
1647
1648#define target_rcmd(command, outbuf) \
1aac633b 1649 (*current_target.to_rcmd) (&current_target, command, outbuf)
96baa820
JM
1650
1651
c906108c
SS
1652/* Does the target include all of memory, or only part of it? This
1653 determines whether we look up the target chain for other parts of
1654 memory if this target can't satisfy a request. */
1655
c35b1492
PA
1656extern int target_has_all_memory_1 (void);
1657#define target_has_all_memory target_has_all_memory_1 ()
c906108c
SS
1658
1659/* Does the target include memory? (Dummy targets don't.) */
1660
c35b1492
PA
1661extern int target_has_memory_1 (void);
1662#define target_has_memory target_has_memory_1 ()
c906108c
SS
1663
1664/* Does the target have a stack? (Exec files don't, VxWorks doesn't, until
1665 we start a process.) */
c5aa993b 1666
c35b1492
PA
1667extern int target_has_stack_1 (void);
1668#define target_has_stack target_has_stack_1 ()
c906108c
SS
1669
1670/* Does the target have registers? (Exec files don't.) */
1671
c35b1492
PA
1672extern int target_has_registers_1 (void);
1673#define target_has_registers target_has_registers_1 ()
c906108c
SS
1674
1675/* Does the target have execution? Can we make it jump (through
52bb452f
DJ
1676 hoops), or pop its stack a few times? This means that the current
1677 target is currently executing; for some targets, that's the same as
1678 whether or not the target is capable of execution, but there are
1679 also targets which can be current while not executing. In that
b3ccfe11
TT
1680 case this will become true after to_create_inferior or
1681 to_attach. */
c906108c 1682
aeaec162
TT
1683extern int target_has_execution_1 (ptid_t);
1684
1685/* Like target_has_execution_1, but always passes inferior_ptid. */
1686
1687extern int target_has_execution_current (void);
1688
1689#define target_has_execution target_has_execution_current ()
c35b1492
PA
1690
1691/* Default implementations for process_stratum targets. Return true
1692 if there's a selected inferior, false otherwise. */
1693
1694extern int default_child_has_all_memory (struct target_ops *ops);
1695extern int default_child_has_memory (struct target_ops *ops);
1696extern int default_child_has_stack (struct target_ops *ops);
1697extern int default_child_has_registers (struct target_ops *ops);
aeaec162
TT
1698extern int default_child_has_execution (struct target_ops *ops,
1699 ptid_t the_ptid);
c906108c
SS
1700
1701/* Can the target support the debugger control of thread execution?
d6350901 1702 Can it lock the thread scheduler? */
c906108c
SS
1703
1704#define target_can_lock_scheduler \
0d06e24b 1705 (current_target.to_has_thread_control & tc_schedlock)
c906108c 1706
329ea579 1707/* Controls whether async mode is permitted. */
c6ebd6cf
VP
1708extern int target_async_permitted;
1709
c378eb4e 1710/* Can the target support asynchronous execution? */
6a109b6b 1711#define target_can_async_p() (current_target.to_can_async_p (&current_target))
6426a772 1712
c378eb4e 1713/* Is the target in asynchronous execution mode? */
6a109b6b 1714#define target_is_async_p() (current_target.to_is_async_p (&current_target))
6426a772 1715
6a3753b3
PA
1716/* Enables/disabled async target events. */
1717#define target_async(ENABLE) \
1718 (current_target.to_async (&current_target, (ENABLE)))
43ff13b4 1719
32231432 1720#define target_execution_direction() \
4c612759 1721 (current_target.to_execution_direction (&current_target))
32231432 1722
c906108c
SS
1723/* Converts a process id to a string. Usually, the string just contains
1724 `process xyz', but on some systems it may contain
1725 `process xyz thread abc'. */
1726
117de6a9 1727extern char *target_pid_to_str (ptid_t ptid);
c906108c 1728
39f77062 1729extern char *normal_pid_to_str (ptid_t ptid);
c5aa993b 1730
0d06e24b
JM
1731/* Return a short string describing extra information about PID,
1732 e.g. "sleeping", "runnable", "running on LWP 3". Null return value
1733 is okay. */
1734
1735#define target_extra_thread_info(TP) \
c15906d8 1736 (current_target.to_extra_thread_info (&current_target, TP))
ed9a39eb 1737
4694da01
TT
1738/* Return the thread's name. A NULL result means that the target
1739 could not determine this thread's name. */
1740
1741extern char *target_thread_name (struct thread_info *);
1742
c906108c
SS
1743/* Attempts to find the pathname of the executable file
1744 that was run to create a specified process.
1745
1746 The process PID must be stopped when this operation is used.
c5aa993b 1747
c906108c
SS
1748 If the executable file cannot be determined, NULL is returned.
1749
1750 Else, a pointer to a character string containing the pathname
1751 is returned. This string should be copied into a buffer by
1752 the client if the string will not be immediately used, or if
0d06e24b 1753 it must persist. */
c906108c
SS
1754
1755#define target_pid_to_exec_file(pid) \
8dd27370 1756 (current_target.to_pid_to_exec_file) (&current_target, pid)
c906108c 1757
3a8f7b07 1758/* See the to_thread_architecture description in struct target_ops. */
c2250ad1
UW
1759
1760#define target_thread_architecture(ptid) \
1761 (current_target.to_thread_architecture (&current_target, ptid))
1762
be4d1333
MS
1763/*
1764 * Iterator function for target memory regions.
1765 * Calls a callback function once for each memory region 'mapped'
1766 * in the child process. Defined as a simple macro rather than
2146d243 1767 * as a function macro so that it can be tested for nullity.
be4d1333
MS
1768 */
1769
1770#define target_find_memory_regions(FUNC, DATA) \
2e73927c 1771 (current_target.to_find_memory_regions) (&current_target, FUNC, DATA)
be4d1333
MS
1772
1773/*
1774 * Compose corefile .note section.
1775 */
1776
1777#define target_make_corefile_notes(BFD, SIZE_P) \
fc6691b2 1778 (current_target.to_make_corefile_notes) (&current_target, BFD, SIZE_P)
be4d1333 1779
6b04bdb7
MS
1780/* Bookmark interfaces. */
1781#define target_get_bookmark(ARGS, FROM_TTY) \
dd0e2830 1782 (current_target.to_get_bookmark) (&current_target, ARGS, FROM_TTY)
6b04bdb7
MS
1783
1784#define target_goto_bookmark(ARG, FROM_TTY) \
3c80fb48 1785 (current_target.to_goto_bookmark) (&current_target, ARG, FROM_TTY)
6b04bdb7 1786
c906108c
SS
1787/* Hardware watchpoint interfaces. */
1788
1789/* Returns non-zero if we were stopped by a hardware watchpoint (memory read or
7f82dfc7 1790 write). Only the INFERIOR_PTID task is being queried. */
c906108c 1791
6a109b6b
TT
1792#define target_stopped_by_watchpoint() \
1793 ((*current_target.to_stopped_by_watchpoint) (&current_target))
7df1a324 1794
1cf4d951
PA
1795/* Returns non-zero if the target stopped because it executed a
1796 software breakpoint instruction. */
1797
1798#define target_stopped_by_sw_breakpoint() \
1799 ((*current_target.to_stopped_by_sw_breakpoint) (&current_target))
1800
1801#define target_supports_stopped_by_sw_breakpoint() \
1802 ((*current_target.to_supports_stopped_by_sw_breakpoint) (&current_target))
1803
1804#define target_stopped_by_hw_breakpoint() \
1805 ((*current_target.to_stopped_by_hw_breakpoint) (&current_target))
1806
1807#define target_supports_stopped_by_hw_breakpoint() \
1808 ((*current_target.to_supports_stopped_by_hw_breakpoint) (&current_target))
1809
74174d2e
UW
1810/* Non-zero if we have steppable watchpoints */
1811
d92524f1 1812#define target_have_steppable_watchpoint \
74174d2e 1813 (current_target.to_have_steppable_watchpoint)
74174d2e 1814
7df1a324
KW
1815/* Non-zero if we have continuable watchpoints */
1816
d92524f1 1817#define target_have_continuable_watchpoint \
7df1a324 1818 (current_target.to_have_continuable_watchpoint)
c906108c 1819
ccaa32c7 1820/* Provide defaults for hardware watchpoint functions. */
c906108c 1821
2146d243 1822/* If the *_hw_beakpoint functions have not been defined
ccaa32c7 1823 elsewhere use the definitions in the target vector. */
c906108c 1824
059790a0
YQ
1825/* Returns positive if we can set a hardware watchpoint of type TYPE.
1826 Returns negative if the target doesn't have enough hardware debug
1827 registers available. Return zero if hardware watchpoint of type
1828 TYPE isn't supported. TYPE is one of bp_hardware_watchpoint,
1829 bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint.
1830 CNT is the number of such watchpoints used so far, including this
1831 one. OTHERTYPE is who knows what... */
c906108c 1832
d92524f1 1833#define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
5461485a 1834 (*current_target.to_can_use_hw_breakpoint) (&current_target, \
059790a0 1835 TYPE, CNT, OTHERTYPE)
c906108c 1836
e09342b5
TJB
1837/* Returns the number of debug registers needed to watch the given
1838 memory region, or zero if not supported. */
1839
d92524f1 1840#define target_region_ok_for_hw_watchpoint(addr, len) \
31568a15
TT
1841 (*current_target.to_region_ok_for_hw_watchpoint) (&current_target, \
1842 addr, len)
e0d24f8d 1843
c906108c 1844
85d721b8
PA
1845/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes.
1846 TYPE is 0 for write, 1 for read, and 2 for read/write accesses.
0cf6dd15 1847 COND is the expression for its condition, or NULL if there's none.
85d721b8
PA
1848 Returns 0 for success, 1 if the watchpoint type is not supported,
1849 -1 for failure. */
c906108c 1850
0cf6dd15 1851#define target_insert_watchpoint(addr, len, type, cond) \
7bb99c53
TT
1852 (*current_target.to_insert_watchpoint) (&current_target, \
1853 addr, len, type, cond)
c906108c 1854
0cf6dd15 1855#define target_remove_watchpoint(addr, len, type, cond) \
11b5219a
TT
1856 (*current_target.to_remove_watchpoint) (&current_target, \
1857 addr, len, type, cond)
c906108c 1858
9c06b0b4
TJB
1859/* Insert a new masked watchpoint at ADDR using the mask MASK.
1860 RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
1861 or hw_access for an access watchpoint. Returns 0 for success, 1 if
1862 masked watchpoints are not supported, -1 for failure. */
1863
1864extern int target_insert_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
1865
1866/* Remove a masked watchpoint at ADDR with the mask MASK.
1867 RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
1868 or hw_access for an access watchpoint. Returns 0 for success, non-zero
1869 for failure. */
1870
1871extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
1872
0000e5cc
PA
1873/* Insert a hardware breakpoint at address BP_TGT->placed_address in
1874 the target machine. Returns 0 for success, and returns non-zero or
1875 throws an error (with a detailed failure reason error code and
1876 message) otherwise. */
1877
a6d9a66e 1878#define target_insert_hw_breakpoint(gdbarch, bp_tgt) \
23a26771
TT
1879 (*current_target.to_insert_hw_breakpoint) (&current_target, \
1880 gdbarch, bp_tgt)
ccaa32c7 1881
a6d9a66e 1882#define target_remove_hw_breakpoint(gdbarch, bp_tgt) \
a64dc96c
TT
1883 (*current_target.to_remove_hw_breakpoint) (&current_target, \
1884 gdbarch, bp_tgt)
c906108c 1885
f1310107
TJB
1886/* Return number of debug registers needed for a ranged breakpoint,
1887 or -1 if ranged breakpoints are not supported. */
1888
1889extern int target_ranged_break_num_registers (void);
1890
7f82dfc7
JK
1891/* Return non-zero if target knows the data address which triggered this
1892 target_stopped_by_watchpoint, in such case place it to *ADDR_P. Only the
1893 INFERIOR_PTID task is being queried. */
1894#define target_stopped_data_address(target, addr_p) \
d8be2939 1895 (*(target)->to_stopped_data_address) (target, addr_p)
c906108c 1896
9b3e86b1
MR
1897/* Return non-zero if ADDR is within the range of a watchpoint spanning
1898 LENGTH bytes beginning at START. */
5009afc5 1899#define target_watchpoint_addr_within_range(target, addr, start, length) \
d8be2939 1900 (*(target)->to_watchpoint_addr_within_range) (target, addr, start, length)
5009afc5 1901
0cf6dd15
TJB
1902/* Return non-zero if the target is capable of using hardware to evaluate
1903 the condition expression. In this case, if the condition is false when
1904 the watched memory location changes, execution may continue without the
1905 debugger being notified.
1906
1907 Due to limitations in the hardware implementation, it may be capable of
1908 avoiding triggering the watchpoint in some cases where the condition
1909 expression is false, but may report some false positives as well.
1910 For this reason, GDB will still evaluate the condition expression when
1911 the watchpoint triggers. */
1912#define target_can_accel_watchpoint_condition(addr, len, type, cond) \
c3a5ff89
TT
1913 (*current_target.to_can_accel_watchpoint_condition) (&current_target, \
1914 addr, len, type, cond)
0cf6dd15 1915
9c06b0b4
TJB
1916/* Return number of debug registers needed for a masked watchpoint,
1917 -1 if masked watchpoints are not supported or -2 if the given address
1918 and mask combination cannot be used. */
1919
1920extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
1921
b2175913
MS
1922/* Target can execute in reverse? */
1923#define target_can_execute_reverse \
53e1cfc7 1924 current_target.to_can_execute_reverse (&current_target)
b2175913 1925
424163ea
DJ
1926extern const struct target_desc *target_read_description (struct target_ops *);
1927
0ef643c8 1928#define target_get_ada_task_ptid(lwp, tid) \
1e6b91a4 1929 (*current_target.to_get_ada_task_ptid) (&current_target, lwp,tid)
0ef643c8 1930
08388c79
DE
1931/* Utility implementation of searching memory. */
1932extern int simple_search_memory (struct target_ops* ops,
1933 CORE_ADDR start_addr,
1934 ULONGEST search_space_len,
1935 const gdb_byte *pattern,
1936 ULONGEST pattern_len,
1937 CORE_ADDR *found_addrp);
1938
1939/* Main entry point for searching memory. */
1940extern int target_search_memory (CORE_ADDR start_addr,
1941 ULONGEST search_space_len,
1942 const gdb_byte *pattern,
1943 ULONGEST pattern_len,
1944 CORE_ADDR *found_addrp);
1945
7313baad
UW
1946/* Target file operations. */
1947
07c138c8
GB
1948/* Return nonzero if the filesystem seen by the current inferior
1949 is the local filesystem, zero otherwise. */
4bd7dc42
GB
1950#define target_filesystem_is_local() \
1951 current_target.to_filesystem_is_local (&current_target)
1952
07c138c8
GB
1953/* Open FILENAME on the target, in the filesystem as seen by INF,
1954 using FLAGS and MODE. If INF is NULL, use the filesystem seen
1955 by the debugger (GDB or, for remote targets, the remote stub).
1956 Return a target file descriptor, or -1 if an error occurs (and
1957 set *TARGET_ERRNO). */
1958extern int target_fileio_open (struct inferior *inf,
1959 const char *filename, int flags,
1960 int mode, int *target_errno);
7313baad
UW
1961
1962/* Write up to LEN bytes from WRITE_BUF to FD on the target.
1963 Return the number of bytes written, or -1 if an error occurs
1964 (and set *TARGET_ERRNO). */
1965extern int target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
1966 ULONGEST offset, int *target_errno);
1967
1968/* Read up to LEN bytes FD on the target into READ_BUF.
1969 Return the number of bytes read, or -1 if an error occurs
1970 (and set *TARGET_ERRNO). */
1971extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len,
1972 ULONGEST offset, int *target_errno);
1973
9b15c1f0
GB
1974/* Get information about the file opened as FD on the target
1975 and put it in SB. Return 0 on success, or -1 if an error
1976 occurs (and set *TARGET_ERRNO). */
1977extern int target_fileio_fstat (int fd, struct stat *sb,
1978 int *target_errno);
1979
7313baad
UW
1980/* Close FD on the target. Return 0, or -1 if an error occurs
1981 (and set *TARGET_ERRNO). */
1982extern int target_fileio_close (int fd, int *target_errno);
1983
07c138c8
GB
1984/* Unlink FILENAME on the target, in the filesystem as seen by INF.
1985 If INF is NULL, use the filesystem seen by the debugger (GDB or,
1986 for remote targets, the remote stub). Return 0, or -1 if an error
7313baad 1987 occurs (and set *TARGET_ERRNO). */
07c138c8
GB
1988extern int target_fileio_unlink (struct inferior *inf,
1989 const char *filename,
1990 int *target_errno);
1991
1992/* Read value of symbolic link FILENAME on the target, in the
1993 filesystem as seen by INF. If INF is NULL, use the filesystem seen
1994 by the debugger (GDB or, for remote targets, the remote stub).
1995 Return a null-terminated string allocated via xmalloc, or NULL if
1996 an error occurs (and set *TARGET_ERRNO). */
1997extern char *target_fileio_readlink (struct inferior *inf,
1998 const char *filename,
1999 int *target_errno);
2000
2001/* Read target file FILENAME, in the filesystem as seen by INF. If
2002 INF is NULL, use the filesystem seen by the debugger (GDB or, for
2003 remote targets, the remote stub). The return value will be -1 if
2004 the transfer fails or is not supported; 0 if the object is empty;
2005 or the length of the object otherwise. If a positive value is
2006 returned, a sufficiently large buffer will be allocated using
2007 xmalloc and returned in *BUF_P containing the contents of the
2008 object.
7313baad
UW
2009
2010 This method should be used for objects sufficiently small to store
2011 in a single xmalloc'd buffer, when no fixed bound on the object's
2012 size is known in advance. */
07c138c8
GB
2013extern LONGEST target_fileio_read_alloc (struct inferior *inf,
2014 const char *filename,
7313baad
UW
2015 gdb_byte **buf_p);
2016
07c138c8
GB
2017/* Read target file FILENAME, in the filesystem as seen by INF. If
2018 INF is NULL, use the filesystem seen by the debugger (GDB or, for
2019 remote targets, the remote stub). The result is NUL-terminated and
7313baad
UW
2020 returned as a string, allocated using xmalloc. If an error occurs
2021 or the transfer is unsupported, NULL is returned. Empty objects
2022 are returned as allocated but empty strings. A warning is issued
2023 if the result contains any embedded NUL bytes. */
07c138c8
GB
2024extern char *target_fileio_read_stralloc (struct inferior *inf,
2025 const char *filename);
7313baad
UW
2026
2027
35b1e5cc
SS
2028/* Tracepoint-related operations. */
2029
2030#define target_trace_init() \
ecae04e1 2031 (*current_target.to_trace_init) (&current_target)
35b1e5cc
SS
2032
2033#define target_download_tracepoint(t) \
548f7808 2034 (*current_target.to_download_tracepoint) (&current_target, t)
35b1e5cc 2035
1e4d1764 2036#define target_can_download_tracepoint() \
a52a8357 2037 (*current_target.to_can_download_tracepoint) (&current_target)
1e4d1764 2038
35b1e5cc 2039#define target_download_trace_state_variable(tsv) \
559d2b81 2040 (*current_target.to_download_trace_state_variable) (&current_target, tsv)
35b1e5cc 2041
d248b706 2042#define target_enable_tracepoint(loc) \
46670d57 2043 (*current_target.to_enable_tracepoint) (&current_target, loc)
d248b706
KY
2044
2045#define target_disable_tracepoint(loc) \
780b049c 2046 (*current_target.to_disable_tracepoint) (&current_target, loc)
d248b706 2047
35b1e5cc 2048#define target_trace_start() \
e2d1aae3 2049 (*current_target.to_trace_start) (&current_target)
35b1e5cc
SS
2050
2051#define target_trace_set_readonly_regions() \
583f9a86 2052 (*current_target.to_trace_set_readonly_regions) (&current_target)
35b1e5cc 2053
00bf0b85 2054#define target_get_trace_status(ts) \
8bd200f1 2055 (*current_target.to_get_trace_status) (&current_target, ts)
35b1e5cc 2056
f196051f 2057#define target_get_tracepoint_status(tp,utp) \
db90e85c 2058 (*current_target.to_get_tracepoint_status) (&current_target, tp, utp)
f196051f 2059
35b1e5cc 2060#define target_trace_stop() \
74499f1b 2061 (*current_target.to_trace_stop) (&current_target)
35b1e5cc
SS
2062
2063#define target_trace_find(type,num,addr1,addr2,tpp) \
bd4c6793
TT
2064 (*current_target.to_trace_find) (&current_target, \
2065 (type), (num), (addr1), (addr2), (tpp))
35b1e5cc
SS
2066
2067#define target_get_trace_state_variable_value(tsv,val) \
4011015b
TT
2068 (*current_target.to_get_trace_state_variable_value) (&current_target, \
2069 (tsv), (val))
35b1e5cc 2070
00bf0b85 2071#define target_save_trace_data(filename) \
dc3decaf 2072 (*current_target.to_save_trace_data) (&current_target, filename)
00bf0b85
SS
2073
2074#define target_upload_tracepoints(utpp) \
ab6617cc 2075 (*current_target.to_upload_tracepoints) (&current_target, utpp)
00bf0b85
SS
2076
2077#define target_upload_trace_state_variables(utsvp) \
181e3713 2078 (*current_target.to_upload_trace_state_variables) (&current_target, utsvp)
00bf0b85
SS
2079
2080#define target_get_raw_trace_data(buf,offset,len) \
88ee6f45
TT
2081 (*current_target.to_get_raw_trace_data) (&current_target, \
2082 (buf), (offset), (len))
00bf0b85 2083
405f8e94 2084#define target_get_min_fast_tracepoint_insn_len() \
0e67620a 2085 (*current_target.to_get_min_fast_tracepoint_insn_len) (&current_target)
405f8e94 2086
35b1e5cc 2087#define target_set_disconnected_tracing(val) \
37b25738 2088 (*current_target.to_set_disconnected_tracing) (&current_target, val)
35b1e5cc 2089
4daf5ac0 2090#define target_set_circular_trace_buffer(val) \
736d5b1f 2091 (*current_target.to_set_circular_trace_buffer) (&current_target, val)
4daf5ac0 2092
f6f899bf 2093#define target_set_trace_buffer_size(val) \
4da384be 2094 (*current_target.to_set_trace_buffer_size) (&current_target, val)
f6f899bf 2095
f196051f 2096#define target_set_trace_notes(user,notes,stopnotes) \
d9e68a2c
TT
2097 (*current_target.to_set_trace_notes) (&current_target, \
2098 (user), (notes), (stopnotes))
f196051f 2099
711e434b 2100#define target_get_tib_address(ptid, addr) \
bd7ae0f5 2101 (*current_target.to_get_tib_address) (&current_target, (ptid), (addr))
711e434b 2102
d914c394 2103#define target_set_permissions() \
c378d69d 2104 (*current_target.to_set_permissions) (&current_target)
d914c394 2105
0fb4aa4b 2106#define target_static_tracepoint_marker_at(addr, marker) \
61fc905d
TT
2107 (*current_target.to_static_tracepoint_marker_at) (&current_target, \
2108 addr, marker)
0fb4aa4b
PA
2109
2110#define target_static_tracepoint_markers_by_strid(marker_id) \
c686c57f
TT
2111 (*current_target.to_static_tracepoint_markers_by_strid) (&current_target, \
2112 marker_id)
0fb4aa4b 2113
b3b9301e 2114#define target_traceframe_info() \
a893e81f 2115 (*current_target.to_traceframe_info) (&current_target)
b3b9301e 2116
d1feda86 2117#define target_use_agent(use) \
2c152180 2118 (*current_target.to_use_agent) (&current_target, use)
d1feda86
YQ
2119
2120#define target_can_use_agent() \
fe38f897 2121 (*current_target.to_can_use_agent) (&current_target)
d1feda86 2122
ced63ec0 2123#define target_augmented_libraries_svr4_read() \
5436ff03 2124 (*current_target.to_augmented_libraries_svr4_read) (&current_target)
ced63ec0 2125
49d03eab
MR
2126/* Command logging facility. */
2127
d9cb0195
TT
2128#define target_log_command(p) \
2129 (*current_target.to_log_command) (&current_target, p)
49d03eab 2130
dc146f7c
VP
2131
2132extern int target_core_of_thread (ptid_t ptid);
2133
ea001bdc
MM
2134/* See to_get_unwinder in struct target_ops. */
2135extern const struct frame_unwind *target_get_unwinder (void);
2136
2137/* See to_get_tailcall_unwinder in struct target_ops. */
2138extern const struct frame_unwind *target_get_tailcall_unwinder (void);
2139
936d2992
PA
2140/* This implements basic memory verification, reading target memory
2141 and performing the comparison here (as opposed to accelerated
2142 verification making use of the qCRC packet, for example). */
2143
2144extern int simple_verify_memory (struct target_ops* ops,
2145 const gdb_byte *data,
2146 CORE_ADDR memaddr, ULONGEST size);
2147
4a5e7a5b
PA
2148/* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range matches
2149 the contents of [DATA,DATA+SIZE). Returns 1 if there's a match, 0
2150 if there's a mismatch, and -1 if an error is encountered while
2151 reading memory. Throws an error if the functionality is found not
2152 to be supported by the current target. */
2153int target_verify_memory (const gdb_byte *data,
2154 CORE_ADDR memaddr, ULONGEST size);
2155
c906108c
SS
2156/* Routines for maintenance of the target structures...
2157
c22a2b88 2158 complete_target_initialization: Finalize a target_ops by filling in
3156469c
JB
2159 any fields needed by the target implementation. Unnecessary for
2160 targets which are registered via add_target, as this part gets
2161 taken care of then.
c22a2b88 2162
c906108c 2163 add_target: Add a target to the list of all possible targets.
3156469c
JB
2164 This only makes sense for targets that should be activated using
2165 the "target TARGET_NAME ..." command.
c906108c
SS
2166
2167 push_target: Make this target the top of the stack of currently used
c5aa993b
JM
2168 targets, within its particular stratum of the stack. Result
2169 is 0 if now atop the stack, nonzero if not on top (maybe
2170 should warn user).
c906108c
SS
2171
2172 unpush_target: Remove this from the stack of currently used targets,
c5aa993b 2173 no matter where it is on the list. Returns 0 if no
7fdc1521 2174 change, 1 if removed from stack. */
c906108c 2175
a14ed312 2176extern void add_target (struct target_ops *);
c906108c 2177
9852c492
YQ
2178extern void add_target_with_completer (struct target_ops *t,
2179 completer_ftype *completer);
2180
c22a2b88
TT
2181extern void complete_target_initialization (struct target_ops *t);
2182
b48d48eb
MM
2183/* Adds a command ALIAS for target T and marks it deprecated. This is useful
2184 for maintaining backwards compatibility when renaming targets. */
2185
2186extern void add_deprecated_target_alias (struct target_ops *t, char *alias);
2187
b26a4dcb 2188extern void push_target (struct target_ops *);
c906108c 2189
a14ed312 2190extern int unpush_target (struct target_ops *);
c906108c 2191
fd79ecee
DJ
2192extern void target_pre_inferior (int);
2193
a14ed312 2194extern void target_preopen (int);
c906108c 2195
460014f5
JK
2196/* Does whatever cleanup is required to get rid of all pushed targets. */
2197extern void pop_all_targets (void);
aa76d38d 2198
87ab71f0
PA
2199/* Like pop_all_targets, but pops only targets whose stratum is
2200 strictly above ABOVE_STRATUM. */
460014f5 2201extern void pop_all_targets_above (enum strata above_stratum);
87ab71f0 2202
c0edd9ed
JK
2203extern int target_is_pushed (struct target_ops *t);
2204
9e35dae4
DJ
2205extern CORE_ADDR target_translate_tls_address (struct objfile *objfile,
2206 CORE_ADDR offset);
2207
0542c86d 2208/* Struct target_section maps address ranges to file sections. It is
c906108c
SS
2209 mostly used with BFD files, but can be used without (e.g. for handling
2210 raw disks, or files not in formats handled by BFD). */
2211
0542c86d 2212struct target_section
c5aa993b
JM
2213 {
2214 CORE_ADDR addr; /* Lowest address in section */
2215 CORE_ADDR endaddr; /* 1+highest address in section */
c906108c 2216
7be0c536 2217 struct bfd_section *the_bfd_section;
c906108c 2218
046ac79f
JK
2219 /* The "owner" of the section.
2220 It can be any unique value. It is set by add_target_sections
2221 and used by remove_target_sections.
2222 For example, for executables it is a pointer to exec_bfd and
2223 for shlibs it is the so_list pointer. */
2224 void *owner;
c5aa993b 2225 };
c906108c 2226
07b82ea5
PA
2227/* Holds an array of target sections. Defined by [SECTIONS..SECTIONS_END[. */
2228
2229struct target_section_table
2230{
2231 struct target_section *sections;
2232 struct target_section *sections_end;
2233};
2234
8db32d44 2235/* Return the "section" containing the specified address. */
0542c86d
PA
2236struct target_section *target_section_by_addr (struct target_ops *target,
2237 CORE_ADDR addr);
8db32d44 2238
07b82ea5
PA
2239/* Return the target section table this target (or the targets
2240 beneath) currently manipulate. */
2241
2242extern struct target_section_table *target_get_section_table
2243 (struct target_ops *target);
2244
c906108c
SS
2245/* From mem-break.c */
2246
3db08215 2247extern int memory_remove_breakpoint (struct target_ops *, struct gdbarch *,
3e43a32a 2248 struct bp_target_info *);
c906108c 2249
3db08215 2250extern int memory_insert_breakpoint (struct target_ops *, struct gdbarch *,
3e43a32a 2251 struct bp_target_info *);
c906108c 2252
08351840
PA
2253/* Check whether the memory at the breakpoint's placed address still
2254 contains the expected breakpoint instruction. */
2255
2256extern int memory_validate_breakpoint (struct gdbarch *gdbarch,
2257 struct bp_target_info *bp_tgt);
2258
3e43a32a
MS
2259extern int default_memory_remove_breakpoint (struct gdbarch *,
2260 struct bp_target_info *);
917317f4 2261
3e43a32a
MS
2262extern int default_memory_insert_breakpoint (struct gdbarch *,
2263 struct bp_target_info *);
917317f4 2264
c906108c
SS
2265
2266/* From target.c */
2267
a14ed312 2268extern void initialize_targets (void);
c906108c 2269
c25c4a8b 2270extern void noprocess (void) ATTRIBUTE_NORETURN;
c906108c 2271
8edfe269
DJ
2272extern void target_require_runnable (void);
2273
a14ed312 2274extern struct target_ops *find_target_beneath (struct target_ops *);
ed9a39eb 2275
8b06beed
TT
2276/* Find the target at STRATUM. If no target is at that stratum,
2277 return NULL. */
2278
2279struct target_ops *find_target_at (enum strata stratum);
2280
e0665bc8
PA
2281/* Read OS data object of type TYPE from the target, and return it in
2282 XML format. The result is NUL-terminated and returned as a string,
2283 allocated using xmalloc. If an error occurs or the transfer is
2284 unsupported, NULL is returned. Empty objects are returned as
2285 allocated but empty strings. */
2286
07e059b5
VP
2287extern char *target_get_osdata (const char *type);
2288
c906108c
SS
2289\f
2290/* Stuff that should be shared among the various remote targets. */
2291
2292/* Debugging level. 0 is off, and non-zero values mean to print some debug
2293 information (higher values, more information). */
2294extern int remote_debug;
2295
2296/* Speed in bits per second, or -1 which means don't mess with the speed. */
2297extern int baud_rate;
236af5e3
YG
2298
2299/* Parity for serial port */
2300extern int serial_parity;
2301
c378eb4e 2302/* Timeout limit for response from target. */
c906108c
SS
2303extern int remote_timeout;
2304
c906108c 2305\f
c906108c 2306
8defab1a
DJ
2307/* Set the show memory breakpoints mode to show, and installs a cleanup
2308 to restore it back to the current value. */
2309extern struct cleanup *make_show_memory_breakpoints_cleanup (int show);
2310
d914c394
SS
2311extern int may_write_registers;
2312extern int may_write_memory;
2313extern int may_insert_breakpoints;
2314extern int may_insert_tracepoints;
2315extern int may_insert_fast_tracepoints;
2316extern int may_stop;
2317
2318extern void update_target_permissions (void);
2319
c906108c 2320\f
c378eb4e 2321/* Imported from machine dependent code. */
c906108c 2322
02d27625 2323/* See to_supports_btrace in struct target_ops. */
043c3577 2324extern int target_supports_btrace (enum btrace_format);
02d27625
MM
2325
2326/* See to_enable_btrace in struct target_ops. */
f4abbc16
MM
2327extern struct btrace_target_info *
2328 target_enable_btrace (ptid_t ptid, const struct btrace_config *);
02d27625
MM
2329
2330/* See to_disable_btrace in struct target_ops. */
2331extern void target_disable_btrace (struct btrace_target_info *btinfo);
2332
2333/* See to_teardown_btrace in struct target_ops. */
2334extern void target_teardown_btrace (struct btrace_target_info *btinfo);
2335
2336/* See to_read_btrace in struct target_ops. */
734b0e4b 2337extern enum btrace_error target_read_btrace (struct btrace_data *,
969c39fb
MM
2338 struct btrace_target_info *,
2339 enum btrace_read_type);
02d27625 2340
f4abbc16
MM
2341/* See to_btrace_conf in struct target_ops. */
2342extern const struct btrace_config *
2343 target_btrace_conf (const struct btrace_target_info *);
2344
7c1687a9
MM
2345/* See to_stop_recording in struct target_ops. */
2346extern void target_stop_recording (void);
2347
d02ed0bb 2348/* See to_save_record in struct target_ops. */
85e1311a 2349extern void target_save_record (const char *filename);
d02ed0bb
MM
2350
2351/* Query if the target supports deleting the execution log. */
2352extern int target_supports_delete_record (void);
2353
2354/* See to_delete_record in struct target_ops. */
2355extern void target_delete_record (void);
2356
2357/* See to_record_is_replaying in struct target_ops. */
2358extern int target_record_is_replaying (void);
2359
2360/* See to_goto_record_begin in struct target_ops. */
2361extern void target_goto_record_begin (void);
2362
2363/* See to_goto_record_end in struct target_ops. */
2364extern void target_goto_record_end (void);
2365
2366/* See to_goto_record in struct target_ops. */
2367extern void target_goto_record (ULONGEST insn);
02d27625 2368
67c86d06
MM
2369/* See to_insn_history. */
2370extern void target_insn_history (int size, int flags);
2371
2372/* See to_insn_history_from. */
2373extern void target_insn_history_from (ULONGEST from, int size, int flags);
2374
2375/* See to_insn_history_range. */
2376extern void target_insn_history_range (ULONGEST begin, ULONGEST end, int flags);
2377
15984c13
MM
2378/* See to_call_history. */
2379extern void target_call_history (int size, int flags);
2380
2381/* See to_call_history_from. */
2382extern void target_call_history_from (ULONGEST begin, int size, int flags);
2383
2384/* See to_call_history_range. */
2385extern void target_call_history_range (ULONGEST begin, ULONGEST end, int flags);
2386
5fff78c4
MM
2387/* See to_prepare_to_generate_core. */
2388extern void target_prepare_to_generate_core (void);
2389
2390/* See to_done_generating_core. */
2391extern void target_done_generating_core (void);
2392
c5aa993b 2393#endif /* !defined (TARGET_H) */
This page took 1.759888 seconds and 4 git commands to generate.