proc-events.c: fix compilation on Solaris
[deliverable/binutils-gdb.git] / gdb / target.h
index e7577e14de29c006efd21d5a6e0c38d8fccad874..f208b10767681dd767aac4c5ce65fb5cbebf7bbe 100644 (file)
@@ -1,6 +1,6 @@
 /* Interface between GDB and target environments, including files and processes
 
-   Copyright (C) 1990-2017 Free Software Foundation, Inc.
+   Copyright (C) 1990-2018 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.  Written by John Gilmore.
 
@@ -181,15 +181,6 @@ enum target_object
   TARGET_OBJECT_THREADS,
   /* Collected static trace data.  */
   TARGET_OBJECT_STATIC_TRACE_DATA,
-  /* The HP-UX registers (those that can be obtained or modified by using
-     the TT_LWP_RUREGS/TT_LWP_WUREGS ttrace requests).  */
-  TARGET_OBJECT_HPUX_UREGS,
-  /* The HP-UX shared library linkage pointer.  ANNEX should be a string
-     image of the code address whose linkage pointer we are looking for.
-
-     The size of the data transfered is always 8 bytes (the size of an
-     address on ia64).  */
-  TARGET_OBJECT_HPUX_SOLIB_GOT,
   /* Traceframe info, in XML format.  */
   TARGET_OBJECT_TRACEFRAME_INFO,
   /* Load maps for FDPIC systems.  */
@@ -236,9 +227,6 @@ enum target_xfer_status
 extern const char *
   target_xfer_status_to_string (enum target_xfer_status status);
 
