Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@codesourcery.com>
To: gdb@sourceware.org
Cc: Daniel Jacobowitz <dan@codesourcery.com>
Subject: reset fileio
Date: Wed, 24 May 2006 12:41:00 -0000	[thread overview]
Message-ID: <4474131D.2080805@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

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


[-- Attachment #2: all.diff --]
[-- Type: text/plain, Size: 2633 bytes --]

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 ();
  

             reply	other threads:[~2006-05-24  8:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-24 12:41 Nathan Sidwell [this message]
2006-05-24 13:06 ` Daniel Jacobowitz
2006-05-24 21:11   ` Nathan Sidwell
2006-06-17 21:16   ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4474131D.2080805@codesourcery.com \
    --to=nathan@codesourcery.com \
    --cc=dan@codesourcery.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox