GDB (API)
/home/stan/gdb/src/gdb/target.h
Go to the documentation of this file.
00001 /* Interface between GDB and target environments, including files and processes
00002 
00003    Copyright (C) 1990-2013 Free Software Foundation, Inc.
00004 
00005    Contributed by Cygnus Support.  Written by John Gilmore.
00006 
00007    This file is part of GDB.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 3 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 #if !defined (TARGET_H)
00023 #define TARGET_H
00024 
00025 struct objfile;
00026 struct ui_file;
00027 struct mem_attrib;
00028 struct target_ops;
00029 struct bp_location;
00030 struct bp_target_info;
00031 struct regcache;
00032 struct target_section_table;
00033 struct trace_state_variable;
00034 struct trace_status;
00035 struct uploaded_tsv;
00036 struct uploaded_tp;
00037 struct static_tracepoint_marker;
00038 struct traceframe_info;
00039 struct expression;
00040 
00041 /* This include file defines the interface between the main part
00042    of the debugger, and the part which is target-specific, or
00043    specific to the communications interface between us and the
00044    target.
00045 
00046    A TARGET is an interface between the debugger and a particular
00047    kind of file or process.  Targets can be STACKED in STRATA,
00048    so that more than one target can potentially respond to a request.
00049    In particular, memory accesses will walk down the stack of targets
00050    until they find a target that is interested in handling that particular
00051    address.  STRATA are artificial boundaries on the stack, within
00052    which particular kinds of targets live.  Strata exist so that
00053    people don't get confused by pushing e.g. a process target and then
00054    a file target, and wondering why they can't see the current values
00055    of variables any more (the file target is handling them and they
00056    never get to the process target).  So when you push a file target,
00057    it goes into the file stratum, which is always below the process
00058    stratum.  */
00059 
00060 #include "target/resume.h"
00061 #include "target/wait.h"
00062 #include "target/waitstatus.h"
00063 #include "bfd.h"
00064 #include "symtab.h"
00065 #include "memattr.h"
00066 #include "vec.h"
00067 #include "gdb_signals.h"
00068 #include "btrace.h"
00069 #include "command.h"
00070 
00071 enum strata
00072   {
00073     dummy_stratum,              /* The lowest of the low */
00074     file_stratum,               /* Executable files, etc */
00075     process_stratum,            /* Executing processes or core dump files */
00076     thread_stratum,             /* Executing threads */
00077     record_stratum,             /* Support record debugging */
00078     arch_stratum                /* Architecture overrides */
00079   };
00080 
00081 enum thread_control_capabilities
00082   {
00083     tc_none = 0,                /* Default: can't control thread execution.  */
00084     tc_schedlock = 1,           /* Can lock the thread scheduler.  */
00085   };
00086 
00087 /* The structure below stores information about a system call.
00088    It is basically used in the "catch syscall" command, and in
00089    every function that gives information about a system call.
00090    
00091    It's also good to mention that its fields represent everything
00092    that we currently know about a syscall in GDB.  */
00093 struct syscall
00094   {
00095     /* The syscall number.  */
00096     int number;
00097 
00098     /* The syscall name.  */
00099     const char *name;
00100   };
00101 
00102 /* Return a pretty printed form of target_waitstatus.
00103    Space for the result is malloc'd, caller must free.  */
00104 extern char *target_waitstatus_to_string (const struct target_waitstatus *);
00105 
00106 /* Return a pretty printed form of TARGET_OPTIONS.
00107    Space for the result is malloc'd, caller must free.  */
00108 extern char *target_options_to_string (int target_options);
00109 
00110 /* Possible types of events that the inferior handler will have to
00111    deal with.  */
00112 enum inferior_event_type
00113   {
00114     /* Process a normal inferior event which will result in target_wait
00115        being called.  */
00116     INF_REG_EVENT,
00117     /* We are called because a timer went off.  */
00118     INF_TIMER,
00119     /* We are called to do stuff after the inferior stops.  */
00120     INF_EXEC_COMPLETE,
00121     /* We are called to do some stuff after the inferior stops, but we
00122        are expected to reenter the proceed() and
00123        handle_inferior_event() functions.  This is used only in case of
00124        'step n' like commands.  */
00125     INF_EXEC_CONTINUE
00126   };
00127 
00128 /* Target objects which can be transfered using target_read,
00129    target_write, et cetera.  */
00130 
00131 enum target_object
00132 {
00133   /* AVR target specific transfer.  See "avr-tdep.c" and "remote.c".  */
00134   TARGET_OBJECT_AVR,
00135   /* SPU target specific transfer.  See "spu-tdep.c".  */
00136   TARGET_OBJECT_SPU,
00137   /* Transfer up-to LEN bytes of memory starting at OFFSET.  */
00138   TARGET_OBJECT_MEMORY,
00139   /* Memory, avoiding GDB's data cache and trusting the executable.
00140      Target implementations of to_xfer_partial never need to handle
00141      this object, and most callers should not use it.  */
00142   TARGET_OBJECT_RAW_MEMORY,
00143   /* Memory known to be part of the target's stack.  This is cached even
00144      if it is not in a region marked as such, since it is known to be
00145      "normal" RAM.  */
00146   TARGET_OBJECT_STACK_MEMORY,
00147   /* Kernel Unwind Table.  See "ia64-tdep.c".  */
00148   TARGET_OBJECT_UNWIND_TABLE,
00149   /* Transfer auxilliary vector.  */
00150   TARGET_OBJECT_AUXV,
00151   /* StackGhost cookie.  See "sparc-tdep.c".  */
00152   TARGET_OBJECT_WCOOKIE,
00153   /* Target memory map in XML format.  */
00154   TARGET_OBJECT_MEMORY_MAP,
00155   /* Flash memory.  This object can be used to write contents to
00156      a previously erased flash memory.  Using it without erasing
00157      flash can have unexpected results.  Addresses are physical
00158      address on target, and not relative to flash start.  */
00159   TARGET_OBJECT_FLASH,
00160   /* Available target-specific features, e.g. registers and coprocessors.
00161      See "target-descriptions.c".  ANNEX should never be empty.  */
00162   TARGET_OBJECT_AVAILABLE_FEATURES,
00163   /* Currently loaded libraries, in XML format.  */
00164   TARGET_OBJECT_LIBRARIES,
00165   /* Currently loaded libraries specific for SVR4 systems, in XML format.  */
00166   TARGET_OBJECT_LIBRARIES_SVR4,
00167   /* Currently loaded libraries specific to AIX systems, in XML format.  */
00168   TARGET_OBJECT_LIBRARIES_AIX,
00169   /* Get OS specific data.  The ANNEX specifies the type (running
00170      processes, etc.).  The data being transfered is expected to follow
00171      the DTD specified in features/osdata.dtd.  */
00172   TARGET_OBJECT_OSDATA,
00173   /* Extra signal info.  Usually the contents of `siginfo_t' on unix
00174      platforms.  */
00175   TARGET_OBJECT_SIGNAL_INFO,
00176   /* The list of threads that are being debugged.  */
00177   TARGET_OBJECT_THREADS,
00178   /* Collected static trace data.  */
00179   TARGET_OBJECT_STATIC_TRACE_DATA,
00180   /* The HP-UX registers (those that can be obtained or modified by using
00181      the TT_LWP_RUREGS/TT_LWP_WUREGS ttrace requests).  */
00182   TARGET_OBJECT_HPUX_UREGS,
00183   /* The HP-UX shared library linkage pointer.  ANNEX should be a string
00184      image of the code address whose linkage pointer we are looking for.
00185 
00186      The size of the data transfered is always 8 bytes (the size of an
00187      address on ia64).  */
00188   TARGET_OBJECT_HPUX_SOLIB_GOT,
00189   /* Traceframe info, in XML format.  */
00190   TARGET_OBJECT_TRACEFRAME_INFO,
00191   /* Load maps for FDPIC systems.  */
00192   TARGET_OBJECT_FDPIC,
00193   /* Darwin dynamic linker info data.  */
00194   TARGET_OBJECT_DARWIN_DYLD_INFO,
00195   /* OpenVMS Unwind Information Block.  */
00196   TARGET_OBJECT_OPENVMS_UIB,
00197   /* Branch trace data, in XML format.  */
00198   TARGET_OBJECT_BTRACE
00199   /* Possible future objects: TARGET_OBJECT_FILE, ...  */
00200 };
00201 
00202 /* Possible error codes returned by target_xfer_partial, etc.  */
00203 
00204 enum target_xfer_error
00205 {
00206   /* Generic I/O error.  Note that it's important that this is '-1',
00207      as we still have target_xfer-related code returning hardcoded
00208      '-1' on error.  */
00209   TARGET_XFER_E_IO = -1,
00210 
00211   /* Transfer failed because the piece of the object requested is
00212      unavailable.  */
00213   TARGET_XFER_E_UNAVAILABLE = -2,
00214 
00215   /* Keep list in sync with target_xfer_error_to_string.  */
00216 };
00217 
00218 /* Return the string form of ERR.  */
00219 
00220 extern const char *target_xfer_error_to_string (enum target_xfer_error err);
00221 
00222 /* Enumeration of the kinds of traceframe searches that a target may
00223    be able to perform.  */
00224 
00225 enum trace_find_type
00226   {
00227     tfind_number,
00228     tfind_pc,
00229     tfind_tp,
00230     tfind_range,
00231     tfind_outside,
00232   };
00233 
00234 typedef struct static_tracepoint_marker *static_tracepoint_marker_p;
00235 DEF_VEC_P(static_tracepoint_marker_p);
00236 
00237 /* Request that OPS transfer up to LEN 8-bit bytes of the target's
00238    OBJECT.  The OFFSET, for a seekable object, specifies the
00239    starting point.  The ANNEX can be used to provide additional
00240    data-specific information to the target.
00241 
00242    Return the number of bytes actually transfered, or a negative error
00243    code (an 'enum target_xfer_error' value) if the transfer is not
00244    supported or otherwise fails.  Return of a positive value less than
00245    LEN indicates that no further transfer is possible.  Unlike the raw
00246    to_xfer_partial interface, callers of these functions do not need
00247    to retry partial transfers.  */
00248 
00249 extern LONGEST target_read (struct target_ops *ops,
00250                             enum target_object object,
00251                             const char *annex, gdb_byte *buf,
00252                             ULONGEST offset, LONGEST len);
00253 
00254 struct memory_read_result
00255   {
00256     /* First address that was read.  */
00257     ULONGEST begin;
00258     /* Past-the-end address.  */
00259     ULONGEST end;
00260     /* The data.  */
00261     gdb_byte *data;
00262 };
00263 typedef struct memory_read_result memory_read_result_s;
00264 DEF_VEC_O(memory_read_result_s);
00265 
00266 extern void free_memory_read_result_vector (void *);
00267 
00268 extern VEC(memory_read_result_s)* read_memory_robust (struct target_ops *ops,
00269                                                       ULONGEST offset,
00270                                                       LONGEST len);
00271   
00272 extern LONGEST target_write (struct target_ops *ops,
00273                              enum target_object object,
00274                              const char *annex, const gdb_byte *buf,
00275                              ULONGEST offset, LONGEST len);
00276 
00277 /* Similar to target_write, except that it also calls PROGRESS with
00278    the number of bytes written and the opaque BATON after every
00279    successful partial write (and before the first write).  This is
00280    useful for progress reporting and user interaction while writing
00281    data.  To abort the transfer, the progress callback can throw an
00282    exception.  */
00283 
00284 LONGEST target_write_with_progress (struct target_ops *ops,
00285                                     enum target_object object,
00286                                     const char *annex, const gdb_byte *buf,
00287                                     ULONGEST offset, LONGEST len,
00288                                     void (*progress) (ULONGEST, void *),
00289                                     void *baton);
00290 
00291 /* Wrapper to perform a full read of unknown size.  OBJECT/ANNEX will
00292    be read using OPS.  The return value will be -1 if the transfer
00293    fails or is not supported; 0 if the object is empty; or the length
00294    of the object otherwise.  If a positive value is returned, a
00295    sufficiently large buffer will be allocated using xmalloc and
00296    returned in *BUF_P containing the contents of the object.
00297 
00298    This method should be used for objects sufficiently small to store
00299    in a single xmalloc'd buffer, when no fixed bound on the object's
00300    size is known in advance.  Don't try to read TARGET_OBJECT_MEMORY
00301    through this function.  */
00302 
00303 extern LONGEST target_read_alloc (struct target_ops *ops,
00304                                   enum target_object object,
00305                                   const char *annex, gdb_byte **buf_p);
00306 
00307 /* Read OBJECT/ANNEX using OPS.  The result is NUL-terminated and
00308    returned as a string, allocated using xmalloc.  If an error occurs
00309    or the transfer is unsupported, NULL is returned.  Empty objects
00310    are returned as allocated but empty strings.  A warning is issued
00311    if the result contains any embedded NUL bytes.  */
00312 
00313 extern char *target_read_stralloc (struct target_ops *ops,
00314                                    enum target_object object,
00315                                    const char *annex);
00316 
00317 /* See target_ops->to_xfer_partial.  */
00318 
00319 extern LONGEST target_xfer_partial (struct target_ops *ops,
00320                                     enum target_object object,
00321                                     const char *annex,
00322                                     void *readbuf, const void *writebuf,
00323                                     ULONGEST offset, LONGEST len);
00324 
00325 /* Wrappers to target read/write that perform memory transfers.  They
00326    throw an error if the memory transfer fails.
00327 
00328    NOTE: cagney/2003-10-23: The naming schema is lifted from
00329    "frame.h".  The parameter order is lifted from get_frame_memory,
00330    which in turn lifted it from read_memory.  */
00331 
00332 extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
00333                                gdb_byte *buf, LONGEST len);
00334 extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
00335                                             CORE_ADDR addr, int len,
00336                                             enum bfd_endian byte_order);
00337 
00338 struct thread_info;             /* fwd decl for parameter list below: */
00339 
00340 struct target_ops
00341   {
00342     struct target_ops *beneath; /* To the target under this one.  */
00343     char *to_shortname;         /* Name this target type */
00344     char *to_longname;          /* Name for printing */
00345     char *to_doc;               /* Documentation.  Does not include trailing
00346                                    newline, and starts with a one-line descrip-
00347                                    tion (probably similar to to_longname).  */
00348     /* Per-target scratch pad.  */
00349     void *to_data;
00350     /* The open routine takes the rest of the parameters from the
00351        command, and (if successful) pushes a new target onto the
00352        stack.  Targets should supply this routine, if only to provide
00353        an error message.  */
00354     void (*to_open) (char *, int);
00355     /* Old targets with a static target vector provide "to_close".
00356        New re-entrant targets provide "to_xclose" and that is expected
00357        to xfree everything (including the "struct target_ops").  */
00358     void (*to_xclose) (struct target_ops *targ);
00359     void (*to_close) (void);
00360     void (*to_attach) (struct target_ops *ops, char *, int);
00361     void (*to_post_attach) (int);
00362     void (*to_detach) (struct target_ops *ops, char *, int);
00363     void (*to_disconnect) (struct target_ops *, char *, int);
00364     void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal);
00365     ptid_t (*to_wait) (struct target_ops *,
00366                        ptid_t, struct target_waitstatus *, int);
00367     void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
00368     void (*to_store_registers) (struct target_ops *, struct regcache *, int);
00369     void (*to_prepare_to_store) (struct regcache *);
00370 
00371     /* Transfer LEN bytes of memory between GDB address MYADDR and
00372        target address MEMADDR.  If WRITE, transfer them to the target, else
00373        transfer them from the target.  TARGET is the target from which we
00374        get this function.
00375 
00376        Return value, N, is one of the following:
00377 
00378        0 means that we can't handle this.  If errno has been set, it is the
00379        error which prevented us from doing it (FIXME: What about bfd_error?).
00380 
00381        positive (call it N) means that we have transferred N bytes
00382        starting at MEMADDR.  We might be able to handle more bytes
00383        beyond this length, but no promises.
00384 
00385        negative (call its absolute value N) means that we cannot
00386        transfer right at MEMADDR, but we could transfer at least
00387        something at MEMADDR + N.
00388 
00389        NOTE: cagney/2004-10-01: This has been entirely superseeded by
00390        to_xfer_partial and inferior inheritance.  */
00391 
00392     int (*deprecated_xfer_memory) (CORE_ADDR memaddr, gdb_byte *myaddr,
00393                                    int len, int write,
00394                                    struct mem_attrib *attrib,
00395                                    struct target_ops *target);
00396 
00397     void (*to_files_info) (struct target_ops *);
00398     int (*to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *);
00399     int (*to_remove_breakpoint) (struct gdbarch *, struct bp_target_info *);
00400     int (*to_can_use_hw_breakpoint) (int, int, int);
00401     int (*to_ranged_break_num_registers) (struct target_ops *);
00402     int (*to_insert_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
00403     int (*to_remove_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
00404 
00405     /* Documentation of what the two routines below are expected to do is
00406        provided with the corresponding target_* macros.  */
00407     int (*to_remove_watchpoint) (CORE_ADDR, int, int, struct expression *);
00408     int (*to_insert_watchpoint) (CORE_ADDR, int, int, struct expression *);
00409 
00410     int (*to_insert_mask_watchpoint) (struct target_ops *,
00411                                       CORE_ADDR, CORE_ADDR, int);
00412     int (*to_remove_mask_watchpoint) (struct target_ops *,
00413                                       CORE_ADDR, CORE_ADDR, int);
00414     int (*to_stopped_by_watchpoint) (void);
00415     int to_have_steppable_watchpoint;
00416     int to_have_continuable_watchpoint;
00417     int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
00418     int (*to_watchpoint_addr_within_range) (struct target_ops *,
00419                                             CORE_ADDR, CORE_ADDR, int);
00420 
00421     /* Documentation of this routine is provided with the corresponding
00422        target_* macro.  */
00423     int (*to_region_ok_for_hw_watchpoint) (CORE_ADDR, int);
00424 
00425     int (*to_can_accel_watchpoint_condition) (CORE_ADDR, int, int,
00426                                               struct expression *);
00427     int (*to_masked_watch_num_registers) (struct target_ops *,
00428                                           CORE_ADDR, CORE_ADDR);
00429     void (*to_terminal_init) (void);
00430     void (*to_terminal_inferior) (void);
00431     void (*to_terminal_ours_for_output) (void);
00432     void (*to_terminal_ours) (void);
00433     void (*to_terminal_save_ours) (void);
00434     void (*to_terminal_info) (const char *, int);
00435     void (*to_kill) (struct target_ops *);
00436     void (*to_load) (char *, int);
00437     void (*to_create_inferior) (struct target_ops *, 
00438                                 char *, char *, char **, int);
00439     void (*to_post_startup_inferior) (ptid_t);
00440     int (*to_insert_fork_catchpoint) (int);
00441     int (*to_remove_fork_catchpoint) (int);
00442     int (*to_insert_vfork_catchpoint) (int);
00443     int (*to_remove_vfork_catchpoint) (int);
00444     int (*to_follow_fork) (struct target_ops *, int, int);
00445     int (*to_insert_exec_catchpoint) (int);
00446     int (*to_remove_exec_catchpoint) (int);
00447     int (*to_set_syscall_catchpoint) (int, int, int, int, int *);
00448     int (*to_has_exited) (int, int, int *);
00449     void (*to_mourn_inferior) (struct target_ops *);
00450     int (*to_can_run) (void);
00451 
00452     /* Documentation of this routine is provided with the corresponding
00453        target_* macro.  */
00454     void (*to_pass_signals) (int, unsigned char *);
00455 
00456     /* Documentation of this routine is provided with the
00457        corresponding target_* function.  */
00458     void (*to_program_signals) (int, unsigned char *);
00459 
00460     int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
00461     void (*to_find_new_threads) (struct target_ops *);
00462     char *(*to_pid_to_str) (struct target_ops *, ptid_t);
00463     char *(*to_extra_thread_info) (struct thread_info *);
00464     char *(*to_thread_name) (struct thread_info *);
00465     void (*to_stop) (ptid_t);
00466     void (*to_rcmd) (char *command, struct ui_file *output);
00467     char *(*to_pid_to_exec_file) (int pid);
00468     void (*to_log_command) (const char *);
00469     struct target_section_table *(*to_get_section_table) (struct target_ops *);
00470     enum strata to_stratum;
00471     int (*to_has_all_memory) (struct target_ops *);
00472     int (*to_has_memory) (struct target_ops *);
00473     int (*to_has_stack) (struct target_ops *);
00474     int (*to_has_registers) (struct target_ops *);
00475     int (*to_has_execution) (struct target_ops *, ptid_t);
00476     int to_has_thread_control;  /* control thread execution */
00477     int to_attach_no_wait;
00478     /* ASYNC target controls */
00479     int (*to_can_async_p) (void);
00480     int (*to_is_async_p) (void);
00481     void (*to_async) (void (*) (enum inferior_event_type, void *), void *);
00482     int (*to_supports_non_stop) (void);
00483     /* find_memory_regions support method for gcore */
00484     int (*to_find_memory_regions) (find_memory_region_ftype func, void *data);
00485     /* make_corefile_notes support method for gcore */
00486     char * (*to_make_corefile_notes) (bfd *, int *);
00487     /* get_bookmark support method for bookmarks */
00488     gdb_byte * (*to_get_bookmark) (char *, int);
00489     /* goto_bookmark support method for bookmarks */
00490     void (*to_goto_bookmark) (gdb_byte *, int);
00491     /* Return the thread-local address at OFFSET in the
00492        thread-local storage for the thread PTID and the shared library
00493        or executable file given by OBJFILE.  If that block of
00494        thread-local storage hasn't been allocated yet, this function
00495        may return an error.  */
00496     CORE_ADDR (*to_get_thread_local_address) (struct target_ops *ops,
00497                                               ptid_t ptid,
00498                                               CORE_ADDR load_module_addr,
00499                                               CORE_ADDR offset);
00500 
00501     /* Request that OPS transfer up to LEN 8-bit bytes of the target's
00502        OBJECT.  The OFFSET, for a seekable object, specifies the
00503        starting point.  The ANNEX can be used to provide additional
00504        data-specific information to the target.
00505 
00506        Return the number of bytes actually transfered, zero when no
00507        further transfer is possible, and a negative error code (really
00508        an 'enum target_xfer_error' value) when the transfer is not
00509        supported.  Return of a positive value smaller than LEN does
00510        not indicate the end of the object, only the end of the
00511        transfer; higher level code should continue transferring if
00512        desired.  This is handled in target.c.
00513 
00514        The interface does not support a "retry" mechanism.  Instead it
00515        assumes that at least one byte will be transfered on each
00516        successful call.
00517 
00518        NOTE: cagney/2003-10-17: The current interface can lead to
00519        fragmented transfers.  Lower target levels should not implement
00520        hacks, such as enlarging the transfer, in an attempt to
00521        compensate for this.  Instead, the target stack should be
00522        extended so that it implements supply/collect methods and a
00523        look-aside object cache.  With that available, the lowest
00524        target can safely and freely "push" data up the stack.
00525 
00526        See target_read and target_write for more information.  One,
00527        and only one, of readbuf or writebuf must be non-NULL.  */
00528 
00529     LONGEST (*to_xfer_partial) (struct target_ops *ops,
00530                                 enum target_object object, const char *annex,
00531                                 gdb_byte *readbuf, const gdb_byte *writebuf,
00532                                 ULONGEST offset, LONGEST len);
00533 
00534     /* Returns the memory map for the target.  A return value of NULL
00535        means that no memory map is available.  If a memory address
00536        does not fall within any returned regions, it's assumed to be
00537        RAM.  The returned memory regions should not overlap.
00538 
00539        The order of regions does not matter; target_memory_map will
00540        sort regions by starting address.  For that reason, this
00541        function should not be called directly except via
00542        target_memory_map.
00543 
00544        This method should not cache data; if the memory map could
00545        change unexpectedly, it should be invalidated, and higher
00546        layers will re-fetch it.  */
00547     VEC(mem_region_s) *(*to_memory_map) (struct target_ops *);
00548 
00549     /* Erases the region of flash memory starting at ADDRESS, of
00550        length LENGTH.
00551 
00552        Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
00553        on flash block boundaries, as reported by 'to_memory_map'.  */
00554     void (*to_flash_erase) (struct target_ops *,
00555                            ULONGEST address, LONGEST length);
00556 
00557     /* Finishes a flash memory write sequence.  After this operation
00558        all flash memory should be available for writing and the result
00559        of reading from areas written by 'to_flash_write' should be
00560        equal to what was written.  */
00561     void (*to_flash_done) (struct target_ops *);
00562 
00563     /* Describe the architecture-specific features of this target.
00564        Returns the description found, or NULL if no description
00565        was available.  */
00566     const struct target_desc *(*to_read_description) (struct target_ops *ops);
00567 
00568     /* Build the PTID of the thread on which a given task is running,
00569        based on LWP and THREAD.  These values are extracted from the
00570        task Private_Data section of the Ada Task Control Block, and
00571        their interpretation depends on the target.  */
00572     ptid_t (*to_get_ada_task_ptid) (long lwp, long thread);
00573 
00574     /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
00575        Return 0 if *READPTR is already at the end of the buffer.
00576        Return -1 if there is insufficient buffer for a whole entry.
00577        Return 1 if an entry was read into *TYPEP and *VALP.  */
00578     int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr,
00579                          gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
00580 
00581     /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
00582        sequence of bytes in PATTERN with length PATTERN_LEN.
00583 
00584        The result is 1 if found, 0 if not found, and -1 if there was an error
00585        requiring halting of the search (e.g. memory read error).
00586        If the pattern is found the address is recorded in FOUND_ADDRP.  */
00587     int (*to_search_memory) (struct target_ops *ops,
00588                              CORE_ADDR start_addr, ULONGEST search_space_len,
00589                              const gdb_byte *pattern, ULONGEST pattern_len,
00590                              CORE_ADDR *found_addrp);
00591 
00592     /* Can target execute in reverse?  */
00593     int (*to_can_execute_reverse) (void);
00594 
00595     /* The direction the target is currently executing.  Must be
00596        implemented on targets that support reverse execution and async
00597        mode.  The default simply returns forward execution.  */
00598     enum exec_direction_kind (*to_execution_direction) (void);
00599 
00600     /* Does this target support debugging multiple processes
00601        simultaneously?  */
00602     int (*to_supports_multi_process) (void);
00603 
00604     /* Does this target support enabling and disabling tracepoints while a trace
00605        experiment is running?  */
00606     int (*to_supports_enable_disable_tracepoint) (void);
00607 
00608     /* Does this target support disabling address space randomization?  */
00609     int (*to_supports_disable_randomization) (void);
00610 
00611     /* Does this target support the tracenz bytecode for string collection?  */
00612     int (*to_supports_string_tracing) (void);
00613 
00614     /* Does this target support evaluation of breakpoint conditions on its
00615        end?  */
00616     int (*to_supports_evaluation_of_breakpoint_conditions) (void);
00617 
00618     /* Does this target support evaluation of breakpoint commands on its
00619        end?  */
00620     int (*to_can_run_breakpoint_commands) (void);
00621 
00622     /* Determine current architecture of thread PTID.
00623 
00624        The target is supposed to determine the architecture of the code where
00625        the target is currently stopped at (on Cell, if a target is in spu_run,
00626        to_thread_architecture would return SPU, otherwise PPC32 or PPC64).
00627        This is architecture used to perform decr_pc_after_break adjustment,
00628        and also determines the frame architecture of the innermost frame.
00629        ptrace operations need to operate according to target_gdbarch ().
00630 
00631        The default implementation always returns target_gdbarch ().  */
00632     struct gdbarch *(*to_thread_architecture) (struct target_ops *, ptid_t);
00633 
00634     /* Determine current address space of thread PTID.
00635 
00636        The default implementation always returns the inferior's
00637        address space.  */
00638     struct address_space *(*to_thread_address_space) (struct target_ops *,
00639                                                       ptid_t);
00640 
00641     /* Target file operations.  */
00642 
00643     /* Open FILENAME on the target, using FLAGS and MODE.  Return a
00644        target file descriptor, or -1 if an error occurs (and set
00645        *TARGET_ERRNO).  */
00646     int (*to_fileio_open) (const char *filename, int flags, int mode,
00647                            int *target_errno);
00648 
00649     /* Write up to LEN bytes from WRITE_BUF to FD on the target.
00650        Return the number of bytes written, or -1 if an error occurs
00651        (and set *TARGET_ERRNO).  */
00652     int (*to_fileio_pwrite) (int fd, const gdb_byte *write_buf, int len,
00653                              ULONGEST offset, int *target_errno);
00654 
00655     /* Read up to LEN bytes FD on the target into READ_BUF.
00656        Return the number of bytes read, or -1 if an error occurs
00657        (and set *TARGET_ERRNO).  */
00658     int (*to_fileio_pread) (int fd, gdb_byte *read_buf, int len,
00659                             ULONGEST offset, int *target_errno);
00660 
00661     /* Close FD on the target.  Return 0, or -1 if an error occurs
00662        (and set *TARGET_ERRNO).  */
00663     int (*to_fileio_close) (int fd, int *target_errno);
00664 
00665     /* Unlink FILENAME on the target.  Return 0, or -1 if an error
00666        occurs (and set *TARGET_ERRNO).  */
00667     int (*to_fileio_unlink) (const char *filename, int *target_errno);
00668 
00669     /* Read value of symbolic link FILENAME on the target.  Return a
00670        null-terminated string allocated via xmalloc, or NULL if an error
00671        occurs (and set *TARGET_ERRNO).  */
00672     char *(*to_fileio_readlink) (const char *filename, int *target_errno);
00673 
00674 
00675     /* Implement the "info proc" command.  */
00676     void (*to_info_proc) (struct target_ops *, char *, enum info_proc_what);
00677 
00678     /* Tracepoint-related operations.  */
00679 
00680     /* Prepare the target for a tracing run.  */
00681     void (*to_trace_init) (void);
00682 
00683     /* Send full details of a tracepoint location to the target.  */
00684     void (*to_download_tracepoint) (struct bp_location *location);
00685 
00686     /* Is the target able to download tracepoint locations in current
00687        state?  */
00688     int (*to_can_download_tracepoint) (void);
00689 
00690     /* Send full details of a trace state variable to the target.  */
00691     void (*to_download_trace_state_variable) (struct trace_state_variable *tsv);
00692 
00693     /* Enable a tracepoint on the target.  */
00694     void (*to_enable_tracepoint) (struct bp_location *location);
00695 
00696     /* Disable a tracepoint on the target.  */
00697     void (*to_disable_tracepoint) (struct bp_location *location);
00698 
00699     /* Inform the target info of memory regions that are readonly
00700        (such as text sections), and so it should return data from
00701        those rather than look in the trace buffer.  */
00702     void (*to_trace_set_readonly_regions) (void);
00703 
00704     /* Start a trace run.  */
00705     void (*to_trace_start) (void);
00706 
00707     /* Get the current status of a tracing run.  */
00708     int (*to_get_trace_status) (struct trace_status *ts);
00709 
00710     void (*to_get_tracepoint_status) (struct breakpoint *tp,
00711                                       struct uploaded_tp *utp);
00712 
00713     /* Stop a trace run.  */
00714     void (*to_trace_stop) (void);
00715 
00716    /* Ask the target to find a trace frame of the given type TYPE,
00717       using NUM, ADDR1, and ADDR2 as search parameters.  Returns the
00718       number of the trace frame, and also the tracepoint number at
00719       TPP.  If no trace frame matches, return -1.  May throw if the
00720       operation fails.  */
00721     int (*to_trace_find) (enum trace_find_type type, int num,
00722                           CORE_ADDR addr1, CORE_ADDR addr2, int *tpp);
00723 
00724     /* Get the value of the trace state variable number TSV, returning
00725        1 if the value is known and writing the value itself into the
00726        location pointed to by VAL, else returning 0.  */
00727     int (*to_get_trace_state_variable_value) (int tsv, LONGEST *val);
00728 
00729     int (*to_save_trace_data) (const char *filename);
00730 
00731     int (*to_upload_tracepoints) (struct uploaded_tp **utpp);
00732 
00733     int (*to_upload_trace_state_variables) (struct uploaded_tsv **utsvp);
00734 
00735     LONGEST (*to_get_raw_trace_data) (gdb_byte *buf,
00736                                       ULONGEST offset, LONGEST len);
00737 
00738     /* Get the minimum length of instruction on which a fast tracepoint
00739        may be set on the target.  If this operation is unsupported,
00740        return -1.  If for some reason the minimum length cannot be
00741        determined, return 0.  */
00742     int (*to_get_min_fast_tracepoint_insn_len) (void);
00743 
00744     /* Set the target's tracing behavior in response to unexpected
00745        disconnection - set VAL to 1 to keep tracing, 0 to stop.  */
00746     void (*to_set_disconnected_tracing) (int val);
00747     void (*to_set_circular_trace_buffer) (int val);
00748     /* Set the size of trace buffer in the target.  */
00749     void (*to_set_trace_buffer_size) (LONGEST val);
00750 
00751     /* Add/change textual notes about the trace run, returning 1 if
00752        successful, 0 otherwise.  */
00753     int (*to_set_trace_notes) (const char *user, const char *notes,
00754                                const char *stopnotes);
00755 
00756     /* Return the processor core that thread PTID was last seen on.
00757        This information is updated only when:
00758        - update_thread_list is called
00759        - thread stops
00760        If the core cannot be determined -- either for the specified
00761        thread, or right now, or in this debug session, or for this
00762        target -- return -1.  */
00763     int (*to_core_of_thread) (struct target_ops *, ptid_t ptid);
00764 
00765     /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
00766        matches the contents of [DATA,DATA+SIZE).  Returns 1 if there's
00767        a match, 0 if there's a mismatch, and -1 if an error is
00768        encountered while reading memory.  */
00769     int (*to_verify_memory) (struct target_ops *, const gdb_byte *data,
00770                              CORE_ADDR memaddr, ULONGEST size);
00771 
00772     /* Return the address of the start of the Thread Information Block
00773        a Windows OS specific feature.  */
00774     int (*to_get_tib_address) (ptid_t ptid, CORE_ADDR *addr);
00775 
00776     /* Send the new settings of write permission variables.  */
00777     void (*to_set_permissions) (void);
00778 
00779     /* Look for a static tracepoint marker at ADDR, and fill in MARKER
00780        with its details.  Return 1 on success, 0 on failure.  */
00781     int (*to_static_tracepoint_marker_at) (CORE_ADDR,
00782                                            struct static_tracepoint_marker *marker);
00783 
00784     /* Return a vector of all tracepoints markers string id ID, or all
00785        markers if ID is NULL.  */
00786     VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid)
00787       (const char *id);
00788 
00789     /* Return a traceframe info object describing the current
00790        traceframe's contents.  If the target doesn't support
00791        traceframe info, return NULL.  If the current traceframe is not
00792        selected (the current traceframe number is -1), the target can
00793        choose to return either NULL or an empty traceframe info.  If
00794        NULL is returned, for example in remote target, GDB will read
00795        from the live inferior.  If an empty traceframe info is
00796        returned, for example in tfile target, which means the
00797        traceframe info is available, but the requested memory is not
00798        available in it.  GDB will try to see if the requested memory
00799        is available in the read-only sections.  This method should not
00800        cache data; higher layers take care of caching, invalidating,
00801        and re-fetching when necessary.  */
00802     struct traceframe_info *(*to_traceframe_info) (void);
00803 
00804     /* Ask the target to use or not to use agent according to USE.  Return 1
00805        successful, 0 otherwise.  */
00806     int (*to_use_agent) (int use);
00807 
00808     /* Is the target able to use agent in current state?  */
00809     int (*to_can_use_agent) (void);
00810 
00811     /* Check whether the target supports branch tracing.  */
00812     int (*to_supports_btrace) (void);
00813 
00814     /* Enable branch tracing for PTID and allocate a branch trace target
00815        information struct for reading and for disabling branch trace.  */
00816     struct btrace_target_info *(*to_enable_btrace) (ptid_t ptid);
00817 
00818     /* Disable branch tracing and deallocate TINFO.  */
00819     void (*to_disable_btrace) (struct btrace_target_info *tinfo);
00820 
00821     /* Disable branch tracing and deallocate TINFO.  This function is similar
00822        to to_disable_btrace, except that it is called during teardown and is
00823        only allowed to perform actions that are safe.  A counter-example would
00824        be attempting to talk to a remote target.  */
00825     void (*to_teardown_btrace) (struct btrace_target_info *tinfo);
00826 
00827     /* Read branch trace data.  */
00828     VEC (btrace_block_s) *(*to_read_btrace) (struct btrace_target_info *,
00829                                              enum btrace_read_type);
00830 
00831     /* Stop trace recording.  */
00832     void (*to_stop_recording) (void);
00833 
00834     /* Print information about the recording.  */
00835     void (*to_info_record) (void);
00836 
00837     /* Save the recorded execution trace into a file.  */
00838     void (*to_save_record) (const char *filename);
00839 
00840     /* Delete the recorded execution trace from the current position onwards.  */
00841     void (*to_delete_record) (void);
00842 
00843     /* Query if the record target is currently replaying.  */
00844     int (*to_record_is_replaying) (void);
00845 
00846     /* Go to the begin of the execution trace.  */
00847     void (*to_goto_record_begin) (void);
00848 
00849     /* Go to the end of the execution trace.  */
00850     void (*to_goto_record_end) (void);
00851 
00852     /* Go to a specific location in the recorded execution trace.  */
00853     void (*to_goto_record) (ULONGEST insn);
00854 
00855     /* Disassemble SIZE instructions in the recorded execution trace from
00856        the current position.
00857        If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
00858        disassemble SIZE succeeding instructions.  */
00859     void (*to_insn_history) (int size, int flags);
00860 
00861     /* Disassemble SIZE instructions in the recorded execution trace around
00862        FROM.
00863        If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
00864        disassemble SIZE instructions after FROM.  */
00865     void (*to_insn_history_from) (ULONGEST from, int size, int flags);
00866 
00867     /* Disassemble a section of the recorded execution trace from instruction
00868        BEGIN (inclusive) to instruction END (exclusive).  */
00869     void (*to_insn_history_range) (ULONGEST begin, ULONGEST end, int flags);
00870 
00871     /* Print a function trace of the recorded execution trace.
00872        If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
00873        succeeding functions.  */
00874     void (*to_call_history) (int size, int flags);
00875 
00876     /* Print a function trace of the recorded execution trace starting
00877        at function FROM.
00878        If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
00879        SIZE functions after FROM.  */
00880     void (*to_call_history_from) (ULONGEST begin, int size, int flags);
00881 
00882     /* Print a function trace of an execution trace section from function BEGIN
00883        (inclusive) to function END (exclusive).  */
00884     void (*to_call_history_range) (ULONGEST begin, ULONGEST end, int flags);
00885 
00886     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
00887        non-empty annex.  */
00888     int (*to_augmented_libraries_svr4_read) (void);
00889 
00890     int to_magic;
00891     /* Need sub-structure for target machine related rather than comm related?
00892      */
00893   };
00894 
00895 /* Magic number for checking ops size.  If a struct doesn't end with this
00896    number, somebody changed the declaration but didn't change all the
00897    places that initialize one.  */
00898 
00899 #define OPS_MAGIC       3840
00900 
00901 /* The ops structure for our "current" target process.  This should
00902    never be NULL.  If there is no target, it points to the dummy_target.  */
00903 
00904 extern struct target_ops current_target;
00905 
00906 /* Define easy words for doing these operations on our current target.  */
00907 
00908 #define target_shortname        (current_target.to_shortname)
00909 #define target_longname         (current_target.to_longname)
00910 
00911 /* Does whatever cleanup is required for a target that we are no
00912    longer going to be calling.  This routine is automatically always
00913    called after popping the target off the target stack - the target's
00914    own methods are no longer available through the target vector.
00915    Closing file descriptors and freeing all memory allocated memory are
00916    typical things it should do.  */
00917 
00918 void target_close (struct target_ops *targ);
00919 
00920 /* Attaches to a process on the target side.  Arguments are as passed
00921    to the `attach' command by the user.  This routine can be called
00922    when the target is not on the target-stack, if the target_can_run
00923    routine returns 1; in that case, it must push itself onto the stack.
00924    Upon exit, the target should be ready for normal operations, and
00925    should be ready to deliver the status of the process immediately
00926    (without waiting) to an upcoming target_wait call.  */
00927 
00928 void target_attach (char *, int);
00929 
00930 /* Some targets don't generate traps when attaching to the inferior,
00931    or their target_attach implementation takes care of the waiting.
00932    These targets must set to_attach_no_wait.  */
00933 
00934 #define target_attach_no_wait \
00935      (current_target.to_attach_no_wait)
00936 
00937 /* The target_attach operation places a process under debugger control,
00938    and stops the process.
00939 
00940    This operation provides a target-specific hook that allows the
00941    necessary bookkeeping to be performed after an attach completes.  */
00942 #define target_post_attach(pid) \
00943      (*current_target.to_post_attach) (pid)
00944 
00945 /* Takes a program previously attached to and detaches it.
00946    The program may resume execution (some targets do, some don't) and will
00947    no longer stop on signals, etc.  We better not have left any breakpoints
00948    in the program or it'll die when it hits one.  ARGS is arguments
00949    typed by the user (e.g. a signal to send the process).  FROM_TTY
00950    says whether to be verbose or not.  */
00951 
00952 extern void target_detach (char *, int);
00953 
00954 /* Disconnect from the current target without resuming it (leaving it
00955    waiting for a debugger).  */
00956 
00957 extern void target_disconnect (char *, int);
00958 
00959 /* Resume execution of the target process PTID (or a group of
00960    threads).  STEP says whether to single-step or to run free; SIGGNAL
00961    is the signal to be given to the target, or GDB_SIGNAL_0 for no
00962    signal.  The caller may not pass GDB_SIGNAL_DEFAULT.  A specific
00963    PTID means `step/resume only this process id'.  A wildcard PTID
00964    (all threads, or all threads of process) means `step/resume
00965    INFERIOR_PTID, and let other threads (for which the wildcard PTID
00966    matches) resume with their 'thread->suspend.stop_signal' signal
00967    (usually GDB_SIGNAL_0) if it is in "pass" state, or with no signal
00968    if in "no pass" state.  */
00969 
00970 extern void target_resume (ptid_t ptid, int step, enum gdb_signal signal);
00971 
00972 /* Wait for process pid to do something.  PTID = -1 to wait for any
00973    pid to do something.  Return pid of child, or -1 in case of error;
00974    store status through argument pointer STATUS.  Note that it is
00975    _NOT_ OK to throw_exception() out of target_wait() without popping
00976    the debugging target from the stack; GDB isn't prepared to get back
00977    to the prompt with a debugging target but without the frame cache,
00978    stop_pc, etc., set up.  OPTIONS is a bitwise OR of TARGET_W*
00979    options.  */
00980 
00981 extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
00982                            int options);
00983 
00984 /* Fetch at least register REGNO, or all regs if regno == -1.  No result.  */
00985 
00986 extern void target_fetch_registers (struct regcache *regcache, int regno);
00987 
00988 /* Store at least register REGNO, or all regs if REGNO == -1.
00989    It can store as many registers as it wants to, so target_prepare_to_store
00990    must have been previously called.  Calls error() if there are problems.  */
00991 
00992 extern void target_store_registers (struct regcache *regcache, int regs);
00993 
00994 /* Get ready to modify the registers array.  On machines which store
00995    individual registers, this doesn't need to do anything.  On machines
00996    which store all the registers in one fell swoop, this makes sure
00997    that REGISTERS contains all the registers from the program being
00998    debugged.  */
00999 
01000 #define target_prepare_to_store(regcache)       \
01001      (*current_target.to_prepare_to_store) (regcache)
01002 
01003 /* Determine current address space of thread PTID.  */
01004 
01005 struct address_space *target_thread_address_space (ptid_t);
01006 
01007 /* Implement the "info proc" command.  This returns one if the request
01008    was handled, and zero otherwise.  It can also throw an exception if
01009    an error was encountered while attempting to handle the
01010    request.  */
01011 
01012 int target_info_proc (char *, enum info_proc_what);
01013 
01014 /* Returns true if this target can debug multiple processes
01015    simultaneously.  */
01016 
01017 #define target_supports_multi_process() \
01018      (*current_target.to_supports_multi_process) ()
01019 
01020 /* Returns true if this target can disable address space randomization.  */
01021 
01022 int target_supports_disable_randomization (void);
01023 
01024 /* Returns true if this target can enable and disable tracepoints
01025    while a trace experiment is running.  */
01026 
01027 #define target_supports_enable_disable_tracepoint() \
01028   (*current_target.to_supports_enable_disable_tracepoint) ()
01029 
01030 #define target_supports_string_tracing() \
01031   (*current_target.to_supports_string_tracing) ()
01032 
01033 /* Returns true if this target can handle breakpoint conditions
01034    on its end.  */
01035 
01036 #define target_supports_evaluation_of_breakpoint_conditions() \
01037   (*current_target.to_supports_evaluation_of_breakpoint_conditions) ()
01038 
01039 /* Returns true if this target can handle breakpoint commands
01040    on its end.  */
01041 
01042 #define target_can_run_breakpoint_commands() \
01043   (*current_target.to_can_run_breakpoint_commands) ()
01044 
01045 /* Invalidate all target dcaches.  */
01046 extern void target_dcache_invalidate (void);
01047 
01048 extern int target_read_string (CORE_ADDR, char **, int, int *);
01049 
01050 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
01051                                ssize_t len);
01052 
01053 extern int target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len);
01054 
01055 extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
01056                                 ssize_t len);
01057 
01058 extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
01059                                     ssize_t len);
01060 
01061 /* Fetches the target's memory map.  If one is found it is sorted
01062    and returned, after some consistency checking.  Otherwise, NULL
01063    is returned.  */
01064 VEC(mem_region_s) *target_memory_map (void);
01065 
01066 /* Erase the specified flash region.  */
01067 void target_flash_erase (ULONGEST address, LONGEST length);
01068 
01069 /* Finish a sequence of flash operations.  */
01070 void target_flash_done (void);
01071 
01072 /* Describes a request for a memory write operation.  */
01073 struct memory_write_request
01074   {
01075     /* Begining address that must be written.  */
01076     ULONGEST begin;
01077     /* Past-the-end address.  */
01078     ULONGEST end;
01079     /* The data to write.  */
01080     gdb_byte *data;
01081     /* A callback baton for progress reporting for this request.  */
01082     void *baton;
01083   };
01084 typedef struct memory_write_request memory_write_request_s;
01085 DEF_VEC_O(memory_write_request_s);
01086 
01087 /* Enumeration specifying different flash preservation behaviour.  */
01088 enum flash_preserve_mode
01089   {
01090     flash_preserve,
01091     flash_discard
01092   };
01093 
01094 /* Write several memory blocks at once.  This version can be more
01095    efficient than making several calls to target_write_memory, in
01096    particular because it can optimize accesses to flash memory.
01097 
01098    Moreover, this is currently the only memory access function in gdb
01099    that supports writing to flash memory, and it should be used for
01100    all cases where access to flash memory is desirable.
01101 
01102    REQUESTS is the vector (see vec.h) of memory_write_request.
01103    PRESERVE_FLASH_P indicates what to do with blocks which must be
01104      erased, but not completely rewritten.
01105    PROGRESS_CB is a function that will be periodically called to provide
01106      feedback to user.  It will be called with the baton corresponding
01107      to the request currently being written.  It may also be called
01108      with a NULL baton, when preserved flash sectors are being rewritten.
01109 
01110    The function returns 0 on success, and error otherwise.  */
01111 int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
01112                                 enum flash_preserve_mode preserve_flash_p,
01113                                 void (*progress_cb) (ULONGEST, void *));
01114 
01115 /* Print a line about the current target.  */
01116 
01117 #define target_files_info()     \
01118      (*current_target.to_files_info) (&current_target)
01119 
01120 /* Insert a breakpoint at address BP_TGT->placed_address in the target
01121    machine.  Result is 0 for success, non-zero for error.  */
01122 
01123 extern int target_insert_breakpoint (struct gdbarch *gdbarch,
01124                                      struct bp_target_info *bp_tgt);
01125 
01126 /* Remove a breakpoint at address BP_TGT->placed_address in the target
01127    machine.  Result is 0 for success, non-zero for error.  */
01128 
01129 extern int target_remove_breakpoint (struct gdbarch *gdbarch,
01130                                      struct bp_target_info *bp_tgt);
01131 
01132 /* Initialize the terminal settings we record for the inferior,
01133    before we actually run the inferior.  */
01134 
01135 #define target_terminal_init() \
01136      (*current_target.to_terminal_init) ()
01137 
01138 /* Put the inferior's terminal settings into effect.
01139    This is preparation for starting or resuming the inferior.  */
01140 
01141 extern void target_terminal_inferior (void);
01142 
01143 /* Put some of our terminal settings into effect,
01144    enough to get proper results from our output,
01145    but do not change into or out of RAW mode
01146    so that no input is discarded.
01147 
01148    After doing this, either terminal_ours or terminal_inferior
01149    should be called to get back to a normal state of affairs.  */
01150 
01151 #define target_terminal_ours_for_output() \
01152      (*current_target.to_terminal_ours_for_output) ()
01153 
01154 /* Put our terminal settings into effect.
01155    First record the inferior's terminal settings
01156    so they can be restored properly later.  */
01157 
01158 #define target_terminal_ours() \
01159      (*current_target.to_terminal_ours) ()
01160 
01161 /* Save our terminal settings.
01162    This is called from TUI after entering or leaving the curses
01163    mode.  Since curses modifies our terminal this call is here
01164    to take this change into account.  */
01165 
01166 #define target_terminal_save_ours() \
01167      (*current_target.to_terminal_save_ours) ()
01168 
01169 /* Print useful information about our terminal status, if such a thing
01170    exists.  */
01171 
01172 #define target_terminal_info(arg, from_tty) \
01173      (*current_target.to_terminal_info) (arg, from_tty)
01174 
01175 /* Kill the inferior process.   Make it go away.  */
01176 
01177 extern void target_kill (void);
01178 
01179 /* Load an executable file into the target process.  This is expected
01180    to not only bring new code into the target process, but also to
01181    update GDB's symbol tables to match.
01182 
01183    ARG contains command-line arguments, to be broken down with
01184    buildargv ().  The first non-switch argument is the filename to
01185    load, FILE; the second is a number (as parsed by strtoul (..., ...,
01186    0)), which is an offset to apply to the load addresses of FILE's
01187    sections.  The target may define switches, or other non-switch
01188    arguments, as it pleases.  */
01189 
01190 extern void target_load (char *arg, int from_tty);
01191 
01192 /* Start an inferior process and set inferior_ptid to its pid.
01193    EXEC_FILE is the file to run.
01194    ALLARGS is a string containing the arguments to the program.
01195    ENV is the environment vector to pass.  Errors reported with error().
01196    On VxWorks and various standalone systems, we ignore exec_file.  */
01197 
01198 void target_create_inferior (char *exec_file, char *args,
01199                              char **env, int from_tty);
01200 
01201 /* Some targets (such as ttrace-based HPUX) don't allow us to request
01202    notification of inferior events such as fork and vork immediately
01203    after the inferior is created.  (This because of how gdb gets an
01204    inferior created via invoking a shell to do it.  In such a scenario,
01205    if the shell init file has commands in it, the shell will fork and
01206    exec for each of those commands, and we will see each such fork
01207    event.  Very bad.)
01208 
01209    Such targets will supply an appropriate definition for this function.  */
01210 
01211 #define target_post_startup_inferior(ptid) \
01212      (*current_target.to_post_startup_inferior) (ptid)
01213 
01214 /* On some targets, we can catch an inferior fork or vfork event when
01215    it occurs.  These functions insert/remove an already-created
01216    catchpoint for such events.  They return  0 for success, 1 if the
01217    catchpoint type is not supported and -1 for failure.  */
01218 
01219 #define target_insert_fork_catchpoint(pid) \
01220      (*current_target.to_insert_fork_catchpoint) (pid)
01221 
01222 #define target_remove_fork_catchpoint(pid) \
01223      (*current_target.to_remove_fork_catchpoint) (pid)
01224 
01225 #define target_insert_vfork_catchpoint(pid) \
01226      (*current_target.to_insert_vfork_catchpoint) (pid)
01227 
01228 #define target_remove_vfork_catchpoint(pid) \
01229      (*current_target.to_remove_vfork_catchpoint) (pid)
01230 
01231 /* If the inferior forks or vforks, this function will be called at
01232    the next resume in order to perform any bookkeeping and fiddling
01233    necessary to continue debugging either the parent or child, as
01234    requested, and releasing the other.  Information about the fork
01235    or vfork event is available via get_last_target_status ().
01236    This function returns 1 if the inferior should not be resumed
01237    (i.e. there is another event pending).  */
01238 
01239 int target_follow_fork (int follow_child, int detach_fork);
01240 
01241 /* On some targets, we can catch an inferior exec event when it
01242    occurs.  These functions insert/remove an already-created
01243    catchpoint for such events.  They return  0 for success, 1 if the
01244    catchpoint type is not supported and -1 for failure.  */
01245 
01246 #define target_insert_exec_catchpoint(pid) \
01247      (*current_target.to_insert_exec_catchpoint) (pid)
01248 
01249 #define target_remove_exec_catchpoint(pid) \
01250      (*current_target.to_remove_exec_catchpoint) (pid)
01251 
01252 /* Syscall catch.
01253 
01254    NEEDED is nonzero if any syscall catch (of any kind) is requested.
01255    If NEEDED is zero, it means the target can disable the mechanism to
01256    catch system calls because there are no more catchpoints of this type.
01257 
01258    ANY_COUNT is nonzero if a generic (filter-less) syscall catch is
01259    being requested.  In this case, both TABLE_SIZE and TABLE should
01260    be ignored.
01261 
01262    TABLE_SIZE is the number of elements in TABLE.  It only matters if
01263    ANY_COUNT is zero.
01264 
01265    TABLE is an array of ints, indexed by syscall number.  An element in
01266    this array is nonzero if that syscall should be caught.  This argument
01267    only matters if ANY_COUNT is zero.
01268 
01269    Return 0 for success, 1 if syscall catchpoints are not supported or -1
01270    for failure.  */
01271 
01272 #define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table) \
01273      (*current_target.to_set_syscall_catchpoint) (pid, needed, any_count, \
01274                                                   table_size, table)
01275 
01276 /* Returns TRUE if PID has exited.  And, also sets EXIT_STATUS to the
01277    exit code of PID, if any.  */
01278 
01279 #define target_has_exited(pid,wait_status,exit_status) \
01280      (*current_target.to_has_exited) (pid,wait_status,exit_status)
01281 
01282 /* The debugger has completed a blocking wait() call.  There is now
01283    some process event that must be processed.  This function should
01284    be defined by those targets that require the debugger to perform
01285    cleanup or internal state changes in response to the process event.  */
01286 
01287 /* The inferior process has died.  Do what is right.  */
01288 
01289 void target_mourn_inferior (void);
01290 
01291 /* Does target have enough data to do a run or attach command? */
01292 
01293 #define target_can_run(t) \
01294      ((t)->to_can_run) ()
01295 
01296 /* Set list of signals to be handled in the target.
01297 
01298    PASS_SIGNALS is an array of size NSIG, indexed by target signal number
01299    (enum gdb_signal).  For every signal whose entry in this array is
01300    non-zero, the target is allowed -but not required- to skip reporting
01301    arrival of the signal to the GDB core by returning from target_wait,
01302    and to pass the signal directly to the inferior instead.
01303 
01304    However, if the target is hardware single-stepping a thread that is
01305    about to receive a signal, it needs to be reported in any case, even
01306    if mentioned in a previous target_pass_signals call.   */
01307 
01308 extern void target_pass_signals (int nsig, unsigned char *pass_signals);
01309 
01310 /* Set list of signals the target may pass to the inferior.  This
01311    directly maps to the "handle SIGNAL pass/nopass" setting.
01312 
01313    PROGRAM_SIGNALS is an array of size NSIG, indexed by target signal
01314    number (enum gdb_signal).  For every signal whose entry in this
01315    array is non-zero, the target is allowed to pass the signal to the
01316    inferior.  Signals not present in the array shall be silently
01317    discarded.  This does not influence whether to pass signals to the
01318    inferior as a result of a target_resume call.  This is useful in
01319    scenarios where the target needs to decide whether to pass or not a
01320    signal to the inferior without GDB core involvement, such as for
01321    example, when detaching (as threads may have been suspended with
01322    pending signals not reported to GDB).  */
01323 
01324 extern void target_program_signals (int nsig, unsigned char *program_signals);
01325 
01326 /* Check to see if a thread is still alive.  */
01327 
01328 extern int target_thread_alive (ptid_t ptid);
01329 
01330 /* Query for new threads and add them to the thread list.  */
01331 
01332 extern void target_find_new_threads (void);
01333 
01334 /* Make target stop in a continuable fashion.  (For instance, under
01335    Unix, this should act like SIGSTOP).  This function is normally
01336    used by GUIs to implement a stop button.  */
01337 
01338 extern void target_stop (ptid_t ptid);
01339 
01340 /* Send the specified COMMAND to the target's monitor
01341    (shell,interpreter) for execution.  The result of the query is
01342    placed in OUTBUF.  */
01343 
01344 #define target_rcmd(command, outbuf) \
01345      (*current_target.to_rcmd) (command, outbuf)
01346 
01347 
01348 /* Does the target include all of memory, or only part of it?  This
01349    determines whether we look up the target chain for other parts of
01350    memory if this target can't satisfy a request.  */
01351 
01352 extern int target_has_all_memory_1 (void);
01353 #define target_has_all_memory target_has_all_memory_1 ()
01354 
01355 /* Does the target include memory?  (Dummy targets don't.)  */
01356 
01357 extern int target_has_memory_1 (void);
01358 #define target_has_memory target_has_memory_1 ()
01359 
01360 /* Does the target have a stack?  (Exec files don't, VxWorks doesn't, until
01361    we start a process.)  */
01362 
01363 extern int target_has_stack_1 (void);
01364 #define target_has_stack target_has_stack_1 ()
01365 
01366 /* Does the target have registers?  (Exec files don't.)  */
01367 
01368 extern int target_has_registers_1 (void);
01369 #define target_has_registers target_has_registers_1 ()
01370 
01371 /* Does the target have execution?  Can we make it jump (through
01372    hoops), or pop its stack a few times?  This means that the current
01373    target is currently executing; for some targets, that's the same as
01374    whether or not the target is capable of execution, but there are
01375    also targets which can be current while not executing.  In that
01376    case this will become true after target_create_inferior or
01377    target_attach.  */
01378 
01379 extern int target_has_execution_1 (ptid_t);
01380 
01381 /* Like target_has_execution_1, but always passes inferior_ptid.  */
01382 
01383 extern int target_has_execution_current (void);
01384 
01385 #define target_has_execution target_has_execution_current ()
01386 
01387 /* Default implementations for process_stratum targets.  Return true
01388    if there's a selected inferior, false otherwise.  */
01389 
01390 extern int default_child_has_all_memory (struct target_ops *ops);
01391 extern int default_child_has_memory (struct target_ops *ops);
01392 extern int default_child_has_stack (struct target_ops *ops);
01393 extern int default_child_has_registers (struct target_ops *ops);
01394 extern int default_child_has_execution (struct target_ops *ops,
01395                                         ptid_t the_ptid);
01396 
01397 /* Can the target support the debugger control of thread execution?
01398    Can it lock the thread scheduler?  */
01399 
01400 #define target_can_lock_scheduler \
01401      (current_target.to_has_thread_control & tc_schedlock)
01402 
01403 /* Should the target enable async mode if it is supported?  Temporary
01404    cludge until async mode is a strict superset of sync mode.  */
01405 extern int target_async_permitted;
01406 
01407 /* Can the target support asynchronous execution?  */
01408 #define target_can_async_p() (current_target.to_can_async_p ())
01409 
01410 /* Is the target in asynchronous execution mode?  */
01411 #define target_is_async_p() (current_target.to_is_async_p ())
01412 
01413 int target_supports_non_stop (void);
01414 
01415 /* Put the target in async mode with the specified callback function.  */
01416 #define target_async(CALLBACK,CONTEXT) \
01417      (current_target.to_async ((CALLBACK), (CONTEXT)))
01418 
01419 #define target_execution_direction() \
01420   (current_target.to_execution_direction ())
01421 
01422 /* Converts a process id to a string.  Usually, the string just contains
01423    `process xyz', but on some systems it may contain
01424    `process xyz thread abc'.  */
01425 
01426 extern char *target_pid_to_str (ptid_t ptid);
01427 
01428 extern char *normal_pid_to_str (ptid_t ptid);
01429 
01430 /* Return a short string describing extra information about PID,
01431    e.g. "sleeping", "runnable", "running on LWP 3".  Null return value
01432    is okay.  */
01433 
01434 #define target_extra_thread_info(TP) \
01435      (current_target.to_extra_thread_info (TP))
01436 
01437 /* Return the thread's name.  A NULL result means that the target
01438    could not determine this thread's name.  */
01439 
01440 extern char *target_thread_name (struct thread_info *);
01441 
01442 /* Attempts to find the pathname of the executable file
01443    that was run to create a specified process.
01444 
01445    The process PID must be stopped when this operation is used.
01446 
01447    If the executable file cannot be determined, NULL is returned.
01448 
01449    Else, a pointer to a character string containing the pathname
01450    is returned.  This string should be copied into a buffer by
01451    the client if the string will not be immediately used, or if
01452    it must persist.  */
01453 
01454 #define target_pid_to_exec_file(pid) \
01455      (current_target.to_pid_to_exec_file) (pid)
01456 
01457 /* See the to_thread_architecture description in struct target_ops.  */
01458 
01459 #define target_thread_architecture(ptid) \
01460      (current_target.to_thread_architecture (&current_target, ptid))
01461 
01462 /*
01463  * Iterator function for target memory regions.
01464  * Calls a callback function once for each memory region 'mapped'
01465  * in the child process.  Defined as a simple macro rather than
01466  * as a function macro so that it can be tested for nullity.
01467  */
01468 
01469 #define target_find_memory_regions(FUNC, DATA) \
01470      (current_target.to_find_memory_regions) (FUNC, DATA)
01471 
01472 /*
01473  * Compose corefile .note section.
01474  */
01475 
01476 #define target_make_corefile_notes(BFD, SIZE_P) \
01477      (current_target.to_make_corefile_notes) (BFD, SIZE_P)
01478 
01479 /* Bookmark interfaces.  */
01480 #define target_get_bookmark(ARGS, FROM_TTY) \
01481      (current_target.to_get_bookmark) (ARGS, FROM_TTY)
01482 
01483 #define target_goto_bookmark(ARG, FROM_TTY) \
01484      (current_target.to_goto_bookmark) (ARG, FROM_TTY)
01485 
01486 /* Hardware watchpoint interfaces.  */
01487 
01488 /* Returns non-zero if we were stopped by a hardware watchpoint (memory read or
01489    write).  Only the INFERIOR_PTID task is being queried.  */
01490 
01491 #define target_stopped_by_watchpoint \
01492    (*current_target.to_stopped_by_watchpoint)
01493 
01494 /* Non-zero if we have steppable watchpoints  */
01495 
01496 #define target_have_steppable_watchpoint \
01497    (current_target.to_have_steppable_watchpoint)
01498 
01499 /* Non-zero if we have continuable watchpoints  */
01500 
01501 #define target_have_continuable_watchpoint \
01502    (current_target.to_have_continuable_watchpoint)
01503 
01504 /* Provide defaults for hardware watchpoint functions.  */
01505 
01506 /* If the *_hw_beakpoint functions have not been defined
01507    elsewhere use the definitions in the target vector.  */
01508 
01509 /* Returns non-zero if we can set a hardware watchpoint of type TYPE.  TYPE is
01510    one of bp_hardware_watchpoint, bp_read_watchpoint, bp_write_watchpoint, or
01511    bp_hardware_breakpoint.  CNT is the number of such watchpoints used so far
01512    (including this one?).  OTHERTYPE is who knows what...  */
01513 
01514 #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
01515  (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE);
01516 
01517 /* Returns the number of debug registers needed to watch the given
01518    memory region, or zero if not supported.  */
01519 
01520 #define target_region_ok_for_hw_watchpoint(addr, len) \
01521     (*current_target.to_region_ok_for_hw_watchpoint) (addr, len)
01522 
01523 
01524 /* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes.
01525    TYPE is 0 for write, 1 for read, and 2 for read/write accesses.
01526    COND is the expression for its condition, or NULL if there's none.
01527    Returns 0 for success, 1 if the watchpoint type is not supported,
01528    -1 for failure.  */
01529 
01530 #define target_insert_watchpoint(addr, len, type, cond) \
01531      (*current_target.to_insert_watchpoint) (addr, len, type, cond)
01532 
01533 #define target_remove_watchpoint(addr, len, type, cond) \
01534      (*current_target.to_remove_watchpoint) (addr, len, type, cond)
01535 
01536 /* Insert a new masked watchpoint at ADDR using the mask MASK.
01537    RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
01538    or hw_access for an access watchpoint.  Returns 0 for success, 1 if
01539    masked watchpoints are not supported, -1 for failure.  */
01540 
01541 extern int target_insert_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
01542 
01543 /* Remove a masked watchpoint at ADDR with the mask MASK.
01544    RW may be hw_read for a read watchpoint, hw_write for a write watchpoint
01545    or hw_access for an access watchpoint.  Returns 0 for success, non-zero
01546    for failure.  */
01547 
01548 extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
01549 
01550 #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \
01551      (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt)
01552 
01553 #define target_remove_hw_breakpoint(gdbarch, bp_tgt) \
01554      (*current_target.to_remove_hw_breakpoint) (gdbarch, bp_tgt)
01555 
01556 /* Return number of debug registers needed for a ranged breakpoint,
01557    or -1 if ranged breakpoints are not supported.  */
01558 
01559 extern int target_ranged_break_num_registers (void);
01560 
01561 /* Return non-zero if target knows the data address which triggered this
01562    target_stopped_by_watchpoint, in such case place it to *ADDR_P.  Only the
01563    INFERIOR_PTID task is being queried.  */
01564 #define target_stopped_data_address(target, addr_p) \
01565     (*target.to_stopped_data_address) (target, addr_p)
01566 
01567 /* Return non-zero if ADDR is within the range of a watchpoint spanning
01568    LENGTH bytes beginning at START.  */
01569 #define target_watchpoint_addr_within_range(target, addr, start, length) \
01570   (*target.to_watchpoint_addr_within_range) (target, addr, start, length)
01571 
01572 /* Return non-zero if the target is capable of using hardware to evaluate
01573    the condition expression.  In this case, if the condition is false when
01574    the watched memory location changes, execution may continue without the
01575    debugger being notified.
01576 
01577    Due to limitations in the hardware implementation, it may be capable of
01578    avoiding triggering the watchpoint in some cases where the condition
01579    expression is false, but may report some false positives as well.
01580    For this reason, GDB will still evaluate the condition expression when
01581    the watchpoint triggers.  */
01582 #define target_can_accel_watchpoint_condition(addr, len, type, cond) \
01583   (*current_target.to_can_accel_watchpoint_condition) (addr, len, type, cond)
01584 
01585 /* Return number of debug registers needed for a masked watchpoint,
01586    -1 if masked watchpoints are not supported or -2 if the given address
01587    and mask combination cannot be used.  */
01588 
01589 extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
01590 
01591 /* Target can execute in reverse?  */
01592 #define target_can_execute_reverse \
01593      (current_target.to_can_execute_reverse ? \
01594       current_target.to_can_execute_reverse () : 0)
01595 
01596 extern const struct target_desc *target_read_description (struct target_ops *);
01597 
01598 #define target_get_ada_task_ptid(lwp, tid) \
01599      (*current_target.to_get_ada_task_ptid) (lwp,tid)
01600 
01601 /* Utility implementation of searching memory.  */
01602 extern int simple_search_memory (struct target_ops* ops,
01603                                  CORE_ADDR start_addr,
01604                                  ULONGEST search_space_len,
01605                                  const gdb_byte *pattern,
01606                                  ULONGEST pattern_len,
01607                                  CORE_ADDR *found_addrp);
01608 
01609 /* Main entry point for searching memory.  */
01610 extern int target_search_memory (CORE_ADDR start_addr,
01611                                  ULONGEST search_space_len,
01612                                  const gdb_byte *pattern,
01613                                  ULONGEST pattern_len,
01614                                  CORE_ADDR *found_addrp);
01615 
01616 /* Target file operations.  */
01617 
01618 /* Open FILENAME on the target, using FLAGS and MODE.  Return a
01619    target file descriptor, or -1 if an error occurs (and set
01620    *TARGET_ERRNO).  */
01621 extern int target_fileio_open (const char *filename, int flags, int mode,
01622                                int *target_errno);
01623 
01624 /* Write up to LEN bytes from WRITE_BUF to FD on the target.
01625    Return the number of bytes written, or -1 if an error occurs
01626    (and set *TARGET_ERRNO).  */
01627 extern int target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
01628                                  ULONGEST offset, int *target_errno);
01629 
01630 /* Read up to LEN bytes FD on the target into READ_BUF.
01631    Return the number of bytes read, or -1 if an error occurs
01632    (and set *TARGET_ERRNO).  */
01633 extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len,
01634                                 ULONGEST offset, int *target_errno);
01635 
01636 /* Close FD on the target.  Return 0, or -1 if an error occurs
01637    (and set *TARGET_ERRNO).  */
01638 extern int target_fileio_close (int fd, int *target_errno);
01639 
01640 /* Unlink FILENAME on the target.  Return 0, or -1 if an error
01641    occurs (and set *TARGET_ERRNO).  */
01642 extern int target_fileio_unlink (const char *filename, int *target_errno);
01643 
01644 /* Read value of symbolic link FILENAME on the target.  Return a
01645    null-terminated string allocated via xmalloc, or NULL if an error
01646    occurs (and set *TARGET_ERRNO).  */
01647 extern char *target_fileio_readlink (const char *filename, int *target_errno);
01648 
01649 /* Read target file FILENAME.  The return value will be -1 if the transfer
01650    fails or is not supported; 0 if the object is empty; or the length
01651    of the object otherwise.  If a positive value is returned, a
01652    sufficiently large buffer will be allocated using xmalloc and
01653    returned in *BUF_P containing the contents of the object.
01654 
01655    This method should be used for objects sufficiently small to store
01656    in a single xmalloc'd buffer, when no fixed bound on the object's
01657    size is known in advance.  */
01658 extern LONGEST target_fileio_read_alloc (const char *filename,
01659                                          gdb_byte **buf_p);
01660 
01661 /* Read target file FILENAME.  The result is NUL-terminated and
01662    returned as a string, allocated using xmalloc.  If an error occurs
01663    or the transfer is unsupported, NULL is returned.  Empty objects
01664    are returned as allocated but empty strings.  A warning is issued
01665    if the result contains any embedded NUL bytes.  */
01666 extern char *target_fileio_read_stralloc (const char *filename);
01667 
01668 
01669 /* Tracepoint-related operations.  */
01670 
01671 #define target_trace_init() \
01672   (*current_target.to_trace_init) ()
01673 
01674 #define target_download_tracepoint(t) \
01675   (*current_target.to_download_tracepoint) (t)
01676 
01677 #define target_can_download_tracepoint() \
01678   (*current_target.to_can_download_tracepoint) ()
01679 
01680 #define target_download_trace_state_variable(tsv) \
01681   (*current_target.to_download_trace_state_variable) (tsv)
01682 
01683 #define target_enable_tracepoint(loc) \
01684   (*current_target.to_enable_tracepoint) (loc)
01685 
01686 #define target_disable_tracepoint(loc) \
01687   (*current_target.to_disable_tracepoint) (loc)
01688 
01689 #define target_trace_start() \
01690   (*current_target.to_trace_start) ()
01691 
01692 #define target_trace_set_readonly_regions() \
01693   (*current_target.to_trace_set_readonly_regions) ()
01694 
01695 #define target_get_trace_status(ts) \
01696   (*current_target.to_get_trace_status) (ts)
01697 
01698 #define target_get_tracepoint_status(tp,utp)            \
01699   (*current_target.to_get_tracepoint_status) (tp, utp)
01700 
01701 #define target_trace_stop() \
01702   (*current_target.to_trace_stop) ()
01703 
01704 #define target_trace_find(type,num,addr1,addr2,tpp) \
01705   (*current_target.to_trace_find) ((type), (num), (addr1), (addr2), (tpp))
01706 
01707 #define target_get_trace_state_variable_value(tsv,val) \
01708   (*current_target.to_get_trace_state_variable_value) ((tsv), (val))
01709 
01710 #define target_save_trace_data(filename) \
01711   (*current_target.to_save_trace_data) (filename)
01712 
01713 #define target_upload_tracepoints(utpp) \
01714   (*current_target.to_upload_tracepoints) (utpp)
01715 
01716 #define target_upload_trace_state_variables(utsvp) \
01717   (*current_target.to_upload_trace_state_variables) (utsvp)
01718 
01719 #define target_get_raw_trace_data(buf,offset,len) \
01720   (*current_target.to_get_raw_trace_data) ((buf), (offset), (len))
01721 
01722 #define target_get_min_fast_tracepoint_insn_len() \
01723   (*current_target.to_get_min_fast_tracepoint_insn_len) ()
01724 
01725 #define target_set_disconnected_tracing(val) \
01726   (*current_target.to_set_disconnected_tracing) (val)
01727 
01728 #define target_set_circular_trace_buffer(val)   \
01729   (*current_target.to_set_circular_trace_buffer) (val)
01730 
01731 #define target_set_trace_buffer_size(val)       \
01732   (*current_target.to_set_trace_buffer_size) (val)
01733 
01734 #define target_set_trace_notes(user,notes,stopnotes)            \
01735   (*current_target.to_set_trace_notes) ((user), (notes), (stopnotes))
01736 
01737 #define target_get_tib_address(ptid, addr) \
01738   (*current_target.to_get_tib_address) ((ptid), (addr))
01739 
01740 #define target_set_permissions() \
01741   (*current_target.to_set_permissions) ()
01742 
01743 #define target_static_tracepoint_marker_at(addr, marker) \
01744   (*current_target.to_static_tracepoint_marker_at) (addr, marker)
01745 
01746 #define target_static_tracepoint_markers_by_strid(marker_id) \
01747   (*current_target.to_static_tracepoint_markers_by_strid) (marker_id)
01748 
01749 #define target_traceframe_info() \
01750   (*current_target.to_traceframe_info) ()
01751 
01752 #define target_use_agent(use) \
01753   (*current_target.to_use_agent) (use)
01754 
01755 #define target_can_use_agent() \
01756   (*current_target.to_can_use_agent) ()
01757 
01758 #define target_augmented_libraries_svr4_read() \
01759   (*current_target.to_augmented_libraries_svr4_read) ()
01760 
01761 /* Command logging facility.  */
01762 
01763 #define target_log_command(p)                                           \
01764   do                                                                    \
01765     if (current_target.to_log_command)                                  \
01766       (*current_target.to_log_command) (p);                             \
01767   while (0)
01768 
01769 
01770 extern int target_core_of_thread (ptid_t ptid);
01771 
01772 /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range matches
01773    the contents of [DATA,DATA+SIZE).  Returns 1 if there's a match, 0
01774    if there's a mismatch, and -1 if an error is encountered while
01775    reading memory.  Throws an error if the functionality is found not
01776    to be supported by the current target.  */
01777 int target_verify_memory (const gdb_byte *data,
01778                           CORE_ADDR memaddr, ULONGEST size);
01779 
01780 /* Routines for maintenance of the target structures...
01781 
01782    complete_target_initialization: Finalize a target_ops by filling in
01783    any fields needed by the target implementation.
01784 
01785    add_target:   Add a target to the list of all possible targets.
01786 
01787    push_target:  Make this target the top of the stack of currently used
01788    targets, within its particular stratum of the stack.  Result
01789    is 0 if now atop the stack, nonzero if not on top (maybe
01790    should warn user).
01791 
01792    unpush_target: Remove this from the stack of currently used targets,
01793    no matter where it is on the list.  Returns 0 if no
01794    change, 1 if removed from stack.  */
01795 
01796 extern void add_target (struct target_ops *);
01797 
01798 extern void add_target_with_completer (struct target_ops *t,
01799                                        completer_ftype *completer);
01800 
01801 extern void complete_target_initialization (struct target_ops *t);
01802 
01803 /* Adds a command ALIAS for target T and marks it deprecated.  This is useful
01804    for maintaining backwards compatibility when renaming targets.  */
01805 
01806 extern void add_deprecated_target_alias (struct target_ops *t, char *alias);
01807 
01808 extern void push_target (struct target_ops *);
01809 
01810 extern int unpush_target (struct target_ops *);
01811 
01812 extern void target_pre_inferior (int);
01813 
01814 extern void target_preopen (int);
01815 
01816 /* Does whatever cleanup is required to get rid of all pushed targets.  */
01817 extern void pop_all_targets (void);
01818 
01819 /* Like pop_all_targets, but pops only targets whose stratum is
01820    strictly above ABOVE_STRATUM.  */
01821 extern void pop_all_targets_above (enum strata above_stratum);
01822 
01823 extern int target_is_pushed (struct target_ops *t);
01824 
01825 extern CORE_ADDR target_translate_tls_address (struct objfile *objfile,
01826                                                CORE_ADDR offset);
01827 
01828 /* Struct target_section maps address ranges to file sections.  It is
01829    mostly used with BFD files, but can be used without (e.g. for handling
01830    raw disks, or files not in formats handled by BFD).  */
01831 
01832 struct target_section
01833   {
01834     CORE_ADDR addr;             /* Lowest address in section */
01835     CORE_ADDR endaddr;          /* 1+highest address in section */
01836 
01837     struct bfd_section *the_bfd_section;
01838 
01839     /* The "owner" of the section.
01840        It can be any unique value.  It is set by add_target_sections
01841        and used by remove_target_sections.
01842        For example, for executables it is a pointer to exec_bfd and
01843        for shlibs it is the so_list pointer.  */
01844     void *owner;
01845   };
01846 
01847 /* Holds an array of target sections.  Defined by [SECTIONS..SECTIONS_END[.  */
01848 
01849 struct target_section_table
01850 {
01851   struct target_section *sections;
01852   struct target_section *sections_end;
01853 };
01854 
01855 /* Return the "section" containing the specified address.  */
01856 struct target_section *target_section_by_addr (struct target_ops *target,
01857                                                CORE_ADDR addr);
01858 
01859 /* Return the target section table this target (or the targets
01860    beneath) currently manipulate.  */
01861 
01862 extern struct target_section_table *target_get_section_table
01863   (struct target_ops *target);
01864 
01865 /* From mem-break.c */
01866 
01867 extern int memory_remove_breakpoint (struct gdbarch *,
01868                                      struct bp_target_info *);
01869 
01870 extern int memory_insert_breakpoint (struct gdbarch *,
01871                                      struct bp_target_info *);
01872 
01873 extern int default_memory_remove_breakpoint (struct gdbarch *,
01874                                              struct bp_target_info *);
01875 
01876 extern int default_memory_insert_breakpoint (struct gdbarch *,
01877                                              struct bp_target_info *);
01878 
01879 
01880 /* From target.c */
01881 
01882 extern void initialize_targets (void);
01883 
01884 extern void noprocess (void) ATTRIBUTE_NORETURN;
01885 
01886 extern void target_require_runnable (void);
01887 
01888 extern void find_default_attach (struct target_ops *, char *, int);
01889 
01890 extern void find_default_create_inferior (struct target_ops *,
01891                                           char *, char *, char **, int);
01892 
01893 extern struct target_ops *find_target_beneath (struct target_ops *);
01894 
01895 /* Read OS data object of type TYPE from the target, and return it in
01896    XML format.  The result is NUL-terminated and returned as a string,
01897    allocated using xmalloc.  If an error occurs or the transfer is
01898    unsupported, NULL is returned.  Empty objects are returned as
01899    allocated but empty strings.  */
01900 
01901 extern char *target_get_osdata (const char *type);
01902 
01903 
01904 /* Stuff that should be shared among the various remote targets.  */
01905 
01906 /* Debugging level.  0 is off, and non-zero values mean to print some debug
01907    information (higher values, more information).  */
01908 extern int remote_debug;
01909 
01910 /* Speed in bits per second, or -1 which means don't mess with the speed.  */
01911 extern int baud_rate;
01912 /* Timeout limit for response from target.  */
01913 extern int remote_timeout;
01914 
01915 
01916 
01917 /* Set the show memory breakpoints mode to show, and installs a cleanup
01918    to restore it back to the current value.  */
01919 extern struct cleanup *make_show_memory_breakpoints_cleanup (int show);
01920 
01921 extern int may_write_registers;
01922 extern int may_write_memory;
01923 extern int may_insert_breakpoints;
01924 extern int may_insert_tracepoints;
01925 extern int may_insert_fast_tracepoints;
01926 extern int may_stop;
01927 
01928 extern void update_target_permissions (void);
01929 
01930 
01931 /* Imported from machine dependent code.  */
01932 
01933 /* Blank target vector entries are initialized to target_ignore.  */
01934 void target_ignore (void);
01935 
01936 /* See to_supports_btrace in struct target_ops.  */
01937 extern int target_supports_btrace (void);
01938 
01939 /* See to_enable_btrace in struct target_ops.  */
01940 extern struct btrace_target_info *target_enable_btrace (ptid_t ptid);
01941 
01942 /* See to_disable_btrace in struct target_ops.  */
01943 extern void target_disable_btrace (struct btrace_target_info *btinfo);
01944 
01945 /* See to_teardown_btrace in struct target_ops.  */
01946 extern void target_teardown_btrace (struct btrace_target_info *btinfo);
01947 
01948 /* See to_read_btrace in struct target_ops.  */
01949 extern VEC (btrace_block_s) *target_read_btrace (struct btrace_target_info *,
01950                                                  enum btrace_read_type);
01951 
01952 /* See to_stop_recording in struct target_ops.  */
01953 extern void target_stop_recording (void);
01954 
01955 /* See to_info_record in struct target_ops.  */
01956 extern void target_info_record (void);
01957 
01958 /* See to_save_record in struct target_ops.  */
01959 extern void target_save_record (const char *filename);
01960 
01961 /* Query if the target supports deleting the execution log.  */
01962 extern int target_supports_delete_record (void);
01963 
01964 /* See to_delete_record in struct target_ops.  */
01965 extern void target_delete_record (void);
01966 
01967 /* See to_record_is_replaying in struct target_ops.  */
01968 extern int target_record_is_replaying (void);
01969 
01970 /* See to_goto_record_begin in struct target_ops.  */
01971 extern void target_goto_record_begin (void);
01972 
01973 /* See to_goto_record_end in struct target_ops.  */
01974 extern void target_goto_record_end (void);
01975 
01976 /* See to_goto_record in struct target_ops.  */
01977 extern void target_goto_record (ULONGEST insn);
01978 
01979 /* See to_insn_history.  */
01980 extern void target_insn_history (int size, int flags);
01981 
01982 /* See to_insn_history_from.  */
01983 extern void target_insn_history_from (ULONGEST from, int size, int flags);
01984 
01985 /* See to_insn_history_range.  */
01986 extern void target_insn_history_range (ULONGEST begin, ULONGEST end, int flags);
01987 
01988 /* See to_call_history.  */
01989 extern void target_call_history (int size, int flags);
01990 
01991 /* See to_call_history_from.  */
01992 extern void target_call_history_from (ULONGEST begin, int size, int flags);
01993 
01994 /* See to_call_history_range.  */
01995 extern void target_call_history_range (ULONGEST begin, ULONGEST end, int flags);
01996 
01997 #endif /* !defined (TARGET_H) */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines