* reset fileio
@ 2006-05-24 12:41 Nathan Sidwell
2006-05-24 13:06 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Sidwell @ 2006-05-24 12:41 UTC (permalink / raw)
To: gdb; +Cc: Daniel Jacobowitz
[-- 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 ();
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: reset fileio
2006-05-24 12:41 reset fileio Nathan Sidwell
@ 2006-05-24 13:06 ` Daniel Jacobowitz
2006-05-24 21:11 ` Nathan Sidwell
2006-06-17 21:16 ` Mark Kettenis
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-05-24 13:06 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gdb
On Wed, May 24, 2006 at 09:02:37AM +0100, Nathan Sidwell wrote:
> + /* Close any open descriptors, and reinitialize the file mapping */
Period at the end of the comment.
> + 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;
> + }
Won't this free NULL if the target hadn't initialized fileio? I think
that's non-portable.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: reset fileio
2006-05-24 13:06 ` Daniel Jacobowitz
@ 2006-05-24 21:11 ` Nathan Sidwell
2006-06-17 21:16 ` Mark Kettenis
1 sibling, 0 replies; 4+ messages in thread
From: Nathan Sidwell @ 2006-05-24 21:11 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
Daniel Jacobowitz wrote:
> On Wed, May 24, 2006 at 09:02:37AM +0100, Nathan Sidwell wrote:
>
> Won't this free NULL if the target hadn't initialized fileio? I think
> that's non-portable.
still? in this day & age? :)
ok with the obvious change to protect free?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: reset fileio
2006-05-24 13:06 ` Daniel Jacobowitz
2006-05-24 21:11 ` Nathan Sidwell
@ 2006-06-17 21:16 ` Mark Kettenis
1 sibling, 0 replies; 4+ messages in thread
From: Mark Kettenis @ 2006-06-17 21:16 UTC (permalink / raw)
To: dan; +Cc: nathan, gdb
> Date: Wed, 24 May 2006 08:41:21 -0400
> From: Daniel Jacobowitz <dan@codesourcery.com>
>
> On Wed, May 24, 2006 at 09:02:37AM +0100, Nathan Sidwell wrote:
> > + /* Close any open descriptors, and reinitialize the file mapping */
>
> Period at the end of the comment.
>
> > + 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;
> > + }
>
> Won't this free NULL if the target hadn't initialized fileio? I think
> that's non-portable.
That's why Nathan should use xfree() instead of free().
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-17 20:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-24 12:41 reset fileio Nathan Sidwell
2006-05-24 13:06 ` Daniel Jacobowitz
2006-05-24 21:11 ` Nathan Sidwell
2006-06-17 21:16 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox