forked from bminor/binutils-gdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarget.h
2657 lines (2059 loc) · 104 KB
/
target.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Interface between GDB and target environments, including files and processes
Copyright (C) 1990-2024 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by John Gilmore.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This include file defines the interface between the main part of
the debugger, and the part which is target-specific, or specific to
the communications interface between us and the target.
A TARGET is an interface between the debugger and a particular
kind of file or process. Targets can be STACKED in STRATA,
so that more than one target can potentially respond to a request.
In particular, memory accesses will walk down the stack of targets
until they find a target that is interested in handling that particular
address. STRATA are artificial boundaries on the stack, within
which particular kinds of targets live. Strata exist so that
people don't get confused by pushing e.g. a process target and then
a file target, and wondering why they can't see the current values
of variables any more (the file target is handling them and they
never get to the process target). So when you push a file target,
it goes into the file stratum, which is always below the process
stratum.
Note that rather than allow an empty stack, we always have the
dummy target at the bottom stratum, so we can call the target
methods without checking them. */
#ifndef GDB_TARGET_H
#define GDB_TARGET_H
struct objfile;
struct ui_file;
struct mem_attrib;
struct target_ops;
struct bp_location;
struct bp_target_info;
struct regcache;
struct trace_state_variable;
struct trace_status;
struct uploaded_tsv;
struct uploaded_tp;
struct static_tracepoint_marker;
struct traceframe_info;
struct expression;
struct dcache_struct;
struct inferior;
/* Define const gdb_byte using one identifier, to make it easy for
make-target-delegates.py to parse. */
typedef const gdb_byte const_gdb_byte;
#include "infrun.h"
#include "breakpoint.h"
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/refcounted-object.h"
#include "target-section.h"
#include "target/target.h"
#include "target/resume.h"
#include "target/wait.h"
#include "target/waitstatus.h"
#include "bfd.h"
#include "symtab.h"
#include "memattr.h"
#include "gdbsupport/gdb_signals.h"
#include "btrace.h"
#include "record.h"
#include "command.h"
#include "disasm-flags.h"
#include "tracepoint.h"
#include "gdbsupport/fileio.h"
#include "gdbsupport/x86-xstate.h"
#include "gdbsupport/break-common.h"
enum strata
{
dummy_stratum, /* The lowest of the low */
file_stratum, /* Executable files, etc */
process_stratum, /* Executing processes or core dump files */
thread_stratum, /* Executing threads */
record_stratum, /* Support record debugging */
arch_stratum, /* Architecture overrides */
debug_stratum /* Target debug. Must be last. */
};
enum thread_control_capabilities
{
tc_none = 0, /* Default: can't control thread execution. */
tc_schedlock = 1, /* Can lock the thread scheduler. */
};
/* The structure below stores information about a system call.
It is basically used in the "catch syscall" command, and in
every function that gives information about a system call.
It's also good to mention that its fields represent everything
that we currently know about a syscall in GDB. */
struct syscall
{
/* The syscall number. */
int number;
/* The syscall name. */
const char *name;
};
/* Return a pretty printed form of TARGET_OPTIONS. */
extern std::string target_options_to_string (target_wait_flags target_options);
/* Possible types of events that the inferior handler will have to
deal with. */
enum inferior_event_type
{
/* Process a normal inferior event which will result in target_wait
being called. */
INF_REG_EVENT,
/* We are called to do stuff after the inferior stops. */
INF_EXEC_COMPLETE,
};
/* Target objects which can be transferred using target_read,
target_write, et cetera. */
enum target_object
{
/* AVR target specific transfer. See "avr-tdep.c" and "remote.c". */
TARGET_OBJECT_AVR,
/* Transfer up-to LEN bytes of memory starting at OFFSET. */
TARGET_OBJECT_MEMORY,
/* Memory, avoiding GDB's data cache and trusting the executable.
Target implementations of to_xfer_partial never need to handle
this object, and most callers should not use it. */
TARGET_OBJECT_RAW_MEMORY,
/* Memory known to be part of the target's stack. This is cached even
if it is not in a region marked as such, since it is known to be
"normal" RAM. */
TARGET_OBJECT_STACK_MEMORY,
/* Memory known to be part of the target code. This is cached even
if it is not in a region marked as such. */
TARGET_OBJECT_CODE_MEMORY,
/* Kernel Unwind Table. See "ia64-tdep.c". */
TARGET_OBJECT_UNWIND_TABLE,
/* Transfer auxiliary vector. */
TARGET_OBJECT_AUXV,
/* StackGhost cookie. See "sparc-tdep.c". */
TARGET_OBJECT_WCOOKIE,
/* Target memory map in XML format. */
TARGET_OBJECT_MEMORY_MAP,
/* Flash memory. This object can be used to write contents to
a previously erased flash memory. Using it without erasing
flash can have unexpected results. Addresses are physical
address on target, and not relative to flash start. */
TARGET_OBJECT_FLASH,
/* Available target-specific features, e.g. registers and coprocessors.
See "target-descriptions.c". ANNEX should never be empty. */
TARGET_OBJECT_AVAILABLE_FEATURES,
/* Currently loaded libraries, in XML format. */
TARGET_OBJECT_LIBRARIES,
/* Currently loaded libraries specific for SVR4 systems, in XML format. */
TARGET_OBJECT_LIBRARIES_SVR4,
/* Currently loaded libraries specific to AIX systems, in XML format. */
TARGET_OBJECT_LIBRARIES_AIX,
/* Get OS specific data. The ANNEX specifies the type (running
processes, etc.). The data being transferred is expected to follow
the DTD specified in features/osdata.dtd. */
TARGET_OBJECT_OSDATA,
/* Extra signal info. Usually the contents of `siginfo_t' on unix
platforms. */
TARGET_OBJECT_SIGNAL_INFO,
/* The list of threads that are being debugged. */
TARGET_OBJECT_THREADS,
/* Collected static trace data. */
TARGET_OBJECT_STATIC_TRACE_DATA,
/* Traceframe info, in XML format. */
TARGET_OBJECT_TRACEFRAME_INFO,
/* Load maps for FDPIC systems. */
TARGET_OBJECT_FDPIC,
/* Darwin dynamic linker info data. */
TARGET_OBJECT_DARWIN_DYLD_INFO,
/* OpenVMS Unwind Information Block. */
TARGET_OBJECT_OPENVMS_UIB,
/* Branch trace data, in XML format. */
TARGET_OBJECT_BTRACE,
/* Branch trace configuration, in XML format. */
TARGET_OBJECT_BTRACE_CONF,
/* The pathname of the executable file that was run to create
a specified process. ANNEX should be a string representation
of the process ID of the process in question, in hexadecimal
format. */
TARGET_OBJECT_EXEC_FILE,
/* FreeBSD virtual memory mappings. */
TARGET_OBJECT_FREEBSD_VMMAP,
/* FreeBSD process strings. */
TARGET_OBJECT_FREEBSD_PS_STRINGS,
/* Possible future objects: TARGET_OBJECT_FILE, ... */
};
/* Possible values returned by target_xfer_partial, etc. */
enum target_xfer_status
{
/* Some bytes are transferred. */
TARGET_XFER_OK = 1,
/* No further transfer is possible. */
TARGET_XFER_EOF = 0,
/* The piece of the object requested is unavailable. */
TARGET_XFER_UNAVAILABLE = 2,
/* Generic I/O error. Note that it's important that this is '-1',
as we still have target_xfer-related code returning hardcoded
'-1' on error. */
TARGET_XFER_E_IO = -1,
/* Keep list in sync with target_xfer_status_to_string. */
};
/* Return the string form of STATUS. */
extern const char *
target_xfer_status_to_string (enum target_xfer_status status);
typedef enum target_xfer_status
target_xfer_partial_ftype (struct target_ops *ops,
enum target_object object,
const char *annex,
gdb_byte *readbuf,
const gdb_byte *writebuf,
ULONGEST offset,
ULONGEST len,
ULONGEST *xfered_len);
enum target_xfer_status
raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
const gdb_byte *writebuf, ULONGEST memaddr,
LONGEST len, ULONGEST *xfered_len);
/* Request that OPS transfer up to LEN addressable units of the target's
OBJECT. When reading from a memory object, the size of an addressable unit
is architecture dependent and can be found using
gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is 1
byte long. BUF should point to a buffer large enough to hold the read data,
taking into account the addressable unit size. The OFFSET, for a seekable
object, specifies the starting point. The ANNEX can be used to provide
additional data-specific information to the target.
Return the number of addressable units actually transferred, or a negative
error code (an 'enum target_xfer_error' value) if the transfer is not
supported or otherwise fails. Return of a positive value less than
LEN indicates that no further transfer is possible. Unlike the raw
to_xfer_partial interface, callers of these functions do not need
to retry partial transfers. */
extern LONGEST target_read (struct target_ops *ops,
enum target_object object,
const char *annex, gdb_byte *buf,
ULONGEST offset, LONGEST len);
struct memory_read_result
{
memory_read_result (ULONGEST begin_, ULONGEST end_,
gdb::unique_xmalloc_ptr<gdb_byte> &&data_)
: begin (begin_),
end (end_),
data (std::move (data_))
{
}
~memory_read_result () = default;
memory_read_result (memory_read_result &&other) = default;
DISABLE_COPY_AND_ASSIGN (memory_read_result);
/* First address that was read. */
ULONGEST begin;
/* Past-the-end address. */
ULONGEST end;
/* The data. */
gdb::unique_xmalloc_ptr<gdb_byte> data;
};
extern std::vector<memory_read_result> read_memory_robust
(struct target_ops *ops, const ULONGEST offset, const LONGEST len);
/* Request that OPS transfer up to LEN addressable units from BUF to the
target's OBJECT. When writing to a memory object, the addressable unit
size is architecture dependent and can be found using
gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is 1
byte long. The OFFSET, for a seekable object, specifies the starting point.
The ANNEX can be used to provide additional data-specific information to
the target.
Return the number of addressable units actually transferred, or a negative
error code (an 'enum target_xfer_status' value) if the transfer is not
supported or otherwise fails. Return of a positive value less than
LEN indicates that no further transfer is possible. Unlike the raw
to_xfer_partial interface, callers of these functions do not need to
retry partial transfers. */
extern LONGEST target_write (struct target_ops *ops,
enum target_object object,
const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len);
/* Similar to target_write, except that it also calls PROGRESS with
the number of bytes written and the opaque BATON after every
successful partial write (and before the first write). This is
useful for progress reporting and user interaction while writing
data. To abort the transfer, the progress callback can throw an
exception. */
LONGEST target_write_with_progress (struct target_ops *ops,
enum target_object object,
const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len,
void (*progress) (ULONGEST, void *),
void *baton);
/* Wrapper to perform a full read of unknown size. OBJECT/ANNEX will be read
using OPS. The return value will be uninstantiated if the transfer fails or
is not supported.
This method should be used for objects sufficiently small to store
in a single xmalloc'd buffer, when no fixed bound on the object's
size is known in advance. Don't try to read TARGET_OBJECT_MEMORY
through this function. */
extern std::optional<gdb::byte_vector> target_read_alloc
(struct target_ops *ops, enum target_object object, const char *annex);
/* Read OBJECT/ANNEX using OPS. The result is a NUL-terminated character vector
(therefore usable as a NUL-terminated string). If an error occurs or the
transfer is unsupported, the return value will be uninstantiated. Empty
objects are returned as allocated but empty strings. Therefore, on success,
the returned vector is guaranteed to have at least one element. A warning is
issued if the result contains any embedded NUL bytes. */
extern std::optional<gdb::char_vector> target_read_stralloc
(struct target_ops *ops, enum target_object object, const char *annex);
/* See target_ops->to_xfer_partial. */
extern target_xfer_partial_ftype target_xfer_partial;
/* Wrappers to target read/write that perform memory transfers. They
throw an error if the memory transfer fails.
NOTE: cagney/2003-10-23: The naming schema is lifted from
"frame.h". The parameter order is lifted from get_frame_memory,
which in turn lifted it from read_memory. */
extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
gdb_byte *buf, LONGEST len);
extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
CORE_ADDR addr, int len,
enum bfd_endian byte_order);
struct thread_info; /* fwd decl for parameter list below: */
/* The type of the callback to the to_async method. */
typedef void async_callback_ftype (enum inferior_event_type event_type,
void *context);
/* Normally target debug printing is purely type-based. However,
sometimes it is necessary to override the debug printing on a
per-argument basis. This macro can be used, attribute-style, to
name the target debug printing function for a particular method
argument. FUNC is the name of the function. The macro's
definition is empty because it is only used by the
make-target-delegates script. */
#define TARGET_DEBUG_PRINTER(FUNC)
/* These defines are used to mark target_ops methods. The script
make-target-delegates scans these and auto-generates the base
method implementations. There are four macros that can be used:
1. TARGET_DEFAULT_IGNORE. There is no argument. The base method
does nothing. This is only valid if the method return type is
'void'.
2. TARGET_DEFAULT_NORETURN. The argument is a function call, like
'tcomplain ()'. The base method simply makes this call, which is
assumed not to return.
3. TARGET_DEFAULT_RETURN. The argument is a C expression. The
base method returns this expression's value.
4. TARGET_DEFAULT_FUNC. The argument is the name of a function.
make-target-delegates does not generate a base method in this case,
but instead uses the argument function as the base method. */
#define TARGET_DEFAULT_IGNORE()
#define TARGET_DEFAULT_NORETURN(ARG)
#define TARGET_DEFAULT_RETURN(ARG)
#define TARGET_DEFAULT_FUNC(ARG)
/* Each target that can be activated with "target TARGET_NAME" passes
the address of one of these objects to add_target, which uses the
object's address as unique identifier, and registers the "target
TARGET_NAME" command using SHORTNAME as target name. */
struct target_info
{
/* Name of this target. */
const char *shortname;
/* Name for printing. */
const char *longname;
/* Documentation. Does not include trailing newline, and starts
with a one-line description (probably similar to longname). */
const char *doc;
};
/* A GDB target.
Each inferior has a stack of these. See overall description at the
top.
Most target methods traverse the current inferior's target stack;
you call the method on the top target (normally via one of the
target_foo wrapper free functions), and the implementation of said
method does its work and returns, or defers to the same method on
the target beneath on the current inferior's target stack. Thus,
the inferior you want to call the target method on must be made the
current inferior before calling a target method, so that the stack
traversal works correctly.
Methods that traverse the stack have a TARGET_DEFAULT_XXX marker in
their declaration below. See the macros' description above, where
they're defined. */
struct target_ops
: public refcounted_object
{
/* Return this target's stratum. */
virtual strata stratum () const = 0;
/* To the target under this one. */
target_ops *beneath () const;
/* Free resources associated with the target. Note that singleton
targets, like e.g., native targets, are global objects, not
heap allocated, and are thus only deleted on GDB exit. The
main teardown entry point is the "close" method, below. */
virtual ~target_ops () {}
/* Return a reference to this target's unique target_info
object. */
virtual const target_info &info () const = 0;
/* Name this target type. */
const char *shortname () const
{ return info ().shortname; }
const char *longname () const
{ return info ().longname; }
/* Close the target. This is where the target can handle
teardown. Heap-allocated targets should delete themselves
before returning. */
virtual void close ();
/* Attaches to a process on the target side. Arguments are as
passed to the `attach' command by the user. This routine can
be called when the target is not on the target-stack, if the
target_ops::can_run method returns 1; in that case, it must push
itself onto the stack. Upon exit, the target should be ready
for normal operations, and should be ready to deliver the
status of the process immediately (without waiting) to an
upcoming target_wait call. */
virtual bool can_attach ();
virtual void attach (const char *, int);
virtual void post_attach (int)
TARGET_DEFAULT_IGNORE ();
/* Detaches from the inferior. Note that on targets that support
async execution (i.e., targets where it is possible to detach
from programs with threads running), the target is responsible
for removing breakpoints from the program before the actual
detach, otherwise the program dies when it hits one. */
virtual void detach (inferior *, int)
TARGET_DEFAULT_IGNORE ();
virtual void disconnect (const char *, int)
TARGET_DEFAULT_NORETURN (tcomplain ());
virtual void resume (ptid_t,
int TARGET_DEBUG_PRINTER (target_debug_print_step),
enum gdb_signal)
TARGET_DEFAULT_NORETURN (noprocess ());
/* Ensure that all resumed threads are committed to the target.
See the description of
process_stratum_target::commit_resumed_state for more
details. */
virtual void commit_resumed ()
TARGET_DEFAULT_IGNORE ();
/* See target_wait's description. Note that implementations of
this method must not assume that inferior_ptid on entry is
pointing at the thread or inferior that ends up reporting an
event. The reported event could be for some other thread in
the current inferior or even for a different process of the
current target. inferior_ptid may also be null_ptid on
entry. */
virtual ptid_t wait (ptid_t, struct target_waitstatus *,
target_wait_flags options)
TARGET_DEFAULT_FUNC (default_target_wait);
virtual void fetch_registers (struct regcache *, int)
TARGET_DEFAULT_IGNORE ();
virtual void store_registers (struct regcache *, int)
TARGET_DEFAULT_NORETURN (noprocess ());
virtual void prepare_to_store (struct regcache *)
TARGET_DEFAULT_NORETURN (noprocess ());
virtual void files_info ()
TARGET_DEFAULT_IGNORE ();
virtual int insert_breakpoint (struct gdbarch *,
struct bp_target_info *)
TARGET_DEFAULT_NORETURN (noprocess ());
virtual int remove_breakpoint (struct gdbarch *,
struct bp_target_info *,
enum remove_bp_reason)
TARGET_DEFAULT_NORETURN (noprocess ());
/* Returns true if the target stopped because it executed a
software breakpoint. This is necessary for correct background
execution / non-stop mode operation, and for correct PC
adjustment on targets where the PC needs to be adjusted when a
software breakpoint triggers. In these modes, by the time GDB
processes a breakpoint event, the breakpoint may already be
done from the target, so GDB needs to be able to tell whether
it should ignore the event and whether it should adjust the PC.
See adjust_pc_after_break. */
virtual bool stopped_by_sw_breakpoint ()
TARGET_DEFAULT_RETURN (false);
/* Returns true if the above method is supported. */
virtual bool supports_stopped_by_sw_breakpoint ()
TARGET_DEFAULT_RETURN (false);
/* Returns true if the target stopped for a hardware breakpoint.
Likewise, if the target supports hardware breakpoints, this
method is necessary for correct background execution / non-stop
mode operation. Even though hardware breakpoints do not
require PC adjustment, GDB needs to be able to tell whether the
hardware breakpoint event is a delayed event for a breakpoint
that is already gone and should thus be ignored. */
virtual bool stopped_by_hw_breakpoint ()
TARGET_DEFAULT_RETURN (false);
/* Returns true if the above method is supported. */
virtual bool supports_stopped_by_hw_breakpoint ()
TARGET_DEFAULT_RETURN (false);
virtual int can_use_hw_breakpoint (enum bptype, int, int)
TARGET_DEFAULT_RETURN (0);
virtual int ranged_break_num_registers ()
TARGET_DEFAULT_RETURN (-1);
virtual int insert_hw_breakpoint (struct gdbarch *,
struct bp_target_info *)
TARGET_DEFAULT_RETURN (-1);
virtual int remove_hw_breakpoint (struct gdbarch *,
struct bp_target_info *)
TARGET_DEFAULT_RETURN (-1);
/* Documentation of what the two routines below are expected to do is
provided with the corresponding target_* macros. */
virtual int remove_watchpoint (CORE_ADDR, int,
enum target_hw_bp_type, struct expression *)
TARGET_DEFAULT_RETURN (-1);
virtual int insert_watchpoint (CORE_ADDR, int,
enum target_hw_bp_type, struct expression *)
TARGET_DEFAULT_RETURN (-1);
virtual int insert_mask_watchpoint (CORE_ADDR, CORE_ADDR,
enum target_hw_bp_type)
TARGET_DEFAULT_RETURN (1);
virtual int remove_mask_watchpoint (CORE_ADDR, CORE_ADDR,
enum target_hw_bp_type)
TARGET_DEFAULT_RETURN (1);
virtual bool stopped_by_watchpoint ()
TARGET_DEFAULT_RETURN (false);
virtual bool have_steppable_watchpoint ()
TARGET_DEFAULT_RETURN (false);
virtual bool stopped_data_address (CORE_ADDR *)
TARGET_DEFAULT_RETURN (false);
virtual bool watchpoint_addr_within_range (CORE_ADDR, CORE_ADDR, int)
TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range);
/* Documentation of this routine is provided with the corresponding
target_* macro. */
virtual int region_ok_for_hw_watchpoint (CORE_ADDR, int)
TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint);
virtual bool can_accel_watchpoint_condition (CORE_ADDR, int, int,
struct expression *)
TARGET_DEFAULT_RETURN (false);
virtual int masked_watch_num_registers (CORE_ADDR, CORE_ADDR)
TARGET_DEFAULT_RETURN (-1);
/* Return 1 for sure target can do single step. Return -1 for
unknown. Return 0 for target can't do. */
virtual int can_do_single_step ()
TARGET_DEFAULT_RETURN (-1);
virtual bool supports_terminal_ours ()
TARGET_DEFAULT_RETURN (false);
virtual void terminal_init ()
TARGET_DEFAULT_IGNORE ();
virtual void terminal_inferior ()
TARGET_DEFAULT_IGNORE ();
virtual void terminal_save_inferior ()
TARGET_DEFAULT_IGNORE ();
virtual void terminal_ours_for_output ()
TARGET_DEFAULT_IGNORE ();
virtual void terminal_ours ()
TARGET_DEFAULT_IGNORE ();
virtual void terminal_info (const char *, int)
TARGET_DEFAULT_FUNC (default_terminal_info);
virtual void kill ()
TARGET_DEFAULT_NORETURN (noprocess ());
virtual void load (const char *, int)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Start an inferior process and set inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error().
On VxWorks and various standalone systems, we ignore exec_file. */
virtual bool can_create_inferior ();
virtual void create_inferior (const char *, const std::string &,
char **, int);
virtual int insert_fork_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual int remove_fork_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual int insert_vfork_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual int remove_vfork_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual void follow_fork (inferior *, ptid_t, target_waitkind, bool, bool)
TARGET_DEFAULT_FUNC (default_follow_fork);
/* Add CHILD_PTID to the thread list, after handling a
TARGET_WAITKIND_THREAD_CLONE event for the clone parent. The
parent is inferior_ptid. */
virtual void follow_clone (ptid_t child_ptid)
TARGET_DEFAULT_FUNC (default_follow_clone);
virtual int insert_exec_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual int remove_exec_catchpoint (int)
TARGET_DEFAULT_RETURN (1);
virtual void follow_exec (inferior *, ptid_t, const char *)
TARGET_DEFAULT_IGNORE ();
virtual int set_syscall_catchpoint (int, bool, int,
gdb::array_view<const int>)
TARGET_DEFAULT_RETURN (1);
virtual void mourn_inferior ()
TARGET_DEFAULT_FUNC (default_mourn_inferior);
/* Note that can_run is special and can be invoked on an unpushed
target. Targets defining this method must also define
to_can_async_p and to_supports_non_stop. */
virtual bool can_run ();
/* Documentation of this routine is provided with the corresponding
target_* macro. */
virtual void pass_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
TARGET_DEFAULT_IGNORE ();
/* Documentation of this routine is provided with the
corresponding target_* function. */
virtual void program_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
TARGET_DEFAULT_IGNORE ();
virtual bool thread_alive (ptid_t ptid)
TARGET_DEFAULT_RETURN (false);
virtual void update_thread_list ()
TARGET_DEFAULT_IGNORE ();
virtual std::string pid_to_str (ptid_t)
TARGET_DEFAULT_FUNC (default_pid_to_str);
virtual const char *extra_thread_info (thread_info *)
TARGET_DEFAULT_RETURN (NULL);
virtual const char *thread_name (thread_info *)
TARGET_DEFAULT_RETURN (NULL);
virtual thread_info *thread_handle_to_thread_info (const gdb_byte *,
int,
inferior *inf)
TARGET_DEFAULT_RETURN (NULL);
/* See target_thread_info_to_thread_handle. */
virtual gdb::array_view<const_gdb_byte> thread_info_to_thread_handle (struct thread_info *)
TARGET_DEFAULT_RETURN (gdb::array_view<const gdb_byte> ());
virtual void stop (ptid_t)
TARGET_DEFAULT_IGNORE ();
virtual void interrupt ()
TARGET_DEFAULT_IGNORE ();
virtual void pass_ctrlc ()
TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
virtual void rcmd (const char *command, struct ui_file *output)
TARGET_DEFAULT_FUNC (default_rcmd);
virtual const char *pid_to_exec_file (int pid)
TARGET_DEFAULT_RETURN (NULL);
virtual void log_command (const char *)
TARGET_DEFAULT_IGNORE ();
virtual const std::vector<target_section> *get_section_table ()
TARGET_DEFAULT_RETURN (default_get_section_table ());
/* Provide default values for all "must have" methods. */
virtual bool has_all_memory () { return false; }
virtual bool has_memory () { return false; }
virtual bool has_stack () { return false; }
virtual bool has_registers () { return false; }
virtual bool has_execution (inferior *inf) { return false; }
/* Control thread execution. */
virtual thread_control_capabilities get_thread_control_capabilities ()
TARGET_DEFAULT_RETURN (tc_none);
virtual bool attach_no_wait ()
TARGET_DEFAULT_RETURN (0);
/* This method must be implemented in some situations. See the
comment on 'can_run'. */
virtual bool can_async_p ()
TARGET_DEFAULT_RETURN (false);
virtual bool is_async_p ()
TARGET_DEFAULT_RETURN (false);
virtual void async (bool)
TARGET_DEFAULT_NORETURN (tcomplain ());
virtual int async_wait_fd ()
TARGET_DEFAULT_NORETURN (noprocess ());
/* Return true if the target has pending events to report to the
core. If true, then GDB avoids resuming the target until all
pending events are consumed, so that multiple resumptions can
be coalesced as an optimization. Most targets can't tell
whether they have pending events without calling target_wait,
so we default to returning false. The only downside is that a
potential optimization is missed. */
virtual bool has_pending_events ()
TARGET_DEFAULT_RETURN (false);
virtual void thread_events (bool)
TARGET_DEFAULT_IGNORE ();
/* Returns true if the target supports setting thread options
OPTIONS, false otherwise. */
virtual bool supports_set_thread_options (gdb_thread_options options)
TARGET_DEFAULT_RETURN (false);
/* This method must be implemented in some situations. See the
comment on 'can_run'. */
virtual bool supports_non_stop ()
TARGET_DEFAULT_RETURN (false);
/* Return true if the target operates in non-stop mode even with
"set non-stop off". */
virtual bool always_non_stop_p ()
TARGET_DEFAULT_RETURN (false);
/* find_memory_regions support method for gcore */
virtual int find_memory_regions (find_memory_region_ftype func, void *data)
TARGET_DEFAULT_FUNC (dummy_find_memory_regions);
/* make_corefile_notes support method for gcore */
virtual gdb::unique_xmalloc_ptr<char> make_corefile_notes (bfd *, int *)
TARGET_DEFAULT_FUNC (dummy_make_corefile_notes);
/* get_bookmark support method for bookmarks */
virtual gdb_byte *get_bookmark (const char *, int)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* goto_bookmark support method for bookmarks */
virtual void goto_bookmark (const gdb_byte *, int)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Return the thread-local address at OFFSET in the
thread-local storage for the thread PTID and the shared library
or executable file given by LOAD_MODULE_ADDR. If that block of
thread-local storage hasn't been allocated yet, this function
may throw an error. LOAD_MODULE_ADDR may be zero for statically
linked multithreaded inferiors. */
virtual CORE_ADDR get_thread_local_address (ptid_t ptid,
CORE_ADDR load_module_addr,
CORE_ADDR offset)
TARGET_DEFAULT_NORETURN (generic_tls_error ());
/* Request that OPS transfer up to LEN addressable units of the target's
OBJECT. When reading from a memory object, the size of an addressable
unit is architecture dependent and can be found using
gdbarch_addressable_memory_unit_size. Otherwise, an addressable unit is
1 byte long. The OFFSET, for a seekable object, specifies the
starting point. The ANNEX can be used to provide additional
data-specific information to the target.
When accessing memory, inferior_ptid indicates which process's
memory is to be accessed. This is usually the same process as
the current inferior, however it may also be a process that is
a fork child of the current inferior, at a moment that the
child does not exist in GDB's inferior lists. This happens
when we remove software breakpoints from the address space of a
fork child process that we're not going to stay attached to.
Because the fork child is a clone of the fork parent, we can
use the fork parent inferior's stack for target method
delegation.
Return the transferred status, error or OK (an
'enum target_xfer_status' value). Save the number of addressable units
actually transferred in *XFERED_LEN if transfer is successful
(TARGET_XFER_OK) or the number unavailable units if the requested
data is unavailable (TARGET_XFER_UNAVAILABLE). *XFERED_LEN
smaller than LEN does not indicate the end of the object, only
the end of the transfer; higher level code should continue
transferring if desired. This is handled in target.c.
The interface does not support a "retry" mechanism. Instead it
assumes that at least one addressable unit will be transferred on each
successful call.
NOTE: cagney/2003-10-17: The current interface can lead to
fragmented transfers. Lower target levels should not implement
hacks, such as enlarging the transfer, in an attempt to
compensate for this. Instead, the target stack should be
extended so that it implements supply/collect methods and a
look-aside object cache. With that available, the lowest
target can safely and freely "push" data up the stack.
See target_read and target_write for more information. One,
and only one, of readbuf or writebuf must be non-NULL. */
virtual enum target_xfer_status xfer_partial (enum target_object object,
const char *annex,
gdb_byte *readbuf,
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len)
TARGET_DEFAULT_RETURN (TARGET_XFER_E_IO);
/* Return the limit on the size of any single memory transfer
for the target. */
virtual ULONGEST get_memory_xfer_limit ()
TARGET_DEFAULT_RETURN (ULONGEST_MAX);
/* Returns the memory map for the target. A return value of NULL
means that no memory map is available. If a memory address
does not fall within any returned regions, it's assumed to be
RAM. The returned memory regions should not overlap.
The order of regions does not matter; target_memory_map will
sort regions by starting address. For that reason, this
function should not be called directly except via
target_memory_map.
This method should not cache data; if the memory map could
change unexpectedly, it should be invalidated, and higher
layers will re-fetch it. */
virtual std::vector<mem_region> memory_map ()
TARGET_DEFAULT_RETURN (std::vector<mem_region> ());
/* Erases the region of flash memory starting at ADDRESS, of
length LENGTH.
Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
on flash block boundaries, as reported by 'to_memory_map'. */
virtual void flash_erase (ULONGEST address, LONGEST length)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Finishes a flash memory write sequence. After this operation
all flash memory should be available for writing and the result
of reading from areas written by 'to_flash_write' should be
equal to what was written. */
virtual void flash_done ()
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Describe the architecture-specific features of the current
inferior.
Returns the description found, or nullptr if no description was
available.
If some target features differ between threads, the description
returned by read_description (and the resulting gdbarch) won't
accurately describe all threads. In this case, the
thread_architecture method can be used to obtain gdbarches that
accurately describe each thread. */
virtual const struct target_desc *read_description ()
TARGET_DEFAULT_RETURN (NULL);
/* Build the PTID of the thread on which a given task is running,
based on LWP and THREAD. These values are extracted from the
task Private_Data section of the Ada Task Control Block, and
their interpretation depends on the target. */
virtual ptid_t get_ada_task_ptid (long lwp, ULONGEST thread)
TARGET_DEFAULT_FUNC (default_get_ada_task_ptid);
/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
Return 0 if *READPTR is already at the end of the buffer.
Return -1 if there is insufficient buffer for a whole entry.
Return 1 if an entry was read into *TYPEP and *VALP. */
virtual int auxv_parse (const gdb_byte **readptr,
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
TARGET_DEFAULT_FUNC (default_auxv_parse);
/* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
sequence of bytes in PATTERN with length PATTERN_LEN.
The result is 1 if found, 0 if not found, and -1 if there was an error
requiring halting of the search (e.g. memory read error).
If the pattern is found the address is recorded in FOUND_ADDRP. */
virtual int search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
const gdb_byte *pattern, ULONGEST pattern_len,
CORE_ADDR *found_addrp)
TARGET_DEFAULT_FUNC (default_search_memory);
/* Can target execute in reverse? */
virtual bool can_execute_reverse ()
TARGET_DEFAULT_RETURN (false);
/* The direction the target is currently executing. Must be
implemented on targets that support reverse execution and async
mode. The default simply returns forward execution. */
virtual enum exec_direction_kind execution_direction ()
TARGET_DEFAULT_FUNC (default_execution_direction);
/* Does this target support debugging multiple processes
simultaneously? */
virtual bool supports_multi_process ()
TARGET_DEFAULT_RETURN (false);
/* Does this target support enabling and disabling tracepoints while a trace
experiment is running? */
virtual bool supports_enable_disable_tracepoint ()
TARGET_DEFAULT_RETURN (false);
/* Does this target support disabling address space randomization? */
virtual bool supports_disable_randomization ()
TARGET_DEFAULT_FUNC (find_default_supports_disable_randomization);
/* Does this target support the tracenz bytecode for string collection? */
virtual bool supports_string_tracing ()
TARGET_DEFAULT_RETURN (false);
/* Does this target support evaluation of breakpoint conditions on its
end? */
virtual bool supports_evaluation_of_breakpoint_conditions ()
TARGET_DEFAULT_RETURN (false);
/* Does this target support native dumpcore API? */
virtual bool supports_dumpcore ()
TARGET_DEFAULT_RETURN (false);
/* Generate the core file with native target API. */
virtual void dumpcore (const char *filename)
TARGET_DEFAULT_IGNORE ();
/* Does this target support evaluation of breakpoint commands on its
end? */
virtual bool can_run_breakpoint_commands ()
TARGET_DEFAULT_RETURN (false);
/* Determine current architecture of thread PTID.
The target is supposed to determine the architecture of the code where
the target is currently stopped at. The architecture information is
used to perform decr_pc_after_break adjustment, and also to determine
the frame architecture of the innermost frame. ptrace operations need to
operate according to the current inferior's gdbarch. */
virtual struct gdbarch *thread_architecture (ptid_t)
TARGET_DEFAULT_RETURN (NULL);
/* Target file operations. */
/* Return true if the filesystem seen by the current inferior
is the local filesystem, false otherwise. */
virtual bool filesystem_is_local ()
TARGET_DEFAULT_RETURN (true);
/* Open FILENAME on the target, in the filesystem as seen by INF,
using FLAGS and MODE. If INF is NULL, use the filesystem seen
by the debugger (GDB or, for remote targets, the remote stub).
If WARN_IF_SLOW is nonzero, print a warning message if the file
is being accessed over a link that may be slow. Return a
target file descriptor, or -1 if an error occurs (and set
*TARGET_ERRNO). */
virtual int fileio_open (struct inferior *inf, const char *filename,
int flags, int mode, int warn_if_slow,
fileio_error *target_errno);
/* Write up to LEN bytes from WRITE_BUF to FD on the target.
Return the number of bytes written, or -1 if an error occurs
(and set *TARGET_ERRNO). */
virtual int fileio_pwrite (int fd, const gdb_byte *write_buf, int len,