-typedef struct static_tracepoint_marker *static_tracepoint_marker_p;
-DEF_VEC_P(static_tracepoint_marker_p);
-
 typedef enum target_xfer_status
   target_xfer_partial_ftype (struct target_ops *ops,
                             enum target_object object,
@@ -336,29 +324,26 @@ LONGEST target_write_with_progress (struct target_ops *ops,
                                    void (*progress) (ULONGEST, void *),
                                    void *baton);
 
-/* Wrapper to perform a full read of unknown size.  OBJECT/ANNEX will
-   be read using OPS.  The return value will be -1 if the transfer
-   fails or is not supported; 0 if the object is empty; or the length
-   of the object otherwise.  If a positive value is returned, a
-   sufficiently large buffer will be allocated using xmalloc and
-   returned in *BUF_P containing the contents of the object.
+/* Wrapper to perform a full read of unknown size.  OBJECT/ANNEX will be read
+   using OPS.  The return value will be uninstantiated if the transfer fails or
+   is not supported.
 
    This method should be used for objects sufficiently small to store
    in a single xmalloc'd buffer, when no fixed bound on the object's
    size is known in advance.  Don't try to read TARGET_OBJECT_MEMORY
    through this function.  */
 
-extern LONGEST target_read_alloc (struct target_ops *ops,
-                                 enum target_object object,
-                                 const char *annex, gdb_byte **buf_p);
+extern gdb::optional<gdb::byte_vector> target_read_alloc
+    (struct target_ops *ops, enum target_object object, const char *annex);
 
-/* Read OBJECT/ANNEX using OPS.  The result is NUL-terminated and
-   returned as a string.  If an error occurs or the transfer is
-   unsupported, NULL is returned.  Empty objects are returned as
-   allocated but empty strings.  A warning is issued if the result
-   contains any embedded NUL bytes.  */
+/* Read OBJECT/ANNEX using OPS.  The result is a NUL-terminated character vector
+   (therefore usable as a NUL-terminated string).  If an error occurs or the
+   transfer is unsupported, the return value will be uninstantiated.  Empty
+   objects are returned as allocated but empty strings.  Therefore, on success,
+   the returned vector is guaranteed to have at least one element.  A warning is
+   issued if the result contains any embedded NUL bytes.  */
 
-extern gdb::unique_xmalloc_ptr<char> target_read_stralloc
+extern gdb::optional<gdb::char_vector> target_read_stralloc
     (struct target_ops *ops, enum target_object object, const char *annex);
 
 /* See target_ops->to_xfer_partial.  */
@@ -418,11 +403,6 @@ typedef void async_callback_ftype (enum inferior_event_type event_type,
 #define TARGET_DEFAULT_RETURN(ARG)
 #define TARGET_DEFAULT_FUNC(ARG)
 
-/* Define a typedef, because make-target-delegates doesn't currently handle type
-   names with templates.  */
-
-typedef std::vector<mem_region> mem_region_vector;
-
 struct target_ops
   {
     struct target_ops *beneath;        /* To the target under this one.  */
@@ -454,7 +434,7 @@ struct target_ops
     void (*to_attach) (struct target_ops *ops, const char *, int);
     void (*to_post_attach) (struct target_ops *, int)
       TARGET_DEFAULT_IGNORE ();
-    void (*to_detach) (struct target_ops *ops, const char *, int)
+    void (*to_detach) (struct target_ops *ops, inferior *, int)
       TARGET_DEFAULT_IGNORE ();
     void (*to_disconnect) (struct target_ops *, const char *, int)
       TARGET_DEFAULT_NORETURN (tcomplain ());
@@ -575,6 +555,8 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
     void (*to_terminal_inferior) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_save_inferior) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
     void (*to_terminal_ours_for_output) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
     void (*to_terminal_ours) (struct target_ops *)
@@ -612,10 +594,9 @@ struct target_ops
     void (*to_follow_exec) (struct target_ops *, struct inferior *, char *)
       TARGET_DEFAULT_IGNORE ();
     int (*to_set_syscall_catchpoint) (struct target_ops *,
-                                     int, int, int, int, int *)
+                                     int, bool, int,
+                                     gdb::array_view<const int>)
       TARGET_DEFAULT_RETURN (1);
-    int (*to_has_exited) (struct target_ops *, int, int, int *)
-      TARGET_DEFAULT_RETURN (0);
     void (*to_mourn_inferior) (struct target_ops *)
       TARGET_DEFAULT_FUNC (default_mourn_inferior);
     /* Note that to_can_run is special and can be invoked on an
@@ -653,7 +634,7 @@ struct target_ops
       TARGET_DEFAULT_RETURN (NULL);
     void (*to_stop) (struct target_ops *, ptid_t)
       TARGET_DEFAULT_IGNORE ();
-    void (*to_interrupt) (struct target_ops *, ptid_t)
+    void (*to_interrupt) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
     void (*to_pass_ctrlc) (struct target_ops *)
       TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
@@ -777,7 +758,7 @@ struct target_ops
        This method should not cache data; if the memory map could
        change unexpectedly, it should be invalidated, and higher
        layers will re-fetch it.  */
-    mem_region_vector (*to_memory_map) (struct target_ops *)
+    std::vector<mem_region> (*to_memory_map) (struct target_ops *)
       TARGET_DEFAULT_RETURN (std::vector<mem_region> ());
 
     /* Erases the region of flash memory starting at ADDRESS, of
@@ -944,12 +925,12 @@ struct target_ops
     /* Read value of symbolic link FILENAME on the target, in the
        filesystem as seen by INF.  If INF is NULL, use the filesystem
        seen by the debugger (GDB or, for remote targets, the remote
-       stub).  Return a null-terminated string allocated via xmalloc,
-       or NULL if an error occurs (and set *TARGET_ERRNO).  */
-    char *(*to_fileio_readlink) (struct target_ops *,
-                                struct inferior *inf,
-                                const char *filename,
-                                int *target_errno);
+       stub).  Return a string, or an empty optional if an error
+       occurs (and set *TARGET_ERRNO).  */
+    gdb::optional<std::string> (*to_fileio_readlink) (struct target_ops *,
+                                                     struct inferior *inf,
+                                                     const char *filename,
+                                                     int *target_errno);
 
 
     /* Implement the "info proc" command.  */
