bounds. */
throw_error (MEMORY_ERROR,
_("Cannot access memory at address %s"),
- paddress (memaddr));
+ paddress (target_gdbarch, memaddr));
else
throw_error (MEMORY_ERROR,
_("Error accessing memory address %s: %s."),
- paddress (memaddr),
+ paddress (target_gdbarch, memaddr),
safe_strerror (status));
}
/* Same as target_read_memory, but report an error if can't read. */
+
void
read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
memory_error (status, memaddr);
}
+/* Same as target_read_stack, but report an error if can't read. */
+
+void
+read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
+{
+ int status;
+ status = target_read_stack (memaddr, myaddr, len);
+ if (status != 0)
+ memory_error (status, memaddr);
+}
+
/* Argument / return result struct for use with
do_captured_read_memory_integer(). MEMADDR and LEN are filled in
by gdb_read_memory_integer(). RESULT is the contents that were
{
CORE_ADDR memaddr;
int len;
+ enum bfd_endian byte_order;
LONGEST result;
};
struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
CORE_ADDR memaddr = args->memaddr;
int len = args->len;
+ enum bfd_endian byte_order = args->byte_order;
- args->result = read_memory_integer (memaddr, len);
+ args->result = read_memory_integer (memaddr, len, byte_order);
return 1;
}
if successful. */
int
-safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
+safe_read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order,
+ LONGEST *return_value)
{
int status;
struct captured_read_memory_integer_arguments args;
args.memaddr = memaddr;
args.len = len;
+ args.byte_order = byte_order;
status = catch_errors (do_captured_read_memory_integer, &args,
"", RETURN_MASK_ALL);
}
LONGEST
-read_memory_integer (CORE_ADDR memaddr, int len)
+read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (LONGEST)];
read_memory (memaddr, buf, len);
- return extract_signed_integer (buf, len);
+ return extract_signed_integer (buf, len, byte_order);
}
ULONGEST
-read_memory_unsigned_integer (CORE_ADDR memaddr, int len)
+read_memory_unsigned_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (ULONGEST)];
read_memory (memaddr, buf, len);
- return extract_unsigned_integer (buf, len);
+ return extract_unsigned_integer (buf, len, byte_order);
}
void
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
void
-write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
+write_memory_unsigned_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+ ULONGEST value)
{
gdb_byte *buf = alloca (len);
- store_unsigned_integer (buf, len, value);
+ store_unsigned_integer (buf, len, byte_order, value);
write_memory (addr, buf, len);
}
/* Store VALUE at ADDR in the inferior as a LEN-byte signed integer. */
void
-write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
+write_memory_signed_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+ LONGEST value)
{
gdb_byte *buf = alloca (len);
- store_signed_integer (buf, len, value);
+ store_signed_integer (buf, len, byte_order, value);
write_memory (addr, buf, len);
}
-
-\f
-
-#if 0
-/* Enable after 4.12. It is not tested. */
-
-/* Search code. Targets can just make this their search function, or
- if the protocol has a less general search function, they can call this
- in the cases it can't handle. */
-void
-generic_search (int len, char *data, char *mask, CORE_ADDR startaddr,
- int increment, CORE_ADDR lorange, CORE_ADDR hirange,
- CORE_ADDR *addr_found, char *data_found)
-{
- int i;
- CORE_ADDR curaddr = startaddr;
-
- while (curaddr >= lorange && curaddr < hirange)
- {
- read_memory (curaddr, data_found, len);
- for (i = 0; i < len; ++i)
- if ((data_found[i] & mask[i]) != data[i])
- goto try_again;
- /* It matches. */
- *addr_found = curaddr;
- return;
-
- try_again:
- curaddr += increment;
- }
- *addr_found = (CORE_ADDR) 0;
- return;
-}
-#endif /* 0 */
\f
/* The current default bfd target. Points to storage allocated for
gnutarget_string. */
{
if (gnutarget_string != NULL)
xfree (gnutarget_string);
- gnutarget_string = savestring (newtarget, strlen (newtarget));
+ gnutarget_string = xstrdup (newtarget);
set_gnutarget_command (NULL, 0, NULL);
}