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]

[PATCH]: more dcache cleanup


Enclosed is a patch that I'll be committing shortly.  

The bulk of it is renaming "dcache_flush" to the less ambigous
"dcache_invd".  It also fixes a problem where the cache wasn't
invalidated when a new image was loaded with the nindy monitor,
and a problem where the dcache i/o functions were different for
different ROM monitors.

        --jtc

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

	* MAINTAINERS: Add myself as dcache.c maintainer.

	* remote-nindy.c (nindy_load): Invalidate dcache.

	* dcache.c (dcache_invd): Renamed from dcache_flush.  The term
 	flush with respect to caches usually implies that data will be 
	written to memory.
	(dcache_init, dcache_xfer_memory): Updated.
	* monitor.c (flush_monitor_dcache, monitor_resume, monitor_load): 
	Updated.
	* ocd.c (ocd_open, ocd_resume, bdm_reset_command): Updated.
	* remote-bug.c (bug_load, bug_resume): Updated.
	* remote-nindy.c (nindy_open, nindy_resume): Updated.
	* remote-sds.c (sds_open, sds_resume): Updated.
	* remote-utils.c (gr_open): Updated.
	* remote.c (remote_open_1, remote_resume, remote_async_resume,
	remote_cisco_open): Updated.
	* wince.c (child_create_inferior, child_resume): Updated.

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

Index: MAINTAINERS
===================================================================
RCS file: /cvs/src/src/gdb/MAINTAINERS,v
retrieving revision 1.46
diff -c -r1.46 MAINTAINERS
*** MAINTAINERS	2000/08/11 00:25:19	1.46
--- MAINTAINERS	2000/08/18 22:40:13
***************
*** 188,193 ****
--- 188,194 ----
    hp tests (gdb.hp)	Jimmy Guo		guo@cup.hp.com
    Java tests (gdb.java)	Anthony Green 		green@cygnus.com
  Kernel Object Display	Fernando Nasser		fnasser@cygnus.com
+ dcache.c		J.T. Conklin		jtc@redback.com
  
  
  UI: External (user) interfaces.
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/18 22:40:14
***************
*** 173,179 ****
  /* Free all the data cache blocks, thus discarding all cached data.  */
  
  void
! dcache_flush (DCACHE *dcache)
  {
    int i;
    dcache->valid_head = 0;
--- 173,179 ----
  /* Free all the data cache blocks, thus discarding all cached data.  */
  
  void
! dcache_invd (DCACHE *dcache)
  {
    int i;
    dcache->valid_head = 0;
***************
*** 402,413 ****
    dcache->the_cache = (struct dcache_block *) xmalloc (csize);
    memset (dcache->the_cache, 0, csize);
  
!   dcache_flush (dcache);
  
    last_cache = dcache;
    return 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. 
--- 402,424 ----
    dcache->the_cache = (struct dcache_block *) xmalloc (csize);
    memset (dcache->the_cache, 0, csize);
  
!   dcache_invd (dcache);
  
    last_cache = dcache;
    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. 
***************
*** 441,447 ****
        xfunc = should_write ? dcache->write_memory : dcache->read_memory;
  
        if (dcache->cache_has_stuff)
! 	dcache_flush (dcache);
  
        len = xfunc (memaddr, myaddr, len);
      }
--- 452,458 ----
        xfunc = should_write ? dcache->write_memory : dcache->read_memory;
  
        if (dcache->cache_has_stuff)
! 	dcache_invd (dcache);
  
        len = xfunc (memaddr, myaddr, len);
      }
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/18 22:40:14
***************
*** 27,37 ****
  
  typedef struct dcache_struct DCACHE;
  
! /* Flush DCACHE. */
! void dcache_flush (DCACHE * dcache);
  
  /* Initialize DCACHE. */
  DCACHE *dcache_init (memxferfunc reading, memxferfunc writing);
  
  /* Simple to call from <remote>_xfer_memory */
  
--- 27,40 ----
  
  typedef struct dcache_struct DCACHE;
  
! /* Invalidate DCACHE. */
! void dcache_invd (DCACHE * dcache);
  
  /* Initialize DCACHE. */
  DCACHE *dcache_init (memxferfunc reading, memxferfunc writing);
