1 /* Interface between GDB and target environments, including files and processes
3 Copyright (C) 1990-2025 Free Software Foundation, Inc.
5 Contributed by Cygnus Support. Written by John Gilmore.
7 This file is part of GDB.
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
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
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.
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
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. */
52 struct bp_target_info
;
54 struct trace_state_variable
;
58 struct static_tracepoint_marker
;
59 struct traceframe_info
;
64 /* Define const gdb_byte using one identifier, to make it easy for
65 make-target-delegates.py to parse. */
66 typedef const gdb_byte const_gdb_byte
;
69 #include "breakpoint.h"
70 #include "gdbsupport/scoped_restore.h"
71 #include "gdbsupport/refcounted-object.h"
72 #include "target-section.h"
73 #include "target/target.h"
74 #include "target/resume.h"
75 #include "target/wait.h"
76 #include "target/waitstatus.h"
80 #include "gdbsupport/gdb_signals.h"
84 #include "disasm-flags.h"
85 #include "tracepoint.h"
86 #include "gdbsupport/fileio.h"
87 #include "gdbsupport/x86-xstate.h"
89 #include "gdbsupport/break-common.h"
93 dummy_stratum
, /* The lowest of the low */
94 file_stratum
, /* Executable files, etc */
95 process_stratum
, /* Executing processes or core dump files */
96 thread_stratum
, /* Executing threads */
97 record_stratum
, /* Support record debugging */
98 arch_stratum
, /* Architecture overrides */
99 debug_stratum
/* Target debug. Must be last. */
102 enum thread_control_capabilities
104 tc_none
= 0, /* Default: can't control thread execution. */
105 tc_schedlock
= 1, /* Can lock the thread scheduler. */
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.
112 It's also good to mention that its fields represent everything
113 that we currently know about a syscall in GDB. */
116 /* The syscall number. */
119 /* The syscall name. */
123 /* Return a pretty printed form of TARGET_OPTIONS. */
124 extern std::string
target_options_to_string (target_wait_flags target_options
);
126 /* Possible types of events that the inferior handler will have to
128 enum inferior_event_type
130 /* Process a normal inferior event which will result in target_wait
133 /* We are called to do stuff after the inferior stops. */
137 /* Target objects which can be transferred using target_read,
138 target_write, et cetera. */
142 /* AVR target specific transfer. See "avr-tdep.c" and "remote.c". */
144 /* Transfer up-to LEN bytes of memory starting at OFFSET. */
145 TARGET_OBJECT_MEMORY
,
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
,
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
153 TARGET_OBJECT_STACK_MEMORY
,
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
,
157 /* Kernel Unwind Table. See "ia64-tdep.c". */
158 TARGET_OBJECT_UNWIND_TABLE
,
159 /* Transfer auxiliary vector. */
161 /* StackGhost cookie. See "sparc-tdep.c". */
162 TARGET_OBJECT_WCOOKIE
,
163 /* Target memory map in XML format. */
164 TARGET_OBJECT_MEMORY_MAP
,
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. */
170 /* Available target-specific features, e.g. registers and coprocessors.
171 See "target-descriptions.c". ANNEX should never be empty. */
172 TARGET_OBJECT_AVAILABLE_FEATURES
,
173 /* Currently loaded libraries, in XML format. */
174 TARGET_OBJECT_LIBRARIES
,
175 /* Currently loaded libraries specific for SVR4 systems, in XML format. */
176 TARGET_OBJECT_LIBRARIES_SVR4
,
177 /* Currently loaded libraries specific to AIX systems, in XML format. */
178 TARGET_OBJECT_LIBRARIES_AIX
,
179 /* Get OS specific data. The ANNEX specifies the type (running
180 processes, etc.). The data being transferred is expected to follow
181 the DTD specified in features/osdata.dtd. */
182 TARGET_OBJECT_OSDATA
,
183 /* Extra signal info. Usually the contents of `siginfo_t' on unix
185 TARGET_OBJECT_SIGNAL_INFO
,
186 /* The list of threads that are being debugged. */
187 TARGET_OBJECT_THREADS
,
188 /* Collected static trace data. */
189 TARGET_OBJECT_STATIC_TRACE_DATA
,
190 /* Traceframe info, in XML format. */
191 TARGET_OBJECT_TRACEFRAME_INFO
,
192 /* Load maps for FDPIC systems. */
194 /* Darwin dynamic linker info data. */
195 TARGET_OBJECT_DARWIN_DYLD_INFO
,
196 /* OpenVMS Unwind Information Block. */
197 TARGET_OBJECT_OPENVMS_UIB
,
198 /* Branch trace data, in XML format. */
199 TARGET_OBJECT_BTRACE
,
200 /* Branch trace configuration, in XML format. */
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
206 TARGET_OBJECT_EXEC_FILE
,
207 /* FreeBSD virtual memory mappings. */
208 TARGET_OBJECT_FREEBSD_VMMAP
,
209 /* FreeBSD process strings. */
210 TARGET_OBJECT_FREEBSD_PS_STRINGS
,
211 /* Possible future objects: TARGET_OBJECT_FILE, ... */
214 /* Possible values returned by target_xfer_partial, etc. */
216 enum target_xfer_status
218 /* Some bytes are transferred. */
221 /* No further transfer is possible. */
224 /* The piece of the object requested is unavailable. */
225 TARGET_XFER_UNAVAILABLE
= 2,
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
230 TARGET_XFER_E_IO
= -1,
232 /* Keep list in sync with target_xfer_status_to_string. */
235 /* Return the string form of STATUS. */
238 target_xfer_status_to_string (enum target_xfer_status status
);
240 typedef enum target_xfer_status
241 target_xfer_partial_ftype (struct target_ops
*ops
,
242 enum target_object object
,
245 const gdb_byte
*writebuf
,
248 ULONGEST
*xfered_len
);
250 enum 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
);
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.
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
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. */
271 extern LONGEST
target_read (struct target_ops
*ops
,
272 enum target_object object
,
273 const char *annex
, gdb_byte
*buf
,
274 ULONGEST offset
, LONGEST len
);
276 struct memory_read_result
278 memory_read_result (ULONGEST begin_
, ULONGEST end_
,
279 gdb::unique_xmalloc_ptr
<gdb_byte
> &&data_
)
282 data (std::move (data_
))
286 ~memory_read_result () = default;
288 memory_read_result (memory_read_result
&&other
) = default;
290 DISABLE_COPY_AND_ASSIGN (memory_read_result
);
292 /* First address that was read. */
294 /* Past-the-end address. */
297 gdb::unique_xmalloc_ptr
<gdb_byte
> data
;
300 extern std::vector
<memory_read_result
> read_memory_robust
301 (struct target_ops
*ops
, const ULONGEST offset
, const LONGEST len
);
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
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. */
318 extern LONGEST
target_write (struct target_ops
*ops
,
319 enum target_object object
,
320 const char *annex
, const gdb_byte
*buf
,
321 ULONGEST offset
, LONGEST len
);
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
330 LONGEST
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 *),
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
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. */
346 extern std::optional
<gdb::byte_vector
> target_read_alloc
347 (struct target_ops
*ops
, enum target_object object
, const char *annex
);
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. */
356 extern std::optional
<gdb::char_vector
> target_read_stralloc
357 (struct target_ops
*ops
, enum target_object object
, const char *annex
);
359 /* See target_ops->to_xfer_partial. */
360 extern target_xfer_partial_ftype target_xfer_partial
;
362 /* Wrappers to target read/write that perform memory transfers. They
363 throw an error if the memory transfer fails.
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. */
369 extern void get_target_memory (struct target_ops
*ops
, CORE_ADDR addr
,
370 gdb_byte
*buf
, LONGEST len
);
371 extern ULONGEST
get_target_memory_unsigned (struct target_ops
*ops
,
372 CORE_ADDR addr
, int len
,
373 enum bfd_endian byte_order
);
375 struct thread_info
; /* fwd decl for parameter list below: */
377 /* The type of the callback to the to_async method. */
379 typedef void async_callback_ftype (enum inferior_event_type event_type
,
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. */
390 #define TARGET_DEBUG_PRINTER(FUNC)
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:
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
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.
404 3. TARGET_DEFAULT_RETURN. The argument is a C expression. The
405 base method returns this expression's value.
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. */
411 #define TARGET_DEFAULT_IGNORE()
412 #define TARGET_DEFAULT_NORETURN(ARG)
413 #define TARGET_DEFAULT_RETURN(ARG)
414 #define TARGET_DEFAULT_FUNC(ARG)
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. */
423 /* Name of this target. */
424 const char *shortname
;
426 /* Name for printing. */
427 const char *longname
;
429 /* Documentation. Does not include trailing newline, and starts
430 with a one-line description (probably similar to longname). */
436 Each inferior has a stack of these. See overall description at the
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.
448 Methods that traverse the stack have a TARGET_DEFAULT_XXX marker in
449 their declaration below. See the macros' description above, where
453 : public refcounted_object
455 /* Return this target's stratum. */
456 virtual strata
stratum () const = 0;
458 /* To the target under this one. */
459 target_ops
*beneath () const;
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. */
465 virtual ~target_ops () {}
467 /* Return a reference to this target's unique target_info
469 virtual const target_info
&info () const = 0;
471 /* Name this target type. */
472 const char *shortname () const
473 { return info ().shortname
; }
475 const char *longname () const
476 { return info ().longname
; }
478 /* Close the target. This is where the target can handle
479 teardown. Heap-allocated targets should delete themselves
481 virtual void close ();
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
486 target_ops::can_run method returns 1; in that case, it must push
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. */
491 virtual bool can_attach ();
492 virtual void attach (const char *, int);
493 virtual void post_attach (int)
494 TARGET_DEFAULT_IGNORE ();
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. */
501 virtual void detach (inferior
*, int)
502 TARGET_DEFAULT_IGNORE ();
504 virtual void disconnect (const char *, int)
505 TARGET_DEFAULT_NORETURN (tcomplain ());
506 virtual void resume (ptid_t
,
507 int TARGET_DEBUG_PRINTER (target_debug_print_step
),
509 TARGET_DEFAULT_NORETURN (noprocess ());
511 /* Ensure that all resumed threads are committed to the target.
513 See the description of
514 process_stratum_target::commit_resumed_state for more
516 virtual void commit_resumed ()
517 TARGET_DEFAULT_IGNORE ();
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
526 virtual ptid_t
wait (ptid_t
, struct target_waitstatus
*,
527 target_wait_flags options
)
528 TARGET_DEFAULT_FUNC (default_target_wait
);
529 virtual void fetch_registers (struct regcache
*, int)
530 TARGET_DEFAULT_IGNORE ();
531 virtual void store_registers (struct regcache
*, int)
532 TARGET_DEFAULT_NORETURN (noprocess ());
533 virtual void prepare_to_store (struct regcache
*)
534 TARGET_DEFAULT_NORETURN (noprocess ());
536 virtual void files_info ()
537 TARGET_DEFAULT_IGNORE ();
538 virtual int insert_breakpoint (struct gdbarch
*,
539 struct bp_target_info
*)
540 TARGET_DEFAULT_NORETURN (noprocess ());
541 virtual int remove_breakpoint (struct gdbarch
*,
542 struct bp_target_info
*,
543 enum remove_bp_reason
)
544 TARGET_DEFAULT_NORETURN (noprocess ());
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. */
555 virtual bool stopped_by_sw_breakpoint ()
556 TARGET_DEFAULT_RETURN (false);
557 /* Returns true if the above method is supported. */
558 virtual bool supports_stopped_by_sw_breakpoint ()
559 TARGET_DEFAULT_RETURN (false);
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. */
568 virtual bool stopped_by_hw_breakpoint ()
569 TARGET_DEFAULT_RETURN (false);
570 /* Returns true if the above method is supported. */
571 virtual bool supports_stopped_by_hw_breakpoint ()
572 TARGET_DEFAULT_RETURN (false);
574 virtual int can_use_hw_breakpoint (enum bptype
, int, int)
575 TARGET_DEFAULT_RETURN (0);
576 virtual int ranged_break_num_registers ()
577 TARGET_DEFAULT_RETURN (-1);
578 virtual int insert_hw_breakpoint (struct gdbarch
*,
579 struct bp_target_info
*)
580 TARGET_DEFAULT_RETURN (-1);
581 virtual int remove_hw_breakpoint (struct gdbarch
*,
582 struct bp_target_info
*)
583 TARGET_DEFAULT_RETURN (-1);
585 /* Documentation of what the two routines below are expected to do is
586 provided with the corresponding target_* macros. */
587 virtual int remove_watchpoint (CORE_ADDR
, int,
588 enum target_hw_bp_type
, struct expression
*)
589 TARGET_DEFAULT_RETURN (-1);
590 virtual int insert_watchpoint (CORE_ADDR
, int,
591 enum target_hw_bp_type
, struct expression
*)
592 TARGET_DEFAULT_RETURN (-1);
594 virtual int insert_mask_watchpoint (CORE_ADDR
, CORE_ADDR
,
595 enum target_hw_bp_type
)
596 TARGET_DEFAULT_RETURN (1);
597 virtual int remove_mask_watchpoint (CORE_ADDR
, CORE_ADDR
,
598 enum target_hw_bp_type
)
599 TARGET_DEFAULT_RETURN (1);
600 virtual bool stopped_by_watchpoint ()
601 TARGET_DEFAULT_RETURN (false);
602 virtual bool have_steppable_watchpoint ()
603 TARGET_DEFAULT_RETURN (false);
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)
607 TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range
);
609 /* Documentation of this routine is provided with the corresponding
611 virtual int region_ok_for_hw_watchpoint (CORE_ADDR
, int)
612 TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint
);
614 virtual bool can_accel_watchpoint_condition (CORE_ADDR
, int, int,
616 TARGET_DEFAULT_RETURN (false);
617 virtual int masked_watch_num_registers (CORE_ADDR
, CORE_ADDR
)
618 TARGET_DEFAULT_RETURN (-1);
620 /* Return 1 for sure target can do single step. Return -1 for
621 unknown. Return 0 for target can't do. */
622 virtual int can_do_single_step ()
623 TARGET_DEFAULT_RETURN (-1);
625 virtual bool supports_terminal_ours ()
626 TARGET_DEFAULT_RETURN (false);
627 virtual void terminal_init ()
628 TARGET_DEFAULT_IGNORE ();
629 virtual void terminal_inferior ()
630 TARGET_DEFAULT_IGNORE ();
631 virtual void terminal_save_inferior ()
632 TARGET_DEFAULT_IGNORE ();
633 virtual void terminal_ours_for_output ()
634 TARGET_DEFAULT_IGNORE ();
635 virtual void terminal_ours ()
636 TARGET_DEFAULT_IGNORE ();
637 virtual void terminal_info (const char *, int)
638 TARGET_DEFAULT_FUNC (default_terminal_info
);
640 TARGET_DEFAULT_NORETURN (noprocess ());
641 virtual void load (const char *, int)
642 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
648 virtual bool can_create_inferior ();
649 virtual void create_inferior (const char *, const std::string
&,
651 virtual int insert_fork_catchpoint (int)
652 TARGET_DEFAULT_RETURN (1);
653 virtual int remove_fork_catchpoint (int)
654 TARGET_DEFAULT_RETURN (1);
655 virtual int insert_vfork_catchpoint (int)
656 TARGET_DEFAULT_RETURN (1);
657 virtual int remove_vfork_catchpoint (int)
658 TARGET_DEFAULT_RETURN (1);
659 virtual void follow_fork (inferior
*, ptid_t
, target_waitkind
, bool, bool)
660 TARGET_DEFAULT_FUNC (default_follow_fork
);
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
);
668 virtual int insert_exec_catchpoint (int)
669 TARGET_DEFAULT_RETURN (1);
670 virtual int remove_exec_catchpoint (int)
671 TARGET_DEFAULT_RETURN (1);
672 virtual void follow_exec (inferior
*, ptid_t
, const char *)
673 TARGET_DEFAULT_IGNORE ();
674 virtual int set_syscall_catchpoint (int, bool, int,
675 gdb::array_view
<const int>)
676 TARGET_DEFAULT_RETURN (1);
677 virtual void mourn_inferior ()
678 TARGET_DEFAULT_FUNC (default_mourn_inferior
);
680 /* Note that can_run is special and can be invoked on an unpushed
681 target. Targets defining this method must also define
682 to_can_async_p and to_supports_non_stop. */
683 virtual bool can_run ();
685 /* Documentation of this routine is provided with the corresponding
687 virtual void pass_signals (gdb::array_view
<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals
))
688 TARGET_DEFAULT_IGNORE ();
690 /* Documentation of this routine is provided with the
691 corresponding target_* function. */
692 virtual void program_signals (gdb::array_view
<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals
))
693 TARGET_DEFAULT_IGNORE ();
695 virtual bool thread_alive (ptid_t ptid
)
696 TARGET_DEFAULT_RETURN (false);
697 virtual void update_thread_list ()
698 TARGET_DEFAULT_IGNORE ();
699 virtual std::string
pid_to_str (ptid_t
)
700 TARGET_DEFAULT_FUNC (default_pid_to_str
);
701 virtual const char *extra_thread_info (thread_info
*)
702 TARGET_DEFAULT_RETURN (NULL
);
703 virtual const char *thread_name (thread_info
*)
704 TARGET_DEFAULT_RETURN (NULL
);
705 virtual thread_info
*thread_handle_to_thread_info (const gdb_byte
*,
708 TARGET_DEFAULT_RETURN (NULL
);
709 /* See target_thread_info_to_thread_handle. */
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
> ());
712 virtual void stop (ptid_t
)
713 TARGET_DEFAULT_IGNORE ();
714 virtual void interrupt ()
715 TARGET_DEFAULT_IGNORE ();
716 virtual void pass_ctrlc ()
717 TARGET_DEFAULT_FUNC (default_target_pass_ctrlc
);
718 virtual void rcmd (const char *command
, struct ui_file
*output
)
719 TARGET_DEFAULT_FUNC (default_rcmd
);
720 virtual const char *pid_to_exec_file (int pid
)
721 TARGET_DEFAULT_RETURN (NULL
);
722 virtual void log_command (const char *)
723 TARGET_DEFAULT_IGNORE ();
724 virtual const std::vector
<target_section
> *get_section_table ()
725 TARGET_DEFAULT_RETURN (default_get_section_table ());
727 /* Provide default values for all "must have" methods. */
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; }
732 virtual bool has_execution (inferior
*inf
) { return false; }
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);
739 /* This method must be implemented in some situations. See the
740 comment on 'can_run'. */
741 virtual bool can_async_p ()
742 TARGET_DEFAULT_RETURN (false);
743 virtual bool is_async_p ()
744 TARGET_DEFAULT_RETURN (false);
745 virtual void async (bool)
746 TARGET_DEFAULT_NORETURN (tcomplain ());
747 virtual int async_wait_fd ()
748 TARGET_DEFAULT_NORETURN (noprocess ());
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);
758 virtual void thread_events (bool)
759 TARGET_DEFAULT_IGNORE ();
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);
764 /* This method must be implemented in some situations. See the
765 comment on 'can_run'. */
766 virtual bool supports_non_stop ()
767 TARGET_DEFAULT_RETURN (false);
768 /* Return true if the target operates in non-stop mode even with
769 "set non-stop off". */
770 virtual bool always_non_stop_p ()
771 TARGET_DEFAULT_RETURN (false);
772 /* find_memory_regions support method for gcore */
773 virtual int find_memory_regions (find_memory_region_ftype func
, void *data
)
774 TARGET_DEFAULT_FUNC (dummy_find_memory_regions
);
775 /* make_corefile_notes support method for gcore */
776 virtual gdb::unique_xmalloc_ptr
<char> make_corefile_notes (bfd
*, int *)
777 TARGET_DEFAULT_FUNC (dummy_make_corefile_notes
);
778 /* get_bookmark support method for bookmarks */
779 virtual gdb_byte
*get_bookmark (const char *, int)
780 TARGET_DEFAULT_NORETURN (tcomplain ());
781 /* goto_bookmark support method for bookmarks */
782 virtual void goto_bookmark (const gdb_byte
*, int)
783 TARGET_DEFAULT_NORETURN (tcomplain ());
784 /* Return the thread-local address at OFFSET in the
785 thread-local storage for the thread PTID and the shared library
786 or executable file given by LOAD_MODULE_ADDR. If that block of
787 thread-local storage hasn't been allocated yet, this function
788 may throw an error. LOAD_MODULE_ADDR may be zero for statically
789 linked multithreaded inferiors. */
790 virtual CORE_ADDR
get_thread_local_address (ptid_t ptid
,
791 CORE_ADDR load_module_addr
,
793 TARGET_DEFAULT_NORETURN (generic_tls_error ());
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
800 starting point. The ANNEX can be used to provide additional
801 data-specific information to the target.
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
814 Return the transferred status, error or OK (an
815 'enum target_xfer_status' value). Save the number of addressable units
816 actually transferred in *XFERED_LEN if transfer is successful
817 (TARGET_XFER_OK) or the number unavailable units if the requested
818 data is unavailable (TARGET_XFER_UNAVAILABLE). *XFERED_LEN
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.
823 The interface does not support a "retry" mechanism. Instead it
824 assumes that at least one addressable unit will be transferred on each
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.
835 See target_read and target_write for more information. One,
836 and only one, of readbuf or writebuf must be non-NULL. */
838 virtual enum target_xfer_status
xfer_partial (enum target_object object
,
841 const gdb_byte
*writebuf
,
842 ULONGEST offset
, ULONGEST len
,
843 ULONGEST
*xfered_len
)
844 TARGET_DEFAULT_RETURN (TARGET_XFER_E_IO
);
846 /* Return the limit on the size of any single memory transfer
849 virtual ULONGEST
get_memory_xfer_limit ()
850 TARGET_DEFAULT_RETURN (ULONGEST_MAX
);
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.
857 The order of regions does not matter; target_memory_map will
858 sort regions by starting address. For that reason, this
859 function should not be called directly except via
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. */
865 virtual std::vector
<mem_region
> memory_map ()
866 TARGET_DEFAULT_RETURN (std::vector
<mem_region
> ());
868 /* Erases the region of flash memory starting at ADDRESS, of
871 Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
872 on flash block boundaries, as reported by 'to_memory_map'. */
873 virtual void flash_erase (ULONGEST address
, LONGEST length
)
874 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
880 virtual void flash_done ()
881 TARGET_DEFAULT_NORETURN (tcomplain ());
883 /* Describe the architecture-specific features of the current
886 Returns the description found, or nullptr if no description was
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. */
894 virtual const struct target_desc
*read_description ()
895 TARGET_DEFAULT_RETURN (NULL
);
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. */
901 virtual ptid_t
get_ada_task_ptid (long lwp
, ULONGEST thread
)
902 TARGET_DEFAULT_FUNC (default_get_ada_task_ptid
);
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. */
908 virtual int auxv_parse (const gdb_byte
**readptr
,
909 const gdb_byte
*endptr
, CORE_ADDR
*typep
, CORE_ADDR
*valp
)
910 TARGET_DEFAULT_FUNC (default_auxv_parse
);
912 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
913 sequence of bytes in PATTERN with length PATTERN_LEN.
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. */
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
)
921 TARGET_DEFAULT_FUNC (default_search_memory
);
923 /* Can target execute in reverse? */
924 virtual bool can_execute_reverse ()
925 TARGET_DEFAULT_RETURN (false);
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. */
930 virtual enum exec_direction_kind
execution_direction ()
931 TARGET_DEFAULT_FUNC (default_execution_direction
);
933 /* Does this target support debugging multiple processes
935 virtual bool supports_multi_process ()
936 TARGET_DEFAULT_RETURN (false);
938 /* Does this target support enabling and disabling tracepoints while a trace
939 experiment is running? */
940 virtual bool supports_enable_disable_tracepoint ()
941 TARGET_DEFAULT_RETURN (false);
943 /* Does this target support disabling address space randomization? */
944 virtual bool supports_disable_randomization ()
945 TARGET_DEFAULT_FUNC (find_default_supports_disable_randomization
);
947 /* Does this target support the tracenz bytecode for string collection? */
948 virtual bool supports_string_tracing ()
949 TARGET_DEFAULT_RETURN (false);
951 /* Does this target support evaluation of breakpoint conditions on its
953 virtual bool supports_evaluation_of_breakpoint_conditions ()
954 TARGET_DEFAULT_RETURN (false);
956 /* Does this target support native dumpcore API? */
957 virtual bool supports_dumpcore ()
958 TARGET_DEFAULT_RETURN (false);
960 /* Generate the core file with native target API. */
961 virtual void dumpcore (const char *filename
)
962 TARGET_DEFAULT_IGNORE ();
964 /* Does this target support evaluation of breakpoint commands on its
966 virtual bool can_run_breakpoint_commands ()
967 TARGET_DEFAULT_RETURN (false);
969 /* Determine current architecture of thread PTID.
971 The target is supposed to determine the architecture of the code where
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
975 operate according to the current inferior's gdbarch. */
976 virtual struct gdbarch
*thread_architecture (ptid_t
)
977 TARGET_DEFAULT_RETURN (NULL
);
979 /* Target file operations. */
981 /* Return true if the filesystem seen by the current inferior
982 is the local filesystem, false otherwise. */
983 virtual bool filesystem_is_local ()
984 TARGET_DEFAULT_RETURN (true);
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).
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
993 virtual int fileio_open (struct inferior
*inf
, const char *filename
,
994 int flags
, int mode
, int warn_if_slow
,
995 fileio_error
*target_errno
);
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). */
1000 virtual int fileio_pwrite (int fd
, const gdb_byte
*write_buf
, int len
,
1001 ULONGEST offset
, fileio_error
*target_errno
);
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). */
1006 virtual int fileio_pread (int fd
, gdb_byte
*read_buf
, int len
,
1007 ULONGEST offset
, fileio_error
*target_errno
);
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
1012 virtual int fileio_fstat (int fd
, struct stat
*sb
, fileio_error
*target_errno
);
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). */
1019 virtual int fileio_lstat (struct inferior
*inf
, const char *filename
,
1020 struct stat
*sb
, fileio_error
*target_errno
);
1022 /* Close FD on the target. Return 0, or -1 if an error occurs
1023 (and set *TARGET_ERRNO). */
1024 virtual int fileio_close (int fd
, fileio_error
*target_errno
);
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). */
1030 virtual int fileio_unlink (struct inferior
*inf
,
1031 const char *filename
,
1032 fileio_error
*target_errno
);
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
1037 stub). Return a string, or an empty optional if an error
1038 occurs (and set *TARGET_ERRNO). */
1039 virtual std::optional
<std::string
> fileio_readlink (struct inferior
*inf
,
1040 const char *filename
,
1041 fileio_error
*target_errno
);
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
);
1047 /* Tracepoint-related operations. */
1049 /* Prepare the target for a tracing run. */
1050 virtual void trace_init ()
1051 TARGET_DEFAULT_NORETURN (tcomplain ());
1053 /* Send full details of a tracepoint location to the target. */
1054 virtual void download_tracepoint (struct bp_location
*location
)
1055 TARGET_DEFAULT_NORETURN (tcomplain ());
1057 /* Is the target able to download tracepoint locations in current
1059 virtual bool can_download_tracepoint ()
1060 TARGET_DEFAULT_RETURN (false);
1062 /* Send full details of a trace state variable to the target. */
1063 virtual void download_trace_state_variable (const trace_state_variable
&tsv
)
1064 TARGET_DEFAULT_NORETURN (tcomplain ());
1066 /* Enable a tracepoint on the target. */
1067 virtual void enable_tracepoint (struct bp_location
*location
)
1068 TARGET_DEFAULT_NORETURN (tcomplain ());
1070 /* Disable a tracepoint on the target. */
1071 virtual void disable_tracepoint (struct bp_location
*location
)
1072 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
1077 virtual void trace_set_readonly_regions ()
1078 TARGET_DEFAULT_NORETURN (tcomplain ());
1080 /* Start a trace run. */
1081 virtual void trace_start ()
1082 TARGET_DEFAULT_NORETURN (tcomplain ());
1084 /* Get the current status of a tracing run. */
1085 virtual int get_trace_status (struct trace_status
*ts
)
1086 TARGET_DEFAULT_RETURN (-1);
1088 virtual void get_tracepoint_status (tracepoint
*tp
,
1089 struct uploaded_tp
*utp
)
1090 TARGET_DEFAULT_NORETURN (tcomplain ());
1092 /* Stop a trace run. */
1093 virtual void trace_stop ()
1094 TARGET_DEFAULT_NORETURN (tcomplain ());
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
1099 TPP. If no trace frame matches, return -1. May throw if the
1101 virtual int trace_find (enum trace_find_type type
, int num
,
1102 CORE_ADDR addr1
, CORE_ADDR addr2
, int *tpp
)
1103 TARGET_DEFAULT_RETURN (-1);
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. */
1108 virtual bool get_trace_state_variable_value (int tsv
, LONGEST
*val
)
1109 TARGET_DEFAULT_RETURN (false);
1111 virtual int save_trace_data (const char *filename
)
1112 TARGET_DEFAULT_NORETURN (tcomplain ());
1114 virtual int upload_tracepoints (struct uploaded_tp
**utpp
)
1115 TARGET_DEFAULT_RETURN (0);
1117 virtual int upload_trace_state_variables (struct uploaded_tsv
**utsvp
)
1118 TARGET_DEFAULT_RETURN (0);
1120 virtual LONGEST
get_raw_trace_data (gdb_byte
*buf
,
1121 ULONGEST offset
, LONGEST len
)
1122 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
1128 virtual int get_min_fast_tracepoint_insn_len ()
1129 TARGET_DEFAULT_RETURN (-1);
1131 /* Set the target's tracing behavior in response to unexpected
1132 disconnection - set VAL to 1 to keep tracing, 0 to stop. */
1133 virtual void set_disconnected_tracing (int val
)
1134 TARGET_DEFAULT_IGNORE ();
1135 virtual void set_circular_trace_buffer (int val
)
1136 TARGET_DEFAULT_IGNORE ();
1137 /* Set the size of trace buffer in the target. */
1138 virtual void set_trace_buffer_size (LONGEST val
)
1139 TARGET_DEFAULT_IGNORE ();
1141 /* Add/change textual notes about the trace run, returning true if
1142 successful, false otherwise. */
1143 virtual bool set_trace_notes (const char *user
, const char *notes
,
1144 const char *stopnotes
)
1145 TARGET_DEFAULT_RETURN (false);
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
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. */
1154 virtual int core_of_thread (ptid_t ptid
)
1155 TARGET_DEFAULT_RETURN (-1);
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. */
1161 virtual int verify_memory (const gdb_byte
*data
,
1162 CORE_ADDR memaddr
, ULONGEST size
)
1163 TARGET_DEFAULT_FUNC (default_verify_memory
);
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
1169 ADDR may be nullptr, in which case the checks will be done but
1170 the result will be discarded. */
1171 virtual bool get_tib_address (ptid_t ptid
, CORE_ADDR
*addr
)
1172 TARGET_DEFAULT_NORETURN (tcomplain ());
1174 /* Send the new settings of write permission variables. */
1175 virtual void set_permissions ()
1176 TARGET_DEFAULT_IGNORE ();
1178 /* Look for a static tracepoint marker at ADDR, and fill in MARKER
1179 with its details. Return true on success, false on failure. */
1180 virtual bool static_tracepoint_marker_at (CORE_ADDR
,
1181 static_tracepoint_marker
*marker
)
1182 TARGET_DEFAULT_RETURN (false);
1184 /* Return a vector of all tracepoints markers string id ID, or all
1185 markers if ID is NULL. */
1186 virtual std::vector
<static_tracepoint_marker
>
1187 static_tracepoint_markers_by_strid (const char *id
)
1188 TARGET_DEFAULT_NORETURN (tcomplain ());
1190 /* Return a traceframe info object describing the current
1191 traceframe's contents. This method should not cache data;
1192 higher layers take care of caching, invalidating, and
1193 re-fetching when necessary. */
1194 virtual traceframe_info_up
traceframe_info ()
1195 TARGET_DEFAULT_NORETURN (tcomplain ());
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
)
1200 TARGET_DEFAULT_NORETURN (tcomplain ());
1202 /* Is the target able to use agent in current state? */
1203 virtual bool can_use_agent ()
1204 TARGET_DEFAULT_RETURN (false);
1206 /* Enable branch tracing for TP using CONF configuration.
1207 Return a branch trace target information struct for reading and for
1208 disabling branch trace. */
1209 virtual struct btrace_target_info
*enable_btrace (thread_info
*tp
,
1210 const struct btrace_config
*conf
)
1211 TARGET_DEFAULT_NORETURN (tcomplain ());
1213 /* Disable branch tracing and deallocate TINFO. */
1214 virtual void disable_btrace (struct btrace_target_info
*tinfo
)
1215 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
1221 virtual void teardown_btrace (struct btrace_target_info
*tinfo
)
1222 TARGET_DEFAULT_NORETURN (tcomplain ());
1224 /* Read branch trace data for the thread indicated by BTINFO into DATA.
1225 DATA is cleared before new trace is added. */
1226 virtual enum btrace_error
read_btrace (struct btrace_data
*data
,
1227 struct btrace_target_info
*btinfo
,
1228 enum btrace_read_type type
)
1229 TARGET_DEFAULT_NORETURN (tcomplain ());
1231 /* Get the branch trace configuration. */
1232 virtual const struct btrace_config
*btrace_conf (const struct btrace_target_info
*)
1233 TARGET_DEFAULT_RETURN (NULL
);
1235 /* Current recording method. */
1236 virtual enum record_method
record_method (ptid_t ptid
)
1237 TARGET_DEFAULT_RETURN (RECORD_METHOD_NONE
);
1239 /* Stop trace recording. */
1240 virtual void stop_recording ()
1241 TARGET_DEFAULT_IGNORE ();
1243 /* Print information about the recording. */
1244 virtual void info_record ()
1245 TARGET_DEFAULT_IGNORE ();
1247 /* Save the recorded execution trace into a file. */
1248 virtual void save_record (const char *filename
)
1249 TARGET_DEFAULT_NORETURN (tcomplain ());
1251 /* Delete the recorded execution trace from the current position
1253 virtual bool supports_delete_record ()
1254 TARGET_DEFAULT_RETURN (false);
1255 virtual void delete_record ()
1256 TARGET_DEFAULT_NORETURN (tcomplain ());
1258 /* Query if the record target is currently replaying PTID. */
1259 virtual bool record_is_replaying (ptid_t ptid
)
1260 TARGET_DEFAULT_RETURN (false);
1262 /* Query if the record target will replay PTID if it were resumed in
1263 execution direction DIR. */
1264 virtual bool record_will_replay (ptid_t ptid
, int dir
)
1265 TARGET_DEFAULT_RETURN (false);
1267 /* Stop replaying. */
1268 virtual void record_stop_replaying ()
1269 TARGET_DEFAULT_IGNORE ();
1271 /* Go to the begin of the execution trace. */
1272 virtual void goto_record_begin ()
1273 TARGET_DEFAULT_NORETURN (tcomplain ());
1275 /* Go to the end of the execution trace. */
1276 virtual void goto_record_end ()
1277 TARGET_DEFAULT_NORETURN (tcomplain ());
1279 /* Go to a specific location in the recorded execution trace. */
1280 virtual void goto_record (ULONGEST insn
)
1281 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
1287 virtual void insn_history (int size
, gdb_disassembly_flags flags
)
1288 TARGET_DEFAULT_NORETURN (tcomplain ());
1290 /* Disassemble SIZE instructions in the recorded execution trace around
1292 If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
1293 disassemble SIZE instructions after FROM. */
1294 virtual void insn_history_from (ULONGEST from
, int size
,
1295 gdb_disassembly_flags flags
)
1296 TARGET_DEFAULT_NORETURN (tcomplain ());
1298 /* Disassemble a section of the recorded execution trace from instruction
1299 BEGIN (inclusive) to instruction END (inclusive). */
1300 virtual void insn_history_range (ULONGEST begin
, ULONGEST end
,
1301 gdb_disassembly_flags flags
)
1302 TARGET_DEFAULT_NORETURN (tcomplain ());
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. */
1307 virtual void call_history (int size
, record_print_flags flags
)
1308 TARGET_DEFAULT_NORETURN (tcomplain ());
1310 /* Print a function trace of the recorded execution trace starting
1312 If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
1313 SIZE functions after FROM. */
1314 virtual void call_history_from (ULONGEST begin
, int size
, record_print_flags flags
)
1315 TARGET_DEFAULT_NORETURN (tcomplain ());
1317 /* Print a function trace of an execution trace section from function BEGIN
1318 (inclusive) to function END (inclusive). */
1319 virtual void call_history_range (ULONGEST begin
, ULONGEST end
, record_print_flags flags
)
1320 TARGET_DEFAULT_NORETURN (tcomplain ());
1322 /* True if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
1324 virtual bool augmented_libraries_svr4_read ()
1325 TARGET_DEFAULT_RETURN (false);
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. */
1330 virtual const struct frame_unwind
*get_unwinder ()
1331 TARGET_DEFAULT_RETURN (NULL
);
1333 virtual const struct frame_unwind
*get_tailcall_unwinder ()
1334 TARGET_DEFAULT_RETURN (NULL
);
1336 /* Prepare to generate a core file. */
1337 virtual void prepare_to_generate_core ()
1338 TARGET_DEFAULT_IGNORE ();
1340 /* Cleanup after generating a core file. */
1341 virtual void done_generating_core ()
1342 TARGET_DEFAULT_IGNORE ();
1344 /* Returns true if the target supports memory tagging, false otherwise. */
1345 virtual bool supports_memory_tagging ()
1346 TARGET_DEFAULT_RETURN (false);
1348 /* Return the allocated memory tags of type TYPE associated with
1349 [ADDRESS, ADDRESS + LEN) in TAGS.
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.
1354 It is up to the architecture/target to interpret the bytes in the TAGS
1355 vector and read the tags appropriately.
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 ());
1362 /* Write the allocation tags of type TYPE contained in TAGS to the memory
1363 range [ADDRESS, ADDRESS + LEN).
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.
1368 It is up to the architecture/target to interpret the bytes in the TAGS
1369 vector and store them appropriately.
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 ());
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 ());
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 ());
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
);
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
);
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
);
1398 /* See documentation of gdbarch_displaced_step_restore_all_in_ptid. */
1399 virtual void displaced_step_restore_all_in_ptid (inferior
*parent_inf
,
1401 TARGET_DEFAULT_FUNC (default_displaced_step_restore_all_in_ptid
);
1404 /* Deleter for std::unique_ptr. See comments in
1405 target_ops::~target_ops and target_ops::close about heap-allocated
1407 struct target_ops_deleter
1409 void operator() (target_ops
*target
)
1415 /* A unique pointer for target_ops. */
1416 typedef std::unique_ptr
<target_ops
, target_ops_deleter
> target_ops_up
;
1418 /* A policy class to interface gdb::ref_ptr with target_ops. */
1420 struct target_ops_ref_policy
1422 static void incref (target_ops
*t
)
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
);
1432 /* A gdb::ref_ptr pointer to a target_ops. */
1433 typedef gdb::ref_ptr
<target_ops
, target_ops_ref_policy
> target_ops_ref
;
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. */
1438 extern void set_native_target (target_ops
*target
);
1440 /* Get the registered native target, if there's one. Otherwise return
1442 extern target_ops
*get_native_target ();
1444 /* Type that manages a target stack. See description of target stacks
1445 and strata at the top of the file. */
1450 target_stack () = default;
1451 DISABLE_COPY_AND_ASSIGN (target_stack
);
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
);
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
);
1461 /* Returns true if T is pushed on the target stack. */
1462 bool is_pushed (const target_ops
*t
) const
1463 { return at (t
->stratum ()) == t
; }
1465 /* Return the target at STRATUM. */
1466 target_ops
*at (strata stratum
) const { return m_stack
[stratum
].get (); }
1468 /* Return the target at the top of the stack. */
1469 target_ops
*top () const { return at (m_top
); }
1471 /* Find the next target down the stack from the specified target. */
1472 target_ops
*find_beneath (const target_ops
*t
) const;
1475 /* The stratum of the top target. */
1476 enum strata m_top
{};
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
1481 std::array
<target_ops_ref
, (int) debug_stratum
+ 1> m_stack
;
1484 /* Return the dummy target. */
1485 extern target_ops
*get_dummy_target ();
1487 /* Define easy words for doing these operations on our current target. */
1489 extern const char *target_shortname ();
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. */
1495 extern struct target_ops
*find_attach_target (void);
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. */
1501 extern struct target_ops
*find_run_target (void);
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. */
1507 extern bool target_attach_no_wait ();
1509 /* The target_attach operation places a process under debugger control,
1510 and stops the process.
1512 This operation provides a target-specific hook that allows the
1513 necessary bookkeeping to be performed after an attach completes. */
1515 extern void target_post_attach (int pid
);
1517 /* Display a message indicating we're about to attach to a given
1520 extern void target_announce_attach (int from_tty
, int pid
);
1522 /* Display a message indicating we're about to detach from the current
1523 inferior process. */
1525 extern void target_announce_detach (int from_tty
);
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
1530 in the program or it'll die when it hits one. FROM_TTY says whether to be
1533 extern void target_detach (inferior
*inf
, int from_tty
);
1535 /* Disconnect from the current target without resuming it (leaving it
1536 waiting for a debugger). */
1538 extern void target_disconnect (const char *, int);
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.
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
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.
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. */
1564 extern void target_resume (ptid_t scope_ptid
,
1565 int step
, enum gdb_signal signal
);
1567 /* Ensure that all resumed threads are committed to the target.
1569 See the description of process_stratum_target::commit_resumed_state
1570 for more details. */
1571 extern void target_commit_resumed ();
1573 /* For target_read_memory see target/target.h. */
1575 /* The default target_ops::to_wait implementation. */
1577 extern ptid_t
default_target_wait (struct target_ops
*ops
,
1579 struct target_waitstatus
*status
,
1580 target_wait_flags options
);
1582 /* Return true if the target has pending events to report to the core.
1583 See target_ops::has_pending_events(). */
1585 extern bool target_has_pending_events ();
1587 /* Fetch at least register REGNO, or all regs if regno == -1. No result. */
1589 extern void target_fetch_registers (struct regcache
*regcache
, int regno
);
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. */
1595 extern void target_store_registers (struct regcache
*regcache
, int regs
);
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
1603 extern void target_prepare_to_store (regcache
*regcache
);
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
1610 int target_info_proc (const char *, enum info_proc_what
);
1612 /* Returns true if this target can disable address space randomization. */
1614 int target_supports_disable_randomization (void);
1616 /* Returns true if this target can enable and disable tracepoints
1617 while a trace experiment is running. */
1619 extern bool target_supports_enable_disable_tracepoint ();
1621 extern bool target_supports_string_tracing ();
1623 /* Returns true if this target can handle breakpoint conditions
1626 extern bool target_supports_evaluation_of_breakpoint_conditions ();
1628 /* Does this target support dumpcore API? */
1630 extern bool target_supports_dumpcore ();
1632 /* Generate the core file with target API. */
1634 extern void target_dumpcore (const char *filename
);
1636 /* Returns true if this target can handle breakpoint commands
1639 extern bool target_can_run_breakpoint_commands ();
1641 /* For target_read_memory see target/target.h. */
1643 extern int target_read_raw_memory (CORE_ADDR memaddr
, gdb_byte
*myaddr
,
1646 extern int target_read_stack (CORE_ADDR memaddr
, gdb_byte
*myaddr
, ssize_t len
);
1648 extern int target_read_code (CORE_ADDR memaddr
, gdb_byte
*myaddr
, ssize_t len
);
1650 /* For target_write_memory see target/target.h. */
1652 extern int target_write_raw_memory (CORE_ADDR memaddr
, const gdb_byte
*myaddr
,
1655 /* Fetches the target's memory map. If one is found it is sorted
1656 and returned, after some consistency checking. Otherwise, NULL
1658 std::vector
<mem_region
> target_memory_map (void);
1660 /* Erases all flash memory regions on the target. */
1661 void flash_erase_command (const char *cmd
, int from_tty
);
1663 /* Erase the specified flash region. */
1664 void target_flash_erase (ULONGEST address
, LONGEST length
);
1666 /* Finish a sequence of flash operations. */
1667 void target_flash_done (void);
1669 /* Describes a request for a memory write operation. */
1670 struct memory_write_request
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_
)
1677 /* Beginning address that must be written. */
1679 /* Past-the-end address. */
1681 /* The data to write. */
1683 /* A callback baton for progress reporting for this request. */
1687 /* Enumeration specifying different flash preservation behavior. */
1688 enum flash_preserve_mode
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.
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.
1702 REQUESTS is the vector of memory_write_request.
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.
1710 The function returns 0 on success, and error otherwise. */
1711 int 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 *));
1716 /* Print a line about the current target. */
1718 extern void target_files_info ();
1720 /* Insert a breakpoint at address BP_TGT->placed_address in
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. */
1725 extern int target_insert_breakpoint (struct gdbarch
*gdbarch
,
1726 struct bp_target_info
*bp_tgt
);
1728 /* Remove a breakpoint at address BP_TGT->placed_address in the target
1729 machine. Result is 0 for success, non-zero for error. */
1731 extern int target_remove_breakpoint (struct gdbarch
*gdbarch
,
1732 struct bp_target_info
*bp_tgt
,
1733 enum remove_bp_reason reason
);
1735 /* Return true if the target stack has a non-default
1736 "terminal_ours" method. */
1738 extern bool target_supports_terminal_ours (void);
1740 /* Kill the inferior process. Make it go away. */
1742 extern void target_kill (void);
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
1746 update GDB's symbol tables to match.
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. */
1755 extern void target_load (const char *arg
, int from_tty
);
1757 /* On some targets, we can catch an inferior fork or vfork event when
1758 it occurs. These functions insert/remove an already-created
1759 catchpoint for such events. They return 0 for success, 1 if the
1760 catchpoint type is not supported and -1 for failure. */
1762 extern int target_insert_fork_catchpoint (int pid
);
1764 extern int target_remove_fork_catchpoint (int pid
);
1766 extern int target_insert_vfork_catchpoint (int pid
);
1768 extern int target_remove_vfork_catchpoint (int pid
);
1770 /* Call the follow_fork method on the current target stack.
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. */
1776 void target_follow_fork (inferior
*inf
, ptid_t child_ptid
,
1777 target_waitkind fork_kind
, bool follow_child
,
1780 /* Handle the target-specific bookkeeping required when the inferior makes an
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.
1790 On exit, the target must leave FOLLOW_INF as the current inferior. */
1792 void target_follow_exec (inferior
*follow_inf
, ptid_t ptid
,
1793 const char *execd_pathname
);
1795 /* On some targets, we can catch an inferior exec event when it
1796 occurs. These functions insert/remove an already-created
1797 catchpoint for such events. They return 0 for success, 1 if the
1798 catchpoint type is not supported and -1 for failure. */
1800 extern int target_insert_exec_catchpoint (int pid
);
1802 extern int target_remove_exec_catchpoint (int pid
);
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
1808 catch system calls because there are no more catchpoints of this type.
1810 ANY_COUNT is nonzero if a generic (filter-less) syscall catch is
1811 being requested. In this case, SYSCALL_COUNTS should be ignored.
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.
1817 Return 0 for success, 1 if syscall catchpoints are not supported or -1
1820 extern int target_set_syscall_catchpoint
1821 (int pid
, bool needed
, int any_count
,
1822 gdb::array_view
<const int> syscall_counts
);
1824 /* The debugger has completed a blocking wait() call. There is now
1825 some process event that must be processed. This function should
1826 be defined by those targets that require the debugger to perform
1827 cleanup or internal state changes in response to the process event. */
1829 /* For target_mourn_inferior see target/target.h. */
1831 /* Does target have enough data to do a run or attach command? */
1833 extern int target_can_run ();
1835 /* Set list of signals to be handled in the target.
1837 PASS_SIGNALS is an array indexed by target signal number
1838 (enum gdb_signal). For every signal whose entry in this array is
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.
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. */
1847 extern void target_pass_signals
1848 (gdb::array_view
<const unsigned char> pass_signals
);
1850 /* Set list of signals the target may pass to the inferior. This
1851 directly maps to the "handle SIGNAL pass/nopass" setting.
1853 PROGRAM_SIGNALS is an array indexed by target signal
1854 number (enum gdb_signal). For every signal whose entry in this
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). */
1864 extern void target_program_signals
1865 (gdb::array_view
<const unsigned char> program_signals
);
1867 /* Check to see if a thread is still alive. */
1869 extern int target_thread_alive (ptid_t ptid
);
1871 /* Sync the target's threads with GDB's thread list. */
1873 extern void target_update_thread_list (void);
1875 /* Make target stop in a continuable fashion. (For instance, under
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. */
1881 extern void target_stop (ptid_t ptid
);
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. */
1888 extern void target_interrupt ();
1890 /* Pass a ^C, as determined to have been pressed by checking the quit
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. */
1896 extern void target_pass_ctrlc (void);
1898 /* The default target_ops::to_pass_ctrlc implementation. Simply calls
1899 target_interrupt. */
1900 extern void default_target_pass_ctrlc (struct target_ops
*ops
);
1902 /* Send the specified COMMAND to the target's monitor
1903 (shell,interpreter) for execution. The result of the query is
1904 placed in OUTBUF. */
1906 extern void target_rcmd (const char *command
, struct ui_file
*outbuf
);
1908 /* Does the target include memory? (Dummy targets don't.) */
1910 extern int target_has_memory ();
1912 /* Does the target have a stack? (Exec files don't, VxWorks doesn't, until
1913 we start a process.) */
1915 extern int target_has_stack ();
1917 /* Does the target have registers? (Exec files don't.) */
1919 extern int target_has_registers ();
1921 /* Does the target have execution? Can we make it jump (through
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
1926 case this will become true after to_create_inferior or
1927 to_attach. INF is the inferior to use; nullptr means to use the
1928 current inferior. */
1930 extern bool target_has_execution (inferior
*inf
= nullptr);
1932 /* Can the target support the debugger control of thread execution?
1933 Can it lock the thread scheduler? */
1935 extern bool target_can_lock_scheduler ();
1937 /* Controls whether async mode is permitted. */
1938 extern bool target_async_permitted
;
1940 /* Can the target support asynchronous execution? */
1941 extern bool target_can_async_p ();
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. */
1945 extern bool target_can_async_p (struct target_ops
*target
);
1947 /* Is the target in asynchronous execution mode? */
1948 extern bool target_is_async_p ();
1950 /* Enables/disabled async target events. */
1951 extern void target_async (bool enable
);
1953 /* Enables/disables thread create and exit events. */
1954 extern void target_thread_events (bool enable
);
1956 /* Returns true if the target supports setting thread options
1958 extern bool target_supports_set_thread_options (gdb_thread_options options
);
1960 /* Whether support for controlling the target backends always in
1961 non-stop mode is enabled. */
1962 extern enum auto_boolean target_non_stop_enabled
;
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
1967 extern bool target_is_non_stop_p ();
1969 /* Return true if at least one inferior has a non-stop target. */
1970 extern bool exists_non_stop_target ();
1972 extern exec_direction_kind
target_execution_direction ();
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'. */
1978 extern std::string
target_pid_to_str (ptid_t ptid
);
1980 extern std::string
normal_pid_to_str (ptid_t ptid
);
1982 /* Return a short string describing extra information about PID,
1983 e.g. "sleeping", "runnable", "running on LWP 3". Null return value
1986 extern const char *target_extra_thread_info (thread_info
*tp
);
1988 /* Return the thread's name, or NULL if the target is unable to determine it.
1989 The returned value must not be freed by the caller.
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. */
1994 extern const char *target_thread_name (struct thread_info
*);
1996 /* Given a pointer to a thread library specific thread handle and
1997 its length, return a pointer to the corresponding thread_info struct. */
1999 extern struct thread_info
*target_thread_handle_to_thread_info
2000 (const gdb_byte
*thread_handle
, int handle_len
, struct inferior
*inf
);
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
2005 extern gdb::array_view
<const gdb_byte
> target_thread_info_to_thread_handle
2006 (struct thread_info
*);
2008 /* Attempts to find the pathname of the executable file
2009 that was run to create a specified process.
2011 The process PID must be stopped when this operation is used.
2013 If the executable file cannot be determined, NULL is returned.
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
2020 extern const char *target_pid_to_exec_file (int pid
);
2022 /* See the to_thread_architecture description in struct target_ops. */
2024 extern gdbarch
*target_thread_architecture (ptid_t ptid
);
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
2030 * as a function macro so that it can be tested for nullity.
2033 extern int target_find_memory_regions (find_memory_region_ftype func
,
2037 * Compose corefile .note section.
2040 extern gdb::unique_xmalloc_ptr
<char> target_make_corefile_notes (bfd
*bfd
,
2043 /* Bookmark interfaces. */
2044 extern gdb_byte
*target_get_bookmark (const char *args
, int from_tty
);
2046 extern void target_goto_bookmark (const gdb_byte
*arg
, int from_tty
);
2048 /* Hardware watchpoint interfaces. */
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.
2053 Those are: continuable, steppable, and non-steppable.
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.
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.
2067 Now, in order to step past that instruction, depending on
2068 architecture and target, you can have two situations:
2070 - steppable watchpoints: you can single-step with the watchpoint
2071 still armed, and the watchpoint won't trigger again.
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.
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
2084 /* Returns true if we were stopped by a hardware watchpoint (memory read or
2085 write). Only the INFERIOR_PTID task is being queried. */
2087 extern bool target_stopped_by_watchpoint ();
2089 /* Returns true if the target stopped because it executed a
2090 software breakpoint instruction. */
2092 extern bool target_stopped_by_sw_breakpoint ();
2094 extern bool target_supports_stopped_by_sw_breakpoint ();
2096 extern bool target_stopped_by_hw_breakpoint ();
2098 extern bool target_supports_stopped_by_hw_breakpoint ();
2100 /* True if we have steppable watchpoints */
2102 extern bool target_have_steppable_watchpoint ();
2104 /* Provide defaults for hardware watchpoint functions. */
2106 /* If the *_hw_breakpoint functions have not been defined
2107 elsewhere use the definitions in the target vector. */
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
2115 one. OTHERTYPE is the number of watchpoints of other types than
2116 this one used so far. */
2118 extern int target_can_use_hardware_watchpoint (bptype type
, int cnt
,
2121 /* Returns the number of debug registers needed to watch the given
2122 memory region, or zero if not supported. */
2124 extern int target_region_ok_for_hw_watchpoint (CORE_ADDR addr
, int len
);
2126 extern int target_can_do_single_step ();
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.
2130 COND is the expression for its condition, or NULL if there's none.
2131 Returns 0 for success, 1 if the watchpoint type is not supported,
2134 extern int target_insert_watchpoint (CORE_ADDR addr
, int len
,
2135 target_hw_bp_type type
, expression
*cond
);
2137 extern int target_remove_watchpoint (CORE_ADDR addr
, int len
,
2138 target_hw_bp_type type
, expression
*cond
);
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. */
2145 extern int target_insert_mask_watchpoint (CORE_ADDR
, CORE_ADDR
,
2146 enum target_hw_bp_type
);
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
2153 extern int target_remove_mask_watchpoint (CORE_ADDR
, CORE_ADDR
,
2154 enum target_hw_bp_type
);
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. */
2161 extern int target_insert_hw_breakpoint (gdbarch
*gdbarch
,
2162 bp_target_info
*bp_tgt
);
2164 extern int target_remove_hw_breakpoint (gdbarch
*gdbarch
,
2165 bp_target_info
*bp_tgt
);
2167 /* Return number of debug registers needed for a ranged breakpoint,
2168 or -1 if ranged breakpoints are not supported. */
2170 extern int target_ranged_break_num_registers (void);
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) \
2176 (target)->stopped_data_address (addr_p)
2178 /* Return non-zero if ADDR is within the range of a watchpoint spanning
2179 LENGTH bytes beginning at START. */
2180 #define target_watchpoint_addr_within_range(target, addr, start, length) \
2181 (target)->watchpoint_addr_within_range (addr, start, length)
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.
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. */
2194 extern bool target_can_accel_watchpoint_condition (CORE_ADDR addr
, int len
,
2195 int type
, expression
*cond
);
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. */
2201 extern int target_masked_watch_num_registers (CORE_ADDR addr
, CORE_ADDR mask
);
2203 /* Target can execute in reverse? */
2205 extern bool target_can_execute_reverse ();
2207 extern const struct target_desc
*target_read_description (struct target_ops
*);
2209 extern ptid_t
target_get_ada_task_ptid (long lwp
, ULONGEST tid
);
2211 /* Main entry point for searching memory. */
2212 extern int target_search_memory (CORE_ADDR start_addr
,
2213 ULONGEST search_space_len
,
2214 const gdb_byte
*pattern
,
2215 ULONGEST pattern_len
,
2216 CORE_ADDR
*found_addrp
);
2218 /* Target file operations. */
2220 /* Return true if the filesystem seen by the current inferior
2221 is the local filesystem, zero otherwise. */
2223 extern bool target_filesystem_is_local ();
2225 /* Open FILENAME on the target, in the filesystem as seen by INF,
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. */
2231 extern int target_fileio_open (struct inferior
*inf
,
2232 const char *filename
, int flags
,
2233 int mode
, bool warn_if_slow
,
2234 fileio_error
*target_errno
);
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). */
2239 extern int target_fileio_pwrite (int fd
, const gdb_byte
*write_buf
, int len
,
2240 ULONGEST offset
, fileio_error
*target_errno
);
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). */
2245 extern int target_fileio_pread (int fd
, gdb_byte
*read_buf
, int len
,
2246 ULONGEST offset
, fileio_error
*target_errno
);
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). */
2251 extern int target_fileio_fstat (int fd
, struct stat
*sb
,
2252 fileio_error
*target_errno
);
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
2259 extern int target_fileio_lstat (struct inferior
*inf
, const char *filename
,
2260 struct stat
*sb
, fileio_error
*target_errno
);
2262 /* Close FD on the target. Return 0, or -1 if an error occurs
2263 (and set *TARGET_ERRNO). */
2264 extern int target_fileio_close (int fd
, fileio_error
*target_errno
);
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
2269 occurs (and set *TARGET_ERRNO). */
2270 extern int target_fileio_unlink (struct inferior
*inf
,
2271 const char *filename
,
2272 fileio_error
*target_errno
);
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). */
2279 extern std::optional
<std::string
> target_fileio_readlink
2280 (struct inferior
*inf
, const char *filename
, fileio_error
*target_errno
);
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
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. */
2294 extern LONGEST
target_fileio_read_alloc (struct inferior
*inf
,
2295 const char *filename
,
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. */
2305 extern gdb::unique_xmalloc_ptr
<char> target_fileio_read_stralloc
2306 (struct inferior
*inf
, const char *filename
);
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
2313 extern void fileio_handles_invalidate_target (target_ops
*targ
);
2315 /* Tracepoint-related operations. */
2317 extern void target_trace_init ();
2319 extern void target_download_tracepoint (bp_location
*location
);
2321 extern bool target_can_download_tracepoint ();
2323 extern void target_download_trace_state_variable (const trace_state_variable
&tsv
);
2325 extern void target_enable_tracepoint (bp_location
*loc
);
2327 extern void target_disable_tracepoint (bp_location
*loc
);
2329 extern void target_trace_start ();
2331 extern void target_trace_set_readonly_regions ();
2333 extern int target_get_trace_status (trace_status
*ts
);
2335 extern void target_get_tracepoint_status (tracepoint
*tp
, uploaded_tp
*utp
);
2337 extern void target_trace_stop ();
2339 extern int target_trace_find (trace_find_type type
, int num
, CORE_ADDR addr1
,
2340 CORE_ADDR addr2
, int *tpp
);
2342 extern bool target_get_trace_state_variable_value (int tsv
, LONGEST
*val
);
2344 extern int target_save_trace_data (const char *filename
);
2346 extern int target_upload_tracepoints (uploaded_tp
**utpp
);
2348 extern int target_upload_trace_state_variables (uploaded_tsv
**utsvp
);
2350 extern LONGEST
target_get_raw_trace_data (gdb_byte
*buf
, ULONGEST offset
,
2353 extern int target_get_min_fast_tracepoint_insn_len ();
2355 extern void target_set_disconnected_tracing (int val
);
2357 extern void target_set_circular_trace_buffer (int val
);
2359 extern void target_set_trace_buffer_size (LONGEST val
);
2361 extern bool target_set_trace_notes (const char *user
, const char *notes
,
2362 const char *stopnotes
);
2364 /* A wrapper that calls get_tib_address on the top target of the
2365 current inferior. */
2366 extern bool target_get_tib_address (ptid_t ptid
, CORE_ADDR
*addr
);
2368 extern void target_set_permissions ();
2370 extern bool target_static_tracepoint_marker_at
2371 (CORE_ADDR addr
, static_tracepoint_marker
*marker
);
2373 extern std::vector
<static_tracepoint_marker
>
2374 target_static_tracepoint_markers_by_strid (const char *marker_id
);
2376 extern traceframe_info_up
target_traceframe_info ();
2378 extern bool target_use_agent (bool use
);
2380 extern bool target_can_use_agent ();
2382 extern bool target_augmented_libraries_svr4_read ();
2384 extern bool target_supports_memory_tagging ();
2386 extern bool target_fetch_memtags (CORE_ADDR address
, size_t len
,
2387 gdb::byte_vector
&tags
, int type
);
2389 extern bool target_store_memtags (CORE_ADDR address
, size_t len
,
2390 const gdb::byte_vector
&tags
, int type
);
2392 extern bool target_is_address_tagged (gdbarch
*gdbarch
, CORE_ADDR address
);
2394 extern x86_xsave_layout
target_fetch_x86_xsave_layout ();
2396 /* Command logging facility. */
2398 extern void target_log_command (const char *p
);
2400 extern int target_core_of_thread (ptid_t ptid
);
2402 /* See to_get_unwinder in struct target_ops. */
2403 extern const struct frame_unwind
*target_get_unwinder (void);
2405 /* See to_get_tailcall_unwinder in struct target_ops. */
2406 extern const struct frame_unwind
*target_get_tailcall_unwinder (void);
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). */
2412 extern int simple_verify_memory (struct target_ops
* ops
,
2413 const gdb_byte
*data
,
2414 CORE_ADDR memaddr
, ULONGEST size
);
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. */
2421 int target_verify_memory (const gdb_byte
*data
,
2422 CORE_ADDR memaddr
, ULONGEST size
);
2424 /* Routines for maintenance of the target structures...
2426 add_target: Add a target to the list of all possible targets.
2427 This only makes sense for targets that should be activated using
2428 the "target TARGET_NAME ..." command.
2430 push_target: Make this target the top of the stack of currently used
2431 targets, within its particular stratum of the stack. Result
2432 is 0 if now atop the stack, nonzero if not on top (maybe
2435 unpush_target: Remove this from the stack of currently used targets,
2436 no matter where it is on the list. Returns 0 if no
2437 change, 1 if removed from stack. */
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. */
2443 typedef void target_open_ftype (const char *args
, int from_tty
);
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. */
2449 extern void add_target (const target_info
&info
,
2450 target_open_ftype
*func
,
2451 completer_ftype
*completer
= NULL
);
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. */
2457 extern void add_deprecated_target_alias (const target_info
&info
,
2460 /* A unique_ptr helper to unpush a target. */
2462 struct target_unpusher
2464 void operator() (struct target_ops
*ops
) const;
2467 /* A unique_ptr that unpushes a target on destruction. */
2469 typedef std::unique_ptr
<struct target_ops
, target_unpusher
> target_unpush_up
;
2471 extern void target_pre_inferior ();
2473 extern void target_preopen (int);
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. */
2480 extern CORE_ADDR
target_translate_tls_address (struct objfile
*objfile
,
2482 const char *name
= nullptr);
2484 /* Return the "section" containing the specified address. */
2485 const struct target_section
*target_section_by_addr (struct target_ops
*target
,
2488 /* Return the target section table this target (or the targets
2489 beneath) currently manipulate. */
2491 extern const std::vector
<target_section
> *target_get_section_table
2492 (struct target_ops
*target
);
2494 /* Default implementation of get_section_table for dummy_target. */
2496 extern const std::vector
<target_section
> *default_get_section_table ();
2498 /* From mem-break.c */
2500 extern int memory_remove_breakpoint (struct target_ops
*,
2501 struct gdbarch
*, struct bp_target_info
*,
2502 enum remove_bp_reason
);
2504 extern int memory_insert_breakpoint (struct target_ops
*,
2505 struct gdbarch
*, struct bp_target_info
*);
2507 /* Convenience template use to add memory breakpoints support to a
2510 template <typename BaseTarget
>
2511 struct memory_breakpoint_target
: public BaseTarget
2513 int insert_breakpoint (struct gdbarch
*gdbarch
,
2514 struct bp_target_info
*bp_tgt
) override
2515 { return memory_insert_breakpoint (this, gdbarch
, bp_tgt
); }
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
); }
2523 /* Check whether the memory at the breakpoint's placed address still
2524 contains the expected breakpoint instruction. */
2526 extern int memory_validate_breakpoint (struct gdbarch
*gdbarch
,
2527 struct bp_target_info
*bp_tgt
);
2529 extern int default_memory_remove_breakpoint (struct gdbarch
*,
2530 struct bp_target_info
*);
2532 extern int default_memory_insert_breakpoint (struct gdbarch
*,
2533 struct bp_target_info
*);
2538 extern void initialize_targets (void);
2540 [[noreturn
]] extern void noprocess (void);
2542 extern void target_require_runnable (void);
2544 /* Find the target at STRATUM. If no target is at that stratum,
2547 struct target_ops
*find_target_at (enum strata stratum
);
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. */
2552 extern std::optional
<gdb::char_vector
> target_get_osdata (const char *type
);
2554 /* Stuff that should be shared among the various remote targets. */
2557 /* Timeout limit for response from target. */
2558 extern int remote_timeout
;
2562 /* Set the show memory breakpoints mode to show, and return a
2563 scoped_restore to restore it back to the current value. */
2564 extern scoped_restore_tmpl
<int>
2565 make_scoped_restore_show_memory_breakpoints (int show
);
2567 /* True if we should trust readonly sections from the
2568 executable when reading memory. */
2569 extern bool trust_readonly
;
2571 extern bool may_write_registers
;
2572 extern bool may_write_memory
;
2573 extern bool may_insert_breakpoints
;
2574 extern bool may_insert_tracepoints
;
2575 extern bool may_insert_fast_tracepoints
;
2576 extern bool may_stop
;
2578 extern void update_target_permissions (void);
2581 /* Imported from machine dependent code. */
2583 /* See to_enable_btrace in struct target_ops. */
2584 extern struct btrace_target_info
*
2585 target_enable_btrace (thread_info
*tp
, const struct btrace_config
*);
2587 /* See to_disable_btrace in struct target_ops. */
2588 extern void target_disable_btrace (struct btrace_target_info
*btinfo
);
2590 /* See to_teardown_btrace in struct target_ops. */
2591 extern void target_teardown_btrace (struct btrace_target_info
*btinfo
);
2593 /* See to_read_btrace in struct target_ops. */
2594 extern enum btrace_error
target_read_btrace (struct btrace_data
*,
2595 struct btrace_target_info
*,
2596 enum btrace_read_type
);
2598 /* See to_btrace_conf in struct target_ops. */
2599 extern const struct btrace_config
*
2600 target_btrace_conf (const struct btrace_target_info
*);
2602 /* See to_stop_recording in struct target_ops. */
2603 extern void target_stop_recording (void);
2605 /* See to_save_record in struct target_ops. */
2606 extern void target_save_record (const char *filename
);
2608 /* Query if the target supports deleting the execution log. */
2609 extern int target_supports_delete_record (void);
2611 /* See to_delete_record in struct target_ops. */
2612 extern void target_delete_record (void);
2614 /* See to_record_method. */
2615 extern enum record_method
target_record_method (ptid_t ptid
);
2617 /* See to_record_is_replaying in struct target_ops. */
2618 extern int target_record_is_replaying (ptid_t ptid
);
2620 /* See to_record_will_replay in struct target_ops. */
2621 extern int target_record_will_replay (ptid_t ptid
, int dir
);
2623 /* See to_record_stop_replaying in struct target_ops. */
2624 extern void target_record_stop_replaying (void);
2626 /* See to_goto_record_begin in struct target_ops. */
2627 extern void target_goto_record_begin (void);
2629 /* See to_goto_record_end in struct target_ops. */
2630 extern void target_goto_record_end (void);
2632 /* See to_goto_record in struct target_ops. */
2633 extern void target_goto_record (ULONGEST insn
);
2635 /* See to_insn_history. */
2636 extern void target_insn_history (int size
, gdb_disassembly_flags flags
);
2638 /* See to_insn_history_from. */
2639 extern void target_insn_history_from (ULONGEST from
, int size
,
2640 gdb_disassembly_flags flags
);
2642 /* See to_insn_history_range. */
2643 extern void target_insn_history_range (ULONGEST begin
, ULONGEST end
,
2644 gdb_disassembly_flags flags
);
2646 /* See to_call_history. */
2647 extern void target_call_history (int size
, record_print_flags flags
);
2649 /* See to_call_history_from. */
2650 extern void target_call_history_from (ULONGEST begin
, int size
,
2651 record_print_flags flags
);
2653 /* See to_call_history_range. */
2654 extern void target_call_history_range (ULONGEST begin
, ULONGEST end
,
2655 record_print_flags flags
);
2657 /* See to_prepare_to_generate_core. */
2658 extern void target_prepare_to_generate_core (void);
2660 /* See to_done_generating_core. */
2661 extern void target_done_generating_core (void);
2663 #endif /* GDB_TARGET_H */