@@ -974,7 +955,7 @@ struct target_ops
 
     /* Send full details of a trace state variable to the target.  */
     void (*to_download_trace_state_variable) (struct target_ops *,
-                                             struct trace_state_variable *tsv)
+                                             const trace_state_variable &tsv)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Enable a tracepoint on the target.  */
@@ -1095,14 +1076,16 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
 
     /* Look for a static tracepoint marker at ADDR, and fill in MARKER
-       with its details.  Return 1 on success, 0 on failure.  */
-    int (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
-                                          struct static_tracepoint_marker *marker)
-      TARGET_DEFAULT_RETURN (0);
+       with its details.  Return true on success, false on failure.  */
+    bool (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
+                                           static_tracepoint_marker *marker)
+      TARGET_DEFAULT_RETURN (false);
 
     /* Return a vector of all tracepoints markers string id ID, or all
        markers if ID is NULL.  */
-    VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid) (struct target_ops *, const char *id)
+    std::vector<static_tracepoint_marker>
+      (*to_static_tracepoint_markers_by_strid) (struct target_ops *,
+                                               const char *id)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Return a traceframe info object describing the current
@@ -1121,10 +1104,6 @@ struct target_ops
     int (*to_can_use_agent) (struct target_ops *)
       TARGET_DEFAULT_RETURN (0);
 
-    /* Check whether the target supports branch tracing.  */
-    int (*to_supports_btrace) (struct target_ops *, enum btrace_format)
-      TARGET_DEFAULT_RETURN (0);
-
     /* Enable branch tracing for PTID using CONF configuration.
        Return a branch trace target information struct for reading and for
        disabling branch trace.  */
@@ -1232,7 +1211,7 @@ struct target_ops
     /* Print a function trace of the recorded execution trace.
        If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
        succeeding functions.  */
-    void (*to_call_history) (struct target_ops *, int size, int flags)
+    void (*to_call_history) (struct target_ops *, int size, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of the recorded execution trace starting
@@ -1240,13 +1219,13 @@ struct target_ops
        If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
        SIZE functions after FROM.  */
     void (*to_call_history_from) (struct target_ops *,
-                                 ULONGEST begin, int size, int flags)
+                                 ULONGEST begin, int size, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of an execution trace section from function BEGIN
        (inclusive) to function END (inclusive).  */
     void (*to_call_history_range) (struct target_ops *,
-                                  ULONGEST begin, ULONGEST end, int flags)
+                                  ULONGEST begin, ULONGEST end, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
@@ -1336,11 +1315,10 @@ extern void target_announce_detach (int from_tty);
 /* Takes a program previously attached to and detaches it.
    The program may resume execution (some targets do, some don't) and will
    no longer stop on signals, etc.  We better not have left any breakpoints
-   in the program or it'll die when it hits one.  ARGS is arguments
-   typed by the user (e.g. a signal to send the process).  FROM_TTY
-   says whether to be verbose or not.  */
+   in the program or it'll die when it hits one.  FROM_TTY says whether to be
+   verbose or not.  */
 
-extern void target_detach (const char *, int);
+extern void target_detach (inferior *inf, int from_tty);
 
 /* Disconnect from the current target without resuming it (leaving it
    waiting for a debugger).  */
@@ -1447,7 +1425,8 @@ int target_supports_disable_randomization (void);
 #define target_can_run_breakpoint_commands() \
   (*current_target.to_can_run_breakpoint_commands) (&current_target)
 
-extern int target_read_string (CORE_ADDR, char **, int, int *);
+extern int target_read_string (CORE_ADDR, gdb::unique_xmalloc_ptr<char> *,
+                              int, int *);
 
 /* For target_read_memory see target/target.h.  */
 
@@ -1469,7 +1448,7 @@ extern int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
 std::vector<mem_region> target_memory_map (void);
 
 /* Erases all flash memory regions on the target.  */
-void flash_erase_command (char *cmd, int from_tty);
+void flash_erase_command (const char *cmd, int from_tty);
 
 /* Erase the specified flash region.  */
 void target_flash_erase (ULONGEST address, LONGEST length);
@@ -1479,18 +1458,21 @@ void target_flash_done (void);
 
 /* Describes a request for a memory write operation.  */
 struct memory_write_request
-  {
-    /* Begining address that must be written.  */
-    ULONGEST begin;
-    /* Past-the-end address.  */
-    ULONGEST end;
-    /* The data to write.  */
-    gdb_byte *data;
-    /* A callback baton for progress reporting for this request.  */
-    void *baton;
-  };
-typedef struct memory_write_request memory_write_request_s;
-DEF_VEC_O(memory_write_request_s);
+{
+  memory_write_request (ULONGEST begin_, ULONGEST end_,
+                       gdb_byte *data_ = nullptr, void *baton_ = nullptr)
+    : begin (begin_), end (end_), data (data_), baton (baton_)
+  {}
+
+  /* Begining address that must be written.  */
+  ULONGEST begin;
+  /* Past-the-end address.  */
+  ULONGEST end;
+  /* The data to write.  */
+  gdb_byte *data;
+  /* A callback baton for progress reporting for this request.  */
+  void *baton;
+};
 
 /* Enumeration specifying different flash preservation behaviour.  */
 enum flash_preserve_mode
@@ -1516,9 +1498,10 @@ enum flash_preserve_mode
      with a NULL baton, when preserved flash sectors are being rewritten.
 
    The function returns 0 on success, and error otherwise.  */
-int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
-                               enum flash_preserve_mode preserve_flash_p,
-                               void (*progress_cb) (ULONGEST, void *));
+int target_write_memory_blocks
+    (const std::vector<memory_write_request> &requests,
+     enum flash_preserve_mode preserve_flash_p,
+     void (*progress_cb) (ULONGEST, void *));
 
 /* Print a line about the current target.  */
 
