Add support for unbuffered and zero sized Guile ports.

gdb/ChangeLog

	* NEWS: Mention support for unbuffered Guile memory ports.
	* scm-ports.c (ioscm_memory_port): Update comments on end, size.
	(ioscm_lseek_address): Improve overflow calculation.
	(gdbscm_memory_port_fill_input): Add assert.
	(gdbscm_memory_port_write): Handle unbuffered ports.
	Handle large writes identical to Guile's fport_write.
	(gdbscm_memory_port_seek): Fix seeking past end check.
	(gdbscm_memory_port_close): Handle closing unbuffered port.
	(ioscm_parse_mode_bits): Recognize "0" for unbuffered ports.
	(ioscm_init_memory_port): Handle unbuffered ports.
	(ioscm_reinit_memory_port): Ditto.
	(ioscm_init_memory_port): Update size calculation.
	(gdbscm_open_memory): Support zero sized ports.

gdb/testsuite/ChangeLog

	* gdb.guile/scm-ports.c: New file.
	* gdb.guile/scm-ports.exp: Add memory port tests.

gdb/doc/ChangeLog

	* guile.texi (Memory Ports in Guile): Document support for unbuffered
	memory ports.
This commit is contained in:
Doug Evans
2015-05-16 12:14:26 -07:00
parent d976bace1c
commit 37442ce10a
8 changed files with 304 additions and 72 deletions

View File

@ -3525,11 +3525,13 @@ returns a port object. One can then read/write memory using that object.
@deffn {Scheme Procedure} open-memory @r{[}#:mode mode{]} @r{[}#:start address{]} @r{[}#:size size{]}
Return a port object that can be used for reading and writing memory.
The port will be open according to @var{mode}, which is the standard
mode argument to Guile port open routines, except that it is
restricted to one of @samp{"r"}, @samp{"w"}, or @samp{"r+"}. For
compatibility @samp{"b"} (binary) may also be present, but we ignore
it: memory ports are binary only. The default is @samp{"r"},
read-only.
mode argument to Guile port open routines, except that the @samp{"a"}
and @samp{"l"} modes are not supported.
@xref{File Ports,,, guile, GNU Guile Reference Manual}.
The @samp{"b"} (binary) character may be present, but is ignored:
memory ports are binary only. If @samp{"0"} is appended then
the port is marked as unbuffered.
The default is @samp{"r"}, read-only and buffered.
The chunk of memory that can be accessed can be bounded.
If both @var{start} and @var{size} are unspecified, all of memory can be