This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: add dcache_free(), change monitor_open() to use it.


I noticed that my patch to fix the dcache leak wasn't quite right for
ROM monitors.  

It is possible (although IMO not likely) that a single GDB session be
used to connect to more than one type of monitor.  But monitor_open()
creates the dcache with different memory xfer functions depending on
the current monitor's flags.

There are two ways that come to mind to fix it.  One is to delete the
dcache and re-create it with the correct flags.  The other is to
change monitor_read_memory() to call monitor_read_memory_block() 
if current_monitor->flags & MO_HAS_BLOCKWRITES.

I chose the former, although it is kind-of a brute force approach to
the problem.  It would be nice to be able to discard a dcache anyway,
and I didn't want to get into the monitor i/o functions yet (there is
quite a bit of work to do when I add support for the 'width' memory
region attribute).

        --jtc

2000-08-11  J.T. Conklin  <jtc@redback.com>

        * monitor.c (monitor_open): Free dcache before creating a new one.
        * dcache.c (dcache_free): New function.
        * dcache.h (dcache_free): New prototype.

Index: dcache.c
===================================================================
RCS file: /cvs/src/src/gdb/dcache.c,v
retrieving revision 1.7
diff -c -r1.7 dcache.c
*** dcache.c	2000/08/11 14:47:38	1.7
--- dcache.c	2000/08/11 18:35:24
***************
*** 408,413 ****
--- 408,424 ----
    return dcache;
  }
  
+ /* Free a data cache */
+ void
+ dcache_free (DCACHE *dcache)
+ {
+   if (last_cache == dcache)
+     last_cache = NULL;
+ 
+   free (dcache->the_cache);
+   free (dcache);
+ }
+ 
  /* Read or write LEN bytes from inferior memory at MEMADDR, transferring
     to or from debugger address MYADDR.  Write to inferior if SHOULD_WRITE is
     nonzero. 
Index: dcache.h
===================================================================
RCS file: /cvs/src/src/gdb/dcache.h,v
retrieving revision 1.4
diff -c -r1.4 dcache.h
*** dcache.h	2000/06/19 18:59:07	1.4
--- dcache.h	2000/08/11 18:35:24
***************
*** 33,38 ****
--- 33,41 ----
  /* Initialize DCACHE. */
  DCACHE *dcache_init (memxferfunc reading, memxferfunc writing);
  
+ /* Free a DCACHE */
+ void dcache_free (DCACHE *);
+ 
  /* Simple to call from <remote>_xfer_memory */
  
  int dcache_xfer_memory (DCACHE * cache, CORE_ADDR mem, char *my, int len,
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.9
diff -c -r1.9 monitor.c
*** monitor.c	2000/08/10 18:54:27	1.9
--- monitor.c	2000/08/11 18:35:36
***************
*** 838,853 ****
  
    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 ();
  }
--- 838,851 ----
  
    monitor_printf (current_monitor->line_term);
  
!   if (remote_dcache)
!     dcache_free (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);
  
    start_remote ();
  }

-- 
J.T. Conklin
RedBack Networks

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]