@@ -1620,35 +1603,24 @@ void target_follow_exec (struct inferior *inf, char *execd_pathname);
 
 /* Syscall catch.
 
-   NEEDED is nonzero if any syscall catch (of any kind) is requested.
-   If NEEDED is zero, it means the target can disable the mechanism to
+   NEEDED is true if any syscall catch (of any kind) is requested.
+   If NEEDED is false, it means the target can disable the mechanism to
    catch system calls because there are no more catchpoints of this type.
 
    ANY_COUNT is nonzero if a generic (filter-less) syscall catch is
-   being requested.  In this case, both TABLE_SIZE and TABLE should
-   be ignored.
+   being requested.  In this case, SYSCALL_COUNTS should be ignored.
 
-   TABLE_SIZE is the number of elements in TABLE.  It only matters if
-   ANY_COUNT is zero.
-
-   TABLE is an array of ints, indexed by syscall number.  An element in
-   this array is nonzero if that syscall should be caught.  This argument
-   only matters if ANY_COUNT is zero.
+   SYSCALL_COUNTS is an array of ints, indexed by syscall number.  An
+   element in this array is nonzero if that syscall should be caught.
+   This argument only matters if ANY_COUNT is zero.
 
    Return 0 for success, 1 if syscall catchpoints are not supported or -1
    for failure.  */
 
-#define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table) \
+#define target_set_syscall_catchpoint(pid, needed, any_count, syscall_counts) \
      (*current_target.to_set_syscall_catchpoint) (&current_target,     \
                                                  pid, needed, any_count, \
-                                                 table_size, table)
-
-/* Returns TRUE if PID has exited.  And, also sets EXIT_STATUS to the
-   exit code of PID, if any.  */
-
-#define target_has_exited(pid,wait_status,exit_status) \
-     (*current_target.to_has_exited) (&current_target, \
-                                     pid,wait_status,exit_status)
+                                                 syscall_counts)
 
 /* The debugger has completed a blocking wait() call.  There is now
    some process event that must be processed.  This function should
@@ -1708,16 +1680,18 @@ extern void target_update_thread_list (void);
 
 extern void target_stop (ptid_t ptid);
 
-/* Interrupt the target just like the user typed a ^C on the
-   inferior's controlling terminal.  (For instance, under Unix, this
-   should act like SIGINT).  This function is asynchronous.  */
+/* Interrupt the target.  Unlike target_stop, this does not specify
+   which thread/process reports the stop.  For most target this acts
+   like raising a SIGINT, though that's not absolutely required.  This
+   function is asynchronous.  */
 
