aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog82
-rw-r--r--gdb/TODO8
-rw-r--r--gdb/dcache.c41
-rw-r--r--gdb/dcache.h8
-rw-r--r--gdb/monitor.c35
-rw-r--r--gdb/monitor.h1
-rw-r--r--gdb/ocd.c21
-rw-r--r--gdb/remote-bug.c15
-rw-r--r--gdb/remote-nindy.c23
-rw-r--r--gdb/remote-sds.c19
-rw-r--r--gdb/remote-utils.c7
-rw-r--r--gdb/remote-utils.h9
-rw-r--r--gdb/remote.c30
-rw-r--r--gdb/target.c97
-rw-r--r--gdb/target.h21
-rw-r--r--gdb/wince.c17
16 files changed, 241 insertions, 193 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca5db2f..a3d1933 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,85 @@
+2000-11-01 J.T. Conklin <jtc@redback.com>
+
+ * TODO: Note abstraction layer violation where "ocd reset" command
+ must invalidate the dcache, and how this might be fixed.
+
+ * monitor.c (#include "dcache.h"): Removed.
+ (remote_dcache): Removed.
+ (monitor_open): Removed code that created local dcache.
+ (flush_monitor_dcache): Removed (unused function).
+ (monitor_resume): Removed call to dcache_invd().
+ (monitor_load): Likewise.
+ (monitor_xfer_memory): Changed to call monitor_write_memory(),
+ monitor_write_memory_block(), and monitor_read_memory() instead
+ of dcache_xfer_memory().
+ * monitor.h (flush_monitor_dcache): Removed (unused function).
+ * ocd.c (#include "dcache.h"): Removed.
+ (ocd_dcache): Removed.
+ (ocd_open): Removed code that created local dcache.
+ (ocd_resume): Removed call to dcache_invd().
+ (ocd_xfer_memory): Changed to call ocd_write_bytes() and
+ ocd_read_bytes() instead of dcache_xfer_memory().
+ (bdm_reset_command): Invalidate target dcache.
+ * remote-bug.c (bug_load): Remove call to dcache_invd().
+ (bug_resume): Likewise.
+ (bug_settings): Remove dcache, readfunc, and writefunc fields
+ from initializer.
+ (bug_xfer_memory): Changed to call bug_read_memory() and
+ bug_write_memory() instead of dcache_xfer_memory().
+ * remote-nindy.c (#include "dcache.h"): Removed.
+ (nindy_dcache): Removed.
+ (nindy_open): Removed code that created local dcache.
+ (nindy_resume): Removed call to dcache_invd().
+ (nindy_load): Likewise.
+ (nindy_xfer_inferior_memory): Changed to call ninMemPut() and
+ ninMemGet() instead of dcache_xfer_memory().
+ * remote-sds.c (#include "dcache.h"): Removed.
+ (sds_dcache): Removed.
+ (sds_open): Removed code that created local dcache.
+ (sds_resume): Removed call to dcache_invd().
+ (sds_xfer_memory): Changed to call sds_write_bytes() and
+ sds_read_bytes() instead of dcache_xfer_memory().
+ * remote-utils.c (gr_open): Removed code that created local dcache.
+ * remote-utils.h (#include "dcache.h"): Removed.
+ (struct gr_settings): Removed dcache, readfunc, and writefunc fields.
+ (gr_get_dcache, gr_set_dcache): Removed macro definitions.
+ * remote.c (#include "dcache.h"): Removed.
+ (remote_dcache): Removed.
+ (remote_open_1): Removed code that created local dcache.
+ (remote_async_open_1): Likewise.
+ (remote_resume): Removed call to dcache_invd().
+ (remote_async_resume): Likewise.
+ (remote_xfer_memory): Changed to call remote_write_bytes() and
+ remote_read_bytes() instead of dcache_xfer_memory().
+ * wince.c (#include "dcache.h"): Removed.
+ (remote_dcache): Removed.
+ (child_create_inferior): Removed code that created local dcache.
+ (child_xfer_memory): Changed to call remote_write_bytes() and
+ remote_read_bytes() instead of dcache_xfer_memory().
+ (child_resume): Removed call to dcache_invd().
+
+ * target.c (target_dcache): Added.
+ (target_load): Invalidate target_dcache.
+ (do_xfer_memory): New function.
+ (target_xfer_memory): Reimplement in terms of dcache_xfer_memory().
+ (target_xfer_memory_partial): Likewise.
+ (initialize_targets): Create target_dcache.
+ * target.h (#include "dcache.h"): Added.
+ (target_open): Invalidate target_dcache.
+ (target_resume): Likewise.
+ (do_xfer_memory): New declaration.
+
+ * dcache.c (dcache_init): Removed reading and writing arguments.
+ (dcache_struct): Removed read_memory and write_memory fields.
+ (dcache_write_line): Call do_xfer_memory.
+ (dcache_read_line): Likewise.
+ (dcache_xfer_memory): Likewise.
+ (dcache_invalidate): Renamed from dcache_invd.
+ (dcache_init): Updated.
+ (dcache_xfer_memory): Updated.
+ * dcache.h (memxferfunc): Removed definition.
+ (dcache_init): Removed reading and writing arguments.
+
2000-11-03 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
* objfiles.c (objfile_relocate): Relocate ei.entry_point with
diff --git a/gdb/TODO b/gdb/TODO
index 2cf6bc4..59c6c50 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -649,6 +649,14 @@ FPU.
--
+The "ocd reset" command needs to flush the dcache, which requires breaking
+the abstraction layer between the target independent and target code. One
+way to address this is provide a generic "reset" command and target vector.
+
+http://sources.redhat.com/ml/gdb-patches/2000-10/msg00011.html
+
+--
+
Thread Support
==============
diff --git a/gdb/dcache.c b/gdb/dcache.c
index 46255d9..ed30eea 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -1,7 +1,5 @@
-/* Caching code. Typically used by remote back ends for
- caching remote memory.
-
- Copyright 1992-1993, 1995, 1998-1999 Free Software Foundation, Inc.
+/* Caching code.
+ Copyright 1992-1993, 1995, 1998-1999, 2000 Free Software Foundation, Inc.
This file is part of GDB.
@@ -25,6 +23,7 @@
#include "gdbcmd.h"
#include "gdb_string.h"
#include "gdbcore.h"
+#include "target.h"
/*
The data cache could lead to incorrect results because it doesn't know
@@ -126,12 +125,6 @@ struct dcache_block
struct dcache_struct
{
- /* Function to actually read the target memory. */
- memxferfunc read_memory;
-
- /* Function to actually write the target memory */
- memxferfunc write_memory;
-
/* free list */
struct dcache_block *free_head;
struct dcache_block *free_tail;
@@ -175,7 +168,7 @@ DCACHE *last_cache; /* Used by info dcache */
/* Free all the data cache blocks, thus discarding all cached data. */
void
-dcache_invd (DCACHE *dcache)
+dcache_invalidate (DCACHE *dcache)
{
int i;
dcache->valid_head = 0;
@@ -250,10 +243,10 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
int done = 0;
while (done < len)
{
- int t = dcache->write_memory (db->addr + s + done,
- db->data + s + done,
- len - done);
- if (t == 0)
+ int t = do_xfer_memory (db->addr + s + done,
+ db->data + s + done,
+ len - done, 1);
+ if (t <= 0)
return 0;
done += t;
}
@@ -267,7 +260,6 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
return 1;
}
-
/* Read cache line */
static int
dcache_read_line (DCACHE *dcache, struct dcache_block *db)
@@ -291,8 +283,8 @@ dcache_read_line (DCACHE *dcache, struct dcache_block *db)
while (len > 0)
{
- res = (*dcache->read_memory) (memaddr, myaddr, len);
- if (res == 0)
+ res = do_xfer_memory (memaddr, myaddr, len, 0);
+ if (res <= 0)
return 0;
memaddr += res;
@@ -420,19 +412,17 @@ dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
/* Initialize the data cache. */
DCACHE *
-dcache_init (memxferfunc reading, memxferfunc writing)
+dcache_init (void)
{
int csize = sizeof (struct dcache_block) * DCACHE_SIZE;
DCACHE *dcache;
dcache = (DCACHE *) xmalloc (sizeof (*dcache));
- dcache->read_memory = reading;
- dcache->write_memory = writing;
dcache->the_cache = (struct dcache_block *) xmalloc (csize);
memset (dcache->the_cache, 0, csize);
- dcache_invd (dcache);
+ dcache_invalidate (dcache);
last_cache = dcache;
return dcache;
@@ -481,13 +471,10 @@ dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
}
else
{
- memxferfunc xfunc;
- xfunc = should_write ? dcache->write_memory : dcache->read_memory;
-
if (dcache->cache_has_stuff)
- dcache_invd (dcache);
+ dcache_invalidate (dcache);
- len = xfunc (memaddr, myaddr, len);
+ len = do_xfer_memory(memaddr, myaddr, len, should_write);
}
return len;
}
diff --git a/gdb/dcache.h b/gdb/dcache.h
index 1615fce..079b037 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -23,22 +23,20 @@
#ifndef DCACHE_H
#define DCACHE_H
-typedef int (*memxferfunc) (CORE_ADDR memaddr, char *myaddr, int len);
-
typedef struct dcache_struct DCACHE;
/* Invalidate DCACHE. */
-void dcache_invd (DCACHE * dcache);
+void dcache_invalidate (DCACHE *dcache);
/* Initialize DCACHE. */
-DCACHE *dcache_init (memxferfunc reading, memxferfunc writing);
+DCACHE *dcache_init (void);
/* 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,
+int dcache_xfer_memory (DCACHE *cache, CORE_ADDR mem, char *my, int len,
int should_write);
/* Turn dcache state on or off */
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 3206470..dec36da 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -51,7 +51,6 @@
#include "gdbcmd.h"
#include "inferior.h"
#include "gdb_regex.h"
-#include "dcache.h"
#include "srec.h"
static char *dev_name;
@@ -130,7 +129,6 @@ static char getmem_resp_delim_fastmap[256];
static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
monitor_wait wakes up. */
-static DCACHE *remote_dcache;
static int first_time = 0; /* is this the first time we're executing after
gaving created the child proccess? */
@@ -838,15 +836,6 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
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 ();
}
@@ -929,12 +918,6 @@ monitor_supply_register (int regno, char *valstr)
/* Tell the remote machine to resume. */
-void
-flush_monitor_dcache (void)
-{
- dcache_invd (remote_dcache);
-}
-
static void
monitor_resume (int pid, int step, enum target_signal sig)
{
@@ -948,7 +931,6 @@ monitor_resume (int pid, int step, enum target_signal sig)
dump_reg_flag = 1;
return;
}
- dcache_invd (remote_dcache);
if (step)
monitor_printf (current_monitor->step);
else
@@ -2008,7 +1990,21 @@ static int
monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *target)
{
- return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, write);
+ int res;
+
+ if (write)
+ {
+ if (current_monitor->flags & MO_HAS_BLOCKWRITES)
+ res = monitor_write_memory_block(memaddr, myaddr, len);
+ else
+ res = monitor_write_memory(memaddr, myaddr, len);
+ }
+ else
+ {
+ res = monitor_read_memory(memaddr, myaddr, len);
+ }
+
+ return res;
}
static void
@@ -2145,7 +2141,6 @@ monitor_wait_srec_ack (void)
static void
monitor_load (char *file, int from_tty)
{
- dcache_invd (remote_dcache);
monitor_debug ("MON load\n");
if (current_monitor->load_routine)
diff --git a/gdb/monitor.h b/gdb/monitor.h
index 712a4c5..562c19e 100644
--- a/gdb/monitor.h
+++ b/gdb/monitor.h
@@ -246,4 +246,3 @@ extern int monitor_readchar (void);
extern char *monitor_get_dev_name (void);
extern void init_monitor_ops (struct target_ops *);
extern int monitor_dump_reg_block (char *dump_cmd);
-extern void flush_monitor_dcache (void);
diff --git a/gdb/ocd.c b/gdb/ocd.c
index 3d054b7..eb83161 100644
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -31,7 +31,6 @@
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
-#include "dcache.h"
#include <sys/types.h>
#include <signal.h>
#include "serial.h"
@@ -273,8 +272,6 @@ ocd_start_remote (PTR dummy)
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
-static DCACHE *ocd_dcache;
-
void
ocd_open (char *name, int from_tty, enum ocd_target_type target_type,
struct target_ops *ops)
@@ -292,11 +289,6 @@ device the OCD device is attached to (e.g. /dev/ttya).");
unpush_target (current_ops);
- if (!ocd_dcache)
- ocd_dcache = dcache_init (ocd_read_bytes, ocd_write_bytes);
- else
- dcache_invd (ocd_dcache);
-
if (strncmp (name, "wiggler", 7) == 0)
{
ocd_desc = SERIAL_OPEN ("ocd");
@@ -387,8 +379,6 @@ ocd_resume (int pid, int step, enum target_signal siggnal)
{
int pktlen;
- dcache_invd (ocd_dcache);
-
if (step)
ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
else
@@ -772,7 +762,14 @@ int
ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
struct target_ops *target)
{
- return dcache_xfer_memory (ocd_dcache, memaddr, myaddr, len, should_write);
+ int res;
+
+ if (should_write)
+ res = ocd_write_bytes (memaddr, myaddr, len);
+ else
+ res = ocd_read_bytes (memaddr, myaddr, len);
+
+ return res;
}
void
@@ -1315,7 +1312,7 @@ bdm_reset_command (char *args, int from_tty)
error ("Not connected to OCD device.");
ocd_do_command (OCD_RESET, &status, &pktlen);
- dcache_invd (ocd_dcache);
+ dcache_invalidate (target_dcache);
registers_changed ();
}
diff --git a/gdb/remote-bug.c b/gdb/remote-bug.c
index 25b769e..eb18812 100644
--- a/gdb/remote-bug.c
+++ b/gdb/remote-bug.c
@@ -119,7 +119,6 @@ bug_load (char *args, int fromtty)
sr_check_open ();
- dcache_invd (gr_get_dcache ());
inferior_pid = 0;
abfd = bfd_openr (args, 0);
if (!abfd)
@@ -198,12 +197,9 @@ get_word (char **p)
static struct gr_settings bug_settings =
{
- NULL, /* dcache */
"Bug>", /* prompt */
&bug_ops, /* ops */
bug_clear_breakpoints, /* clear_all_breakpoints */
- bug_read_memory, /* readfunc */
- bug_write_memory, /* writefunc */
gr_generic_checkin, /* checkin */
};
@@ -242,8 +238,6 @@ bug_open (char *args, int from_tty)
void
bug_resume (int pid, int step, enum target_signal sig)
{
- dcache_invd (gr_get_dcache ());
-
if (step)
{
sr_write_cr ("t");
@@ -563,10 +557,17 @@ int
bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *target)
{
+ int res;
+
if (len <= 0)
return 0;
- return dcache_xfer_memory (gr_get_dcache (), memaddr, myaddr, len, write);
+ if (write)
+ res = bug_write_memory (memaddr, myaddr, len);
+ else
+ res = bug_read_memory (memaddr, myaddr, len);
+
+ return res;
}
static void
diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c
index c5e0a4a..6428541 100644
--- a/gdb/remote-nindy.c
+++ b/gdb/remote-nindy.c
@@ -115,12 +115,8 @@
#include "serial.h"
#include "nindy-share/env.h"
#include "nindy-share/stop.h"
-
-#include "dcache.h"
#include "remote-utils.h"
-static DCACHE *nindy_dcache;
-
extern int unlink ();
extern char *getenv ();
extern char *mktemp ();
@@ -188,11 +184,6 @@ nindy_open (char *name, /* "/dev/ttyXX", "ttyXX", or "XX": tty to be opened */
have_regs = regs_changed = 0;
- 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. */
immediate_quit++;
@@ -268,7 +259,6 @@ nindy_resume (int pid, int step, enum target_signal siggnal)
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);
@@ -488,10 +478,17 @@ int
nindy_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len,
int should_write, struct target_ops *target)
{
+ int res;
+
if (len <= 0)
return 0;
- return dcache_xfer_memory (nindy_dcache, memaddr, myaddr,
- len, should_write);
+
+ if (should_write)
+ res = ninMemPut (memaddr, myaddr, len);
+ else
+ res = ninMemGet (memaddr, myaddr, len);
+
+ return res;
}
static void
@@ -610,8 +607,6 @@ nindy_load (char *filename, int from_tty)
}
}
bfd_close (file);
-
- dcache_invd(nindy_dcache);
}
static int
diff --git a/gdb/remote-sds.c b/gdb/remote-sds.c
index 1549978..96fa4a8 100644
--- a/gdb/remote-sds.c
+++ b/gdb/remote-sds.c
@@ -37,7 +37,6 @@
#include "gdb-stabs.h"
#include "gdbthread.h"
#include "gdbcore.h"
-#include "dcache.h"
#ifdef USG
#include <sys/types.h>
@@ -190,8 +189,6 @@ sds_start_remote (PTR dummy)
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
-static DCACHE *sds_dcache;
-
static void
sds_open (char *name, int from_tty)
{
@@ -203,11 +200,6 @@ device is attached to the remote system (e.g. /dev/ttya).");
unpush_target (&sds_ops);
- 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)
perror_with_name (name);
@@ -358,8 +350,6 @@ sds_resume (int pid, int step, enum target_signal siggnal)
{
unsigned char buf[PBUFSIZ];
- dcache_invd (sds_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
@@ -669,7 +659,14 @@ static int
sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
struct target_ops *target)
{
- return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
+ int res;
+
+ if (should_write)
+ res = sds_write_bytes (memaddr, myaddr, len);
+ else
+ res = sds_read_bytes (memaddr, myaddr, len);
+
+ return res;
}
diff --git a/gdb/remote-utils.c b/gdb/remote-utils.c
index c2b833e..e723a56 100644
--- a/gdb/remote-utils.c
+++ b/gdb/remote-utils.c
@@ -154,19 +154,12 @@ gr_generic_checkin (void)
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_invd (dcache);
-
if (sr_get_desc () != NULL)
gr_close (0);
diff --git a/gdb/remote-utils.h b/gdb/remote-utils.h
index 75e852a..9f57068 100644
--- a/gdb/remote-utils.h
+++ b/gdb/remote-utils.h
@@ -24,7 +24,6 @@
#include "serial.h"
#include "target.h"
-#include "dcache.h"
/* Stuff that should be shared (and handled consistently) among the various
remote targets. */
@@ -73,22 +72,14 @@ extern struct _sr_settings sr_settings;
struct gr_settings
{
- /* This is our data cache. */
- DCACHE *dcache;
char *prompt;
struct target_ops *ops;
int (*clear_all_breakpoints) (void);
- memxferfunc readfunc;
- memxferfunc writefunc;
void (*checkin) (void);
};
extern struct gr_settings *gr_settings;
-/* get and set dcache. */
-#define gr_get_dcache() (gr_settings->dcache)
-#define gr_set_dcache(newval) (gr_settings->dcache = (newval))
-
/* get and set prompt. */
#define gr_get_prompt() (gr_settings->prompt)
#define gr_set_prompt(newval) (gr_settings->prompt = (newval))
diff --git a/gdb/remote.c b/gdb/remote.c
index 61a730e..2cd3089 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -37,8 +37,6 @@
#include "gdbthread.h"
#include "remote.h"
-#include "dcache.h"
-
#include <ctype.h>
#include <sys/time.h>
#ifdef USG
@@ -2027,8 +2025,6 @@ extended_remote_async_open (char *name, int from_tty)
/* Generic code for opening a connection to a remote target. */
-static DCACHE *remote_dcache;
-
static void
init_all_packet_configs (void)
{
@@ -2057,11 +2053,6 @@ serial device is attached to the remote system\n\
unpush_target (target);
- 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)
perror_with_name (name);
@@ -2140,8 +2131,6 @@ serial device is attached to the remote system\n\
unpush_target (target);
- remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-
remote_desc = SERIAL_OPEN (name);
if (!remote_desc)
perror_with_name (name);
@@ -2309,8 +2298,6 @@ remote_resume (int pid, int step, enum target_signal siggnal)
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
@@ -2343,8 +2330,6 @@ remote_async_resume (int pid, int step, enum target_signal siggnal)
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
@@ -3555,12 +3540,18 @@ remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
{
CORE_ADDR targ_addr;
int targ_len;
+ int res;
+
REMOTE_TRANSLATE_XFER_ADDRESS (mem_addr, mem_len, &targ_addr, &targ_len);
if (targ_len <= 0)
return 0;
- return dcache_xfer_memory (remote_dcache, targ_addr, buffer,
- targ_len, should_write);
+ if (should_write)
+ res = remote_write_bytes (targ_addr, buffer, targ_len);
+ else
+ res = remote_read_bytes (targ_addr, buffer, targ_len);
+
+ return res;
}
@@ -5044,11 +5035,6 @@ device is attached to the remote system (e.g. host:port).");
unpush_target (&remote_cisco_ops);
- 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)
perror_with_name (name);
diff --git a/gdb/target.c b/gdb/target.c
index 4f4f8b0..668987e 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -31,6 +31,7 @@
#include "symfile.h"
#include "objfiles.h"
#include "gdb_wait.h"
+#include "dcache.h"
#include <signal.h>
extern int errno;
@@ -177,6 +178,8 @@ static int targetdebug = 0;
static void setup_target_debug (void);
+DCACHE *target_dcache;
+
/* The user just typed 'target' without the name of a target. */
/* ARGSUSED */
@@ -229,6 +232,7 @@ target_ignore (void)
void
target_load (char *arg, int from_tty)
{
+ dcache_invalidate (target_dcache);
(*current_target.to_load) (arg, from_tty);
}
@@ -843,11 +847,11 @@ target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
Result is 0 or errno value. */
-static int
-target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+int
+do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{
- int curlen;
int res;
+ int done = 0;
struct target_ops *t;
struct target_stack_item *item;
@@ -863,22 +867,21 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, &current_target);
if (res == len)
- return 0;
+ return len;
if (res > 0)
goto bump;
/* If res <= 0 then we call it again in the loop. Ah well. */
- for (; len > 0;)
+ while (len > 0)
{
- curlen = len; /* Want to do it all */
for (item = target_stack; item; item = item->next)
{
t = item->target_ops;
if (!t->to_has_memory)
continue;
- res = t->to_xfer_memory (memaddr, myaddr, curlen, write, t);
+ res = t->to_xfer_memory (memaddr, myaddr, len, write, t);
if (res > 0)
break; /* Handled all or part of xfer */
if (t->to_has_all_memory)
@@ -887,6 +890,34 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
if (res <= 0)
{
+ return -1;
+ }
+ bump:
+ done += res;
+ memaddr += res;
+ myaddr += res;
+ len -= res;
+ }
+
+ return done;
+}
+
+static int
+target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+{
+ int res;
+
+ /* Zero length requests are ok and require no work. */
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ while (len > 0)
+ {
+ res = dcache_xfer_memory(target_dcache, memaddr, myaddr, len, write);
+ if (res <= 0)
+ {
/* If this address is for nonexistent memory,
read zeros if reading, or do nothing if writing. Return error. */
if (!write)
@@ -896,11 +927,12 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
else
return errno;
}
- bump:
+
memaddr += res;
- myaddr += res;
- len -= res;
+ myaddr += res;
+ len -= res;
}
+
return 0; /* We managed to cover it all somehow. */
}
@@ -908,7 +940,7 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
/* Perform a partial memory transfer. */
static int
-target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
+target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
int write_p, int *err)
{
int res;
@@ -924,42 +956,19 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
return 0;
}
- /* The quick case is that the top target does it all. */
- res = current_target.to_xfer_memory (memaddr, buf, len, write_p, &current_target);
- if (res > 0)
+ res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
+ if (res <= 0)
{
- *err = 0;
- return res;
- }
-
- /* xfer memory doesn't always reliably set errno. */
- errno = 0;
+ if (errno != 0)
+ *err = errno;
+ else
+ *err = EIO;
- /* Try all levels of the target stack to see one can handle it. */
- for (item = target_stack; item; item = item->next)
- {
- t = item->target_ops;
- if (!t->to_has_memory)
- continue;
- res = t->to_xfer_memory (memaddr, buf, len, write_p, t);
- if (res > 0)
- {
- /* Handled all or part of xfer */
- *err = 0;
- return res;
- }
- if (t->to_has_all_memory)
- break;
+ return -1;
}
- /* Total failure. Return error. */
- if (errno != 0)
- {
- *err = errno;
- return -1;
- }
- *err = EIO;
- return -1;
+ *err = 0;
+ return 0;
}
int
@@ -2920,6 +2929,8 @@ When non-zero, target debugging is enabled.", &setdebuglist),
add_com ("monitor", class_obscure, do_monitor_command,
"Send a command to the remote monitor (remote targets only).");
+ target_dcache = dcache_init();
+
if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
abort ();
}
diff --git a/gdb/target.h b/gdb/target.h
index 0dc3c8e..98c017b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -43,6 +43,7 @@
#include "bfd.h"
#include "symtab.h"
+#include "dcache.h"
enum strata
{
@@ -487,8 +488,11 @@ extern struct target_stack_item *target_stack;
and (if successful) pushes a new target onto the stack.
Targets should supply this routine, if only to provide an error message. */
-#define target_open(name, from_tty) \
- (*current_target.to_open) (name, from_tty)
+#define target_open(name, from_tty) \
+ do { \
+ dcache_invalidate (target_dcache); \
+ (*current_target.to_open) (name, from_tty); \
+ } while (0)
/* Does whatever cleanup is required for a target that we are no longer
going to be calling. Argument says whether we are quitting gdb and
@@ -560,8 +564,11 @@ extern void target_detach (char *, int);
the target, or TARGET_SIGNAL_0 for no signal. The caller may not
pass TARGET_SIGNAL_DEFAULT. */
-#define target_resume(pid, step, siggnal) \
- (*current_target.to_resume) (pid, step, siggnal)
+#define target_resume(pid, step, siggnal) \
+ do { \
+ dcache_invalidate(target_dcache); \
+ (*current_target.to_resume) (pid, step, siggnal); \
+ } while (0)
/* Wait for process pid to do something. Pid = -1 to wait for any pid
to do something. Return pid of child, or -1 in case of error;
@@ -608,11 +615,15 @@ extern void target_detach (char *, int);
#define target_prepare_to_store() \
(*current_target.to_prepare_to_store) ()
+extern DCACHE *target_dcache;
+
+extern int do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write);
+
extern int target_read_string (CORE_ADDR, char **, int, int *);
extern int target_read_memory (CORE_ADDR memaddr, char *myaddr, int len);
-extern int target_write_memory (CORE_ADDR, char *, int);
+extern int target_write_memory (CORE_ADDR memaddr, char *myaddr, int len);
extern int xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
diff --git a/gdb/wince.c b/gdb/wince.c
index 7081dd2..381cfda 100644
--- a/gdb/wince.c
+++ b/gdb/wince.c
@@ -54,7 +54,6 @@
#include "gdbcmd.h"
#include <sys/param.h>
#include "wince-stub.h"
-#include "dcache.h"
#include <time.h>
/* The ui's event loop. */
@@ -89,8 +88,6 @@ extern int (*ui_loop_hook) (int signo);
static int connection_initialized = 0; /* True if we've initialized a RAPI session. */
-static DCACHE *remote_dcache;
-
/* The directory where the stub and executable files are uploaded. */
static const char *remote_directory = "\\gdb";
@@ -1729,10 +1726,6 @@ child_create_inferior (char *exec_file, char *args, char **env)
flags = DEBUG_PROCESS;
wince_initialize (); /* Make sure we've got a connection. */
- 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);
@@ -1798,7 +1791,13 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len,
{
if (len <= 0)
return 0;
- return dcache_xfer_memory (remote_dcache, memaddr, our, len, write);
+
+ if (write)
+ res = remote_write_bytes (memaddr, our, len);
+ else
+ res = remote_read_bytes (memaddr, our, len);
+
+ return res;
}
/* Terminate the process and wait for child to tell us it has completed. */
@@ -1842,8 +1841,6 @@ child_resume (int pid, int step, enum target_signal sig)
th->context.ContextFlags = 0;
}
- dcache_invd (remote_dcache);
-
/* Allow continuing with the same signal that interrupted us.
Otherwise complain. */
if (sig && sig != last_sig)