diff options
author | Andrew Cagney <cagney@redhat.com> | 2004-10-01 16:12:26 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2004-10-01 16:12:26 +0000 |
commit | 213d5768630333fb2bfac19c5dbccd9d0bd43207 (patch) | |
tree | 0bac22e3d463fdbe0be38baf002ebf5c3b1cd474 /gdb/inf-ptrace.c | |
parent | 865945d457204f84636200201b59dc34a26a8597 (diff) | |
download | gdb-213d5768630333fb2bfac19c5dbccd9d0bd43207.tar.gz |
2004-10-01 Andrew Cagney <cagney@gnu.org>
* target.c (xfer_using_stratum): Change return type to LONGEST.
On each iteration offset, readbuf and writebuf.
* inf-ptrace.c (inf_ptrace_xfer_partial): Simplify computation of
partial_length, and read/modify/write predicate, update comments.
Pass buffer.word to ptrace write.
Diffstat (limited to 'gdb/inf-ptrace.c')
-rw-r--r-- | gdb/inf-ptrace.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 4a37d394d63..0aa6fd17c81 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -514,25 +514,27 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object, ULONGEST rounded_offset; LONGEST partial_len; - /* Round the start address down to the next long word boundary. */ + /* Round the start offset down to the next long word + boundary. */ rounded_offset = offset & -(ULONGEST) sizeof (PTRACE_TYPE_RET); - /* Truncate the length so that at max a single word will be - transfered. Remember, this function is required to perform - only a partial read so no more than one word should be - transfered). */ - if (rounded_offset + sizeof (PTRACE_TYPE_RET) < offset + len) - partial_len = sizeof (PTRACE_TYPE_RET) - (offset - rounded_offset); - else + /* Since ptrace will transfer a single word starting at that + rounded_offset the partial_len needs to be adjusted down to + that (remember this function only does a single transfer). + Should the required length be even less, adjust it down + again. */ + partial_len = (rounded_offset + sizeof (PTRACE_TYPE_RET)) - offset; + if (partial_len > len) partial_len = len; if (writebuf) { - /* Fill start and end extra bytes of buffer with existing - memory data. */ + /* If OFFSET:PARTIAL_LEN is smaller than + ROUNDED_OFFSET:WORDSIZE then a read/modify write will + be needed. Read in the entire word. */ if (rounded_offset < offset - || (partial_len + (offset - rounded_offset) - < sizeof (PTRACE_TYPE_RET))) + || (offset + partial_len + < rounded_offset + sizeof (PTRACE_TYPE_RET))) /* Need part of initial word -- fetch it. */ buffer.word = ptrace (PT_READ_I, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) (long) rounded_offset, @@ -545,7 +547,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object, errno = 0; ptrace (PT_WRITE_D, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) (long) rounded_offset, - (int) buffer.byte); + buffer.word); if (errno) { /* Using the appropriate one (I or D) is necessary for @@ -553,7 +555,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object, errno = 0; ptrace (PT_WRITE_I, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) (long) rounded_offset, - (int) buffer.byte); + buffer.word); if (errno) return 0; } |