From: Vladimir Prus <ghost@cs.msu.su>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Cleanup target memory reading
Date: Wed, 28 Jun 2006 07:56:00 -0000 [thread overview]
Message-ID: <200606281155.59166.ghost@cs.msu.su> (raw)
[-- Attachment #1: Type: text/plain, Size: 672 bytes --]
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.
[-- Attachment #2: target_read.diff --]
[-- Type: text/x-diff, Size: 3065 bytes --]
=== 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);
\f
/* If certain kinds of activity happen, target_wait should perform
next reply other threads:[~2006-06-28 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-28 7:56 Vladimir Prus [this message]
2006-06-28 21:30 ` Mark Kettenis
2006-06-29 2:42 ` Daniel Jacobowitz
2006-06-29 9:34 ` Vladimir Prus
2006-07-12 19:22 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200606281155.59166.ghost@cs.msu.su \
--to=ghost@cs.msu.su \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox