/* Caching code for GDB, the GNU debugger.
- Copyright 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free
- Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2007
+ Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "dcache.h"
{
struct dcache_block *p; /* next in list */
CORE_ADDR addr; /* Address for which data is recorded. */
- char data[LINE_SIZE]; /* bytes at given address */
+ gdb_byte data[LINE_SIZE]; /* bytes at given address */
unsigned char state[LINE_SIZE]; /* what state the data is in */
/* whether anything in state is dirty - used to speed up the
struct dcache_block *the_cache;
};
-static int dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
-static int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
static int dcache_write_line (DCACHE *dcache, struct dcache_block *db);
void _initialize_dcache (void);
static int dcache_enabled_p = 0;
+static void
+show_dcache_enabled_p (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Cache use for remote targets is %s.\n"), value);
+}
+
DCACHE *last_cache; /* Used by info dcache */
dcache_write_line (DCACHE *dcache, struct dcache_block *db)
{
CORE_ADDR memaddr;
- char *myaddr;
+ gdb_byte *myaddr;
int len;
int res;
int reg_len;
}
dirty_len = e - s;
- while (dirty_len > 0)
- {
- res = do_xfer_memory(memaddr, myaddr, dirty_len, 1,
- ®ion->attrib);
- if (res <= 0)
- return 0;
-
- memset (&db->state[XFORM(memaddr)], ENTRY_OK, res);
- memaddr += res;
- myaddr += res;
- len -= res;
- dirty_len -= res;
- }
+ res = target_write (¤t_target, TARGET_OBJECT_RAW_MEMORY,
+ NULL, myaddr, memaddr, dirty_len);
+ if (res < dirty_len)
+ return 0;
+
+ memset (&db->state[XFORM(memaddr)], ENTRY_OK, res);
+ memaddr += res;
+ myaddr += res;
+ len -= res;
}
}
dcache_read_line (DCACHE *dcache, struct dcache_block *db)
{
CORE_ADDR memaddr;
- char *myaddr;
+ gdb_byte *myaddr;
int len;
int res;
int reg_len;
continue;
}
- while (reg_len > 0)
- {
- res = do_xfer_memory (memaddr, myaddr, reg_len, 0,
- ®ion->attrib);
- if (res <= 0)
- return 0;
+ res = target_read (¤t_target, TARGET_OBJECT_RAW_MEMORY,
+ NULL, myaddr, memaddr, reg_len);
+ if (res < reg_len)
+ return 0;
- memaddr += res;
- myaddr += res;
- len -= res;
- reg_len -= res;
- }
+ memaddr += res;
+ myaddr += res;
+ len -= res;
}
memset (db->state, ENTRY_OK, sizeof (db->data));
Returns 0 on error. */
static int
-dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
{
struct dcache_block *db = dcache_hit (dcache, addr);
*/
static int
-dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
{
struct dcache_block *db = dcache_hit (dcache, addr);
This routine is indended to be called by remote_xfer_ functions. */
int
-dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
- int should_write)
+dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr,
+ int len, int should_write)
{
int i;
- int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, char *ptr);
+ int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr);
xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
for (i = 0; i < len; i++)
registers and thus data caching will produce incorrect results with\n\
volatile registers are in use. By default, this option is off."),
NULL,
- NULL, /* FIXME: i18n: */
+ show_dcache_enabled_p,
&setlist, &showlist);
add_info ("dcache", dcache_info,