/* Select target systems and architectures at runtime for GDB.
- Copyright 1990, 1992-1995, 1998-2000 Free Software Foundation, Inc.
+ Copyright 1990, 1992-1995, 1998-2000, 2001 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB.
static void debug_to_prepare_to_store (void);
static int
-debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
+debug_to_xfer_memory (CORE_ADDR, char *, int, int, struct mem_attrib *,
+ struct target_ops *);
static void debug_to_files_info (struct target_ops *);
(void (*) (void))
noprocess);
de_fault (to_xfer_memory,
- (int (*) (CORE_ADDR, char *, int, int, struct target_ops *))
+ (int (*) (CORE_ADDR, char *, int, int, struct mem_attrib *, struct target_ops *))
nomemory);
de_fault (to_files_info,
(void (*) (struct target_ops *))
else
target_stack = cur->next; /* Unchain first on list */
tmp = cur->next;
- free (cur);
+ xfree (cur);
cur = tmp;
}
else
prev->next = cur->next;
- free (cur); /* Release the target_stack_item */
+ xfree (cur); /* Release the target_stack_item */
update_current_target ();
cleanup_target (¤t_target);
Result is -1 on error, or the number of bytes transfered. */
int
-do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib)
{
int res;
int done = 0;
/* The quick case is that the top target can handle the transfer. */
res = current_target.to_xfer_memory
- (memaddr, myaddr, len, write, ¤t_target);
+ (memaddr, myaddr, len, write, attrib, ¤t_target);
/* If res <= 0 then we call it again in the loop. Ah well. */
if (res <= 0)
if (!t->to_has_memory)
continue;
- res = t->to_xfer_memory (memaddr, myaddr, len, write, t);
+ res = t->to_xfer_memory (memaddr, myaddr, len, write, attrib, t);
if (res > 0)
break; /* Handled all or part of xfer */
if (t->to_has_all_memory)
target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
{
int res;
+ int reg_len;
+ struct mem_region *region;
/* Zero length requests are ok and require no work. */
if (len == 0)
while (len > 0)
{
- res = dcache_xfer_memory(target_dcache, memaddr, myaddr, len, write);
- if (res <= 0)
+ region = lookup_mem_region(memaddr);
+ if (memaddr + len < region->hi)
+ reg_len = len;
+ else
+ reg_len = region->hi - memaddr;
+
+ switch (region->attrib.mode)
{
- /* If this address is for nonexistent memory,
- read zeros if reading, or do nothing if writing. Return error. */
+ case MEM_RO:
+ if (write)
+ return EIO;
+ break;
+
+ case MEM_WO:
if (!write)
- memset (myaddr, 0, len);
- if (errno == 0)
return EIO;
- else
- return errno;
+ break;
}
- memaddr += res;
- myaddr += res;
- len -= res;
+ while (reg_len > 0)
+ {
+ if (region->attrib.cache)
+ res = dcache_xfer_memory(target_dcache, memaddr, myaddr,
+ reg_len, write);
+ else
+ res = do_xfer_memory(memaddr, myaddr, reg_len, write,
+ ®ion->attrib);
+
+ if (res <= 0)
+ {
+ /* If this address is for nonexistent memory, read zeros
+ if reading, or do nothing if writing. Return
+ error. */
+ if (!write)
+ memset (myaddr, 0, len);
+ if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ memaddr += res;
+ myaddr += res;
+ len -= res;
+ reg_len -= res;
+ }
}
return 0; /* We managed to cover it all somehow. */
int write_p, int *err)
{
int res;
+ int reg_len;
+ struct mem_region *region;
/* Zero length requests are ok and require no work. */
if (len == 0)
return 0;
}
- res = dcache_xfer_memory (target_dcache, memaddr, myaddr, len, write_p);
+ region = lookup_mem_region(memaddr);
+ if (memaddr + len < region->hi)
+ reg_len = len;
+ else
+ reg_len = region->hi - memaddr;
+
+ switch (region->attrib.mode)
+ {
+ case MEM_RO:
+ if (write_p)
+ {
+ *err = EIO;
+ return 0;
+ }
+ break;
+
+ case MEM_WO:
+ if (write_p)
+ {
+ *err = EIO;
+ return 0;
+ }
+ break;
+ }
+
+ if (region->attrib.cache)
+ res = dcache_xfer_memory (target_dcache, memaddr, myaddr,
+ reg_len, write_p);
+ else
+ res = do_xfer_memory (memaddr, myaddr, reg_len, write_p,
+ ®ion->attrib);
+
if (res <= 0)
{
if (errno != 0)
{"SIG63", "Real-time event 63"},
{"SIGCANCEL", "LWP internal signal"},
{"SIG32", "Real-time event 32"},
+ {"SIG64", "Real-time event 64"},
#if defined(MACH) || defined(__MACH__)
/* Mach exceptions */
if (33 <= hostsig && hostsig <= 63)
return (enum target_signal)
(hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+ else if (hostsig == 64)
+ return TARGET_SIGNAL_REALTIME_64;
else
error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
}
if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
return retsig;
}
+ else if (oursig == TARGET_SIGNAL_REALTIME_64)
+ return 64;
#endif
*oursig_ok = 0;
return 0;
static int
debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib,
struct target_ops *target)
{
int retval;
- retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
+ retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write,
+ attrib, target);
fprintf_unfiltered (gdb_stdlog,
"target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",