From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19803 invoked by alias); 24 May 2006 08:03:45 -0000 Received: (qmail 19782 invoked by uid 22791); 24 May 2006 08:03:42 -0000 X-Spam-Check-By: sourceware.org Received: from intranet.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.6) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 May 2006 08:03:10 +0000 Received: (qmail 10867 invoked from network); 24 May 2006 08:03:08 -0000 Received: from unknown (HELO ?192.168.189.145?) (nathan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 May 2006 08:03:08 -0000 Message-ID: <4474131D.2080805@codesourcery.com> Date: Wed, 24 May 2006 12:41:00 -0000 From: Nathan Sidwell User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060502) MIME-Version: 1.0 To: gdb@sourceware.org CC: Daniel Jacobowitz Subject: reset fileio Content-Type: multipart/mixed; boundary="------------060304050505040203070907" Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00348.txt.bz2 This is a multi-part message in MIME format. --------------060304050505040203070907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 479 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 --------------060304050505040203070907 Content-Type: text/plain; name="all.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="all.diff" Content-length: 2633 2006-05-24 Nathan Sidwell * 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 (); --------------060304050505040203070907--