+ 
+ /* Free a DCACHE */
+ void dcache_free (DCACHE *);
  
  /* Simple to call from <remote>_xfer_memory */
  
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/18 22:40:16
***************
*** 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 ();
  }
***************
*** 934,940 ****
  void
  flush_monitor_dcache (void)
  {
!   dcache_flush (remote_dcache);
  }
  
  static void
--- 932,938 ----
  void
  flush_monitor_dcache (void)
  {
!   dcache_invd (remote_dcache);
  }
  
  static void
***************
*** 950,956 ****
  	dump_reg_flag = 1;
        return;
      }
!   dcache_flush (remote_dcache);
    if (step)
      monitor_printf (current_monitor->step);
    else
--- 948,954 ----
  	dump_reg_flag = 1;
        return;
      }
!   dcache_invd (remote_dcache);
    if (step)
      monitor_printf (current_monitor->step);
    else
***************
*** 2147,2153 ****
  static void
  monitor_load (char *file, int from_tty)
  {
!   dcache_flush (remote_dcache);
    monitor_debug ("MON load\n");
  
    if (current_monitor->load_routine)
--- 2145,2151 ----
  static void
  monitor_load (char *file, int from_tty)
  {
!   dcache_invd (remote_dcache);
    monitor_debug ("MON load\n");
  
    if (current_monitor->load_routine)
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.6
diff -c -r1.6 ocd.c
*** ocd.c	2000/08/10 18:54:27	1.6
--- ocd.c	2000/08/18 22:40:17
***************
*** 295,301 ****
    if (!ocd_dcache)
      ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
    else
!     dcache_flush (ocd_dcache);
  
    if (strncmp (name, "wiggler", 7) == 0)
      {
--- 295,301 ----
    if (!ocd_dcache)
      ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
    else
!     dcache_invd (ocd_dcache);
  
    if (strncmp (name, "wiggler", 7) == 0)
      {
***************
*** 387,393 ****
  {
    int pktlen;
  
!   dcache_flush (ocd_dcache);
  
    if (step)
      ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
--- 387,393 ----
  {
    int pktlen;
  
!   dcache_invd (ocd_dcache);
  
    if (step)
      ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
***************
*** 1318,1324 ****
      error ("Not connected to OCD device.");
  
    ocd_do_command (OCD_RESET, &status, &pktlen);
!   dcache_flush (ocd_dcache);
    registers_changed ();
  }
  
--- 1318,1324 ----
      error ("Not connected to OCD device.");
  
    ocd_do_command (OCD_RESET, &status, &pktlen);
!   dcache_invd (ocd_dcache);
    registers_changed ();
  }
  
Index: remote-bug.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-bug.c,v
retrieving revision 1.5
diff -c -r1.5 remote-bug.c
*** remote-bug.c	2000/07/30 01:48:26	1.5
--- remote-bug.c	2000/08/18 22:40:17
***************
*** 119,125 ****
  
    sr_check_open ();
  
!   dcache_flush (gr_get_dcache ());
    inferior_pid = 0;
    abfd = bfd_openr (args, 0);
    if (!abfd)
--- 119,125 ----
  
    sr_check_open ();
  
!   dcache_invd (gr_get_dcache ());
    inferior_pid = 0;
    abfd = bfd_openr (args, 0);
    if (!abfd)
***************
*** 242,248 ****
  void
  bug_resume (int pid, int step, enum target_signal sig)
  {
!   dcache_flush (gr_get_dcache ());
  
    if (step)
      {
--- 242,248 ----
  void
  bug_resume (int pid, int step, enum target_signal sig)
  {
!   dcache_invd (gr_get_dcache ());
  
    if (step)
      {
Index: remote-nindy.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-nindy.c,v
retrieving revision 1.6
diff -c -r1.6 remote-nindy.c
*** remote-nindy.c	2000/08/10 18:54:27	1.6
--- remote-nindy.c	2000/08/18 22:40:18
***************
*** 191,197 ****
    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.  */
--- 191,197 ----
    if (!nindy_dcache)
      nindy_dcache = dcache_init (ninMemGet, ninMemPut);
    else
!     dcache_invd (nindy_dcache);
  
    /* Allow user to interrupt the following -- we could hang if there's
       no NINDY at the other end of the remote tty.  */
***************
*** 269,275 ****
    if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
      warning ("Can't send signals to remote NINDY targets.");
  
!   dcache_flush (nindy_dcache);
    if (regs_changed)
      {
        nindy_store_registers (-1);
--- 269,275 ----
    if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
      warning ("Can't send signals to remote NINDY targets.");
  
!   dcache_invd (nindy_dcache);
    if (regs_changed)
      {
        nindy_store_registers (-1);
***************
*** 614,619 ****
--- 614,621 ----
  	}
      }
    bfd_close (file);
+ 
+   dcache_invd(nindy_dcache);
  }
  
  static int
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.5
diff -c -r1.5 remote-sds.c
*** remote-sds.c	2000/08/10 18:54:27	1.5
--- remote-sds.c	2000/08/18 22:40:19
***************
*** 206,212 ****
    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)
--- 206,212 ----
    if (!sds_dcache)
      sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
    else
!     dcache_invd (sds_dcache);
  
    sds_desc = SERIAL_OPEN (name);
    if (!sds_desc)
***************
*** 358,364 ****
  {
    unsigned char buf[PBUFSIZ];
  
!   dcache_flush (sds_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
--- 358,364 ----
  {
    unsigned char buf[PBUFSIZ];
  
!   dcache_invd (sds_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-utils.c,v
retrieving revision 1.5
diff -c -r1.5 remote-utils.c
*** remote-utils.c	2000/08/10 18:54:27	1.5
--- remote-utils.c	2000/08/18 22:40:19
***************
*** 165,171 ****
    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);
--- 165,171 ----
    if ((dcache = gr_get_dcache()) == NULL)
      gr_set_dcache (dcache_init (gr->readfunc, gr->writefunc));
    else
!     dcache_invd (dcache);
  
    if (sr_get_desc () != NULL)
      gr_close (0);
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.20
diff -c -r1.20 remote.c
*** remote.c	2000/08/10 18:54:27	1.20
--- remote.c	2000/08/18 22:40:23
***************
*** 2060,2066 ****
    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)
--- 2060,2066 ----
    if (!remote_dcache)
      remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
    else
!     dcache_invd (remote_dcache);
  
    remote_desc = SERIAL_OPEN (name);
    if (!remote_desc)
***************
*** 2309,2315 ****
    else
      set_thread (pid, 0);	/* run this thread */
  
!   dcache_flush (remote_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
--- 2309,2315 ----
    else
      set_thread (pid, 0);	/* run this thread */
  
!   dcache_invd (remote_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
***************
*** 2343,2349 ****
    else
      set_thread (pid, 0);	/* run this thread */
  
!   dcache_flush (remote_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
--- 2343,2349 ----
    else
      set_thread (pid, 0);	/* run this thread */
  
!   dcache_invd (remote_dcache);
  
    last_sent_signal = siggnal;
    last_sent_step = step;
***************
*** 5040,5046 ****
    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)
--- 5040,5046 ----
    if (!remote_dcache)
      remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
    else
!     dcache_invd (remote_dcache);
  
    remote_desc = SERIAL_OPEN (name);
    if (!remote_desc)
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.8
diff -c -r1.8 wince.c
*** wince.c	2000/07/30 01:48:28	1.8
--- wince.c	2000/08/18 22:40:25
***************
*** 1732,1738 ****
    if (!remote_dcache)
      remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
    else
!     dcache_flush (remote_dcache);
  
    exec_file = upload_to_device (exec_file, exec_file);
  
--- 1732,1738 ----
    if (!remote_dcache)
      remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
    else
!     dcache_invd (remote_dcache);
  
    exec_file = upload_to_device (exec_file, exec_file);
  
***************
*** 1842,1848 ****
        th->context.ContextFlags = 0;
      }
  
!   dcache_flush (remote_dcache);
  
    /* Allow continuing with the same signal that interrupted us.
       Otherwise complain. */
--- 1842,1848 ----
        th->context.ContextFlags = 0;
      }
  
!   dcache_invd (remote_dcache);
  
    /* Allow continuing with the same signal that interrupted us.
       Otherwise complain. */


-- 
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]