Update copyright notices to add year 2010.
[deliverable/binutils-gdb.git] / include / gdb / callback.h
index 30752842ed90aefd2d33a30701b6aba0a94e53ae..114e2f32564d76ede5f90de8e219d1e1d3ecad02 100644 (file)
@@ -1,22 +1,21 @@
 /* Remote target system call callback support.
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This interface isn't intended to be specific to any particular kind
    of remote (hardware, simulator, whatever).  As such, support for it
@@ -50,12 +49,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #ifndef va_start
 #include <ansidecl.h>
-#ifdef ANSI_PROTOTYPES
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #endif
+/* Needed for enum bfd_endian.  */
+#include "bfd.h"
 \f
 /* Mapping of host/target values.  */
 /* ??? For debugging purposes, one might want to add a string of the
@@ -93,6 +90,17 @@ struct host_callback_struct
   void (*flush_stderr) PARAMS ((host_callback *));
   int (*stat) PARAMS ((host_callback *, const char *, struct stat *));
   int (*fstat) PARAMS ((host_callback *, int, struct stat *));
+  int (*lstat) PARAMS ((host_callback *, const char *, struct stat *));
+  int (*ftruncate) PARAMS ((host_callback *, int, long));
+  int (*truncate) PARAMS ((host_callback *, const char *, long));
+  int (*pipe) PARAMS ((host_callback *, int *));
+
+  /* Called by the framework when a read call has emptied a pipe buffer.  */
+  void (*pipe_empty) PARAMS ((host_callback *, int read_fd, int write_fd));
+
+  /* Called by the framework when a write call makes a pipe buffer
+     non-empty.  */
+  void (*pipe_nonempty) PARAMS ((host_callback *, int read_fd, int write_fd));
 
   /* When present, call to the client to give it the oportunity to
      poll any io devices for a request to quit (indicated by a nonzero
@@ -116,13 +124,40 @@ struct host_callback_struct
   /* Print an error message and "exit".
      In the case of gdb "exiting" means doing a longjmp back to the main
      command loop.  */
-  void (*error) PARAMS ((host_callback *, const char *, ...));
+  void (*error) PARAMS ((host_callback *, const char *, ...))
+#ifdef __GNUC__
+    __attribute__ ((__noreturn__))
+#endif
+    ;
 
   int last_errno;              /* host format */
 
   int fdmap[MAX_CALLBACK_FDS];
-  char fdopen[MAX_CALLBACK_FDS];
-  char alwaysopen[MAX_CALLBACK_FDS];
+  /* fd_buddy is used to contruct circular lists of target fds that point to
+     the same host fd.  A uniquely mapped fd points to itself; for a closed
+     one, fd_buddy has the value -1.  The host file descriptors for stdin /
+     stdout / stderr are never closed by the simulators, so they are put
+     in a special fd_buddy circular list which also has MAX_CALLBACK_FDS
+     as a member.  */
+  /* ??? We don't have a callback entry for dup, although it is trival to
+     implement now.  */
+  short fd_buddy[MAX_CALLBACK_FDS+1];
+
+  /* 0 = none, >0 = reader (index of writer),
+     <0 = writer (negative index of reader).
+     If abs (ispipe[N]) == N, then N is an end of a pipe whose other
+     end is closed.  */
+  short ispipe[MAX_CALLBACK_FDS];
+
+  /* A writer stores the buffer at its index.  Consecutive writes
+     realloc the buffer and add to the size.  The reader indicates the
+     read part in its .size, until it has consumed it all, at which
+     point it deallocates the buffer and zeroes out both sizes.  */
+  struct pipe_write_buffer
+  {
+    int size;
+    char *buffer;
+  } pipe_buffer[MAX_CALLBACK_FDS];
 
   /* System call numbers.  */
   CB_TARGET_DEFS_MAP *syscall_map;
@@ -141,6 +176,16 @@ struct host_callback_struct
      Example: "st_dev,4:st_ino,4:st_mode,4:..."  */
   const char *stat_map;
 
+  enum bfd_endian target_endian;
+
+  /* Size of an "int" on the target (for syscalls whose ABI uses "int").
+     This must include padding, and only padding-at-higher-address is
+     supported.  For example, a 64-bit target with 32-bit int:s which
+     are padded to 64 bits when in an array, should supposedly set this
+     to 8.  The default is 4 which matches ILP32 targets and 64-bit
+     targets with 32-bit ints and no padding.  */
+  int target_sizeof_int;
+
   /* Marker for those wanting to do sanity checks.
      This should remain the last member of this struct to help catch
      miscompilation errors. */
@@ -179,6 +224,13 @@ extern host_callback default_callback;
 #define CB_SYS_chmod   16
 #define CB_SYS_utime   17
 #define CB_SYS_time    18
+
+/* More standard syscalls.  */
+#define CB_SYS_lstat    19
+#define CB_SYS_rename  20
+#define CB_SYS_truncate        21
+#define CB_SYS_ftruncate 22
+#define CB_SYS_pipe    23
 \f
 /* Struct use to pass and return information necessary to perform a
    system call.  */
@@ -264,6 +316,14 @@ int cb_host_to_target_signal PARAMS ((host_callback *, int));
    Result is size of target stat struct or 0 if error.  */
 int cb_host_to_target_stat PARAMS ((host_callback *, const struct stat *, PTR));
 
+/* Translate a value to target endian.  */
+void cb_store_target_endian PARAMS ((host_callback *, char *, int, long));
+
+/* Tests for special fds.  */
+int cb_is_stdin PARAMS ((host_callback *, int));
+int cb_is_stdout PARAMS ((host_callback *, int));
+int cb_is_stderr PARAMS ((host_callback *, int));
+
 /* Perform a system call.  */
 CB_RC cb_syscall PARAMS ((host_callback *, CB_SYSCALL *));
 
This page took 0.024715 seconds and 4 git commands to generate.