-extern void target_interrupt (ptid_t ptid);
+extern void target_interrupt ();
 
 /* Pass a ^C, as determined to have been pressed by checking the quit
-   flag, to the target.  Normally calls target_interrupt, but remote
-   targets may take the opportunity to detect the remote side is not
-   responding and offer to disconnect.  */
+   flag, to the target, as if the user had typed the ^C on the
+   inferior's controlling terminal while the inferior was in the
+   foreground.  Remote targets may take the opportunity to detect the
+   remote side is not responding and offer to disconnect.  */
 
 extern void target_pass_ctrlc (void);
 
@@ -2109,9 +2083,8 @@ extern int target_fileio_unlink (struct inferior *inf,
    by the debugger (GDB or, for remote targets, the remote stub).
    Return a null-terminated string allocated via xmalloc, or NULL if
    an error occurs (and set *TARGET_ERRNO).  */
-extern char *target_fileio_readlink (struct inferior *inf,
-                                    const char *filename,
-                                    int *target_errno);
+extern gdb::optional<std::string> target_fileio_readlink
+    (struct inferior *inf, const char *filename, int *target_errno);
 
 /* Read target file FILENAME, in the filesystem as seen by INF.  If
    INF is NULL, use the filesystem seen by the debugger (GDB or, for
@@ -2399,15 +2372,11 @@ extern struct target_ops *find_target_beneath (struct target_ops *);
 
 struct target_ops *find_target_at (enum strata stratum);
 
-/* Read OS data object of type TYPE from the target, and return it in
-   XML format.  The result is NUL-terminated and returned as a string.
-   If an error occurs or the transfer is unsupported, NULL is
-   returned.  Empty objects are returned as allocated but empty
-   strings.  */
+/* Read OS data object of type TYPE from the target, and return it in XML
+   format.  The return value follows the same rules as target_read_stralloc.  */
 
-extern gdb::unique_xmalloc_ptr<char> target_get_osdata (const char *type);
+extern gdb::optional<gdb::char_vector> target_get_osdata (const char *type);
 
-\f
 /* Stuff that should be shared among the various remote targets.  */
 
 /* Debugging level.  0 is off, and non-zero values mean to print some debug
@@ -2442,9 +2411,6 @@ extern void update_target_permissions (void);
 \f
 /* Imported from machine dependent code.  */
 
-/* See to_supports_btrace in struct target_ops.  */
-extern int target_supports_btrace (enum btrace_format);
-
 /* See to_enable_btrace in struct target_ops.  */
 extern struct btrace_target_info *
   target_enable_btrace (ptid_t ptid, const struct btrace_config *);
@@ -2509,13 +2475,15 @@ extern void target_insn_history_range (ULONGEST begin, ULONGEST end,
                                       gdb_disassembly_flags flags);
 
 /* See to_call_history.  */
-extern void target_call_history (int size, int flags);
+extern void target_call_history (int size, record_print_flags flags);
 
 /* See to_call_history_from.  */
-extern void target_call_history_from (ULONGEST begin, int size, int flags);
+extern void target_call_history_from (ULONGEST begin, int size,
+                                     record_print_flags flags);
 
 /* See to_call_history_range.  */
-extern void target_call_history_range (ULONGEST begin, ULONGEST end, int flags);
+extern void target_call_history_range (ULONGEST begin, ULONGEST end,
+                                      record_print_flags flags);
 
 /* See to_prepare_to_generate_core.  */
 extern void target_prepare_to_generate_core (void);
@@ -2523,4 +2491,18 @@ extern void target_prepare_to_generate_core (void);
 /* See to_done_generating_core.  */
 extern void target_done_generating_core (void);
 
+#if GDB_SELF_TEST
+namespace selftests {
+
+/* A mock process_stratum target_ops that doesn't read/write registers
+   anywhere.  */
+
+class test_target_ops : public target_ops
+{
+public:
+  test_target_ops ();
+};
+} // namespace selftests
+#endif /* GDB_SELF_TEST */
+
 #endif /* !defined (TARGET_H) */
This page took 0.030299 seconds and 4 git commands to generate.