This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: patch to invalidate dcache in .to_open vector
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: RFA: patch to invalidate dcache in .to_open vector
- From: jtc at redback dot com (J.T. Conklin)
- Date: 09 Aug 2000 16:16:34 -0700
- Reply-To: jtc at redback dot com
I submit the enclosed patch for approval.
I found that most of .to_open vectors which call dcache_init() do so
even if the dcache has been created in an earlier call. This leads to
a dcache-sized memory leak each time the target is opened. Instead,
the cache should be invalidated ("flushed" using gdb's strange sense
of the word --- I swear I'm going to change that soon :-).
--jtc
2000-08-09 J.T. Conklin <jtc@redback.com>
* monitor.c (monitor_open): If a dcache has already been created,
invalidate it rather than creating another.
* ocd.c (ocd_open): Likewise.
* remote-nindy.c (nindy_open): Likewise.
* remote-sds.c (sds_open): Likewise.
* remote-utils.c (gr_open): Likewise.
* remote.c (remote_open_1, remote_cisco_open): Likewise.
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.8
diff -c -r1.8 monitor.c
*** monitor.c 2000/07/30 01:48:26 1.8
--- monitor.c 2000/08/09 22:45:47
***************
*** 838,847 ****
monitor_printf (current_monitor->line_term);
! if (current_monitor->flags & MO_HAS_BLOCKWRITES)
! remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory_block);
else
! remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory);
start_remote ();
}
--- 838,854 ----
monitor_printf (current_monitor->line_term);
! if (!remote_dcache)
! {
! if (current_monitor->flags & MO_HAS_BLOCKWRITES)
! remote_dcache = dcache_init (monitor_read_memory,
! monitor_write_memory_block);
! else
! remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory);
! }
else
! dcache_flush (remote_dcache);
!
start_remote ();
}
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.5
diff -c -r1.5 ocd.c
*** ocd.c 2000/07/30 01:48:26 1.5
--- ocd.c 2000/08/09 22:45:48
***************
*** 292,298 ****
unpush_target (current_ops);
! ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
if (strncmp (name, "wiggler", 7) == 0)
{
--- 292,301 ----
unpush_target (current_ops);
! if (!ocd_dcache)
! ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
! else
! dcache_flush (ocd_dcache);
if (strncmp (name, "wiggler", 7) == 0)
{
Index: remote-nindy.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-nindy.c,v
retrieving revision 1.5
diff -c -r1.5 remote-nindy.c
*** remote-nindy.c 2000/07/30 01:48:26 1.5
--- remote-nindy.c 2000/08/09 22:45:48
***************
*** 187,193 ****
nindy_close (0);
have_regs = regs_changed = 0;
! nindy_dcache = dcache_init (ninMemGet, ninMemPut);
/* Allow user to interrupt the following -- we could hang if there's
no NINDY at the other end of the remote tty. */
--- 187,197 ----
nindy_close (0);
have_regs = regs_changed = 0;
!
! if (!nindy_dcache)
! nindy_dcache = dcache_init (ninMemGet, ninMemPut);
! else
! dcache_flush (nindy_dcache);
/* Allow user to interrupt the following -- we could hang if there's
no NINDY at the other end of the remote tty. */
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.4
diff -c -r1.4 remote-sds.c
*** remote-sds.c 2000/07/30 01:48:27 1.4
--- remote-sds.c 2000/08/09 22:45:49
***************
*** 203,209 ****
unpush_target (&sds_ops);
! sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
sds_desc = SERIAL_OPEN (name);
if (!sds_desc)
--- 203,212 ----
unpush_target (&sds_ops);
! if (!sds_dcache)
! sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
! else
! dcache_flush (sds_dcache);
sds_desc = SERIAL_OPEN (name);
if (!sds_desc)
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-utils.c,v
retrieving revision 1.4
diff -c -r1.4 remote-utils.c
*** remote-utils.c 2000/07/30 01:48:27 1.4
--- remote-utils.c 2000/08/09 22:45:49
***************
*** 154,166 ****
void
gr_open (char *args, int from_tty, struct gr_settings *gr)
{
target_preopen (from_tty);
sr_scan_args (gr->ops->to_shortname, args);
unpush_target (gr->ops);
gr_settings = gr;
! gr_set_dcache (dcache_init (gr->readfunc, gr->writefunc));
if (sr_get_desc () != NULL)
gr_close (0);
--- 154,171 ----
void
gr_open (char *args, int from_tty, struct gr_settings *gr)
{
+ DCACHE *dcache;
+
target_preopen (from_tty);
sr_scan_args (gr->ops->to_shortname, args);
unpush_target (gr->ops);
gr_settings = gr;
! if ((dcache = gr_get_dcache()) == NULL)
! gr_set_dcache (dcache_init (gr->readfunc, gr->writefunc));
! else
! dcache_flush (dcache);
if (sr_get_desc () != NULL)
gr_close (0);
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.19
diff -c -r1.19 remote.c
*** remote.c 2000/08/07 15:02:48 1.19
--- remote.c 2000/08/09 22:45:54
***************
*** 2057,2063 ****
unpush_target (target);
! remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
remote_desc = SERIAL_OPEN (name);
if (!remote_desc)
--- 2057,2066 ----
unpush_target (target);
! if (!remote_dcache)
! remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
! else
! dcache_flush (remote_dcache);
remote_desc = SERIAL_OPEN (name);
if (!remote_desc)
***************
*** 5034,5040 ****
unpush_target (&remote_cisco_ops);
! remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
remote_desc = SERIAL_OPEN (name);
if (!remote_desc)
--- 5037,5046 ----
unpush_target (&remote_cisco_ops);
! if (!remote_dcache)
! remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
! else
! dcache_flush (remote_dcache);
remote_desc = SERIAL_OPEN (name);
if (!remote_desc)
--
J.T. Conklin
RedBack Networks