[RFA]: File-I/O patch

Andrew Cagney ac131313@redhat.com
Tue Jun 3 18:31:00 GMT 2003


> On Fri, Mar 07, 2003 at 02:30:56PM -0500, Andrew Cagney wrote:
> 
>> I think the basic file io implementation should be moved out of 
>> "remote.c" and into "fileio.[hc]" so that both remote.c and remote-sim.c 
>> can share it.
> 
> 
> Ok.  New ChangeLog and patch attached.

I'm now looking carefully at the code and, sigh, as things stand, yes, 
the split isn't that simple :-(  So I'm trying to figure out the easiest 
way of getting this current code into something nearer to the expected 
structure.

What i was thinking of was:

remote-fileio.[hc]:
Would provide a target_fileio object and methods leading to something like:
- struct remote_fileio;
- struct remote_fileio *new_remote_fileio();
- create/initialize the fileio
- remote_fileio_open(fileio, const char *name, int modes)
- remote_fileio_read(fileio, CORE_ADDR addr, len)
- et.al.

remote.[hc]:
Would be responsible for the protocol and mapping the remote requests 
onto relevant remote_fileio_XXX() calls.

That way I could modify remote-sim to use those file I/O methods and 
delete the duplicated code.

Unfortunatly, the current code assumes a single target (using the global 
remote_fio_data); and the existing remote_fileio_func_open() methods 
both unpack the protocol and perform the I/O operation.  This makes 
reusing this code from remote-sim very hard.  Sigh.

I'm not sure what to do next, any suggestions?

My best guess is if the code at least addresses the global 
remote_fio_data problem it avoids problems with trying to have multiple 
targets.  The re-org needed for integrating it into remote-sim would 
have to come much much later (i.e., it probably wouldn't happen).

Andrew

> 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.
> 




More information about the Gdb-patches mailing list