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