This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Cleanup target memory reading
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 28 Jun 2006 11:55:57 +0400
- Subject: [PATCH] Cleanup target memory reading
Hi,
at the moment, pretty much every read of target memory goes via
target_read_memory, and then via xfer_using_stratum.
The only exception is the get_target_memory_unsigned function, which calls
target_read function. It's the only use of 'target_read'.
The attached patch removes target_read, and makes get_target_memory_unsigned
use target_read_memory.
OK?
- Volodya
2006-06-28 Vladimir Prus <vladimir@codesourcery.com>
* target.h (target_read): Remove
(get_target_memory): Remove.
* target.c (target_read): Remove
(get_target_memory): Remove.
(get_target_memory_unsigned): Use target_read_memory.
=== target.c
==================================================================
--- target.c (revision 16)
+++ target.c (revision 18)
@@ -1359,30 +1359,7 @@
return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
}
-/* Wrappers to perform the full transfer. */
LONGEST
-target_read (struct target_ops *ops,
- enum target_object object,
- const char *annex, gdb_byte *buf,
- ULONGEST offset, LONGEST len)
-{
- LONGEST xfered = 0;
- while (xfered < len)
- {
- LONGEST xfer = target_read_partial (ops, object, annex,
- (gdb_byte *) buf + xfered,
- offset + xfered, len - xfered);
- /* Call an observer, notifying them of the xfer progress? */
- if (xfer <= 0)
- /* Call memory_error? */
- return -1;
- xfered += xfer;
- QUIT;
- }
- return len;
-}
-
-LONGEST
target_write (struct target_ops *ops,
enum target_object object,
const char *annex, const gdb_byte *buf,
@@ -1404,25 +1381,13 @@
return len;
}
-/* Memory transfer methods. */
-
-void
-get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
- LONGEST len)
-{
- if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len)
- != len)
- memory_error (EIO, addr);
-}
-
ULONGEST
-get_target_memory_unsigned (struct target_ops *ops,
- CORE_ADDR addr, int len)
+get_target_memory_unsigned (CORE_ADDR addr, int len)
{
gdb_byte buf[sizeof (ULONGEST)];
gdb_assert (len <= sizeof (buf));
- get_target_memory (ops, addr, buf, len);
+ target_read_memory (addr, buf, len);
return extract_unsigned_integer (buf, len);
}
=== target.h
==================================================================
--- target.h (revision 16)
+++ target.h (revision 18)
@@ -247,27 +247,19 @@
ULONGEST offset, LONGEST len);
/* Wrappers to perform the full transfer. */
-extern LONGEST target_read (struct target_ops *ops,
- enum target_object object,
- const char *annex, gdb_byte *buf,
- ULONGEST offset, LONGEST len);
extern LONGEST target_write (struct target_ops *ops,
enum target_object object,
const char *annex, const gdb_byte *buf,
ULONGEST offset, LONGEST len);
-/* Wrappers to target read/write that perform memory transfers. They
- throw an error if the memory transfer fails.
+/* Read an unsigned value of LEN bytes from ADDR.
+ Endianess differences between host and target are handled automatically.
- NOTE: cagney/2003-10-23: The naming schema is lifted from
- "frame.h". The parameter order is lifted from get_frame_memory,
- which in turn lifted it from read_memory. */
+ Throws an error is unsuccessfull.
-extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
- gdb_byte *buf, LONGEST len);
-extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
- CORE_ADDR addr, int len);
+*/
+extern ULONGEST get_target_memory_unsigned (CORE_ADDR addr, int len);
/* If certain kinds of activity happen, target_wait should perform