This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
reset fileio
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gdb at sourceware dot org
- Cc: Daniel Jacobowitz <dan at codesourcery dot com>
- Date: Wed, 24 May 2006 09:02:37 +0100
- Subject: reset fileio
I discovered that multiple target remote sessions within a single gdb session
would not reset the fileio state. This meant that all but the first target
connection found stdout available for instance.
This patch adds a reset function and calls it when reinitiating remote
connections. Tested manually, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2006-05-24 Nathan Sidwell <nathan@codesourcery.com>
* gdb/remote-fileio.c (remote_fileio_reset): New.
* gdb/remote-fileio.h (remote_fileio_reset): Prototype.
* gdb/remote.c (extended_remote_restart, remote_open_1): Call it.
Index: gdb/remote-fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-fileio.c,v
retrieving revision 1.17
diff -c -3 -p -r1.17 remote-fileio.c
*** gdb/remote-fileio.c 17 Jan 2006 14:47:31 -0000 1.17
--- gdb/remote-fileio.c 24 May 2006 07:55:53 -0000
*************** do_remote_fileio_request (struct ui_out
*** 1355,1360 ****
--- 1355,1379 ----
return 0;
}
+ /* Close any open descriptors, and reinitialize the file mapping */
+
+ void
+ remote_fileio_reset (void)
+ {
+ int ix;
+
+ for (ix = 0; ix != remote_fio_data.fd_map_size; ix++)
+ {
+ int fd = remote_fio_data.fd_map[ix];
+
+ if (fd >= 0)
+ close (fd);
+ }
+ free (remote_fio_data.fd_map);
+ remote_fio_data.fd_map = NULL;
+ remote_fio_data.fd_map_size = 0;
+ }
+
void
remote_fileio_request (char *buf)
{
Index: gdb/remote-fileio.h
===================================================================
RCS file: /cvs/src/src/gdb/remote-fileio.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 remote-fileio.h
*** gdb/remote-fileio.h 17 Dec 2005 22:34:01 -0000 1.4
--- gdb/remote-fileio.h 24 May 2006 07:55:53 -0000
*************** struct cmd_list_element;
*** 30,35 ****
--- 30,38 ----
remote_wait () and remote_async_wait () */
extern void remote_fileio_request (char *buf);
+ /* Cleanup any remote fileio state. */
+ extern void remote_fileio_reset (void);
+
/* Called from _initialize_remote () */
extern void initialize_remote_fileio (
struct cmd_list_element *remote_set_cmdlist,
Index: gdb/remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.202.2.3
diff -c -3 -p -r1.202.2.3 remote.c
*** gdb/remote.c 3 Apr 2006 00:47:40 -0000 1.202.2.3
--- gdb/remote.c 24 May 2006 07:55:55 -0000
*************** extended_remote_restart (void)
*** 1820,1825 ****
--- 1820,1827 ----
xsnprintf (buf, rs->remote_packet_size, "R%x", 0);
putpkt (buf);
+ remote_fileio_reset ();
+
/* Now query for status so this looks just like we restarted
gdbserver from scratch. */
putpkt ("?");
*************** remote_open_1 (char *name, int from_tty,
*** 2176,2181 ****
--- 2178,2185 ----
if (!async_p)
wait_forever_enabled_p = 1;
+ remote_fileio_reset ();
+
reopen_exec_file ();
reread_symbols ();