]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-05-21 Andrew Cagney <cagney@redhat.com> cagney_fileio-20030521-branch
authorAndrew Cagney <cagney@redhat.com>
Wed, 21 May 2003 22:02:12 +0000 (22:02 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 21 May 2003 22:02:12 +0000 (22:02 +0000)
* fileio.c: Include "gdb_wait.h".

2003-03-10  Corinna Vinschen  <vinschen@redhat.com>
        * fileio.c: New file implementing the remote File-I/O protocol.
* fileio.h: New header file defining remote File-I/O interface.
        * remote.c (remote_write_bytes, remote_read_bytes): Remove
static storage class.
(remote_wait, remote_async_wait): Call remote_fileio_request() on
        'F' packet.
        (_initialize_remote): Call initialize_remote_fileio().
* remote.h: Declare remote_write_bytes() and remote_read_bytes().

2002-11-21  Martin M. Hunt  <hunt@redhat.com>
* Makefile.in (REMOTE_OBS): Add fileio.o
(SFILES): Add fileio.c.
Add dependencies for building fileio.o.  Add fileio.h to
dependencies for building remote.o.
        * defs.h: Declare gdb_stdin, gdb_stdtargerr and gdb_stdtargin.
        * main.c: New ui_file gdb_stdin, gdb_stdtargerr and gdb_stdtargin.
        (captured_main): Initialize new ui_files.
        * ui-file.c: Add read and fgets input functions.
        (ui_file_new): set ui_file_fputs and ui_file_read to null functions.
        (null_file_read): New function.
        (ui_file_read): New function.
        (set_ui_file_read): New function.
        (stdio_file_read): New function.
        * ui-file.h: New type ui_file_read_ftype.
        (set_ui_file_read): Declare.
        (ui_file_read): Declare.

gdb/ChangeLog
gdb/Makefile.in
gdb/defs.h
gdb/main.c
gdb/remote.c
gdb/remote.h
gdb/ui-file.c
gdb/ui-file.h

index 9cf50e6ec024d5b0df90afa96b7a7b92ff985f99..6295f96b7fa9535e34351d3e502afd9c2da1673f 100644 (file)
@@ -1,3 +1,35 @@
+2003-05-21  Andrew Cagney  <cagney@redhat.com>
+
+       * fileio.c: Include "gdb_wait.h".
+       
+       2003-03-10  Corinna Vinschen  <vinschen@redhat.com>
+        * fileio.c: New file implementing the remote File-I/O protocol.
+       * fileio.h: New header file defining remote File-I/O interface.
+        * remote.c (remote_write_bytes, remote_read_bytes): Remove
+       static storage class.
+       (remote_wait, remote_async_wait): Call remote_fileio_request() on
+        'F' packet.
+        (_initialize_remote): Call initialize_remote_fileio().
+       * remote.h: Declare remote_write_bytes() and remote_read_bytes().
+
+       2002-11-21  Martin M. Hunt  <hunt@redhat.com>
+       * Makefile.in (REMOTE_OBS): Add fileio.o
+       (SFILES): Add fileio.c.
+       Add dependencies for building fileio.o.  Add fileio.h to
+       dependencies for building remote.o.
+        * defs.h: Declare gdb_stdin, gdb_stdtargerr and gdb_stdtargin.
+        * main.c: New ui_file gdb_stdin, gdb_stdtargerr and gdb_stdtargin.
+        (captured_main): Initialize new ui_files.
+        * ui-file.c: Add read and fgets input functions.
+        (ui_file_new): set ui_file_fputs and ui_file_read to null functions.
+        (null_file_read): New function.
+        (ui_file_read): New function.
+        (set_ui_file_read): New function.
+        (stdio_file_read): New function.
+        * ui-file.h: New type ui_file_read_ftype.
+        (set_ui_file_read): Declare.
+        (ui_file_read): Declare.
+
 2003-05-20  Kevin Buettner  <kevinb@redhat.com>
 
        * mips-nat.c (REGISTER_PTRACE_ADDR): Convert macro to function
index 38be4f6aadb1d8a99e219840e8c0cf41a6de8f55..c42f12a702fa6511bea7775b08ada8ab0e0783f4 100644 (file)
@@ -400,7 +400,7 @@ SER_HARDWIRE = @SER_HARDWIRE@
 
 # The `remote' debugging target is supported for most architectures,
 # but not all (e.g. 960)
-REMOTE_OBS = remote.o dcache.o remote-utils.o tracepoint.o ax-general.o ax-gdb.o
+REMOTE_OBS = remote.o dcache.o remote-utils.o tracepoint.o ax-general.o ax-gdb.o fileio.o
 
 # This is remote-sim.o if a simulator is to be linked in.
 SIM_OBS =
@@ -516,7 +516,9 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
        dbxread.c demangle.c disasm.c doublest.c \
        dummy-frame.c dwarfread.c dwarf2expr.c dwarf2loc.c dwarf2read.c \
        elfread.c environ.c eval.c event-loop.c event-top.c expprint.c \
-       f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c frame.c \
+       f-exp.y f-lang.c f-typeprint.c f-valprint.c \
+       fileio.c \
+       findvar.c frame.c \
        frame-base.c \
        frame-unwind.c \
        gdbarch.c arch-utils.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \
@@ -643,6 +645,7 @@ event_loop_h = event-loop.h
 event_top_h = event-top.h
 expression_h = expression.h $(symtab_h) $(doublest_h)
 f_lang_h = f-lang.h
+fileio_h = fileio.h
 frame_h = frame.h
 frame_unwind_h = frame-unwind.h $(frame_h)
 frame_base_h = frame-base.h
@@ -1712,6 +1715,7 @@ f-valprint.o: f-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \
        $(f_lang_h) $(frame_h) $(gdbcore_h) $(command_h) $(block_h)
 fbsd-proc.o: fbsd-proc.c $(defs_h) $(gdbcore_h) $(inferior_h) \
        $(gdb_string_h) $(elf_bfd_h) $(gregset_h)
+fileio.o: fileio.c $(defs_h) $(gdb_string_h) $(gdbcmd_h) $(remote_h)
 findvar.o: findvar.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(frame_h) \
        $(value_h) $(gdbcore_h) $(inferior_h) $(target_h) $(gdb_string_h) \
        $(gdb_assert_h) $(floatformat_h) $(symfile_h) $(regcache_h) \
@@ -2137,7 +2141,7 @@ remote.o: remote.c $(defs_h) $(gdb_string_h) $(inferior_h) $(bfd_h) \
        $(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) $(gdb_stabs_h) \
        $(gdbthread_h) $(remote_h) $(regcache_h) $(value_h) $(gdb_assert_h) \
        $(event_loop_h) $(event_top_h) $(inf_loop_h) $(serial_h) \
-       $(gdbcore_h) $(solib_h)
+       $(gdbcore_h) $(solib_h) $(fileio_h) 
 rom68k-rom.o: rom68k-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
        $(serial_h) $(regcache_h) $(value_h) $(m68k_tdep_h)
 rs6000-nat.o: rs6000-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \
index a90ef9ef7c0fcb58eef961b3efa461f0a4145208..fc93fa9c8b72baf42b637316bbd3bddb4c797b77 100644 (file)
@@ -405,6 +405,8 @@ extern void reinitialize_more_filter (void);
 
 /* Normal results */
 extern struct ui_file *gdb_stdout;
+/* Input stream */
+extern struct ui_file *gdb_stdin;
 /* Serious error notifications */
 extern struct ui_file *gdb_stderr;
 /* Log/debug/trace messages that should bypass normal stdout/stderr
@@ -417,6 +419,8 @@ extern struct ui_file *gdb_stdlog;
    very near future that restriction shall be removed - either call
    shall be unfiltered. (cagney 1999-07-02). */
 extern struct ui_file *gdb_stdtarg;
+extern struct ui_file *gdb_stdtargerr;
+extern struct ui_file *gdb_stdtargin;
 
 #if defined(TUI)
 #include "tui.h"
index fd25750b94e5306fbe189a91e73c499d8a4e4653..559aef82d5e970eda006fcc5f64568c6018e4c49 100644 (file)
@@ -73,6 +73,10 @@ struct ui_file *gdb_stdout;
 struct ui_file *gdb_stderr;
 struct ui_file *gdb_stdlog;
 struct ui_file *gdb_stdtarg;
+struct ui_file *gdb_stdin;
+/* target IO streams */
+struct ui_file *gdb_stdtargin;
+struct ui_file *gdb_stdtargerr;
 
 /* Used to initialize error() - defined in utils.c */
 
@@ -193,6 +197,9 @@ captured_main (void *data)
   gdb_stderr = stdio_fileopen (stderr);
   gdb_stdlog = gdb_stderr;     /* for moment */
   gdb_stdtarg = gdb_stderr;    /* for moment */
+  gdb_stdin = stdio_fileopen (stdin);
+  gdb_stdtargerr = gdb_stderr; /* for moment */
+  gdb_stdtargin = gdb_stdin;   /* for moment */
 
   /* initialize error() */
   error_init ();
index 40be8e6badc2034a177773b332ec32efb02b1fa3..bbe468a1a557c28f8e38a8b3aa7cc7f805a3ddd9 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "gdbcore.h" /* for exec_bfd */
 
+#include "fileio.h"
+
 /* Prototypes for local functions */
 static void cleanup_sigint_signal_handler (void *dummy);
 static void initialize_sigint_signal_handler (void);
@@ -67,10 +69,6 @@ void async_remote_interrupt_twice (gdb_client_data);
 
 static void build_remote_gdbarch_data (void);
 
-static int remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
-
-static int remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len);
-
 static void remote_files_info (struct target_ops *ignore);
 
 static int remote_xfer_memory (CORE_ADDR memaddr, char *myaddr,
@@ -2945,6 +2943,9 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
        case 'E':               /* Error of some sort */
          warning ("Remote failure reply: %s", buf);
          continue;
+       case 'F':               /* File-I/O request */
+         remote_fileio_request (buf);
+         continue;
        case 'T':               /* Status with PC, SP, FP, ... */
          {
            int i;
@@ -3196,6 +3197,9 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
        case 'E':               /* Error of some sort */
          warning ("Remote failure reply: %s", buf);
          continue;
+       case 'F':               /* File-I/O request */
+         remote_fileio_request (buf);
+         continue;
        case 'T':               /* Status with PC, SP, FP, ... */
          {
            int i;
@@ -3750,7 +3754,7 @@ check_binary_download (CORE_ADDR addr)
    Returns number of bytes transferred, or 0 (setting errno) for
    error.  Only transfer a single packet. */
 
-static int
+int
 remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   unsigned char *buf;
@@ -3894,7 +3898,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
    caller and its callers caller ;-) already contains code for
    handling partial reads. */
 
-static int
+int
 remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
 {
   char *buf;
@@ -6268,4 +6272,7 @@ Set use of remote protocol `Z' packets",
                                set_remote_protocol_Z_packet_cmd,
                                show_remote_protocol_Z_packet_cmd,
                                &remote_set_cmdlist, &remote_show_cmdlist);
+
+  /* Eventually initialize fileio.  See fileio.c */
+  initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist);
 }
index 4477148f9c8f5ce1c7d9ca2f7ddf15de86f87665..7c0df32ad6ffdd676712eadbaf10366e0e803252 100644 (file)
@@ -54,6 +54,10 @@ extern void remote_cisco_objfile_relocate (bfd_signed_vma text_off,
 
 extern void async_remote_interrupt_twice (void *arg);
 
+extern int remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
+
+extern int remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len);
+
 extern void (*target_resume_hook) (void);
 extern void (*target_wait_loop_hook) (void);
 
index 3af6d2cc3b252c350725065c03484b00f8407919..6ad5414b19ff7e7f50bb1a0fdc80e7cb6539fe25 100644 (file)
 #include "ui-file.h"
 #include "gdb_string.h"
 
+#include <errno.h>
+
 static ui_file_isatty_ftype null_file_isatty;
 static ui_file_write_ftype null_file_write;
 static ui_file_fputs_ftype null_file_fputs;
+static ui_file_read_ftype null_file_read;
 static ui_file_flush_ftype null_file_flush;
 static ui_file_delete_ftype null_file_delete;
 static ui_file_rewind_ftype null_file_rewind;
@@ -39,6 +42,7 @@ struct ui_file
     ui_file_flush_ftype *to_flush;
     ui_file_write_ftype *to_write;
     ui_file_fputs_ftype *to_fputs;
+    ui_file_read_ftype *to_read;
     ui_file_delete_ftype *to_delete;
     ui_file_isatty_ftype *to_isatty;
     ui_file_rewind_ftype *to_rewind;
@@ -56,6 +60,7 @@ ui_file_new (void)
   set_ui_file_flush (file, null_file_flush);
   set_ui_file_write (file, null_file_write);
   set_ui_file_fputs (file, null_file_fputs);
+  set_ui_file_read (file, null_file_read);
   set_ui_file_isatty (file, null_file_isatty);
   set_ui_file_rewind (file, null_file_rewind);
   set_ui_file_put (file, null_file_put);
@@ -123,6 +128,15 @@ null_file_write (struct ui_file *file,
     }
 }
 
+static long
+null_file_read (struct ui_file *file,
+               char *buf,
+               long sizeof_buf)
+{
+  errno = EBADF;
+  return 0;
+}
+
 static void
 null_file_fputs (const char *buf, struct ui_file *file)
 {
@@ -186,6 +200,12 @@ ui_file_write (struct ui_file *file,
   file->to_write (file, buf, length_buf);
 }
 
+long
+ui_file_read (struct ui_file *file, char *buf, long length_buf)
+{
+  return file->to_read (file, buf, length_buf); 
+}
+
 void
 fputs_unfiltered (const char *buf, struct ui_file *file)
 {
@@ -223,6 +243,12 @@ set_ui_file_write (struct ui_file *file,
   file->to_write = write;
 }
 
+void
+set_ui_file_read (struct ui_file *file, ui_file_read_ftype *read)
+{
+  file->to_read = read;
+}
+
 void
 set_ui_file_fputs (struct ui_file *file, ui_file_fputs_ftype *fputs)
 {
@@ -383,6 +409,7 @@ mem_file_write (struct ui_file *file,
 
 static ui_file_write_ftype stdio_file_write;
 static ui_file_fputs_ftype stdio_file_fputs;
+static ui_file_read_ftype stdio_file_read;
 static ui_file_isatty_ftype stdio_file_isatty;
 static ui_file_delete_ftype stdio_file_delete;
 static struct ui_file *stdio_file_new (FILE * file, int close_p);
@@ -409,6 +436,7 @@ stdio_file_new (FILE *file, int close_p)
   set_ui_file_flush (ui_file, stdio_file_flush);
   set_ui_file_write (ui_file, stdio_file_write);
   set_ui_file_fputs (ui_file, stdio_file_fputs);
+  set_ui_file_read (ui_file, stdio_file_read);
   set_ui_file_isatty (ui_file, stdio_file_isatty);
   return ui_file;
 }
@@ -437,6 +465,16 @@ stdio_file_flush (struct ui_file *file)
   fflush (stdio->file);
 }
 
+static long
+stdio_file_read (struct ui_file *file, char *buf, long length_buf)
+{
+  struct stdio_file *stdio = ui_file_data (file);
+  if (stdio->magic != &stdio_file_magic)
+    internal_error (__FILE__, __LINE__,
+                   "stdio_file_read: bad magic number");
+  return read (fileno (stdio->file), buf, length_buf);
+}
+
 static void
 stdio_file_write (struct ui_file *file, const char *buf, long length_buf)
 {
index 989c343dfa096963e01410910e3a7ad316ec1c9b..8b28d1a41393afa2b43d5bbbdb8da5ee4814ae34 100644 (file)
@@ -41,6 +41,9 @@ extern void set_ui_file_write (struct ui_file *stream, ui_file_write_ftype *fput
 typedef void (ui_file_fputs_ftype) (const char *, struct ui_file * stream);
 extern void set_ui_file_fputs (struct ui_file *stream, ui_file_fputs_ftype * fputs);
 
+typedef long (ui_file_read_ftype) (struct ui_file * stream, char *buf, long length_buf);
+extern void set_ui_file_read (struct ui_file *stream, ui_file_read_ftype *fread);
+
 typedef int (ui_file_isatty_ftype) (struct ui_file * stream);
 extern void set_ui_file_isatty (struct ui_file *stream, ui_file_isatty_ftype * isatty);
 
@@ -78,6 +81,8 @@ extern char *ui_file_xstrdup (struct ui_file *file, long *length);
 
 
 
+extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
+
 /* Create/open a memory based file. Can be used as a scratch buffer
    for collecting output. */
 extern struct ui_file *mem_fileopen (void);