This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA]: Changes to move dcache above target vector functions.
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA]: Changes to move dcache above target vector functions.
- From: jtc at redback dot com (J.T. Conklin)
- Date: 02 Oct 2000 14:31:08 -0700
- Reply-To: jtc at redback dot com
Early last month, I trolled for comments about the enclosed patch.
The only bite I got was about my suggestion that reset is a higher
level concept and probably deserves a separate command / target
function.
I'd seeking approval to commit the enclosed patch. It's the same as
the earlier one, except I "fixed" the problem with invalidating the
dcache in ocd.c's bdm_reset_command(). This was fixed by accessing
target_dcache in ocd.c. This is an abstraction layer violation, but
it seemed the most expedient way to handle the problem. Support for a
reset command would make this hack unnecessary. I'm open to changing
this if necessary.
--jtc
2000-10-02 J.T. Conklin <jtc@redback.com>
* 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.
Index: dcache.c
===================================================================
RCS file: /cvs/src/src/gdb/dcache.c,v
retrieving revision 1.9
diff -c -r1.9 dcache.c
*** dcache.c 2000/09/01 00:12:10 1.9
--- dcache.c 2000/10/02 21:04:18
***************
*** 1,8 ****
! /* Caching code. Typically used by remote back ends for
! caching remote memory.
- Copyright 1992-1993, 1995, 1998-1999 Free Software Foundation, Inc.
-
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
--- 1,6 ----
! /* Caching code.
! Copyright 1992-1993, 1995, 1998-1999, 2000 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
***************
*** 25,30 ****
--- 23,29 ----
#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,137 ****
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;
--- 125,130 ----
***************
*** 175,181 ****
/* Free all the data cache blocks, thus discarding all cached data. */
void
! dcache_invd (DCACHE *dcache)
{
int i;
dcache->valid_head = 0;
--- 168,174 ----
/* Free all the data cache blocks, thus discarding all cached data. */
void
! dcache_invalidate (DCACHE *dcache)
{
int i;
dcache->valid_head = 0;
***************
*** 250,259 ****
int done = 0;
while (done < len)
{
! int t = dcache->write_memory (db->addr + s + done,
! db->data + s + done,
! len - done);
! if (t == 0)
return 0;
done += t;
}
--- 243,252 ----
int done = 0;
while (done < len)
{
! int t = do_xfer_memory (db->addr + s + done,
! db->data + s + done,
! len - done, 1);
! if (t <= 0)
return 0;
done += t;
}
***************
*** 267,273 ****
return 1;
}
-
/* Read cache line */
static int
dcache_read_line (DCACHE *dcache, struct dcache_block *db)
--- 260,265 ----
***************
*** 291,298 ****
while (len > 0)
{
! res = (*dcache->read_memory) (memaddr, myaddr, len);
! if (res == 0)
return 0;
memaddr += res;
--- 283,290 ----
while (len > 0)
{
! res = do_xfer_memory (memaddr, myaddr, len, 0);
! if (res <= 0)
return 0;
memaddr += res;
***************
*** 420,438 ****
/* Initialize the data cache. */
DCACHE *
! dcache_init (memxferfunc reading, memxferfunc writing)
{
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);
last_cache = dcache;
return dcache;
--- 412,428 ----
/* Initialize the data cache. */
DCACHE *
! dcache_init (void)
{
int csize = sizeof (struct dcache_block) * DCACHE_SIZE;
DCACHE *dcache;
dcache = (DCACHE *) xmalloc (sizeof (*dcache));
dcache->the_cache = (struct dcache_block *) xmalloc (csize);
memset (dcache->the_cache, 0, csize);
! dcache_invalidate (dcache);
last_cache = dcache;
return dcache;
***************
*** 481,493 ****
}
else
{
- memxferfunc xfunc;
- xfunc = should_write ? dcache->write_memory : dcache->read_memory;
-
if (dcache->cache_has_stuff)
! dcache_invd (dcache);
! len = xfunc (memaddr, myaddr, len);
}
return len;
}
--- 471,480 ----
}
else
{
if (dcache->cache_has_stuff)
! dcache_invalidate (dcache);
! len = do_xfer_memory(memaddr, myaddr, len, should_write);
}
return len;
}
Index: dcache.h
===================================================================
RCS file: /cvs/src/src/gdb/dcache.h,v
retrieving revision 1.5
diff -c -r1.5 dcache.h
*** dcache.h 2000/08/18 22:52:22 1.5
--- dcache.h 2000/10/02 21:04:18
***************
*** 23,44 ****
#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);
/* 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,
int should_write);
/* Turn dcache state on or off */
--- 23,42 ----
#ifndef DCACHE_H
#define DCACHE_H
typedef struct dcache_struct DCACHE;
/* Invalidate DCACHE. */
! void dcache_invalidate (DCACHE *dcache);
/* Initialize DCACHE. */
! 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 should_write);
/* Turn dcache state on or off */
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.12
diff -c -r1.12 monitor.c
*** monitor.c 2000/09/24 04:42:12 1.12
--- monitor.c 2000/10/02 21:04:26
***************
*** 51,57 ****
#include "gdbcmd.h"
#include "inferior.h"
#include "gdb_regex.h"
- #include "dcache.h"
#include "srec.h"
static char *dev_name;
--- 51,56 ----
***************
*** 130,136 ****
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? */
--- 129,134 ----
***************
*** 838,852 ****
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 ();
}
--- 836,841 ----
***************
*** 929,940 ****
/* 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)
{
--- 918,923 ----
***************
*** 948,954 ****
dump_reg_flag = 1;
return;
}
- dcache_invd (remote_dcache);
if (step)
monitor_printf (current_monitor->step);
else
--- 931,936 ----
***************
*** 2008,2014 ****
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);
}
static void
--- 1990,2010 ----
monitor_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct target_ops *target)
{
! 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,2151 ****
static void
monitor_load (char *file, int from_tty)
{
- dcache_invd (remote_dcache);
monitor_debug ("MON load\n");
if (current_monitor->load_routine)
--- 2141,2146 ----
Index: monitor.h
===================================================================
RCS file: /cvs/src/src/gdb/monitor.h,v
retrieving revision 1.4
diff -c -r1.4 monitor.h
*** monitor.h 2000/06/10 01:32:12 1.4
--- monitor.h 2000/10/02 21:04:27
***************
*** 246,249 ****
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);
--- 246,248 ----
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.9
diff -c -r1.9 ocd.c
*** ocd.c 2000/09/26 04:27:59 1.9
--- ocd.c 2000/10/02 21:04:30
***************
*** 31,37 ****
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
- #include "dcache.h"
#include <sys/types.h>
#include <signal.h>
#include "serial.h"
--- 31,36 ----
***************
*** 273,280 ****
/* 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)
--- 272,277 ----
***************
*** 292,302 ****
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");
--- 289,294 ----
***************
*** 387,394 ****
{
int pktlen;
- dcache_invd (ocd_dcache);
-
if (step)
ocd_do_command (OCD_STEP, &last_run_status, &pktlen);
else
--- 379,384 ----
***************
*** 772,778 ****
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);
}
void
--- 762,775 ----
ocd_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
struct target_ops *target)
{
! int res;
!
! if (should_write)
! res = ocd_write_bytes (memaddr, myaddr, len);
! else
! res = ocd_read_bytes (memaddr, myaddr, len);
!
! return res;
}
void
***************
*** 1315,1321 ****
error ("Not connected to OCD device.");
ocd_do_command (OCD_RESET, &status, &pktlen);
! dcache_invd (ocd_dcache);
registers_changed ();
}
--- 1312,1318 ----
error ("Not connected to OCD device.");
ocd_do_command (OCD_RESET, &status, &pktlen);
! dcache_invalidate (target_dcache);
registers_changed ();
}
Index: remote-bug.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-bug.c,v
retrieving revision 1.6
diff -c -r1.6 remote-bug.c
*** remote-bug.c 2000/08/18 22:52:22 1.6
--- remote-bug.c 2000/10/02 21:04:31
***************
*** 119,125 ****
sr_check_open ();
- dcache_invd (gr_get_dcache ());
inferior_pid = 0;
abfd = bfd_openr (args, 0);
if (!abfd)
--- 119,124 ----
***************
*** 198,209 ****
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 */
};
--- 197,205 ----
***************
*** 242,249 ****
void
bug_resume (int pid, int step, enum target_signal sig)
{
- dcache_invd (gr_get_dcache ());
-
if (step)
{
sr_write_cr ("t");
--- 238,243 ----
***************
*** 561,570 ****
int write;
struct target_ops *target; /* ignored */
{
if (len <= 0)
return 0;
! return dcache_xfer_memory (gr_get_dcache (), memaddr, myaddr, len, write);
}
static void
--- 555,571 ----
int write;
struct target_ops *target; /* ignored */
{
+ int res;
+
if (len <= 0)
return 0;
+
+ if (write)
+ res = bug_write_memory (memaddr, myaddr, len);
+ else
+ res = bug_read_memory (memaddr, myaddr, len);
! return res;
}
static void
Index: remote-nindy.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-nindy.c,v
retrieving revision 1.7
diff -c -r1.7 remote-nindy.c
*** remote-nindy.c 2000/08/18 22:52:23 1.7
--- remote-nindy.c 2000/10/02 21:04:32
***************
*** 115,126 ****
#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 ();
--- 115,122 ----
***************
*** 188,198 ****
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++;
--- 184,189 ----
***************
*** 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);
--- 260,265 ----
***************
*** 492,501 ****
int should_write;
struct target_ops *target; /* ignored */
{
if (len <= 0)
return 0;
! return dcache_xfer_memory (nindy_dcache, memaddr, myaddr,
! len, should_write);
}
static void
--- 482,498 ----
int should_write;
struct target_ops *target; /* ignored */
{
+ int res;
+
if (len <= 0)
return 0;
!
! if (should_write)
! res = ninMemPut (memaddr, myaddr, len);
! else
! res = ninMemGet (memaddr, myaddr, len);
!
! return res;
}
static void
***************
*** 614,621 ****
}
}
bfd_close (file);
-
- dcache_invd(nindy_dcache);
}
static int
--- 611,616 ----
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.7
diff -c -r1.7 remote-sds.c
*** remote-sds.c 2000/09/01 00:12:10 1.7
--- remote-sds.c 2000/10/02 21:04:34
***************
*** 37,43 ****
#include "gdb-stabs.h"
#include "gdbthread.h"
#include "gdbcore.h"
- #include "dcache.h"
#ifdef USG
#include <sys/types.h>
--- 37,42 ----
***************
*** 190,197 ****
/* 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)
{
--- 189,194 ----
***************
*** 203,213 ****
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);
--- 200,205 ----
***************
*** 358,365 ****
{
unsigned char buf[PBUFSIZ];
- dcache_invd (sds_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
--- 350,355 ----
***************
*** 673,679 ****
int should_write;
struct target_ops *target; /* ignored */
{
! return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
}
--- 663,676 ----
int should_write;
struct target_ops *target; /* ignored */
{
! int res;
!
! if (should_write)
! res = sds_write_bytes (memaddr, myaddr, len);
! else
! res = sds_read_bytes (memaddr, myaddr, len);
!
! return res;
}
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-utils.c,v
retrieving revision 1.7
diff -c -r1.7 remote-utils.c
*** remote-utils.c 2000/09/01 00:12:10 1.7
--- remote-utils.c 2000/10/02 21:04:34
***************
*** 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_invd (dcache);
if (sr_get_desc () != NULL)
gr_close (0);
--- 154,164 ----
Index: remote-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/remote-utils.h,v
retrieving revision 1.4
diff -c -r1.4 remote-utils.h
*** remote-utils.h 2000/06/19 18:59:07 1.4
--- remote-utils.h 2000/10/02 21:04:35
***************
*** 24,30 ****
#include "serial.h"
#include "target.h"
- #include "dcache.h"
/* Stuff that should be shared (and handled consistently) among the various
remote targets. */
--- 24,29 ----
***************
*** 73,93 ****
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)
--- 72,84 ----
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.23
diff -c -r1.23 remote.c
*** remote.c 2000/09/01 00:12:10 1.23
--- remote.c 2000/10/02 21:04:41
***************
*** 37,44 ****
#include "gdbthread.h"
#include "remote.h"
- #include "dcache.h"
-
#include <ctype.h>
#include <sys/time.h>
#ifdef USG
--- 37,42 ----
***************
*** 2027,2034 ****
/* Generic code for opening a connection to a remote target. */
- static DCACHE *remote_dcache;
-
static void
init_all_packet_configs (void)
{
--- 2025,2030 ----
***************
*** 2057,2067 ****
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);
--- 2053,2058 ----
***************
*** 2140,2147 ****
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);
--- 2131,2136 ----
***************
*** 2309,2316 ****
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
--- 2298,2303 ----
***************
*** 2343,2350 ****
else
set_thread (pid, 0); /* run this thread */
- dcache_invd (remote_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
--- 2330,2335 ----
***************
*** 3559,3570 ****
{
CORE_ADDR targ_addr;
int targ_len;
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);
}
--- 3544,3561 ----
{
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;
+
+ if (should_write)
+ res = remote_write_bytes (targ_addr, buffer, targ_len);
+ else
+ res = remote_read_bytes (targ_addr, buffer, targ_len);
! return res;
}
***************
*** 5049,5059 ****
target_preopen (from_tty);
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)
--- 5040,5045 ----
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.11
diff -c -r1.11 target.c
*** target.c 2000/09/28 07:48:14 1.11
--- target.c 2000/10/02 21:04:44
***************
*** 31,36 ****
--- 31,37 ----
#include "symfile.h"
#include "objfiles.h"
#include "gdb_wait.h"
+ #include "dcache.h"
#include <signal.h>
extern int errno;
***************
*** 177,182 ****
--- 178,185 ----
static void setup_target_debug (void);
+ DCACHE *target_dcache;
+
/* The user just typed 'target' without the name of a target. */
/* ARGSUSED */
***************
*** 229,234 ****
--- 232,238 ----
void
target_load (char *arg, int from_tty)
{
+ dcache_invalidate (target_dcache);
(*current_target.to_load) (arg, from_tty);
}
***************
*** 843,853 ****
Result is 0 or errno value. */
! static int
! target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{
- int curlen;
int res;
struct target_ops *t;
struct target_stack_item *item;
--- 847,857 ----
Result is 0 or errno value. */
! int
! do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{
int res;
+ int done = 0;
struct target_ops *t;
struct target_stack_item *item;
***************
*** 863,884 ****
res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, ¤t_target);
if (res == len)
! return 0;
if (res > 0)
goto bump;
/* If res <= 0 then we call it again in the loop. Ah well. */
! for (; 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);
if (res > 0)
break; /* Handled all or part of xfer */
if (t->to_has_all_memory)
--- 867,887 ----
res = current_target.to_xfer_memory
(memaddr, myaddr, len, write, ¤t_target);
if (res == len)
! return len;
if (res > 0)
goto bump;
/* If res <= 0 then we call it again in the loop. Ah well. */
! while (len > 0)
{
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, len, write, t);
if (res > 0)
break; /* Handled all or part of xfer */
if (t->to_has_all_memory)
***************
*** 887,892 ****
--- 890,923 ----
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,906 ****
else
return errno;
}
! bump:
memaddr += res;
! myaddr += res;
! len -= res;
}
return 0; /* We managed to cover it all somehow. */
}
--- 927,938 ----
else
return errno;
}
!
memaddr += res;
! myaddr += res;
! len -= res;
}
+
return 0; /* We managed to cover it all somehow. */
}
***************
*** 908,914 ****
/* Perform a partial memory transfer. */
static int
! target_xfer_memory_partial (CORE_ADDR memaddr, char *buf, int len,
int write_p, int *err)
{
int res;
--- 940,946 ----
/* Perform a partial memory transfer. */
static int
! target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
int write_p, int *err)
{
int res;
***************
*** 924,965 ****
return 0;
}
! /* The quick case is that the top target does it all. */
! res = current_target.to_xfer_memory (memaddr, buf, len, write_p, ¤t_target);
! if (res > 0)
{
! *err = 0;
! return res;
! }
!
! /* xfer memory doesn't always reliably set errno. */
! errno = 0;
! /* 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;
}
! /* Total failure. Return error. */
! if (errno != 0)
! {
! *err = errno;
! return -1;
! }
! *err = EIO;
! return -1;
}
int
--- 956,974 ----
return 0;
}
! res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
! if (res <= 0)
{
! if (errno != 0)
! *err = errno;
! else
! *err = EIO;
! return -1;
}
! *err = 0;
! return 0;
}
int
***************
*** 2916,2921 ****
--- 2925,2932 ----
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 ();
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.7
diff -c -r1.7 target.h
*** target.h 2000/09/02 00:12:17 1.7
--- target.h 2000/10/02 21:04:46
***************
*** 43,48 ****
--- 43,49 ----
#include "bfd.h"
#include "symtab.h"
+ #include "dcache.h"
enum strata
{
***************
*** 487,494 ****
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)
/* 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
--- 488,498 ----
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) \
! 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,567 ****
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)
/* 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;
--- 564,574 ----
the target, or TARGET_SIGNAL_0 for no signal. The caller may not
pass TARGET_SIGNAL_DEFAULT. */
! #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,618 ****
#define target_prepare_to_store() \
(*current_target.to_prepare_to_store) ()
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 xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
--- 615,629 ----
#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 memaddr, char *myaddr, int len);
extern int xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.9
diff -c -r1.9 wince.c
*** wince.c 2000/08/18 22:52:23 1.9
--- wince.c 2000/10/02 21:04:47
***************
*** 54,60 ****
#include "gdbcmd.h"
#include <sys/param.h>
#include "wince-stub.h"
- #include "dcache.h"
#include <time.h>
/* The ui's event loop. */
--- 54,59 ----
***************
*** 89,96 ****
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";
--- 88,93 ----
***************
*** 1729,1738 ****
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);
--- 1726,1731 ----
***************
*** 1798,1804 ****
{
if (len <= 0)
return 0;
! return dcache_xfer_memory (remote_dcache, memaddr, our, len, write);
}
/* Terminate the process and wait for child to tell us it has completed. */
--- 1791,1803 ----
{
if (len <= 0)
return 0;
!
! 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. */
***************
*** 1841,1848 ****
CHECK (set_thread_context (th->h, &th->context));
th->context.ContextFlags = 0;
}
-
- dcache_invd (remote_dcache);
/* Allow continuing with the same signal that interrupted us.
Otherwise complain. */
--- 1840,1845 ----
--
J.T. Conklin
RedBack Networks