This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[fileio] I checked in corinna's patch
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 21 May 2003 18:01:33 -0400
- Subject: [fileio] I checked in corinna's patch
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.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.381
diff -u -r1.381 Makefile.in
--- Makefile.in 20 May 2003 23:44:22 -0000 1.381
+++ Makefile.in 21 May 2003 22:00:15 -0000
@@ -400,7 +400,7 @@
# 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 @@
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_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_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 @@
$(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: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.122
diff -u -r1.122 defs.h
--- defs.h 13 May 2003 19:27:27 -0000 1.122
+++ defs.h 21 May 2003 22:00:15 -0000
@@ -405,6 +405,8 @@
/* 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 @@
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: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.32
diff -u -r1.32 main.c
--- main.c 20 Mar 2003 22:25:16 -0000 1.32
+++ main.c 21 May 2003 22:00:15 -0000
@@ -73,6 +73,10 @@
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 @@
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: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.100
diff -u -r1.100 remote.c
--- remote.c 17 May 2003 05:59:58 -0000 1.100
+++ remote.c 21 May 2003 22:00:16 -0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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_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: remote.h
===================================================================
RCS file: /cvs/src/src/gdb/remote.h,v
retrieving revision 1.3
diff -u -r1.3 remote.h
--- remote.h 29 Mar 2003 01:40:01 -0000 1.3
+++ remote.h 21 May 2003 22:00:16 -0000
@@ -54,6 +54,10 @@
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: ui-file.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.c,v
retrieving revision 1.9
diff -u -r1.9 ui-file.c
--- ui-file.c 25 Jul 2002 03:14:28 -0000 1.9
+++ ui-file.c 21 May 2003 22:00:17 -0000
@@ -25,9 +25,12 @@
#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 @@
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 @@
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 @@
}
}
+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 @@
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)
{
@@ -224,6 +244,12 @@
}
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)
{
file->to_fputs = fputs;
@@ -383,6 +409,7 @@
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 @@
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;
}
@@ -435,6 +463,16 @@
internal_error (__FILE__, __LINE__,
"stdio_file_flush: bad magic number");
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
Index: ui-file.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-file.h,v
retrieving revision 1.3
diff -u -r1.3 ui-file.h
--- ui-file.h 25 Jul 2002 03:14:28 -0000 1.3
+++ ui-file.h 21 May 2003 22:00:17 -0000
@@ -41,6 +41,9 @@
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);
@@ -77,6 +80,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. */