]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/target.h
[gdb/testsuite] Use support_displaced_stepping in gdb.arch/amd64-disp-step-avx.exp
[thirdparty/binutils-gdb.git] / gdb / target.h
CommitLineData
c906108c 1/* Interface between GDB and target environments, including files and processes
0088c768 2
d01e8234 3 Copyright (C) 1990-2025 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 21
d9df7f16
PA
22/* This include file defines the interface between the main part of
23 the debugger, and the part which is target-specific, or specific to
24 the communications interface between us and the target.
25
26 A TARGET is an interface between the debugger and a particular
27 kind of file or process. Targets can be STACKED in STRATA,
28 so that more than one target can potentially respond to a request.
29 In particular, memory accesses will walk down the stack of targets
30 until they find a target that is interested in handling that particular
31 address. STRATA are artificial boundaries on the stack, within
32 which particular kinds of targets live. Strata exist so that
33 people don't get confused by pushing e.g. a process target and then
34 a file target, and wondering why they can't see the current values
35 of variables any more (the file target is handling them and they
36 never get to the process target). So when you push a file target,
37 it goes into the file stratum, which is always below the process
38 stratum.
39
40 Note that rather than allow an empty stack, we always have the
41 dummy target at the bottom stratum, so we can call the target
42 methods without checking them. */
43
cc709640
TT
44#ifndef GDB_TARGET_H
45#define GDB_TARGET_H
c906108c 46
da3331ec
AC
47struct objfile;
48struct ui_file;
49struct mem_attrib;
1e3ff5ad 50struct target_ops;
d248b706 51struct bp_location;
8181d85f 52struct bp_target_info;
56be3814 53struct regcache;
35b1e5cc 54struct trace_state_variable;
00bf0b85
SS
55struct trace_status;
56struct uploaded_tsv;
57struct uploaded_tp;
0fb4aa4b 58struct static_tracepoint_marker;
b3b9301e 59struct traceframe_info;
0cf6dd15 60struct expression;
2a2f9fe4 61struct dcache_struct;
07c138c8 62struct inferior;
0cf6dd15 63
1f08d324
TV
64/* Define const gdb_byte using one identifier, to make it easy for
65 make-target-delegates.py to parse. */
66typedef const gdb_byte const_gdb_byte;
67
ef0f16cc
TT
68#include "infrun.h"
69#include "breakpoint.h"
268a13a5 70#include "gdbsupport/scoped_restore.h"
5b6d1e4f 71#include "gdbsupport/refcounted-object.h"
7b466b10 72#include "target-section.h"
721ec300 73#include "target/target.h"
33b60d58
LM
74#include "target/resume.h"
75#include "target/wait.h"
76#include "target/waitstatus.h"
c906108c
SS
77#include "bfd.h"
78#include "symtab.h"
29e57380 79#include "memattr.h"
268a13a5 80#include "gdbsupport/gdb_signals.h"
02d27625 81#include "btrace.h"
b158a20f 82#include "record.h"
9852c492 83#include "command.h"
c8154ce0 84#include "disasm-flags.h"
2098b393 85#include "tracepoint.h"
b872057a 86#include "gdbsupport/fileio.h"
a388ab0b 87#include "gdbsupport/x86-xstate.h"
c906108c 88
ef0f16cc 89#include "gdbsupport/break-common.h"
f486487f 90
c5aa993b
JM
91enum strata
92 {
93 dummy_stratum, /* The lowest of the low */
94 file_stratum, /* Executable files, etc */
c0edd9ed 95 process_stratum, /* Executing processes or core dump files */
81e64f55 96 thread_stratum, /* Executing threads */
85e747d2 97 record_stratum, /* Support record debugging */
f6ac5f3d
PA
98 arch_stratum, /* Architecture overrides */
99 debug_stratum /* Target debug. Must be last. */
c5aa993b 100 };
c906108c 101
c5aa993b
JM
102enum thread_control_capabilities
103 {
0d06e24b
JM
104 tc_none = 0, /* Default: can't control thread execution. */
105 tc_schedlock = 1, /* Can lock the thread scheduler. */
c5aa993b 106 };
c906108c 107
a96d9b2e
SDJ
108/* The structure below stores information about a system call.
109 It is basically used in the "catch syscall" command, and in
110 every function that gives information about a system call.
111
112 It's also good to mention that its fields represent everything
113 that we currently know about a syscall in GDB. */
114struct syscall
115 {
116 /* The syscall number. */
117 int number;
118
119 /* The syscall name. */
120 const char *name;
121 };
122
09ce46f2 123/* Return a pretty printed form of TARGET_OPTIONS. */
b60cea74 124extern std::string target_options_to_string (target_wait_flags target_options);
09826ec5 125
2acceee2 126/* Possible types of events that the inferior handler will have to
0d06e24b 127 deal with. */
2acceee2
JM
128enum inferior_event_type
129 {
2acceee2 130 /* Process a normal inferior event which will result in target_wait
0d06e24b 131 being called. */
2146d243 132 INF_REG_EVENT,
0d06e24b 133 /* We are called to do stuff after the inferior stops. */
c2d11a7d 134 INF_EXEC_COMPLETE,
2acceee2 135 };
c906108c 136\f
8f6606b6 137/* Target objects which can be transferred using target_read,
13547ab6 138 target_write, et cetera. */
1e3ff5ad
AC
139
140enum target_object
141{
1e3ff5ad
AC
142 /* AVR target specific transfer. See "avr-tdep.c" and "remote.c". */
143 TARGET_OBJECT_AVR,
144 /* Transfer up-to LEN bytes of memory starting at OFFSET. */
287a334e 145 TARGET_OBJECT_MEMORY,
cf7a04e8
DJ
146 /* Memory, avoiding GDB's data cache and trusting the executable.
147 Target implementations of to_xfer_partial never need to handle
148 this object, and most callers should not use it. */
149 TARGET_OBJECT_RAW_MEMORY,
4e5d721f
DE
150 /* Memory known to be part of the target's stack. This is cached even
151 if it is not in a region marked as such, since it is known to be
152 "normal" RAM. */
153 TARGET_OBJECT_STACK_MEMORY,
29453a14
YQ
154 /* Memory known to be part of the target code. This is cached even
155 if it is not in a region marked as such. */
156 TARGET_OBJECT_CODE_MEMORY,
287a334e
JJ
157 /* Kernel Unwind Table. See "ia64-tdep.c". */
158 TARGET_OBJECT_UNWIND_TABLE,
8f6606b6 159 /* Transfer auxiliary vector. */
2146d243 160 TARGET_OBJECT_AUXV,
baf92889 161 /* StackGhost cookie. See "sparc-tdep.c". */
fd79ecee
DJ
162 TARGET_OBJECT_WCOOKIE,
163 /* Target memory map in XML format. */
164 TARGET_OBJECT_MEMORY_MAP,
a76d924d
DJ
165 /* Flash memory. This object can be used to write contents to
166 a previously erased flash memory. Using it without erasing
167 flash can have unexpected results. Addresses are physical
168 address on target, and not relative to flash start. */
23181151
DJ
169 TARGET_OBJECT_FLASH,
170 /* Available target-specific features, e.g. registers and coprocessors.
171 See "target-descriptions.c". ANNEX should never be empty. */
cfa9d6d9
DJ
172 TARGET_OBJECT_AVAILABLE_FEATURES,
173 /* Currently loaded libraries, in XML format. */
07e059b5 174 TARGET_OBJECT_LIBRARIES,
2268b414
JK
175 /* Currently loaded libraries specific for SVR4 systems, in XML format. */
176 TARGET_OBJECT_LIBRARIES_SVR4,
4d1eb6b4 177 /* Currently loaded libraries specific to AIX systems, in XML format. */
ff99b71b 178 TARGET_OBJECT_LIBRARIES_AIX,
07e059b5 179 /* Get OS specific data. The ANNEX specifies the type (running
8f6606b6 180 processes, etc.). The data being transferred is expected to follow
113a6f1e 181 the DTD specified in features/osdata.dtd. */
4aa995e1
PA
182 TARGET_OBJECT_OSDATA,
183 /* Extra signal info. Usually the contents of `siginfo_t' on unix
184 platforms. */
185 TARGET_OBJECT_SIGNAL_INFO,
dc146f7c
VP
186 /* The list of threads that are being debugged. */
187 TARGET_OBJECT_THREADS,
0fb4aa4b
PA
188 /* Collected static trace data. */
189 TARGET_OBJECT_STATIC_TRACE_DATA,
b3b9301e
PA
190 /* Traceframe info, in XML format. */
191 TARGET_OBJECT_TRACEFRAME_INFO,
78d85199
YQ
192 /* Load maps for FDPIC systems. */
193 TARGET_OBJECT_FDPIC,
f00c55f8 194 /* Darwin dynamic linker info data. */
169081d0
TG
195 TARGET_OBJECT_DARWIN_DYLD_INFO,
196 /* OpenVMS Unwind Information Block. */
02d27625 197 TARGET_OBJECT_OPENVMS_UIB,
9accd112 198 /* Branch trace data, in XML format. */
f4abbc16
MM
199 TARGET_OBJECT_BTRACE,
200 /* Branch trace configuration, in XML format. */
c78fa86a
GB
201 TARGET_OBJECT_BTRACE_CONF,
202 /* The pathname of the executable file that was run to create
203 a specified process. ANNEX should be a string representation
204 of the process ID of the process in question, in hexadecimal
205 format. */
206 TARGET_OBJECT_EXEC_FILE,
739ab2e9
SS
207 /* FreeBSD virtual memory mappings. */
208 TARGET_OBJECT_FREEBSD_VMMAP,
209 /* FreeBSD process strings. */
210 TARGET_OBJECT_FREEBSD_PS_STRINGS,
c378eb4e 211 /* Possible future objects: TARGET_OBJECT_FILE, ... */
1e3ff5ad
AC
212};
213
9b409511 214/* Possible values returned by target_xfer_partial, etc. */
6be7b56e 215
9b409511 216enum target_xfer_status
6be7b56e 217{
9b409511
YQ
218 /* Some bytes are transferred. */
219 TARGET_XFER_OK = 1,
220
221 /* No further transfer is possible. */
222 TARGET_XFER_EOF = 0,
223
bc113b4e
YQ
224 /* The piece of the object requested is unavailable. */
225 TARGET_XFER_UNAVAILABLE = 2,
226
6be7b56e
PA
227 /* Generic I/O error. Note that it's important that this is '-1',
228 as we still have target_xfer-related code returning hardcoded
229 '-1' on error. */
230 TARGET_XFER_E_IO = -1,
231
01cb8804 232 /* Keep list in sync with target_xfer_status_to_string. */
6be7b56e
PA
233};
234
01cb8804 235/* Return the string form of STATUS. */
6be7b56e 236
01cb8804
YQ
237extern const char *
238 target_xfer_status_to_string (enum target_xfer_status status);
6be7b56e 239
9b409511 240typedef enum target_xfer_status
4ac248ca
YQ
241 target_xfer_partial_ftype (struct target_ops *ops,
242 enum target_object object,
243 const char *annex,
244 gdb_byte *readbuf,
245 const gdb_byte *writebuf,
246 ULONGEST offset,
9b409511
YQ
247 ULONGEST len,
248 ULONGEST *xfered_len);
4ac248ca 249
cc9f16aa
YQ
250enum target_xfer_status
251 raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
252 const gdb_byte *writebuf, ULONGEST memaddr,
253 LONGEST len, ULONGEST *xfered_len);
254
d309493c
SM
255/* Request that OPS transfer up to LEN addressable units of the target's
256 OBJECT. When reading from a memory object, the size of an addressable unit
257 is architecture dependent and can be found using
258 gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is 1
259 byte long. BUF should point to a buffer large enough to hold the read data,
260 taking into account the addressable unit size. The OFFSET, for a seekable
261 object, specifies the starting point. The ANNEX can be used to provide
262 additional data-specific information to the target.
263
264 Return the number of addressable units actually transferred, or a negative
265 error code (an 'enum target_xfer_error' value) if the transfer is not
578d3588
PA
266 supported or otherwise fails. Return of a positive value less than
267 LEN indicates that no further transfer is possible. Unlike the raw
268 to_xfer_partial interface, callers of these functions do not need
269 to retry partial transfers. */
1e3ff5ad 270
1e3ff5ad
AC
271extern LONGEST target_read (struct target_ops *ops,
272 enum target_object object,
1b0ba102 273 const char *annex, gdb_byte *buf,
1e3ff5ad
AC
274 ULONGEST offset, LONGEST len);
275
8dedea02 276struct memory_read_result
386c8614
TT
277{
278 memory_read_result (ULONGEST begin_, ULONGEST end_,
279 gdb::unique_xmalloc_ptr<gdb_byte> &&data_)
280 : begin (begin_),
281 end (end_),
282 data (std::move (data_))
8dedea02 283 {
386c8614
TT
284 }
285
286 ~memory_read_result () = default;
8dedea02 287
386c8614
TT
288 memory_read_result (memory_read_result &&other) = default;
289
290 DISABLE_COPY_AND_ASSIGN (memory_read_result);
291
292 /* First address that was read. */
293 ULONGEST begin;
294 /* Past-the-end address. */
295 ULONGEST end;
296 /* The data. */
297 gdb::unique_xmalloc_ptr<gdb_byte> data;
298};
8dedea02 299
386c8614
TT
300extern std::vector<memory_read_result> read_memory_robust
301 (struct target_ops *ops, const ULONGEST offset, const LONGEST len);
279a6fed 302
d309493c
SM
303/* Request that OPS transfer up to LEN addressable units from BUF to the
304 target's OBJECT. When writing to a memory object, the addressable unit
305 size is architecture dependent and can be found using
306 gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is 1
307 byte long. The OFFSET, for a seekable object, specifies the starting point.
308 The ANNEX can be used to provide additional data-specific information to
309 the target.
310
311 Return the number of addressable units actually transferred, or a negative
312 error code (an 'enum target_xfer_status' value) if the transfer is not
313 supported or otherwise fails. Return of a positive value less than
314 LEN indicates that no further transfer is possible. Unlike the raw
315 to_xfer_partial interface, callers of these functions do not need to
316 retry partial transfers. */
317
1e3ff5ad
AC
318extern LONGEST target_write (struct target_ops *ops,
319 enum target_object object,
1b0ba102 320 const char *annex, const gdb_byte *buf,
1e3ff5ad 321 ULONGEST offset, LONGEST len);
b6591e8b 322
a76d924d
DJ
323/* Similar to target_write, except that it also calls PROGRESS with
324 the number of bytes written and the opaque BATON after every
325 successful partial write (and before the first write). This is
326 useful for progress reporting and user interaction while writing
327 data. To abort the transfer, the progress callback can throw an
328 exception. */
329
cf7a04e8
DJ
330LONGEST target_write_with_progress (struct target_ops *ops,
331 enum target_object object,
332 const char *annex, const gdb_byte *buf,
333 ULONGEST offset, LONGEST len,
334 void (*progress) (ULONGEST, void *),
335 void *baton);
336
9018be22
SM
337/* Wrapper to perform a full read of unknown size. OBJECT/ANNEX will be read
338 using OPS. The return value will be uninstantiated if the transfer fails or
339 is not supported.
13547ab6
DJ
340
341 This method should be used for objects sufficiently small to store
342 in a single xmalloc'd buffer, when no fixed bound on the object's
343 size is known in advance. Don't try to read TARGET_OBJECT_MEMORY
344 through this function. */
345
6b09f134 346extern std::optional<gdb::byte_vector> target_read_alloc
9018be22 347 (struct target_ops *ops, enum target_object object, const char *annex);
13547ab6 348
9018be22
SM
349/* Read OBJECT/ANNEX using OPS. The result is a NUL-terminated character vector
350 (therefore usable as a NUL-terminated string). If an error occurs or the
351 transfer is unsupported, the return value will be uninstantiated. Empty
352 objects are returned as allocated but empty strings. Therefore, on success,
353 the returned vector is guaranteed to have at least one element. A warning is
354 issued if the result contains any embedded NUL bytes. */
159f81f3 355
6b09f134 356extern std::optional<gdb::char_vector> target_read_stralloc
b7b030ad 357 (struct target_ops *ops, enum target_object object, const char *annex);
159f81f3 358
6be7b56e 359/* See target_ops->to_xfer_partial. */
4ac248ca 360extern target_xfer_partial_ftype target_xfer_partial;
6be7b56e 361
b6591e8b
AC
362/* Wrappers to target read/write that perform memory transfers. They
363 throw an error if the memory transfer fails.
364
365 NOTE: cagney/2003-10-23: The naming schema is lifted from
366 "frame.h". The parameter order is lifted from get_frame_memory,
367 which in turn lifted it from read_memory. */
368
369extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
1b0ba102 370 gdb_byte *buf, LONGEST len);
b6591e8b 371extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
e17a4113
UW
372 CORE_ADDR addr, int len,
373 enum bfd_endian byte_order);
1e3ff5ad 374\f
0d06e24b
JM
375struct thread_info; /* fwd decl for parameter list below: */
376
b0a16e66
TT
377/* The type of the callback to the to_async method. */
378
379typedef void async_callback_ftype (enum inferior_event_type event_type,
380 void *context);
381
a7068b60
TT
382/* Normally target debug printing is purely type-based. However,
383 sometimes it is necessary to override the debug printing on a
384 per-argument basis. This macro can be used, attribute-style, to
385 name the target debug printing function for a particular method
386 argument. FUNC is the name of the function. The macro's
387 definition is empty because it is only used by the
388 make-target-delegates script. */
389
390#define TARGET_DEBUG_PRINTER(FUNC)
391
1101cb7b
TT
392/* These defines are used to mark target_ops methods. The script
393 make-target-delegates scans these and auto-generates the base
394 method implementations. There are four macros that can be used:
395
396 1. TARGET_DEFAULT_IGNORE. There is no argument. The base method
397 does nothing. This is only valid if the method return type is
398 'void'.
399
400 2. TARGET_DEFAULT_NORETURN. The argument is a function call, like
401 'tcomplain ()'. The base method simply makes this call, which is
402 assumed not to return.
403
404 3. TARGET_DEFAULT_RETURN. The argument is a C expression. The
405 base method returns this expression's value.
406
407 4. TARGET_DEFAULT_FUNC. The argument is the name of a function.
408 make-target-delegates does not generate a base method in this case,
409 but instead uses the argument function as the base method. */
410
411#define TARGET_DEFAULT_IGNORE()
412#define TARGET_DEFAULT_NORETURN(ARG)
413#define TARGET_DEFAULT_RETURN(ARG)
414#define TARGET_DEFAULT_FUNC(ARG)
415
d9f719f1
PA
416/* Each target that can be activated with "target TARGET_NAME" passes
417 the address of one of these objects to add_target, which uses the
418 object's address as unique identifier, and registers the "target
419 TARGET_NAME" command using SHORTNAME as target name. */
420
421struct target_info
422{
423 /* Name of this target. */
424 const char *shortname;
425
426 /* Name for printing. */
427 const char *longname;
428
429 /* Documentation. Does not include trailing newline, and starts
430 with a one-line description (probably similar to longname). */
431 const char *doc;
432};
433
d9df7f16
PA
434/* A GDB target.
435
436 Each inferior has a stack of these. See overall description at the
437 top.
438
439 Most target methods traverse the current inferior's target stack;
440 you call the method on the top target (normally via one of the
441 target_foo wrapper free functions), and the implementation of said
442 method does its work and returns, or defers to the same method on
443 the target beneath on the current inferior's target stack. Thus,
444 the inferior you want to call the target method on must be made the
445 current inferior before calling a target method, so that the stack
446 traversal works correctly.
447
448 Methods that traverse the stack have a TARGET_DEFAULT_XXX marker in
449 their declaration below. See the macros' description above, where
450 they're defined. */
451
c906108c 452struct target_ops
5b6d1e4f 453 : public refcounted_object
c5aa993b 454 {
66b4deae
PA
455 /* Return this target's stratum. */
456 virtual strata stratum () const = 0;
457
b6a8c27b 458 /* To the target under this one. */
b6a8c27b 459 target_ops *beneath () const;
f6ac5f3d 460
d9f719f1
PA
461 /* Free resources associated with the target. Note that singleton
462 targets, like e.g., native targets, are global objects, not
463 heap allocated, and are thus only deleted on GDB exit. The
464 main teardown entry point is the "close" method, below. */
f6ac5f3d
PA
465 virtual ~target_ops () {}
466
d9f719f1
PA
467 /* Return a reference to this target's unique target_info
468 object. */
469 virtual const target_info &info () const = 0;
f6ac5f3d 470
d9f719f1 471 /* Name this target type. */
5b6d1e4f 472 const char *shortname () const
d9f719f1 473 { return info ().shortname; }
f6ac5f3d 474
5b6d1e4f 475 const char *longname () const
d9f719f1 476 { return info ().longname; }
3fffc070
PA
477
478 /* Close the target. This is where the target can handle
479 teardown. Heap-allocated targets should delete themselves
480 before returning. */
f6ac5f3d 481 virtual void close ();
3fffc070 482
b3ccfe11
TT
483 /* Attaches to a process on the target side. Arguments are as
484 passed to the `attach' command by the user. This routine can
485 be called when the target is not on the target-stack, if the
f6ac5f3d 486 target_ops::can_run method returns 1; in that case, it must push
b3ccfe11
TT
487 itself onto the stack. Upon exit, the target should be ready
488 for normal operations, and should be ready to deliver the
489 status of the process immediately (without waiting) to an
490 upcoming target_wait call. */
f6ac5f3d
PA
491 virtual bool can_attach ();
492 virtual void attach (const char *, int);
493 virtual void post_attach (int)
bebd3233 494 TARGET_DEFAULT_IGNORE ();
e87f0fe8
PA
495
496 /* Detaches from the inferior. Note that on targets that support
497 async execution (i.e., targets where it is possible to detach
498 from programs with threads running), the target is responsible
499 for removing breakpoints from the program before the actual
500 detach, otherwise the program dies when it hits one. */
f6ac5f3d 501 virtual void detach (inferior *, int)
09da0d0a 502 TARGET_DEFAULT_IGNORE ();
e87f0fe8 503
f6ac5f3d 504 virtual void disconnect (const char *, int)
86a0854a 505 TARGET_DEFAULT_NORETURN (tcomplain ());
f6ac5f3d
PA
506 virtual void resume (ptid_t,
507 int TARGET_DEBUG_PRINTER (target_debug_print_step),
508 enum gdb_signal)
6b84065d 509 TARGET_DEFAULT_NORETURN (noprocess ());
1192f124
SM
510
511 /* Ensure that all resumed threads are committed to the target.
512
513 See the description of
514 process_stratum_target::commit_resumed_state for more
515 details. */
516 virtual void commit_resumed ()
85ad3aaf 517 TARGET_DEFAULT_IGNORE ();
1192f124 518
ec506636
PA
519 /* See target_wait's description. Note that implementations of
520 this method must not assume that inferior_ptid on entry is
521 pointing at the thread or inferior that ends up reporting an
522 event. The reported event could be for some other thread in
523 the current inferior or even for a different process of the
524 current target. inferior_ptid may also be null_ptid on
525 entry. */
f6ac5f3d 526 virtual ptid_t wait (ptid_t, struct target_waitstatus *,
b60cea74 527 target_wait_flags options)
0b333c5e 528 TARGET_DEFAULT_FUNC (default_target_wait);
f6ac5f3d 529 virtual void fetch_registers (struct regcache *, int)
ad5989bd 530 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 531 virtual void store_registers (struct regcache *, int)
6b84065d 532 TARGET_DEFAULT_NORETURN (noprocess ());
f6ac5f3d 533 virtual void prepare_to_store (struct regcache *)
6c628163 534 TARGET_DEFAULT_NORETURN (noprocess ());
c5aa993b 535
f6ac5f3d 536 virtual void files_info ()
f86e59b2 537 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 538 virtual int insert_breakpoint (struct gdbarch *,
6b84065d 539 struct bp_target_info *)
f6ac5f3d
PA
540 TARGET_DEFAULT_NORETURN (noprocess ());
541 virtual int remove_breakpoint (struct gdbarch *,
73971819
PA
542 struct bp_target_info *,
543 enum remove_bp_reason)
f6ac5f3d 544 TARGET_DEFAULT_NORETURN (noprocess ());
1cf4d951
PA
545
546 /* Returns true if the target stopped because it executed a
547 software breakpoint. This is necessary for correct background
548 execution / non-stop mode operation, and for correct PC
549 adjustment on targets where the PC needs to be adjusted when a
550 software breakpoint triggers. In these modes, by the time GDB
551 processes a breakpoint event, the breakpoint may already be
552 done from the target, so GDB needs to be able to tell whether
553 it should ignore the event and whether it should adjust the PC.
554 See adjust_pc_after_break. */
57810aa7
PA
555 virtual bool stopped_by_sw_breakpoint ()
556 TARGET_DEFAULT_RETURN (false);
1cf4d951 557 /* Returns true if the above method is supported. */
57810aa7
PA
558 virtual bool supports_stopped_by_sw_breakpoint ()
559 TARGET_DEFAULT_RETURN (false);
1cf4d951
PA
560
561 /* Returns true if the target stopped for a hardware breakpoint.
562 Likewise, if the target supports hardware breakpoints, this
563 method is necessary for correct background execution / non-stop
564 mode operation. Even though hardware breakpoints do not
565 require PC adjustment, GDB needs to be able to tell whether the
566 hardware breakpoint event is a delayed event for a breakpoint
567 that is already gone and should thus be ignored. */
57810aa7
PA
568 virtual bool stopped_by_hw_breakpoint ()
569 TARGET_DEFAULT_RETURN (false);
1cf4d951 570 /* Returns true if the above method is supported. */
57810aa7
PA
571 virtual bool supports_stopped_by_hw_breakpoint ()
572 TARGET_DEFAULT_RETURN (false);
1cf4d951 573
f6ac5f3d 574 virtual int can_use_hw_breakpoint (enum bptype, int, int)
52b51d06 575 TARGET_DEFAULT_RETURN (0);
f6ac5f3d 576 virtual int ranged_break_num_registers ()
a134316b 577 TARGET_DEFAULT_RETURN (-1);
f6ac5f3d
PA
578 virtual int insert_hw_breakpoint (struct gdbarch *,
579 struct bp_target_info *)
61b371f9 580 TARGET_DEFAULT_RETURN (-1);
f6ac5f3d
PA
581 virtual int remove_hw_breakpoint (struct gdbarch *,
582 struct bp_target_info *)
418dabac 583 TARGET_DEFAULT_RETURN (-1);
0cf6dd15
TJB
584
585 /* Documentation of what the two routines below are expected to do is
586 provided with the corresponding target_* macros. */
f6ac5f3d 587 virtual int remove_watchpoint (CORE_ADDR, int,
f486487f 588 enum target_hw_bp_type, struct expression *)
61dd109f 589 TARGET_DEFAULT_RETURN (-1);
f6ac5f3d 590 virtual int insert_watchpoint (CORE_ADDR, int,
f486487f 591 enum target_hw_bp_type, struct expression *)
016facd4 592 TARGET_DEFAULT_RETURN (-1);
0cf6dd15 593
f6ac5f3d
PA
594 virtual int insert_mask_watchpoint (CORE_ADDR, CORE_ADDR,
595 enum target_hw_bp_type)
cd4ae029 596 TARGET_DEFAULT_RETURN (1);
f6ac5f3d
PA
597 virtual int remove_mask_watchpoint (CORE_ADDR, CORE_ADDR,
598 enum target_hw_bp_type)
8b1c364c 599 TARGET_DEFAULT_RETURN (1);
57810aa7
PA
600 virtual bool stopped_by_watchpoint ()
601 TARGET_DEFAULT_RETURN (false);
c2a6c5da 602 virtual bool have_steppable_watchpoint ()
57810aa7 603 TARGET_DEFAULT_RETURN (false);
57810aa7
PA
604 virtual bool stopped_data_address (CORE_ADDR *)
605 TARGET_DEFAULT_RETURN (false);
606 virtual bool watchpoint_addr_within_range (CORE_ADDR, CORE_ADDR, int)
65f160a9 607 TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range);
e09342b5
TJB
608
609 /* Documentation of this routine is provided with the corresponding
610 target_* macro. */
f6ac5f3d 611 virtual int region_ok_for_hw_watchpoint (CORE_ADDR, int)
d03655e4 612 TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint);
e09342b5 613
57810aa7
PA
614 virtual bool can_accel_watchpoint_condition (CORE_ADDR, int, int,
615 struct expression *)
616 TARGET_DEFAULT_RETURN (false);
f6ac5f3d 617 virtual int masked_watch_num_registers (CORE_ADDR, CORE_ADDR)
6c7e5e5c 618 TARGET_DEFAULT_RETURN (-1);
750ce8d1
YQ
619
620 /* Return 1 for sure target can do single step. Return -1 for
621 unknown. Return 0 for target can't do. */
f6ac5f3d 622 virtual int can_do_single_step ()
750ce8d1
YQ
623 TARGET_DEFAULT_RETURN (-1);
624
f6ac5f3d 625 virtual bool supports_terminal_ours ()
57810aa7 626 TARGET_DEFAULT_RETURN (false);
f6ac5f3d 627 virtual void terminal_init ()
0343661d 628 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 629 virtual void terminal_inferior ()
ddeaacc9 630 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 631 virtual void terminal_save_inferior ()
e671cd59 632 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 633 virtual void terminal_ours_for_output ()
74fcbef9 634 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 635 virtual void terminal_ours ()
e4a733f1 636 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 637 virtual void terminal_info (const char *, int)
e19e919f 638 TARGET_DEFAULT_FUNC (default_terminal_info);
f6ac5f3d 639 virtual void kill ()
423a4807 640 TARGET_DEFAULT_NORETURN (noprocess ());
f6ac5f3d 641 virtual void load (const char *, int)
7634da87 642 TARGET_DEFAULT_NORETURN (tcomplain ());
b3ccfe11
TT
643 /* Start an inferior process and set inferior_ptid to its pid.
644 EXEC_FILE is the file to run.
645 ALLARGS is a string containing the arguments to the program.
646 ENV is the environment vector to pass. Errors reported with error().
647 On VxWorks and various standalone systems, we ignore exec_file. */
f6ac5f3d
PA
648 virtual bool can_create_inferior ();
649 virtual void create_inferior (const char *, const std::string &,
650 char **, int);
f6ac5f3d 651 virtual int insert_fork_catchpoint (int)
5958ebeb 652 TARGET_DEFAULT_RETURN (1);
f6ac5f3d 653 virtual int remove_fork_catchpoint (int)
e1a21fb7 654 TARGET_DEFAULT_RETURN (1);
f6ac5f3d 655 virtual int insert_vfork_catchpoint (int)
7e18a8dc 656 TARGET_DEFAULT_RETURN (1);
f6ac5f3d 657 virtual int remove_vfork_catchpoint (int)
95c3375e 658 TARGET_DEFAULT_RETURN (1);
82d1f134 659 virtual void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool)
098dba18 660 TARGET_DEFAULT_FUNC (default_follow_fork);
0d36baa9
PA
661
662 /* Add CHILD_PTID to the thread list, after handling a
663 TARGET_WAITKIND_THREAD_CLONE event for the clone parent. The
664 parent is inferior_ptid. */
665 virtual void follow_clone (ptid_t child_ptid)
666 TARGET_DEFAULT_FUNC (default_follow_clone);
667
f6ac5f3d 668 virtual int insert_exec_catchpoint (int)
62f64d7a 669 TARGET_DEFAULT_RETURN (1);
f6ac5f3d 670 virtual int remove_exec_catchpoint (int)
cda0f38c 671 TARGET_DEFAULT_RETURN (1);
294c36eb 672 virtual void follow_exec (inferior *, ptid_t, const char *)
94585166 673 TARGET_DEFAULT_IGNORE ();
f6ac5f3d
PA
674 virtual int set_syscall_catchpoint (int, bool, int,
675 gdb::array_view<const int>)
6a9fa051 676 TARGET_DEFAULT_RETURN (1);
f6ac5f3d 677 virtual void mourn_inferior ()
8d657035 678 TARGET_DEFAULT_FUNC (default_mourn_inferior);
f6ac5f3d
PA
679
680 /* Note that can_run is special and can be invoked on an unpushed
681 target. Targets defining this method must also define
b3ccfe11 682 to_can_async_p and to_supports_non_stop. */
57810aa7 683 virtual bool can_run ();
2455069d
UW
684
685 /* Documentation of this routine is provided with the corresponding
686 target_* macro. */
adc6a863 687 virtual void pass_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
035cad7f 688 TARGET_DEFAULT_IGNORE ();
2455069d 689
9b224c5e
PA
690 /* Documentation of this routine is provided with the
691 corresponding target_* function. */
adc6a863 692 virtual void program_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
7d4f8efa 693 TARGET_DEFAULT_IGNORE ();
9b224c5e 694
57810aa7
PA
695 virtual bool thread_alive (ptid_t ptid)
696 TARGET_DEFAULT_RETURN (false);
f6ac5f3d 697 virtual void update_thread_list ()
09b0dc2b 698 TARGET_DEFAULT_IGNORE ();
a068643d 699 virtual std::string pid_to_str (ptid_t)
770234d3 700 TARGET_DEFAULT_FUNC (default_pid_to_str);
f6ac5f3d 701 virtual const char *extra_thread_info (thread_info *)
9b144037 702 TARGET_DEFAULT_RETURN (NULL);
f6ac5f3d 703 virtual const char *thread_name (thread_info *)
9b144037 704 TARGET_DEFAULT_RETURN (NULL);
f6ac5f3d
PA
705 virtual thread_info *thread_handle_to_thread_info (const gdb_byte *,
706 int,
707 inferior *inf)
e04ee09e 708 TARGET_DEFAULT_RETURN (NULL);
3d6c6204 709 /* See target_thread_info_to_thread_handle. */
1f08d324
TV
710 virtual gdb::array_view<const_gdb_byte> thread_info_to_thread_handle (struct thread_info *)
711 TARGET_DEFAULT_RETURN (gdb::array_view<const gdb_byte> ());
f6ac5f3d 712 virtual void stop (ptid_t)
46ee7e8d 713 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 714 virtual void interrupt ()
bfedc46a 715 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 716 virtual void pass_ctrlc ()
93692b58 717 TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
f6ac5f3d 718 virtual void rcmd (const char *command, struct ui_file *output)
a53f3625 719 TARGET_DEFAULT_FUNC (default_rcmd);
0e90c441 720 virtual const char *pid_to_exec_file (int pid)
9b144037 721 TARGET_DEFAULT_RETURN (NULL);
f6ac5f3d 722 virtual void log_command (const char *)
d9cb0195 723 TARGET_DEFAULT_IGNORE ();
25b5a04e 724 virtual const std::vector<target_section> *get_section_table ()
336aa7b7 725 TARGET_DEFAULT_RETURN (default_get_section_table ());
f6ac5f3d
PA
726
727 /* Provide default values for all "must have" methods. */
57810aa7
PA
728 virtual bool has_all_memory () { return false; }
729 virtual bool has_memory () { return false; }
730 virtual bool has_stack () { return false; }
731 virtual bool has_registers () { return false; }
5018ce90 732 virtual bool has_execution (inferior *inf) { return false; }
f6ac5f3d
PA
733
734 /* Control thread execution. */
735 virtual thread_control_capabilities get_thread_control_capabilities ()
736 TARGET_DEFAULT_RETURN (tc_none);
737 virtual bool attach_no_wait ()
738 TARGET_DEFAULT_RETURN (0);
b3ccfe11 739 /* This method must be implemented in some situations. See the
f6ac5f3d 740 comment on 'can_run'. */
57810aa7
PA
741 virtual bool can_async_p ()
742 TARGET_DEFAULT_RETURN (false);
743 virtual bool is_async_p ()
744 TARGET_DEFAULT_RETURN (false);
4a570176 745 virtual void async (bool)
6b84065d 746 TARGET_DEFAULT_NORETURN (tcomplain ());
5b6d1e4f
PA
747 virtual int async_wait_fd ()
748 TARGET_DEFAULT_NORETURN (noprocess ());
b4b1a226
SM
749 /* Return true if the target has pending events to report to the
750 core. If true, then GDB avoids resuming the target until all
751 pending events are consumed, so that multiple resumptions can
752 be coalesced as an optimization. Most targets can't tell
753 whether they have pending events without calling target_wait,
754 so we default to returning false. The only downside is that a
755 potential optimization is missed. */
756 virtual bool has_pending_events ()
757 TARGET_DEFAULT_RETURN (false);
2db17c87 758 virtual void thread_events (bool)
65706a29 759 TARGET_DEFAULT_IGNORE ();
65c459ab
PA
760 /* Returns true if the target supports setting thread options
761 OPTIONS, false otherwise. */
762 virtual bool supports_set_thread_options (gdb_thread_options options)
763 TARGET_DEFAULT_RETURN (false);
b3ccfe11 764 /* This method must be implemented in some situations. See the
f6ac5f3d 765 comment on 'can_run'. */
57810aa7
PA
766 virtual bool supports_non_stop ()
767 TARGET_DEFAULT_RETURN (false);
fbea99ea
PA
768 /* Return true if the target operates in non-stop mode even with
769 "set non-stop off". */
57810aa7
PA
770 virtual bool always_non_stop_p ()
771 TARGET_DEFAULT_RETURN (false);
6b04bdb7 772 /* find_memory_regions support method for gcore */
f6ac5f3d 773 virtual int find_memory_regions (find_memory_region_ftype func, void *data)
0b5a2719 774 TARGET_DEFAULT_FUNC (dummy_find_memory_regions);
6b04bdb7 775 /* make_corefile_notes support method for gcore */
24f5300a 776 virtual gdb::unique_xmalloc_ptr<char> make_corefile_notes (bfd *, int *)
16f796b1 777 TARGET_DEFAULT_FUNC (dummy_make_corefile_notes);
6b04bdb7 778 /* get_bookmark support method for bookmarks */
f6ac5f3d 779 virtual gdb_byte *get_bookmark (const char *, int)
3dbafbbb 780 TARGET_DEFAULT_NORETURN (tcomplain ());
6b04bdb7 781 /* goto_bookmark support method for bookmarks */
f6ac5f3d 782 virtual void goto_bookmark (const gdb_byte *, int)
9bb9d61d 783 TARGET_DEFAULT_NORETURN (tcomplain ());
3f47be5c
EZ
784 /* Return the thread-local address at OFFSET in the
785 thread-local storage for the thread PTID and the shared library
cd250a18 786 or executable file given by LOAD_MODULE_ADDR. If that block of
3f47be5c 787 thread-local storage hasn't been allocated yet, this function
cd250a18 788 may throw an error. LOAD_MODULE_ADDR may be zero for statically
5876f503 789 linked multithreaded inferiors. */
f6ac5f3d
PA
790 virtual CORE_ADDR get_thread_local_address (ptid_t ptid,
791 CORE_ADDR load_module_addr,
792 CORE_ADDR offset)
f0f9ff95 793 TARGET_DEFAULT_NORETURN (generic_tls_error ());
3f47be5c 794
e4da2c61
SM
795 /* Request that OPS transfer up to LEN addressable units of the target's
796 OBJECT. When reading from a memory object, the size of an addressable
797 unit is architecture dependent and can be found using
798 gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is
799 1 byte long. The OFFSET, for a seekable object, specifies the
13547ab6
DJ
800 starting point. The ANNEX can be used to provide additional
801 data-specific information to the target.
802
d9df7f16
PA
803 When accessing memory, inferior_ptid indicates which process's
804 memory is to be accessed. This is usually the same process as
805 the current inferior, however it may also be a process that is
806 a fork child of the current inferior, at a moment that the
807 child does not exist in GDB's inferior lists. This happens
808 when we remove software breakpoints from the address space of a
809 fork child process that we're not going to stay attached to.
810 Because the fork child is a clone of the fork parent, we can
811 use the fork parent inferior's stack for target method
812 delegation.
813
9b409511 814 Return the transferred status, error or OK (an
e4da2c61 815 'enum target_xfer_status' value). Save the number of addressable units
9b409511 816 actually transferred in *XFERED_LEN if transfer is successful
e4da2c61 817 (TARGET_XFER_OK) or the number unavailable units if the requested
bc113b4e 818 data is unavailable (TARGET_XFER_UNAVAILABLE). *XFERED_LEN
9b409511
YQ
819 smaller than LEN does not indicate the end of the object, only
820 the end of the transfer; higher level code should continue
821 transferring if desired. This is handled in target.c.
13547ab6
DJ
822
823 The interface does not support a "retry" mechanism. Instead it
8f6606b6 824 assumes that at least one addressable unit will be transferred on each
13547ab6
DJ
825 successful call.
826
827 NOTE: cagney/2003-10-17: The current interface can lead to
828 fragmented transfers. Lower target levels should not implement
829 hacks, such as enlarging the transfer, in an attempt to
830 compensate for this. Instead, the target stack should be
831 extended so that it implements supply/collect methods and a
832 look-aside object cache. With that available, the lowest
833 target can safely and freely "push" data up the stack.
834
835 See target_read and target_write for more information. One,
836 and only one, of readbuf or writebuf must be non-NULL. */
837
f6ac5f3d
PA
838 virtual enum target_xfer_status xfer_partial (enum target_object object,
839 const char *annex,
840 gdb_byte *readbuf,
841 const gdb_byte *writebuf,
842 ULONGEST offset, ULONGEST len,
843 ULONGEST *xfered_len)
6b84065d 844 TARGET_DEFAULT_RETURN (TARGET_XFER_E_IO);
1e3ff5ad 845
09c98b44
DB
846 /* Return the limit on the size of any single memory transfer
847 for the target. */
848
f6ac5f3d 849 virtual ULONGEST get_memory_xfer_limit ()
09c98b44
DB
850 TARGET_DEFAULT_RETURN (ULONGEST_MAX);
851
fd79ecee
DJ
852 /* Returns the memory map for the target. A return value of NULL
853 means that no memory map is available. If a memory address
854 does not fall within any returned regions, it's assumed to be
855 RAM. The returned memory regions should not overlap.
856
857 The order of regions does not matter; target_memory_map will
c378eb4e 858 sort regions by starting address. For that reason, this
fd79ecee
DJ
859 function should not be called directly except via
860 target_memory_map.
861
862 This method should not cache data; if the memory map could
863 change unexpectedly, it should be invalidated, and higher
864 layers will re-fetch it. */
f6ac5f3d 865 virtual std::vector<mem_region> memory_map ()
a664f67e 866 TARGET_DEFAULT_RETURN (std::vector<mem_region> ());
fd79ecee 867
a76d924d
DJ
868 /* Erases the region of flash memory starting at ADDRESS, of
869 length LENGTH.
870
871 Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
872 on flash block boundaries, as reported by 'to_memory_map'. */
f6ac5f3d 873 virtual void flash_erase (ULONGEST address, LONGEST length)
e8a6c6ac 874 TARGET_DEFAULT_NORETURN (tcomplain ());
a76d924d
DJ
875
876 /* Finishes a flash memory write sequence. After this operation
877 all flash memory should be available for writing and the result
878 of reading from areas written by 'to_flash_write' should be
879 equal to what was written. */
f6ac5f3d 880 virtual void flash_done ()
f6fb2925 881 TARGET_DEFAULT_NORETURN (tcomplain ());
a76d924d 882
fbf3c4b9
TV
883 /* Describe the architecture-specific features of the current
884 inferior.
885
886 Returns the description found, or nullptr if no description was
887 available.
888
889 If some target features differ between threads, the description
890 returned by read_description (and the resulting gdbarch) won't
891 accurately describe all threads. In this case, the
892 thread_architecture method can be used to obtain gdbarches that
893 accurately describe each thread. */
f6ac5f3d 894 virtual const struct target_desc *read_description ()
9b144037 895 TARGET_DEFAULT_RETURN (NULL);
424163ea 896
0ef643c8
JB
897 /* Build the PTID of the thread on which a given task is running,
898 based on LWP and THREAD. These values are extracted from the
899 task Private_Data section of the Ada Task Control Block, and
900 their interpretation depends on the target. */
c80e29db 901 virtual ptid_t get_ada_task_ptid (long lwp, ULONGEST thread)
4229b31d 902 TARGET_DEFAULT_FUNC (default_get_ada_task_ptid);
0ef643c8 903
c47ffbe3
VP
904 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
905 Return 0 if *READPTR is already at the end of the buffer.
906 Return -1 if there is insufficient buffer for a whole entry.
907 Return 1 if an entry was read into *TYPEP and *VALP. */
3fe639b8
SM
908 virtual int auxv_parse (const gdb_byte **readptr,
909 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
8de71aab 910 TARGET_DEFAULT_FUNC (default_auxv_parse);
c47ffbe3 911
08388c79
DE
912 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
913 sequence of bytes in PATTERN with length PATTERN_LEN.
914
915 The result is 1 if found, 0 if not found, and -1 if there was an error
916 requiring halting of the search (e.g. memory read error).
917 If the pattern is found the address is recorded in FOUND_ADDRP. */
f6ac5f3d
PA
918 virtual int search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
919 const gdb_byte *pattern, ULONGEST pattern_len,
920 CORE_ADDR *found_addrp)
58a5184e 921 TARGET_DEFAULT_FUNC (default_search_memory);
08388c79 922
b2175913 923 /* Can target execute in reverse? */
57810aa7
PA
924 virtual bool can_execute_reverse ()
925 TARGET_DEFAULT_RETURN (false);
b2175913 926
32231432
PA
927 /* The direction the target is currently executing. Must be
928 implemented on targets that support reverse execution and async
929 mode. The default simply returns forward execution. */
f6ac5f3d 930 virtual enum exec_direction_kind execution_direction ()
fe31bf5b 931 TARGET_DEFAULT_FUNC (default_execution_direction);
32231432 932
8a305172
PA
933 /* Does this target support debugging multiple processes
934 simultaneously? */
57810aa7
PA
935 virtual bool supports_multi_process ()
936 TARGET_DEFAULT_RETURN (false);
8a305172 937
d248b706
KY
938 /* Does this target support enabling and disabling tracepoints while a trace
939 experiment is running? */
57810aa7
PA
940 virtual bool supports_enable_disable_tracepoint ()
941 TARGET_DEFAULT_RETURN (false);
d248b706 942
03583c20 943 /* Does this target support disabling address space randomization? */
57810aa7 944 virtual bool supports_disable_randomization ()
f6ac5f3d 945 TARGET_DEFAULT_FUNC (find_default_supports_disable_randomization);
03583c20 946
3065dfb6 947 /* Does this target support the tracenz bytecode for string collection? */
57810aa7
PA
948 virtual bool supports_string_tracing ()
949 TARGET_DEFAULT_RETURN (false);
3065dfb6 950
b775012e
LM
951 /* Does this target support evaluation of breakpoint conditions on its
952 end? */
57810aa7
PA
953 virtual bool supports_evaluation_of_breakpoint_conditions ()
954 TARGET_DEFAULT_RETURN (false);
b775012e 955
b31488a3
KR
956 /* Does this target support native dumpcore API? */
957 virtual bool supports_dumpcore ()
958 TARGET_DEFAULT_RETURN (false);
959
960 /* Generate the core file with native target API. */
961 virtual void dumpcore (const char *filename)
962 TARGET_DEFAULT_IGNORE ();
963
d3ce09f5
SS
964 /* Does this target support evaluation of breakpoint commands on its
965 end? */
57810aa7
PA
966 virtual bool can_run_breakpoint_commands ()
967 TARGET_DEFAULT_RETURN (false);
d3ce09f5 968
3a8f7b07
JK
969 /* Determine current architecture of thread PTID.
970
971 The target is supposed to determine the architecture of the code where
8133c7dc
LM
972 the target is currently stopped at. The architecture information is
973 used to perform decr_pc_after_break adjustment, and also to determine
974 the frame architecture of the innermost frame. ptrace operations need to
99d9c3b9 975 operate according to the current inferior's gdbarch. */
f6ac5f3d 976 virtual struct gdbarch *thread_architecture (ptid_t)
3b3dac9b 977 TARGET_DEFAULT_RETURN (NULL);
c0694254 978
7313baad
UW
979 /* Target file operations. */
980
d777bf0d
SM
981 /* Return true if the filesystem seen by the current inferior
982 is the local filesystem, false otherwise. */
57810aa7
PA
983 virtual bool filesystem_is_local ()
984 TARGET_DEFAULT_RETURN (true);
4bd7dc42 985
07c138c8
GB
986 /* Open FILENAME on the target, in the filesystem as seen by INF,
987 using FLAGS and MODE. If INF is NULL, use the filesystem seen
988 by the debugger (GDB or, for remote targets, the remote stub).
4313b8c0
GB
989 If WARN_IF_SLOW is nonzero, print a warning message if the file
990 is being accessed over a link that may be slow. Return a
991 target file descriptor, or -1 if an error occurs (and set
992 *TARGET_ERRNO). */
f6ac5f3d
PA
993 virtual int fileio_open (struct inferior *inf, const char *filename,
994 int flags, int mode, int warn_if_slow,
b872057a 995 fileio_error *target_errno);
7313baad
UW
996
997 /* Write up to LEN bytes from WRITE_BUF to FD on the target.
998 Return the number of bytes written, or -1 if an error occurs
999 (and set *TARGET_ERRNO). */
f6ac5f3d 1000 virtual int fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
b872057a 1001 ULONGEST offset, fileio_error *target_errno);
7313baad
UW
1002
1003 /* Read up to LEN bytes FD on the target into READ_BUF.
1004 Return the number of bytes read, or -1 if an error occurs
1005 (and set *TARGET_ERRNO). */
f6ac5f3d 1006 virtual int fileio_pread (int fd, gdb_byte *read_buf, int len,
b872057a 1007 ULONGEST offset, fileio_error *target_errno);
7313baad 1008
9b15c1f0
GB
1009 /* Get information about the file opened as FD and put it in
1010 SB. Return 0 on success, or -1 if an error occurs (and set
1011 *TARGET_ERRNO). */
b872057a 1012 virtual int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno);
9b15c1f0 1013
08a115cc
AB
1014 /* Get information about the file FILENAME and put it in SB. Look for
1015 FILENAME in the filesystem as seen by INF. If INF is NULL, use the
1016 filesystem seen by the debugger (GDB or, for remote targets, the
1017 remote stub). Return 0 on success, or -1 if an error occurs (and
1018 set *TARGET_ERRNO). */
5d560402
AB
1019 virtual int fileio_lstat (struct inferior *inf, const char *filename,
1020 struct stat *sb, fileio_error *target_errno);
08a115cc 1021
7313baad
UW
1022 /* Close FD on the target. Return 0, or -1 if an error occurs
1023 (and set *TARGET_ERRNO). */
b872057a 1024 virtual int fileio_close (int fd, fileio_error *target_errno);
7313baad 1025
07c138c8
GB
1026 /* Unlink FILENAME on the target, in the filesystem as seen by
1027 INF. If INF is NULL, use the filesystem seen by the debugger
1028 (GDB or, for remote targets, the remote stub). Return 0, or
1029 -1 if an error occurs (and set *TARGET_ERRNO). */
f6ac5f3d
PA
1030 virtual int fileio_unlink (struct inferior *inf,
1031 const char *filename,
b872057a 1032 fileio_error *target_errno);
07c138c8
GB
1033
1034 /* Read value of symbolic link FILENAME on the target, in the
1035 filesystem as seen by INF. If INF is NULL, use the filesystem
1036 seen by the debugger (GDB or, for remote targets, the remote
e0d3522b
TT
1037 stub). Return a string, or an empty optional if an error
1038 occurs (and set *TARGET_ERRNO). */
6b09f134 1039 virtual std::optional<std::string> fileio_readlink (struct inferior *inf,
f6ac5f3d 1040 const char *filename,
b872057a 1041 fileio_error *target_errno);
b9e7b9c3 1042
f6ac5f3d
PA
1043 /* Implement the "info proc" command. Returns true if the target
1044 actually implemented the command, false otherwise. */
1045 virtual bool info_proc (const char *, enum info_proc_what);
145b16a9 1046
35b1e5cc
SS
1047 /* Tracepoint-related operations. */
1048
1049 /* Prepare the target for a tracing run. */
f6ac5f3d 1050 virtual void trace_init ()
5536135b 1051 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 1052
e8ba3115 1053 /* Send full details of a tracepoint location to the target. */
f6ac5f3d 1054 virtual void download_tracepoint (struct bp_location *location)
9a980a22 1055 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 1056
1e4d1764
YQ
1057 /* Is the target able to download tracepoint locations in current
1058 state? */
57810aa7
PA
1059 virtual bool can_download_tracepoint ()
1060 TARGET_DEFAULT_RETURN (false);
1e4d1764 1061
35b1e5cc 1062 /* Send full details of a trace state variable to the target. */
f6ac5f3d 1063 virtual void download_trace_state_variable (const trace_state_variable &tsv)
94eb98b9 1064 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc 1065
d248b706 1066 /* Enable a tracepoint on the target. */
f6ac5f3d 1067 virtual void enable_tracepoint (struct bp_location *location)
151f70f1 1068 TARGET_DEFAULT_NORETURN (tcomplain ());
d248b706
KY
1069
1070 /* Disable a tracepoint on the target. */
f6ac5f3d 1071 virtual void disable_tracepoint (struct bp_location *location)
05c41993 1072 TARGET_DEFAULT_NORETURN (tcomplain ());
d248b706 1073
35b1e5cc
SS
1074 /* Inform the target info of memory regions that are readonly
1075 (such as text sections), and so it should return data from
1076 those rather than look in the trace buffer. */
f6ac5f3d 1077 virtual void trace_set_readonly_regions ()
86dd181d 1078 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
1079
1080 /* Start a trace run. */
f6ac5f3d 1081 virtual void trace_start ()
25da2e80 1082 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
1083
1084 /* Get the current status of a tracing run. */
f6ac5f3d 1085 virtual int get_trace_status (struct trace_status *ts)
4072d4ff 1086 TARGET_DEFAULT_RETURN (-1);
35b1e5cc 1087
01bccc56 1088 virtual void get_tracepoint_status (tracepoint *tp,
f6ac5f3d 1089 struct uploaded_tp *utp)
6fea14cd 1090 TARGET_DEFAULT_NORETURN (tcomplain ());
f196051f 1091
35b1e5cc 1092 /* Stop a trace run. */
f6ac5f3d 1093 virtual void trace_stop ()
e51c07ea 1094 TARGET_DEFAULT_NORETURN (tcomplain ());
35b1e5cc
SS
1095
1096 /* Ask the target to find a trace frame of the given type TYPE,
1097 using NUM, ADDR1, and ADDR2 as search parameters. Returns the
1098 number of the trace frame, and also the tracepoint number at
c378eb4e 1099 TPP. If no trace frame matches, return -1. May throw if the
f197e0f1 1100 operation fails. */
f6ac5f3d
PA
1101 virtual int trace_find (enum trace_find_type type, int num,
1102 CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
afc94e66 1103 TARGET_DEFAULT_RETURN (-1);
35b1e5cc
SS
1104
1105 /* Get the value of the trace state variable number TSV, returning
1106 1 if the value is known and writing the value itself into the
1107 location pointed to by VAL, else returning 0. */
57810aa7
PA
1108 virtual bool get_trace_state_variable_value (int tsv, LONGEST *val)
1109 TARGET_DEFAULT_RETURN (false);
35b1e5cc 1110
f6ac5f3d 1111 virtual int save_trace_data (const char *filename)
a2e6c147 1112 TARGET_DEFAULT_NORETURN (tcomplain ());
00bf0b85 1113
f6ac5f3d 1114 virtual int upload_tracepoints (struct uploaded_tp **utpp)
1e949b00 1115 TARGET_DEFAULT_RETURN (0);
00bf0b85 1116
f6ac5f3d 1117 virtual int upload_trace_state_variables (struct uploaded_tsv **utsvp)
08120467 1118 TARGET_DEFAULT_RETURN (0);
00bf0b85 1119
f6ac5f3d
PA
1120 virtual LONGEST get_raw_trace_data (gdb_byte *buf,
1121 ULONGEST offset, LONGEST len)
ace92e7d 1122 TARGET_DEFAULT_NORETURN (tcomplain ());
00bf0b85 1123
405f8e94
SS
1124 /* Get the minimum length of instruction on which a fast tracepoint
1125 may be set on the target. If this operation is unsupported,
1126 return -1. If for some reason the minimum length cannot be
1127 determined, return 0. */
f6ac5f3d 1128 virtual int get_min_fast_tracepoint_insn_len ()
9249843f 1129 TARGET_DEFAULT_RETURN (-1);
405f8e94 1130
35b1e5cc
SS
1131 /* Set the target's tracing behavior in response to unexpected
1132 disconnection - set VAL to 1 to keep tracing, 0 to stop. */
f6ac5f3d 1133 virtual void set_disconnected_tracing (int val)
0bcfeddf 1134 TARGET_DEFAULT_IGNORE ();
f6ac5f3d 1135 virtual void set_circular_trace_buffer (int val)
8d526939 1136 TARGET_DEFAULT_IGNORE ();
f6f899bf 1137 /* Set the size of trace buffer in the target. */
f6ac5f3d 1138 virtual void set_trace_buffer_size (LONGEST val)
91df8d1d 1139 TARGET_DEFAULT_IGNORE ();
35b1e5cc 1140
d777bf0d
SM
1141 /* Add/change textual notes about the trace run, returning true if
1142 successful, false otherwise. */
57810aa7
PA
1143 virtual bool set_trace_notes (const char *user, const char *notes,
1144 const char *stopnotes)
1145 TARGET_DEFAULT_RETURN (false);
f196051f 1146
dc146f7c
VP
1147 /* Return the processor core that thread PTID was last seen on.
1148 This information is updated only when:
1149 - update_thread_list is called
1150 - thread stops
3e43a32a
MS
1151 If the core cannot be determined -- either for the specified
1152 thread, or right now, or in this debug session, or for this
1153 target -- return -1. */
f6ac5f3d 1154 virtual int core_of_thread (ptid_t ptid)
9e538d0d 1155 TARGET_DEFAULT_RETURN (-1);
dc146f7c 1156
4a5e7a5b
PA
1157 /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
1158 matches the contents of [DATA,DATA+SIZE). Returns 1 if there's
1159 a match, 0 if there's a mismatch, and -1 if an error is
1160 encountered while reading memory. */
f6ac5f3d
PA
1161 virtual int verify_memory (const gdb_byte *data,
1162 CORE_ADDR memaddr, ULONGEST size)
936d2992 1163 TARGET_DEFAULT_FUNC (default_verify_memory);
4a5e7a5b 1164
904d3768
TT
1165 /* Set *ADDR to the address of the start of the Thread Information
1166 Block (TIB) for thread PTID. Return true on success and false
1167 otherwise.
1168
1169 ADDR may be nullptr, in which case the checks will be done but
1170 the result will be discarded. */
57810aa7 1171 virtual bool get_tib_address (ptid_t ptid, CORE_ADDR *addr)
22bcceee 1172 TARGET_DEFAULT_NORETURN (tcomplain ());
711e434b 1173
d914c394 1174 /* Send the new settings of write permission variables. */
f6ac5f3d 1175 virtual void set_permissions ()
dcd6917f 1176 TARGET_DEFAULT_IGNORE ();
d914c394 1177
0fb4aa4b 1178 /* Look for a static tracepoint marker at ADDR, and fill in MARKER
5d9310c4 1179 with its details. Return true on success, false on failure. */
f6ac5f3d
PA
1180 virtual bool static_tracepoint_marker_at (CORE_ADDR,
1181 static_tracepoint_marker *marker)
5d9310c4 1182 TARGET_DEFAULT_RETURN (false);
0fb4aa4b
PA
1183
1184 /* Return a vector of all tracepoints markers string id ID, or all
1185 markers if ID is NULL. */
ad6a4e2d
PA
1186 virtual std::vector<static_tracepoint_marker>
1187 static_tracepoint_markers_by_strid (const char *id)
d6522a22 1188 TARGET_DEFAULT_NORETURN (tcomplain ());
0fb4aa4b 1189
b3b9301e 1190 /* Return a traceframe info object describing the current
f73023dd
YQ
1191 traceframe's contents. This method should not cache data;
1192 higher layers take care of caching, invalidating, and
1193 re-fetching when necessary. */
f6ac5f3d 1194 virtual traceframe_info_up traceframe_info ()
2098b393 1195 TARGET_DEFAULT_NORETURN (tcomplain ());
b3b9301e 1196
57810aa7
PA
1197 /* Ask the target to use or not to use agent according to USE.
1198 Return true if successful, false otherwise. */
1199 virtual bool use_agent (bool use)
d9db5b21 1200 TARGET_DEFAULT_NORETURN (tcomplain ());
d1feda86
YQ
1201
1202 /* Is the target able to use agent in current state? */
57810aa7
PA
1203 virtual bool can_use_agent ()
1204 TARGET_DEFAULT_RETURN (false);
d1feda86 1205
696c0d5e 1206 /* Enable branch tracing for TP using CONF configuration.
f4abbc16
MM
1207 Return a branch trace target information struct for reading and for
1208 disabling branch trace. */
696c0d5e 1209 virtual struct btrace_target_info *enable_btrace (thread_info *tp,
f6ac5f3d 1210 const struct btrace_config *conf)
6dc7fcf4 1211 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625
MM
1212
1213 /* Disable branch tracing and deallocate TINFO. */
f6ac5f3d 1214 virtual void disable_btrace (struct btrace_target_info *tinfo)
8dc292d3 1215 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625
MM
1216
1217 /* Disable branch tracing and deallocate TINFO. This function is similar
1218 to to_disable_btrace, except that it is called during teardown and is
1219 only allowed to perform actions that are safe. A counter-example would
1220 be attempting to talk to a remote target. */
f6ac5f3d 1221 virtual void teardown_btrace (struct btrace_target_info *tinfo)
9ace480d 1222 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625 1223
969c39fb 1224 /* Read branch trace data for the thread indicated by BTINFO into DATA.
734b0e4b 1225 DATA is cleared before new trace is added. */
f6ac5f3d
PA
1226 virtual enum btrace_error read_btrace (struct btrace_data *data,
1227 struct btrace_target_info *btinfo,
1228 enum btrace_read_type type)
eb5b20d4 1229 TARGET_DEFAULT_NORETURN (tcomplain ());
02d27625 1230
f4abbc16 1231 /* Get the branch trace configuration. */
f6ac5f3d 1232 virtual const struct btrace_config *btrace_conf (const struct btrace_target_info *)
f4abbc16
MM
1233 TARGET_DEFAULT_RETURN (NULL);
1234
b158a20f 1235 /* Current recording method. */
f6ac5f3d 1236 virtual enum record_method record_method (ptid_t ptid)
b158a20f
TW
1237 TARGET_DEFAULT_RETURN (RECORD_METHOD_NONE);
1238
7c1687a9 1239 /* Stop trace recording. */
f6ac5f3d 1240 virtual void stop_recording ()
ee97f592 1241 TARGET_DEFAULT_IGNORE ();
7c1687a9 1242
d02ed0bb 1243 /* Print information about the recording. */
f6ac5f3d 1244 virtual void info_record ()
38e229b2 1245 TARGET_DEFAULT_IGNORE ();
d02ed0bb
MM
1246
1247 /* Save the recorded execution trace into a file. */
f6ac5f3d 1248 virtual void save_record (const char *filename)
f09e2107 1249 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb 1250
252db1b5
TT
1251 /* Delete the recorded execution trace from the current position
1252 onwards. */
f6ac5f3d
PA
1253 virtual bool supports_delete_record ()
1254 TARGET_DEFAULT_RETURN (false);
1255 virtual void delete_record ()
07366925 1256 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb 1257
a52eab48 1258 /* Query if the record target is currently replaying PTID. */
57810aa7
PA
1259 virtual bool record_is_replaying (ptid_t ptid)
1260 TARGET_DEFAULT_RETURN (false);
d02ed0bb 1261
7ff27e9b
MM
1262 /* Query if the record target will replay PTID if it were resumed in
1263 execution direction DIR. */
57810aa7
PA
1264 virtual bool record_will_replay (ptid_t ptid, int dir)
1265 TARGET_DEFAULT_RETURN (false);
7ff27e9b 1266
797094dd 1267 /* Stop replaying. */
f6ac5f3d 1268 virtual void record_stop_replaying ()
797094dd
MM
1269 TARGET_DEFAULT_IGNORE ();
1270
d02ed0bb 1271 /* Go to the begin of the execution trace. */
f6ac5f3d 1272 virtual void goto_record_begin ()
671e76cc 1273 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb
MM
1274
1275 /* Go to the end of the execution trace. */
f6ac5f3d 1276 virtual void goto_record_end ()
e9179bb3 1277 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb
MM
1278
1279 /* Go to a specific location in the recorded execution trace. */
f6ac5f3d 1280 virtual void goto_record (ULONGEST insn)
05969c84 1281 TARGET_DEFAULT_NORETURN (tcomplain ());
d02ed0bb 1282
67c86d06
MM
1283 /* Disassemble SIZE instructions in the recorded execution trace from
1284 the current position.
1285 If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
1286 disassemble SIZE succeeding instructions. */
f6ac5f3d 1287 virtual void insn_history (int size, gdb_disassembly_flags flags)
3679abfa 1288 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06
MM
1289
1290 /* Disassemble SIZE instructions in the recorded execution trace around
1291 FROM.
1292 If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
1293 disassemble SIZE instructions after FROM. */
f6ac5f3d
PA
1294 virtual void insn_history_from (ULONGEST from, int size,
1295 gdb_disassembly_flags flags)
8444ab58 1296 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06
MM
1297
1298 /* Disassemble a section of the recorded execution trace from instruction
0688d04e 1299 BEGIN (inclusive) to instruction END (inclusive). */
f6ac5f3d
PA
1300 virtual void insn_history_range (ULONGEST begin, ULONGEST end,
1301 gdb_disassembly_flags flags)
c29302cc 1302 TARGET_DEFAULT_NORETURN (tcomplain ());
67c86d06 1303
15984c13
MM
1304 /* Print a function trace of the recorded execution trace.
1305 If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
1306 succeeding functions. */
f6ac5f3d 1307 virtual void call_history (int size, record_print_flags flags)
170049d4 1308 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13
MM
1309
1310 /* Print a function trace of the recorded execution trace starting
1311 at function FROM.
1312 If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
1313 SIZE functions after FROM. */
f6ac5f3d 1314 virtual void call_history_from (ULONGEST begin, int size, record_print_flags flags)
16fc27d6 1315 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13
MM
1316
1317 /* Print a function trace of an execution trace section from function BEGIN
0688d04e 1318 (inclusive) to function END (inclusive). */
f6ac5f3d 1319 virtual void call_history_range (ULONGEST begin, ULONGEST end, record_print_flags flags)
115d9817 1320 TARGET_DEFAULT_NORETURN (tcomplain ());
15984c13 1321
57810aa7 1322 /* True if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
ced63ec0 1323 non-empty annex. */
57810aa7
PA
1324 virtual bool augmented_libraries_svr4_read ()
1325 TARGET_DEFAULT_RETURN (false);
ced63ec0 1326
ac01945b
TT
1327 /* Those unwinders are tried before any other arch unwinders. If
1328 SELF doesn't have unwinders, it should delegate to the
1329 "beneath" target. */
f6ac5f3d 1330 virtual const struct frame_unwind *get_unwinder ()
ac01945b
TT
1331 TARGET_DEFAULT_RETURN (NULL);
1332
f6ac5f3d 1333 virtual const struct frame_unwind *get_tailcall_unwinder ()
ac01945b 1334 TARGET_DEFAULT_RETURN (NULL);
ea001bdc 1335
5fff78c4 1336 /* Prepare to generate a core file. */
f6ac5f3d 1337 virtual void prepare_to_generate_core ()
5fff78c4
MM
1338 TARGET_DEFAULT_IGNORE ();
1339
1340 /* Cleanup after generating a core file. */
f6ac5f3d 1341 virtual void done_generating_core ()
5fff78c4 1342 TARGET_DEFAULT_IGNORE ();
dbe692af
LM
1343
1344 /* Returns true if the target supports memory tagging, false otherwise. */
1345 virtual bool supports_memory_tagging ()
1346 TARGET_DEFAULT_RETURN (false);
1347
1348 /* Return the allocated memory tags of type TYPE associated with
1349 [ADDRESS, ADDRESS + LEN) in TAGS.
1350
1351 LEN is the number of bytes in the memory range. TAGS is a vector of
1352 bytes containing the tags found in the above memory range.
1353
1354 It is up to the architecture/target to interpret the bytes in the TAGS
1355 vector and read the tags appropriately.
1356
1357 Returns true if fetching the tags succeeded and false otherwise. */
1358 virtual bool fetch_memtags (CORE_ADDR address, size_t len,
1359 gdb::byte_vector &tags, int type)
1360 TARGET_DEFAULT_NORETURN (tcomplain ());
1361
1362 /* Write the allocation tags of type TYPE contained in TAGS to the memory
1363 range [ADDRESS, ADDRESS + LEN).
1364
1365 LEN is the number of bytes in the memory range. TAGS is a vector of
1366 bytes containing the tags to be stored to the memory range.
1367
1368 It is up to the architecture/target to interpret the bytes in the TAGS
1369 vector and store them appropriately.
1370
1371 Returns true if storing the tags succeeded and false otherwise. */
1372 virtual bool store_memtags (CORE_ADDR address, size_t len,
1373 const gdb::byte_vector &tags, int type)
1374 TARGET_DEFAULT_NORETURN (tcomplain ());
a388ab0b 1375
7202f41f
GR
1376 /* Returns true if ADDRESS is tagged, otherwise returns false. */
1377 virtual bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address)
1378 TARGET_DEFAULT_NORETURN (tcomplain ());
1379
a388ab0b
JB
1380 /* Return the x86 XSAVE extended state area layout. */
1381 virtual x86_xsave_layout fetch_x86_xsave_layout ()
1382 TARGET_DEFAULT_RETURN (x86_xsave_layout ());
7f7e6755
SM
1383
1384 /* Return true if the target supports displaced stepping for THREAD. */
1385 virtual bool supports_displaced_step (thread_info *thread)
1386 TARGET_DEFAULT_FUNC (default_supports_displaced_step);
1387
1388 /* See documentation of gdbarch_displaced_step_prepare. */
1389 virtual displaced_step_prepare_status displaced_step_prepare (thread_info *thread,
1390 CORE_ADDR &displaced_pc)
1391 TARGET_DEFAULT_FUNC (default_displaced_step_prepare);
1392
1393 /* See documentation of gdbarch_displaced_step_finish. */
1394 virtual displaced_step_finish_status displaced_step_finish
1395 (thread_info *thread, const target_waitstatus &status)
1396 TARGET_DEFAULT_FUNC (default_displaced_step_finish);
1397
1398 /* See documentation of gdbarch_displaced_step_restore_all_in_ptid. */
1399 virtual void displaced_step_restore_all_in_ptid (inferior *parent_inf,
1400 ptid_t child_ptid)
1401 TARGET_DEFAULT_FUNC (default_displaced_step_restore_all_in_ptid);
c5aa993b 1402 };
c906108c 1403
15244507
PA
1404/* Deleter for std::unique_ptr. See comments in
1405 target_ops::~target_ops and target_ops::close about heap-allocated
1406 targets. */
1407struct target_ops_deleter
1408{
1409 void operator() (target_ops *target)
1410 {
1411 target->close ();
1412 }
1413};
1414
1415/* A unique pointer for target_ops. */
1416typedef std::unique_ptr<target_ops, target_ops_deleter> target_ops_up;
1417
5b6d1e4f
PA
1418/* A policy class to interface gdb::ref_ptr with target_ops. */
1419
1420struct target_ops_ref_policy
1421{
1422 static void incref (target_ops *t)
1423 {
1424 t->incref ();
1425 }
1426
9678f8fe
AB
1427 /* Decrement the reference count on T, and, if the reference count
1428 reaches zero, close the target. */
1429 static void decref (target_ops *t);
5b6d1e4f
PA
1430};
1431
1432/* A gdb::ref_ptr pointer to a target_ops. */
1433typedef gdb::ref_ptr<target_ops, target_ops_ref_policy> target_ops_ref;
1434
d9f719f1
PA
1435/* Native target backends call this once at initialization time to
1436 inform the core about which is the target that can respond to "run"
1437 or "attach". Note: native targets are always singletons. */
1438extern void set_native_target (target_ops *target);
1439
1440/* Get the registered native target, if there's one. Otherwise return
1441 NULL. */
1442extern target_ops *get_native_target ();
1443
a1740ee1
PA
1444/* Type that manages a target stack. See description of target stacks
1445 and strata at the top of the file. */
1446
1447class target_stack
1448{
1449public:
1450 target_stack () = default;
1451 DISABLE_COPY_AND_ASSIGN (target_stack);
1452
1453 /* Push a new target into the stack of the existing target
1454 accessors, possibly superseding some existing accessor. */
1455 void push (target_ops *t);
1456
1457 /* Remove a target from the stack, wherever it may be. Return true
1458 if it was removed, false otherwise. */
1459 bool unpush (target_ops *t);
1460
1461 /* Returns true if T is pushed on the target stack. */
31282a84 1462 bool is_pushed (const target_ops *t) const
66b4deae 1463 { return at (t->stratum ()) == t; }
a1740ee1
PA
1464
1465 /* Return the target at STRATUM. */
91e3d1d1 1466 target_ops *at (strata stratum) const { return m_stack[stratum].get (); }
a1740ee1
PA
1467
1468 /* Return the target at the top of the stack. */
1469 target_ops *top () const { return at (m_top); }
1470
1471 /* Find the next target down the stack from the specified target. */
1472 target_ops *find_beneath (const target_ops *t) const;
1473
1474private:
1475 /* The stratum of the top target. */
1476 enum strata m_top {};
1477
1478 /* The stack, represented as an array, with one slot per stratum.
1479 If no target is pushed at some stratum, the corresponding slot is
1480 null. */
91e3d1d1 1481 std::array<target_ops_ref, (int) debug_stratum + 1> m_stack;
a1740ee1
PA
1482};
1483
5b6d1e4f
PA
1484/* Return the dummy target. */
1485extern target_ops *get_dummy_target ();
1486
c906108c
SS
1487/* Define easy words for doing these operations on our current target. */
1488
d777bf0d 1489extern const char *target_shortname ();
c906108c 1490
b3ccfe11
TT
1491/* Find the correct target to use for "attach". If a target on the
1492 current stack supports attaching, then it is returned. Otherwise,
1493 the default run target is returned. */
1494
1495extern struct target_ops *find_attach_target (void);
c906108c 1496
b3ccfe11
TT
1497/* Find the correct target to use for "run". If a target on the
1498 current stack supports creating a new inferior, then it is
1499 returned. Otherwise, the default run target is returned. */
1500
1501extern struct target_ops *find_run_target (void);
c906108c 1502
dc177b7a
PA
1503/* Some targets don't generate traps when attaching to the inferior,
1504 or their target_attach implementation takes care of the waiting.
1505 These targets must set to_attach_no_wait. */
1506
d777bf0d 1507extern bool target_attach_no_wait ();
dc177b7a 1508
c906108c
SS
1509/* The target_attach operation places a process under debugger control,
1510 and stops the process.
1511
1512 This operation provides a target-specific hook that allows the
0d06e24b 1513 necessary bookkeeping to be performed after an attach completes. */
d777bf0d
SM
1514
1515extern void target_post_attach (int pid);
c906108c 1516
bc521517
TT
1517/* Display a message indicating we're about to attach to a given
1518 process. */
1519
1520extern void target_announce_attach (int from_tty, int pid);
1521
0f48b757
PA
1522/* Display a message indicating we're about to detach from the current
1523 inferior process. */
1524
1525extern void target_announce_detach (int from_tty);
1526
c906108c
SS
1527/* Takes a program previously attached to and detaches it.
1528 The program may resume execution (some targets do, some don't) and will
1529 no longer stop on signals, etc. We better not have left any breakpoints
6bd6f3b6
SM
1530 in the program or it'll die when it hits one. FROM_TTY says whether to be
1531 verbose or not. */
c906108c 1532
6e1e1966 1533extern void target_detach (inferior *inf, int from_tty);
c906108c 1534
6ad8ae5c
DJ
1535/* Disconnect from the current target without resuming it (leaving it
1536 waiting for a debugger). */
1537
fee354ee 1538extern void target_disconnect (const char *, int);
6ad8ae5c 1539
d51926f0
PA
1540/* Resume execution (or prepare for execution) of the current thread
1541 (INFERIOR_PTID), while optionally letting other threads of the
1542 current process or all processes run free.
1543
1544 STEP says whether to hardware single-step the current thread or to
1545 let it run free; SIGNAL is the signal to be given to the current
1546 thread, or GDB_SIGNAL_0 for no signal. The caller may not pass
1547 GDB_SIGNAL_DEFAULT.
1548
1549 SCOPE_PTID indicates the resumption scope. I.e., which threads
1550 (other than the current) run free. If resuming a single thread,
1551 SCOPE_PTID is the same thread as the current thread. A wildcard
1552 SCOPE_PTID (all threads, or all threads of process) lets threads
1553 other than the current (for which the wildcard SCOPE_PTID matches)
1554 resume with their 'thread->suspend.stop_signal' signal (usually
1555 GDB_SIGNAL_0) if it is in "pass" state, or with no signal if in "no
1556 pass" state. Note neither STEP nor SIGNAL apply to any thread
1557 other than the current.
85ad3aaf
PA
1558
1559 In order to efficiently handle batches of resumption requests,
1560 targets may implement this method such that it records the
1561 resumption request, but defers the actual resumption to the
1562 target_commit_resume method implementation. See
1563 target_commit_resume below. */
d51926f0
PA
1564extern void target_resume (ptid_t scope_ptid,
1565 int step, enum gdb_signal signal);
c906108c 1566
1192f124
SM
1567/* Ensure that all resumed threads are committed to the target.
1568
1569 See the description of process_stratum_target::commit_resumed_state
1570 for more details. */
1571extern void target_commit_resumed ();
85ad3aaf 1572
f2b9e3df 1573/* For target_read_memory see target/target.h. */
c906108c 1574
0b333c5e
PA
1575/* The default target_ops::to_wait implementation. */
1576
1577extern ptid_t default_target_wait (struct target_ops *ops,
1578 ptid_t ptid,
1579 struct target_waitstatus *status,
b60cea74 1580 target_wait_flags options);
0b333c5e 1581
b4b1a226
SM
1582/* Return true if the target has pending events to report to the core.
1583 See target_ops::has_pending_events(). */
1584
1585extern bool target_has_pending_events ();
1586
17dee195 1587/* Fetch at least register REGNO, or all regs if regno == -1. No result. */
c906108c 1588
28439f5e 1589extern void target_fetch_registers (struct regcache *regcache, int regno);
c906108c
SS
1590
1591/* Store at least register REGNO, or all regs if REGNO == -1.
1592 It can store as many registers as it wants to, so target_prepare_to_store
1593 must have been previously called. Calls error() if there are problems. */
1594
28439f5e 1595extern void target_store_registers (struct regcache *regcache, int regs);
c906108c
SS
1596
1597/* Get ready to modify the registers array. On machines which store
1598 individual registers, this doesn't need to do anything. On machines
1599 which store all the registers in one fell swoop, this makes sure
1600 that REGISTERS contains all the registers from the program being
1601 debugged. */
1602
d777bf0d 1603extern void target_prepare_to_store (regcache *regcache);
c906108c 1604
451b7c33
TT
1605/* Implement the "info proc" command. This returns one if the request
1606 was handled, and zero otherwise. It can also throw an exception if
1607 an error was encountered while attempting to handle the
1608 request. */
145b16a9 1609
7bc112c1 1610int target_info_proc (const char *, enum info_proc_what);
145b16a9 1611
03583c20
UW
1612/* Returns true if this target can disable address space randomization. */
1613
1614int target_supports_disable_randomization (void);
1615
d248b706
KY
1616/* Returns true if this target can enable and disable tracepoints
1617 while a trace experiment is running. */
1618
d777bf0d 1619extern bool target_supports_enable_disable_tracepoint ();
d248b706 1620
d777bf0d 1621extern bool target_supports_string_tracing ();
3065dfb6 1622
b775012e
LM
1623/* Returns true if this target can handle breakpoint conditions
1624 on its end. */
1625
d777bf0d 1626extern bool target_supports_evaluation_of_breakpoint_conditions ();
b775012e 1627
b31488a3
KR
1628/* Does this target support dumpcore API? */
1629
d777bf0d 1630extern bool target_supports_dumpcore ();
b31488a3
KR
1631
1632/* Generate the core file with target API. */
1633
d777bf0d 1634extern void target_dumpcore (const char *filename);
b31488a3 1635
d3ce09f5
SS
1636/* Returns true if this target can handle breakpoint commands
1637 on its end. */
1638
d777bf0d 1639extern bool target_can_run_breakpoint_commands ();
d3ce09f5 1640
721ec300 1641/* For target_read_memory see target/target.h. */
c906108c 1642
aee4bf85
PA
1643extern int target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
1644 ssize_t len);
1645
45aa4659 1646extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
4e5d721f 1647
29453a14
YQ
1648extern int target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
1649
721ec300 1650/* For target_write_memory see target/target.h. */
c906108c 1651
f0ba3972 1652extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
45aa4659 1653 ssize_t len);
f0ba3972 1654
fd79ecee
DJ
1655/* Fetches the target's memory map. If one is found it is sorted
1656 and returned, after some consistency checking. Otherwise, NULL
1657 is returned. */
a664f67e 1658std::vector<mem_region> target_memory_map (void);
fd79ecee 1659
78cbbba8 1660/* Erases all flash memory regions on the target. */
0b39b52e 1661void flash_erase_command (const char *cmd, int from_tty);
78cbbba8 1662
a76d924d
DJ
1663/* Erase the specified flash region. */
1664void target_flash_erase (ULONGEST address, LONGEST length);
1665
1666/* Finish a sequence of flash operations. */
1667void target_flash_done (void);
1668
1669/* Describes a request for a memory write operation. */
1670struct memory_write_request
55089490
TT
1671{
1672 memory_write_request (ULONGEST begin_, ULONGEST end_,
1673 gdb_byte *data_ = nullptr, void *baton_ = nullptr)
1674 : begin (begin_), end (end_), data (data_), baton (baton_)
1675 {}
1676
5cb0406b 1677 /* Beginning address that must be written. */
55089490
TT
1678 ULONGEST begin;
1679 /* Past-the-end address. */
1680 ULONGEST end;
1681 /* The data to write. */
1682 gdb_byte *data;
1683 /* A callback baton for progress reporting for this request. */
1684 void *baton;
1685};
a76d924d 1686
ac51afb5 1687/* Enumeration specifying different flash preservation behavior. */
a76d924d
DJ
1688enum flash_preserve_mode
1689 {
1690 flash_preserve,
1691 flash_discard
1692 };
1693
1694/* Write several memory blocks at once. This version can be more
1695 efficient than making several calls to target_write_memory, in
1696 particular because it can optimize accesses to flash memory.
1697
1698 Moreover, this is currently the only memory access function in gdb
1699 that supports writing to flash memory, and it should be used for
1700 all cases where access to flash memory is desirable.
1701
791b7405 1702 REQUESTS is the vector of memory_write_request.
a76d924d
DJ
1703 PRESERVE_FLASH_P indicates what to do with blocks which must be
1704 erased, but not completely rewritten.
1705 PROGRESS_CB is a function that will be periodically called to provide
1706 feedback to user. It will be called with the baton corresponding
1707 to the request currently being written. It may also be called
1708 with a NULL baton, when preserved flash sectors are being rewritten.
1709
1710 The function returns 0 on success, and error otherwise. */
55089490
TT
1711int target_write_memory_blocks
1712 (const std::vector<memory_write_request> &requests,
1713 enum flash_preserve_mode preserve_flash_p,
1714 void (*progress_cb) (ULONGEST, void *));
a76d924d 1715
c906108c
SS
1716/* Print a line about the current target. */
1717
d777bf0d 1718extern void target_files_info ();
c906108c 1719
7d03f2eb 1720/* Insert a breakpoint at address BP_TGT->placed_address in
0000e5cc
PA
1721 the target machine. Returns 0 for success, and returns non-zero or
1722 throws an error (with a detailed failure reason error code and
1723 message) otherwise. */
c906108c 1724
d914c394
SS
1725extern int target_insert_breakpoint (struct gdbarch *gdbarch,
1726 struct bp_target_info *bp_tgt);
c906108c 1727
8181d85f 1728/* Remove a breakpoint at address BP_TGT->placed_address in the target
578d3588 1729 machine. Result is 0 for success, non-zero for error. */
c906108c 1730
d914c394 1731extern int target_remove_breakpoint (struct gdbarch *gdbarch,
73971819
PA
1732 struct bp_target_info *bp_tgt,
1733 enum remove_bp_reason reason);
c906108c 1734
b0ed115f 1735/* Return true if the target stack has a non-default
f6ac5f3d 1736 "terminal_ours" method. */
b0ed115f 1737
20f0d60d 1738extern bool target_supports_terminal_ours (void);
b0ed115f 1739
c906108c
SS
1740/* Kill the inferior process. Make it go away. */
1741
7d85a9c0 1742extern void target_kill (void);
c906108c 1743
0d06e24b
JM
1744/* Load an executable file into the target process. This is expected
1745 to not only bring new code into the target process, but also to
1986bccd
AS
1746 update GDB's symbol tables to match.
1747
1748 ARG contains command-line arguments, to be broken down with
1749 buildargv (). The first non-switch argument is the filename to
1750 load, FILE; the second is a number (as parsed by strtoul (..., ...,
1751 0)), which is an offset to apply to the load addresses of FILE's
1752 sections. The target may define switches, or other non-switch
1753 arguments, as it pleases. */
c906108c 1754
9cbe5fff 1755extern void target_load (const char *arg, int from_tty);
c906108c 1756
0d06e24b
JM
1757/* On some targets, we can catch an inferior fork or vfork event when
1758 it occurs. These functions insert/remove an already-created
77b06cd7
TJB
1759 catchpoint for such events. They return 0 for success, 1 if the
1760 catchpoint type is not supported and -1 for failure. */
c906108c 1761
d777bf0d 1762extern int target_insert_fork_catchpoint (int pid);
c906108c 1763
d777bf0d 1764extern int target_remove_fork_catchpoint (int pid);
c906108c 1765
d777bf0d 1766extern int target_insert_vfork_catchpoint (int pid);
c906108c 1767
d777bf0d 1768extern int target_remove_vfork_catchpoint (int pid);
c906108c 1769
3a849a34 1770/* Call the follow_fork method on the current target stack.
0d06e24b 1771
3a849a34
SM
1772 This function is called when the inferior forks or vforks, to perform any
1773 bookkeeping and fiddling necessary to continue debugging either the parent,
1774 the child or both. */
1775
82d1f134
SM
1776void target_follow_fork (inferior *inf, ptid_t child_ptid,
1777 target_waitkind fork_kind, bool follow_child,
1778 bool detach_fork);
c906108c 1779
2af87c85 1780/* Handle the target-specific bookkeeping required when the inferior makes an
294c36eb 1781 exec call.
94585166 1782
294c36eb
SM
1783 The current inferior at the time of the call is the inferior that did the
1784 exec. FOLLOW_INF is the inferior in which execution continues post-exec.
1785 If "follow-exec-mode" is "same", FOLLOW_INF is the same as the current
1786 inferior, meaning that execution continues with the same inferior. If
1787 "follow-exec-mode" is "new", FOLLOW_INF is a different inferior, meaning
1788 that execution continues in a new inferior.
1789
1790 On exit, the target must leave FOLLOW_INF as the current inferior. */
1791
1792void target_follow_exec (inferior *follow_inf, ptid_t ptid,
1793 const char *execd_pathname);
94585166 1794
c906108c 1795/* On some targets, we can catch an inferior exec event when it
0d06e24b 1796 occurs. These functions insert/remove an already-created
77b06cd7
TJB
1797 catchpoint for such events. They return 0 for success, 1 if the
1798 catchpoint type is not supported and -1 for failure. */
0d06e24b 1799
d777bf0d 1800extern int target_insert_exec_catchpoint (int pid);
c5aa993b 1801
d777bf0d 1802extern int target_remove_exec_catchpoint (int pid);
c906108c 1803
a96d9b2e
SDJ
1804/* Syscall catch.
1805
649a140c
PA
1806 NEEDED is true if any syscall catch (of any kind) is requested.
1807 If NEEDED is false, it means the target can disable the mechanism to
a96d9b2e
SDJ
1808 catch system calls because there are no more catchpoints of this type.
1809
1810 ANY_COUNT is nonzero if a generic (filter-less) syscall catch is
649a140c 1811 being requested. In this case, SYSCALL_COUNTS should be ignored.
a96d9b2e 1812
649a140c
PA
1813 SYSCALL_COUNTS is an array of ints, indexed by syscall number. An
1814 element in this array is nonzero if that syscall should be caught.
1815 This argument only matters if ANY_COUNT is zero.
77b06cd7
TJB
1816
1817 Return 0 for success, 1 if syscall catchpoints are not supported or -1
1818 for failure. */
a96d9b2e 1819
d777bf0d
SM
1820extern int target_set_syscall_catchpoint
1821 (int pid, bool needed, int any_count,
1822 gdb::array_view<const int> syscall_counts);
a96d9b2e 1823
c906108c 1824/* The debugger has completed a blocking wait() call. There is now
2146d243 1825 some process event that must be processed. This function should
c906108c 1826 be defined by those targets that require the debugger to perform
0d06e24b 1827 cleanup or internal state changes in response to the process event. */
c906108c 1828
bc1e6c81 1829/* For target_mourn_inferior see target/target.h. */
c906108c 1830
f6ac5f3d 1831/* Does target have enough data to do a run or attach command? */
c906108c 1832
f6ac5f3d 1833extern int target_can_run ();
c906108c 1834
2455069d
UW
1835/* Set list of signals to be handled in the target.
1836
adc6a863 1837 PASS_SIGNALS is an array indexed by target signal number
2ea28649 1838 (enum gdb_signal). For every signal whose entry in this array is
2455069d
UW
1839 non-zero, the target is allowed -but not required- to skip reporting
1840 arrival of the signal to the GDB core by returning from target_wait,
1841 and to pass the signal directly to the inferior instead.
1842
1843 However, if the target is hardware single-stepping a thread that is
1844 about to receive a signal, it needs to be reported in any case, even
1845 if mentioned in a previous target_pass_signals call. */
c906108c 1846
adc6a863
PA
1847extern void target_pass_signals
1848 (gdb::array_view<const unsigned char> pass_signals);
c906108c 1849
9b224c5e
PA
1850/* Set list of signals the target may pass to the inferior. This
1851 directly maps to the "handle SIGNAL pass/nopass" setting.
1852
adc6a863 1853 PROGRAM_SIGNALS is an array indexed by target signal
2ea28649 1854 number (enum gdb_signal). For every signal whose entry in this
9b224c5e
PA
1855 array is non-zero, the target is allowed to pass the signal to the
1856 inferior. Signals not present in the array shall be silently
1857 discarded. This does not influence whether to pass signals to the
1858 inferior as a result of a target_resume call. This is useful in
1859 scenarios where the target needs to decide whether to pass or not a
1860 signal to the inferior without GDB core involvement, such as for
1861 example, when detaching (as threads may have been suspended with
1862 pending signals not reported to GDB). */
1863
adc6a863
PA
1864extern void target_program_signals
1865 (gdb::array_view<const unsigned char> program_signals);
9b224c5e 1866
c906108c
SS
1867/* Check to see if a thread is still alive. */
1868
28439f5e 1869extern int target_thread_alive (ptid_t ptid);
c906108c 1870
e8032dde 1871/* Sync the target's threads with GDB's thread list. */
b83266a0 1872
e8032dde 1873extern void target_update_thread_list (void);
b83266a0 1874
0d06e24b 1875/* Make target stop in a continuable fashion. (For instance, under
9a6cf368
GB
1876 Unix, this should act like SIGSTOP). Note that this function is
1877 asynchronous: it does not wait for the target to become stopped
1878 before returning. If this is the behavior you want please use
1879 target_stop_and_wait. */
c906108c 1880
d914c394 1881extern void target_stop (ptid_t ptid);
c906108c 1882
e671cd59
PA
1883/* Interrupt the target. Unlike target_stop, this does not specify
1884 which thread/process reports the stop. For most target this acts
1885 like raising a SIGINT, though that's not absolutely required. This
1886 function is asynchronous. */
bfedc46a 1887
e671cd59 1888extern void target_interrupt ();
bfedc46a 1889
93692b58 1890/* Pass a ^C, as determined to have been pressed by checking the quit
e671cd59
PA
1891 flag, to the target, as if the user had typed the ^C on the
1892 inferior's controlling terminal while the inferior was in the
1893 foreground. Remote targets may take the opportunity to detect the
1894 remote side is not responding and offer to disconnect. */
93692b58
PA
1895
1896extern void target_pass_ctrlc (void);
1897
1898/* The default target_ops::to_pass_ctrlc implementation. Simply calls
1899 target_interrupt. */
1900extern void default_target_pass_ctrlc (struct target_ops *ops);
1901
96baa820
JM
1902/* Send the specified COMMAND to the target's monitor
1903 (shell,interpreter) for execution. The result of the query is
0d06e24b 1904 placed in OUTBUF. */
96baa820 1905
d777bf0d 1906extern void target_rcmd (const char *command, struct ui_file *outbuf);
c906108c
SS
1907
1908/* Does the target include memory? (Dummy targets don't.) */
1909
a739972c 1910extern int target_has_memory ();
c906108c
SS
1911
1912/* Does the target have a stack? (Exec files don't, VxWorks doesn't, until
1913 we start a process.) */
c5aa993b 1914
841de120 1915extern int target_has_stack ();
c906108c
SS
1916
1917/* Does the target have registers? (Exec files don't.) */
1918
9dccd06e 1919extern int target_has_registers ();
c906108c
SS
1920
1921/* Does the target have execution? Can we make it jump (through
52bb452f
DJ
1922 hoops), or pop its stack a few times? This means that the current
1923 target is currently executing; for some targets, that's the same as
1924 whether or not the target is capable of execution, but there are
1925 also targets which can be current while not executing. In that
b3ccfe11 1926 case this will become true after to_create_inferior or
55f6301a
TT
1927 to_attach. INF is the inferior to use; nullptr means to use the
1928 current inferior. */
c906108c 1929
55f6301a 1930extern bool target_has_execution (inferior *inf = nullptr);
c35b1492 1931
c906108c 1932/* Can the target support the debugger control of thread execution?
d6350901 1933 Can it lock the thread scheduler? */
c906108c 1934
d777bf0d 1935extern bool target_can_lock_scheduler ();
c906108c 1936
329ea579 1937/* Controls whether async mode is permitted. */
491144b5 1938extern bool target_async_permitted;
c6ebd6cf 1939
c378eb4e 1940/* Can the target support asynchronous execution? */
d777bf0d 1941extern bool target_can_async_p ();
6426a772 1942
0c1e6e26
AB
1943/* An overload of the above that can be called when the target is not yet
1944 pushed, this calls TARGET::can_async_p directly. */
1945extern bool target_can_async_p (struct target_ops *target);
1946
c378eb4e 1947/* Is the target in asynchronous execution mode? */
d777bf0d 1948extern bool target_is_async_p ();
6426a772 1949
6a3753b3 1950/* Enables/disabled async target events. */
4a570176 1951extern void target_async (bool enable);
43ff13b4 1952
65706a29 1953/* Enables/disables thread create and exit events. */
2db17c87 1954extern void target_thread_events (bool enable);
65706a29 1955
65c459ab
PA
1956/* Returns true if the target supports setting thread options
1957 OPTIONS. */
1958extern bool target_supports_set_thread_options (gdb_thread_options options);
1959
fbea99ea
PA
1960/* Whether support for controlling the target backends always in
1961 non-stop mode is enabled. */
1962extern enum auto_boolean target_non_stop_enabled;
1963
1964/* Is the target in non-stop mode? Some targets control the inferior
1965 in non-stop mode even with "set non-stop off". Always true if "set
1966 non-stop" is on. */
6ff267e1 1967extern bool target_is_non_stop_p ();
fbea99ea 1968
a0714d30
TBA
1969/* Return true if at least one inferior has a non-stop target. */
1970extern bool exists_non_stop_target ();
1971
d777bf0d 1972extern exec_direction_kind target_execution_direction ();
32231432 1973
c906108c
SS
1974/* Converts a process id to a string. Usually, the string just contains
1975 `process xyz', but on some systems it may contain
1976 `process xyz thread abc'. */
1977
a068643d 1978extern std::string target_pid_to_str (ptid_t ptid);
c906108c 1979
a068643d 1980extern std::string normal_pid_to_str (ptid_t ptid);
c5aa993b 1981
0d06e24b
JM
1982/* Return a short string describing extra information about PID,
1983 e.g. "sleeping", "runnable", "running on LWP 3". Null return value
1984 is okay. */
1985
d777bf0d 1986extern const char *target_extra_thread_info (thread_info *tp);
ed9a39eb 1987
79efa585 1988/* Return the thread's name, or NULL if the target is unable to determine it.
25558938
SM
1989 The returned value must not be freed by the caller.
1990
1991 You likely don't want to call this function, but use the thread_name
1992 function instead, which prefers the user-given thread name, if set. */
4694da01 1993
73ede765 1994extern const char *target_thread_name (struct thread_info *);
4694da01 1995
e04ee09e
KB
1996/* Given a pointer to a thread library specific thread handle and
1997 its length, return a pointer to the corresponding thread_info struct. */
1998
1999extern struct thread_info *target_thread_handle_to_thread_info
2000 (const gdb_byte *thread_handle, int handle_len, struct inferior *inf);
2001
3d6c6204
KB
2002/* Given a thread, return the thread handle, a target-specific sequence of
2003 bytes which serves as a thread identifier within the program being
2004 debugged. */
1f08d324 2005extern gdb::array_view<const gdb_byte> target_thread_info_to_thread_handle
3d6c6204
KB
2006 (struct thread_info *);
2007
c906108c
SS
2008/* Attempts to find the pathname of the executable file
2009 that was run to create a specified process.
2010
2011 The process PID must be stopped when this operation is used.
c5aa993b 2012
c906108c
SS
2013 If the executable file cannot be determined, NULL is returned.
2014
2015 Else, a pointer to a character string containing the pathname
2016 is returned. This string should be copied into a buffer by
2017 the client if the string will not be immediately used, or if
0d06e24b 2018 it must persist. */
c906108c 2019
0e90c441 2020extern const char *target_pid_to_exec_file (int pid);
c906108c 2021
3a8f7b07 2022/* See the to_thread_architecture description in struct target_ops. */
c2250ad1 2023
d777bf0d 2024extern gdbarch *target_thread_architecture (ptid_t ptid);
c2250ad1 2025
be4d1333
MS
2026/*
2027 * Iterator function for target memory regions.
2028 * Calls a callback function once for each memory region 'mapped'
2029 * in the child process. Defined as a simple macro rather than
2146d243 2030 * as a function macro so that it can be tested for nullity.
be4d1333
MS
2031 */
2032
d777bf0d
SM
2033extern int target_find_memory_regions (find_memory_region_ftype func,
2034 void *data);
be4d1333
MS
2035
2036/*
2037 * Compose corefile .note section.
2038 */
2039
d777bf0d
SM
2040extern gdb::unique_xmalloc_ptr<char> target_make_corefile_notes (bfd *bfd,
2041 int *size_p);
be4d1333 2042
6b04bdb7 2043/* Bookmark interfaces. */
d777bf0d 2044extern gdb_byte *target_get_bookmark (const char *args, int from_tty);
6b04bdb7 2045
d777bf0d 2046extern void target_goto_bookmark (const gdb_byte *arg, int from_tty);
6b04bdb7 2047
c906108c
SS
2048/* Hardware watchpoint interfaces. */
2049
7ea65f08
PA
2050/* GDB's current model is that there are three "kinds" of watchpoints,
2051 with respect to when they trigger and how you can move past them.
2052
2053 Those are: continuable, steppable, and non-steppable.
2054
2055 Continuable watchpoints are like x86's -- those trigger after the
2056 memory access's side effects are fully committed to memory. I.e.,
2057 they trap with the PC pointing at the next instruction already.
2058 Continuing past such a watchpoint is doable by just normally
2059 continuing, hence the name.
2060
2061 Both steppable and non-steppable watchpoints trap before the memory
2062 access. I.e, the PC points at the instruction that is accessing
2063 the memory. So GDB needs to single-step once past the current
2064 instruction in order to make the access effective and check whether
2065 the instruction's side effects change the watched expression.
2066
2067 Now, in order to step past that instruction, depending on
2068 architecture and target, you can have two situations:
2069
2070 - steppable watchpoints: you can single-step with the watchpoint
2071 still armed, and the watchpoint won't trigger again.
2072
2073 - non-steppable watchpoints: if you try to single-step with the
2074 watchpoint still armed, you'd trap the watchpoint again and the
2075 thread wouldn't make any progress. So GDB needs to temporarily
2076 remove the watchpoint in order to step past it.
2077
2078 If your target/architecture does not signal that it has either
2079 steppable or non-steppable watchpoints via either
2080 target_have_steppable_watchpoint or
2081 gdbarch_have_nonsteppable_watchpoint, GDB assumes continuable
2082 watchpoints. */
2083
d777bf0d 2084/* Returns true if we were stopped by a hardware watchpoint (memory read or
7f82dfc7 2085 write). Only the INFERIOR_PTID task is being queried. */
c906108c 2086
d777bf0d 2087extern bool target_stopped_by_watchpoint ();
7df1a324 2088
d777bf0d 2089/* Returns true if the target stopped because it executed a
1cf4d951
PA
2090 software breakpoint instruction. */
2091
d777bf0d 2092extern bool target_stopped_by_sw_breakpoint ();
1cf4d951 2093
d777bf0d 2094extern bool target_supports_stopped_by_sw_breakpoint ();
1cf4d951 2095
d777bf0d 2096extern bool target_stopped_by_hw_breakpoint ();
1cf4d951 2097
d777bf0d 2098extern bool target_supports_stopped_by_hw_breakpoint ();
1cf4d951 2099
d777bf0d 2100/* True if we have steppable watchpoints */
74174d2e 2101
d777bf0d 2102extern bool target_have_steppable_watchpoint ();
74174d2e 2103
ccaa32c7 2104/* Provide defaults for hardware watchpoint functions. */
c906108c 2105
33b5899f 2106/* If the *_hw_breakpoint functions have not been defined
ccaa32c7 2107 elsewhere use the definitions in the target vector. */
c906108c 2108
059790a0
YQ
2109/* Returns positive if we can set a hardware watchpoint of type TYPE.
2110 Returns negative if the target doesn't have enough hardware debug
2111 registers available. Return zero if hardware watchpoint of type
2112 TYPE isn't supported. TYPE is one of bp_hardware_watchpoint,
2113 bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint.
2114 CNT is the number of such watchpoints used so far, including this
2343b78a
JM
2115 one. OTHERTYPE is the number of watchpoints of other types than
2116 this one used so far. */
c906108c 2117
d777bf0d
SM
2118extern int target_can_use_hardware_watchpoint (bptype type, int cnt,
2119 int othertype);
c906108c 2120
e09342b5
TJB
2121/* Returns the number of debug registers needed to watch the given
2122 memory region, or zero if not supported. */
2123
d777bf0d 2124extern int target_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len);
c906108c 2125
d777bf0d 2126extern int target_can_do_single_step ();
750ce8d1 2127
85d721b8
PA
2128/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes.
2129 TYPE is 0 for write, 1 for read, and 2 for read/write accesses.
0cf6dd15 2130 COND is the expression for its condition, or NULL if there's none.
85d721b8
PA
2131 Returns 0 for success, 1 if the watchpoint type is not supported,
2132 -1 for failure. */
c906108c 2133
d777bf0d
SM
2134extern int target_insert_watchpoint (CORE_ADDR addr, int len,
2135 target_hw_bp_type type, expression *cond);
c906108c 2136
d777bf0d
SM
2137extern int target_remove_watchpoint (CORE_ADDR addr, int len,
2138 target_hw_bp_type type, expression *cond);
c906108c 2139
9c06b0b4
TJB
2140/* Insert a new masked watchpoint at ADDR using the mask MASK.
2141 RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
2142 or hw_access for an access watchpoint. Returns 0 for success, 1 if
2143 masked watchpoints are not supported, -1 for failure. */
2144
f4b0a671
SM
2145extern int target_insert_mask_watchpoint (CORE_ADDR, CORE_ADDR,
2146 enum target_hw_bp_type);
9c06b0b4
TJB
2147
2148/* Remove a masked watchpoint at ADDR with the mask MASK.
2149 RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
2150 or hw_access for an access watchpoint. Returns 0 for success, non-zero
2151 for failure. */
2152
f4b0a671
SM
2153extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR,
2154 enum target_hw_bp_type);
9c06b0b4 2155
0000e5cc
PA
2156/* Insert a hardware breakpoint at address BP_TGT->placed_address in
2157 the target machine. Returns 0 for success, and returns non-zero or
2158 throws an error (with a detailed failure reason error code and
2159 message) otherwise. */
2160
d777bf0d
SM
2161extern int target_insert_hw_breakpoint (gdbarch *gdbarch,
2162 bp_target_info *bp_tgt);
ccaa32c7 2163
d777bf0d
SM
2164extern int target_remove_hw_breakpoint (gdbarch *gdbarch,
2165 bp_target_info *bp_tgt);
c906108c 2166
f1310107
TJB
2167/* Return number of debug registers needed for a ranged breakpoint,
2168 or -1 if ranged breakpoints are not supported. */
2169
2170extern int target_ranged_break_num_registers (void);
2171
7f82dfc7
JK
2172/* Return non-zero if target knows the data address which triggered this
2173 target_stopped_by_watchpoint, in such case place it to *ADDR_P. Only the
2174 INFERIOR_PTID task is being queried. */
2175#define target_stopped_data_address(target, addr_p) \
f6ac5f3d 2176 (target)->stopped_data_address (addr_p)
c906108c 2177
9b3e86b1
MR
2178/* Return non-zero if ADDR is within the range of a watchpoint spanning
2179 LENGTH bytes beginning at START. */
5009afc5 2180#define target_watchpoint_addr_within_range(target, addr, start, length) \
f6ac5f3d 2181 (target)->watchpoint_addr_within_range (addr, start, length)
5009afc5 2182
0cf6dd15
TJB
2183/* Return non-zero if the target is capable of using hardware to evaluate
2184 the condition expression. In this case, if the condition is false when
2185 the watched memory location changes, execution may continue without the
2186 debugger being notified.
2187
2188 Due to limitations in the hardware implementation, it may be capable of
2189 avoiding triggering the watchpoint in some cases where the condition
2190 expression is false, but may report some false positives as well.
2191 For this reason, GDB will still evaluate the condition expression when
2192 the watchpoint triggers. */
d777bf0d
SM
2193
2194extern bool target_can_accel_watchpoint_condition (CORE_ADDR addr, int len,
2195 int type, expression *cond);
0cf6dd15 2196
9c06b0b4
TJB
2197/* Return number of debug registers needed for a masked watchpoint,
2198 -1 if masked watchpoints are not supported or -2 if the given address
2199 and mask combination cannot be used. */
2200
2201extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
2202
b2175913 2203/* Target can execute in reverse? */
d777bf0d
SM
2204
2205extern bool target_can_execute_reverse ();
b2175913 2206
424163ea
DJ
2207extern const struct target_desc *target_read_description (struct target_ops *);
2208
c80e29db 2209extern ptid_t target_get_ada_task_ptid (long lwp, ULONGEST tid);
0ef643c8 2210
08388c79
DE
2211/* Main entry point for searching memory. */
2212extern int target_search_memory (CORE_ADDR start_addr,
dda83cd7
SM
2213 ULONGEST search_space_len,
2214 const gdb_byte *pattern,
2215 ULONGEST pattern_len,
2216 CORE_ADDR *found_addrp);
08388c79 2217
7313baad
UW
2218/* Target file operations. */
2219
d777bf0d 2220/* Return true if the filesystem seen by the current inferior
07c138c8 2221 is the local filesystem, zero otherwise. */
d777bf0d
SM
2222
2223extern bool target_filesystem_is_local ();
4bd7dc42 2224
07c138c8 2225/* Open FILENAME on the target, in the filesystem as seen by INF,
4111f652
PA
2226 using FLAGS and MODE. If INF is NULL, use the filesystem seen by
2227 the debugger (GDB or, for remote targets, the remote stub). Return
2228 a target file descriptor, or -1 if an error occurs (and set
2229 *TARGET_ERRNO). If WARN_IF_SLOW is true, print a warning message
2230 if the file is being accessed over a link that may be slow. */
07c138c8
GB
2231extern int target_fileio_open (struct inferior *inf,
2232 const char *filename, int flags,
4111f652 2233 int mode, bool warn_if_slow,
b872057a 2234 fileio_error *target_errno);
4313b8c0 2235
7313baad
UW
2236/* Write up to LEN bytes from WRITE_BUF to FD on the target.
2237 Return the number of bytes written, or -1 if an error occurs
2238 (and set *TARGET_ERRNO). */
2239extern int target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
b872057a 2240 ULONGEST offset, fileio_error *target_errno);
7313baad
UW
2241
2242/* Read up to LEN bytes FD on the target into READ_BUF.
2243 Return the number of bytes read, or -1 if an error occurs
2244 (and set *TARGET_ERRNO). */
2245extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len,
b872057a 2246 ULONGEST offset, fileio_error *target_errno);
7313baad 2247
9b15c1f0
GB
2248/* Get information about the file opened as FD on the target
2249 and put it in SB. Return 0 on success, or -1 if an error
2250 occurs (and set *TARGET_ERRNO). */
2251extern int target_fileio_fstat (int fd, struct stat *sb,
b872057a 2252 fileio_error *target_errno);
9b15c1f0 2253
08a115cc
AB
2254/* Get information about the file at FILENAME on the target and put it in
2255 SB. Look in the filesystem as seen by INF. If INF is NULL, use the
2256 filesystem seen by the debugger (GDB or, for remote targets, the remote
2257 stub). Return 0 on success, or -1 if an error occurs (and set
2258 *TARGET_ERRNO). */
5d560402
AB
2259extern int target_fileio_lstat (struct inferior *inf, const char *filename,
2260 struct stat *sb, fileio_error *target_errno);
08a115cc 2261
7313baad
UW
2262/* Close FD on the target. Return 0, or -1 if an error occurs
2263 (and set *TARGET_ERRNO). */
b872057a 2264extern int target_fileio_close (int fd, fileio_error *target_errno);
7313baad 2265
07c138c8
GB
2266/* Unlink FILENAME on the target, in the filesystem as seen by INF.
2267 If INF is NULL, use the filesystem seen by the debugger (GDB or,
2268 for remote targets, the remote stub). Return 0, or -1 if an error
7313baad 2269 occurs (and set *TARGET_ERRNO). */
07c138c8
GB
2270extern int target_fileio_unlink (struct inferior *inf,
2271 const char *filename,
b872057a 2272 fileio_error *target_errno);
07c138c8
GB
2273
2274/* Read value of symbolic link FILENAME on the target, in the
2275 filesystem as seen by INF. If INF is NULL, use the filesystem seen
2276 by the debugger (GDB or, for remote targets, the remote stub).
2277 Return a null-terminated string allocated via xmalloc, or NULL if
2278 an error occurs (and set *TARGET_ERRNO). */
6b09f134 2279extern std::optional<std::string> target_fileio_readlink
b872057a 2280 (struct inferior *inf, const char *filename, fileio_error *target_errno);
07c138c8
GB
2281
2282/* Read target file FILENAME, in the filesystem as seen by INF. If
2283 INF is NULL, use the filesystem seen by the debugger (GDB or, for
2284 remote targets, the remote stub). The return value will be -1 if
2285 the transfer fails or is not supported; 0 if the object is empty;
2286 or the length of the object otherwise. If a positive value is
2287 returned, a sufficiently large buffer will be allocated using
2288 xmalloc and returned in *BUF_P containing the contents of the
2289 object.
7313baad
UW
2290
2291 This method should be used for objects sufficiently small to store
2292 in a single xmalloc'd buffer, when no fixed bound on the object's
2293 size is known in advance. */
07c138c8
GB
2294extern LONGEST target_fileio_read_alloc (struct inferior *inf,
2295 const char *filename,
7313baad
UW
2296 gdb_byte **buf_p);
2297
db1ff28b
JK
2298/* Read target file FILENAME, in the filesystem as seen by INF. If
2299 INF is NULL, use the filesystem seen by the debugger (GDB or, for
2300 remote targets, the remote stub). The result is NUL-terminated and
2301 returned as a string, allocated using xmalloc. If an error occurs
2302 or the transfer is unsupported, NULL is returned. Empty objects
2303 are returned as allocated but empty strings. A warning is issued
2304 if the result contains any embedded NUL bytes. */
87028b87
TT
2305extern gdb::unique_xmalloc_ptr<char> target_fileio_read_stralloc
2306 (struct inferior *inf, const char *filename);
db1ff28b 2307
d7cb0ef3
PA
2308/* Invalidate the target associated with open handles that were open
2309 on target TARG, since we're about to close (and maybe destroy) the
2310 target. The handles remain open from the client's perspective, but
2311 trying to do anything with them other than closing them will fail
2312 with EIO. */
2313extern void fileio_handles_invalidate_target (target_ops *targ);
7313baad 2314
35b1e5cc
SS
2315/* Tracepoint-related operations. */
2316
d777bf0d 2317extern void target_trace_init ();
35b1e5cc 2318
d777bf0d 2319extern void target_download_tracepoint (bp_location *location);
35b1e5cc 2320
d777bf0d 2321extern bool target_can_download_tracepoint ();
1e4d1764 2322
d777bf0d 2323extern void target_download_trace_state_variable (const trace_state_variable &tsv);
35b1e5cc 2324
d777bf0d 2325extern void target_enable_tracepoint (bp_location *loc);
d248b706 2326
d777bf0d 2327extern void target_disable_tracepoint (bp_location *loc);
d248b706 2328
d777bf0d 2329extern void target_trace_start ();
35b1e5cc 2330
d777bf0d 2331extern void target_trace_set_readonly_regions ();
35b1e5cc 2332
d777bf0d 2333extern int target_get_trace_status (trace_status *ts);
35b1e5cc 2334
01bccc56 2335extern void target_get_tracepoint_status (tracepoint *tp, uploaded_tp *utp);
f196051f 2336
d777bf0d 2337extern void target_trace_stop ();
35b1e5cc 2338
d777bf0d
SM
2339extern int target_trace_find (trace_find_type type, int num, CORE_ADDR addr1,
2340 CORE_ADDR addr2, int *tpp);
35b1e5cc 2341
d777bf0d 2342extern bool target_get_trace_state_variable_value (int tsv, LONGEST *val);
35b1e5cc 2343
d777bf0d 2344extern int target_save_trace_data (const char *filename);
00bf0b85 2345
d777bf0d 2346extern int target_upload_tracepoints (uploaded_tp **utpp);
00bf0b85 2347
d777bf0d 2348extern int target_upload_trace_state_variables (uploaded_tsv **utsvp);
00bf0b85 2349
d777bf0d
SM
2350extern LONGEST target_get_raw_trace_data (gdb_byte *buf, ULONGEST offset,
2351 LONGEST len);
00bf0b85 2352
d777bf0d 2353extern int target_get_min_fast_tracepoint_insn_len ();
405f8e94 2354
d777bf0d 2355extern void target_set_disconnected_tracing (int val);
35b1e5cc 2356
d777bf0d 2357extern void target_set_circular_trace_buffer (int val);
4daf5ac0 2358
d777bf0d 2359extern void target_set_trace_buffer_size (LONGEST val);
f6f899bf 2360
d777bf0d
SM
2361extern bool target_set_trace_notes (const char *user, const char *notes,
2362 const char *stopnotes);
f196051f 2363
904d3768
TT
2364/* A wrapper that calls get_tib_address on the top target of the
2365 current inferior. */
d777bf0d 2366extern bool target_get_tib_address (ptid_t ptid, CORE_ADDR *addr);
711e434b 2367
d777bf0d 2368extern void target_set_permissions ();
d914c394 2369
d777bf0d
SM
2370extern bool target_static_tracepoint_marker_at
2371 (CORE_ADDR addr, static_tracepoint_marker *marker);
0fb4aa4b 2372
d777bf0d
SM
2373extern std::vector<static_tracepoint_marker>
2374 target_static_tracepoint_markers_by_strid (const char *marker_id);
0fb4aa4b 2375
d777bf0d 2376extern traceframe_info_up target_traceframe_info ();
b3b9301e 2377
d777bf0d 2378extern bool target_use_agent (bool use);
d1feda86 2379
d777bf0d 2380extern bool target_can_use_agent ();
d1feda86 2381
d777bf0d 2382extern bool target_augmented_libraries_svr4_read ();
ced63ec0 2383
d777bf0d 2384extern bool target_supports_memory_tagging ();
dbe692af 2385
d777bf0d
SM
2386extern bool target_fetch_memtags (CORE_ADDR address, size_t len,
2387 gdb::byte_vector &tags, int type);
dbe692af 2388
d777bf0d
SM
2389extern bool target_store_memtags (CORE_ADDR address, size_t len,
2390 const gdb::byte_vector &tags, int type);
dbe692af 2391
7202f41f
GR
2392extern bool target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address);
2393
a388ab0b
JB
2394extern x86_xsave_layout target_fetch_x86_xsave_layout ();
2395
49d03eab
MR
2396/* Command logging facility. */
2397
d777bf0d 2398extern void target_log_command (const char *p);
dc146f7c
VP
2399
2400extern int target_core_of_thread (ptid_t ptid);
2401
ea001bdc
MM
2402/* See to_get_unwinder in struct target_ops. */
2403extern const struct frame_unwind *target_get_unwinder (void);
2404
2405/* See to_get_tailcall_unwinder in struct target_ops. */
2406extern const struct frame_unwind *target_get_tailcall_unwinder (void);
2407
936d2992
PA
2408/* This implements basic memory verification, reading target memory
2409 and performing the comparison here (as opposed to accelerated
2410 verification making use of the qCRC packet, for example). */
2411
2412extern int simple_verify_memory (struct target_ops* ops,
2413 const gdb_byte *data,
2414 CORE_ADDR memaddr, ULONGEST size);
2415
4a5e7a5b
PA
2416/* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range matches
2417 the contents of [DATA,DATA+SIZE). Returns 1 if there's a match, 0
2418 if there's a mismatch, and -1 if an error is encountered while
2419 reading memory. Throws an error if the functionality is found not
2420 to be supported by the current target. */
2421int target_verify_memory (const gdb_byte *data,
2422 CORE_ADDR memaddr, ULONGEST size);
2423
c906108c
SS
2424/* Routines for maintenance of the target structures...
2425
2426 add_target: Add a target to the list of all possible targets.
3156469c
JB
2427 This only makes sense for targets that should be activated using
2428 the "target TARGET_NAME ..." command.
c906108c
SS
2429
2430 push_target: Make this target the top of the stack of currently used
c5aa993b
JM
2431 targets, within its particular stratum of the stack. Result
2432 is 0 if now atop the stack, nonzero if not on top (maybe
2433 should warn user).
c906108c
SS
2434
2435 unpush_target: Remove this from the stack of currently used targets,
c5aa993b 2436 no matter where it is on the list. Returns 0 if no
7fdc1521 2437 change, 1 if removed from stack. */
c906108c 2438
d9f719f1
PA
2439/* Type of callback called when the user activates a target with
2440 "target TARGET_NAME". The callback routine takes the rest of the
2441 parameters from the command, and (if successful) pushes a new
2442 target onto the stack. */
2443typedef void target_open_ftype (const char *args, int from_tty);
2444
2445/* Add the target described by INFO to the list of possible targets
2446 and add a new command 'target $(INFO->shortname)'. Set COMPLETER
2447 as the command's completer if not NULL. */
c906108c 2448
d9f719f1
PA
2449extern void add_target (const target_info &info,
2450 target_open_ftype *func,
2451 completer_ftype *completer = NULL);
9852c492 2452
d9f719f1
PA
2453/* Adds a command ALIAS for the target described by INFO and marks it
2454 deprecated. This is useful for maintaining backwards compatibility
2455 when renaming targets. */
b48d48eb 2456
d9f719f1 2457extern void add_deprecated_target_alias (const target_info &info,
a121b7c1 2458 const char *alias);
b48d48eb 2459
de146e19
SM
2460/* A unique_ptr helper to unpush a target. */
2461
2462struct target_unpusher
2463{
fadf6add 2464 void operator() (struct target_ops *ops) const;
de146e19
SM
2465};
2466
2467/* A unique_ptr that unpushes a target on destruction. */
2468
2469typedef std::unique_ptr<struct target_ops, target_unpusher> target_unpush_up;
2470
89dc60d9 2471extern void target_pre_inferior ();
fd79ecee 2472
a14ed312 2473extern void target_preopen (int);
c906108c 2474
8b87fe90
KB
2475/* Using the objfile specified in OBJFILE, find the address for the
2476 current thread's thread-local storage with offset OFFSET. If it's
2477 provided, NAME might be used to indicate the relevant variable
2478 in an error message. */
2479
9e35dae4 2480extern CORE_ADDR target_translate_tls_address (struct objfile *objfile,
8b87fe90
KB
2481 CORE_ADDR offset,
2482 const char *name = nullptr);
9e35dae4 2483
8db32d44 2484/* Return the "section" containing the specified address. */
19cf757a
AB
2485const struct target_section *target_section_by_addr (struct target_ops *target,
2486 CORE_ADDR addr);
8db32d44 2487
07b82ea5
PA
2488/* Return the target section table this target (or the targets
2489 beneath) currently manipulate. */
2490
25b5a04e 2491extern const std::vector<target_section> *target_get_section_table
07b82ea5
PA
2492 (struct target_ops *target);
2493
336aa7b7
AB
2494/* Default implementation of get_section_table for dummy_target. */
2495
25b5a04e 2496extern const std::vector<target_section> *default_get_section_table ();
336aa7b7 2497
c906108c
SS
2498/* From mem-break.c */
2499
f6ac5f3d
PA
2500extern int memory_remove_breakpoint (struct target_ops *,
2501 struct gdbarch *, struct bp_target_info *,
73971819 2502 enum remove_bp_reason);
c906108c 2503
f6ac5f3d
PA
2504extern int memory_insert_breakpoint (struct target_ops *,
2505 struct gdbarch *, struct bp_target_info *);
2506
2507/* Convenience template use to add memory breakpoints support to a
2508 target. */
2509
2510template <typename BaseTarget>
2511struct memory_breakpoint_target : public BaseTarget
2512{
2513 int insert_breakpoint (struct gdbarch *gdbarch,
2514 struct bp_target_info *bp_tgt) override
2515 { return memory_insert_breakpoint (this, gdbarch, bp_tgt); }
2516
2517 int remove_breakpoint (struct gdbarch *gdbarch,
2518 struct bp_target_info *bp_tgt,
2519 enum remove_bp_reason reason) override
2520 { return memory_remove_breakpoint (this, gdbarch, bp_tgt, reason); }
2521};
c906108c 2522
08351840
PA
2523/* Check whether the memory at the breakpoint's placed address still
2524 contains the expected breakpoint instruction. */
2525
2526extern int memory_validate_breakpoint (struct gdbarch *gdbarch,
2527 struct bp_target_info *bp_tgt);
2528
3e43a32a
MS
2529extern int default_memory_remove_breakpoint (struct gdbarch *,
2530 struct bp_target_info *);
917317f4 2531
3e43a32a
MS
2532extern int default_memory_insert_breakpoint (struct gdbarch *,
2533 struct bp_target_info *);
917317f4 2534
c906108c
SS
2535
2536/* From target.c */
2537
a14ed312 2538extern void initialize_targets (void);
c906108c 2539
d9deb60b 2540[[noreturn]] extern void noprocess (void);
c906108c 2541
8edfe269
DJ
2542extern void target_require_runnable (void);
2543
8b06beed
TT
2544/* Find the target at STRATUM. If no target is at that stratum,
2545 return NULL. */
2546
2547struct target_ops *find_target_at (enum strata stratum);
2548
9018be22
SM
2549/* Read OS data object of type TYPE from the target, and return it in XML
2550 format. The return value follows the same rules as target_read_stralloc. */
e0665bc8 2551
6b09f134 2552extern std::optional<gdb::char_vector> target_get_osdata (const char *type);
07e059b5 2553
c906108c
SS
2554/* Stuff that should be shared among the various remote targets. */
2555
c906108c 2556
c378eb4e 2557/* Timeout limit for response from target. */
c906108c
SS
2558extern int remote_timeout;
2559
c906108c 2560\f
c906108c 2561
cb85b21b
TT
2562/* Set the show memory breakpoints mode to show, and return a
2563 scoped_restore to restore it back to the current value. */
2564extern scoped_restore_tmpl<int>
2565 make_scoped_restore_show_memory_breakpoints (int show);
8defab1a 2566
358be6e7
TT
2567/* True if we should trust readonly sections from the
2568 executable when reading memory. */
2569extern bool trust_readonly;
2570
491144b5
CB
2571extern bool may_write_registers;
2572extern bool may_write_memory;
2573extern bool may_insert_breakpoints;
2574extern bool may_insert_tracepoints;
2575extern bool may_insert_fast_tracepoints;
2576extern bool may_stop;
d914c394
SS
2577
2578extern void update_target_permissions (void);
2579
c906108c 2580\f
c378eb4e 2581/* Imported from machine dependent code. */
c906108c 2582
02d27625 2583/* See to_enable_btrace in struct target_ops. */
f4abbc16 2584extern struct btrace_target_info *
696c0d5e 2585 target_enable_btrace (thread_info *tp, const struct btrace_config *);
02d27625
MM
2586
2587/* See to_disable_btrace in struct target_ops. */
2588extern void target_disable_btrace (struct btrace_target_info *btinfo);
2589
2590/* See to_teardown_btrace in struct target_ops. */
2591extern void target_teardown_btrace (struct btrace_target_info *btinfo);
2592
2593/* See to_read_btrace in struct target_ops. */
734b0e4b 2594extern enum btrace_error target_read_btrace (struct btrace_data *,
969c39fb
MM
2595 struct btrace_target_info *,
2596 enum btrace_read_type);
02d27625 2597
f4abbc16
MM
2598/* See to_btrace_conf in struct target_ops. */
2599extern const struct btrace_config *
2600 target_btrace_conf (const struct btrace_target_info *);
2601
7c1687a9
MM
2602/* See to_stop_recording in struct target_ops. */
2603extern void target_stop_recording (void);
2604
d02ed0bb 2605/* See to_save_record in struct target_ops. */
85e1311a 2606extern void target_save_record (const char *filename);
d02ed0bb
MM
2607
2608/* Query if the target supports deleting the execution log. */
2609extern int target_supports_delete_record (void);
2610
2611/* See to_delete_record in struct target_ops. */
2612extern void target_delete_record (void);
2613
b158a20f
TW
2614/* See to_record_method. */
2615extern enum record_method target_record_method (ptid_t ptid);
2616
d02ed0bb 2617/* See to_record_is_replaying in struct target_ops. */
a52eab48 2618extern int target_record_is_replaying (ptid_t ptid);
d02ed0bb 2619
7ff27e9b
MM
2620/* See to_record_will_replay in struct target_ops. */
2621extern int target_record_will_replay (ptid_t ptid, int dir);
2622
797094dd
MM
2623/* See to_record_stop_replaying in struct target_ops. */
2624extern void target_record_stop_replaying (void);
2625
d02ed0bb
MM
2626/* See to_goto_record_begin in struct target_ops. */
2627extern void target_goto_record_begin (void);
2628
2629/* See to_goto_record_end in struct target_ops. */
2630extern void target_goto_record_end (void);
2631
2632/* See to_goto_record in struct target_ops. */
2633extern void target_goto_record (ULONGEST insn);
02d27625 2634
67c86d06 2635/* See to_insn_history. */
9a24775b 2636extern void target_insn_history (int size, gdb_disassembly_flags flags);
67c86d06
MM
2637
2638/* See to_insn_history_from. */
9a24775b
PA
2639extern void target_insn_history_from (ULONGEST from, int size,
2640 gdb_disassembly_flags flags);
67c86d06
MM
2641
2642/* See to_insn_history_range. */
9a24775b
PA
2643extern void target_insn_history_range (ULONGEST begin, ULONGEST end,
2644 gdb_disassembly_flags flags);
67c86d06 2645
15984c13 2646/* See to_call_history. */
0cb7c7b0 2647extern void target_call_history (int size, record_print_flags flags);
15984c13
MM
2648
2649/* See to_call_history_from. */
0cb7c7b0
SM
2650extern void target_call_history_from (ULONGEST begin, int size,
2651 record_print_flags flags);
15984c13
MM
2652
2653/* See to_call_history_range. */
0cb7c7b0
SM
2654extern void target_call_history_range (ULONGEST begin, ULONGEST end,
2655 record_print_flags flags);
15984c13 2656
5fff78c4
MM
2657/* See to_prepare_to_generate_core. */
2658extern void target_prepare_to_generate_core (void);
2659
2660/* See to_done_generating_core. */
2661extern void target_done_generating_core (void);
2662
cc709640 2663#endif /* GDB_TARGET_H */