diff options
author | Andrew Cagney <cagney@redhat.com> | 2004-09-30 20:36:27 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2004-09-30 20:36:27 +0000 |
commit | 2739459855afeaf557aea2a585813b571da935c9 (patch) | |
tree | 215e174c8333156944caf00dbf6348c739730967 /gdb/target.c | |
parent | 74a4fe3270886cdd47a0e50c2426426a78e357df (diff) | |
download | gdb-2739459855afeaf557aea2a585813b571da935c9.zip gdb-2739459855afeaf557aea2a585813b571da935c9.tar.gz gdb-2739459855afeaf557aea2a585813b571da935c9.tar.bz2 |
2004-09-30 Andrew Cagney <cagney@gnu.org>
* target.c (target_xfer_partial): New function.
(target_read_memory_partial, target_write_memory_partial)
(default_xfer_partial, target_read_partial, target_write_partial)
(xfer_using_stratum): Use.
(debug_to_xfer_partial): Delete function.
(setup_target_debug): Do not override to_xfer_partial.
Diffstat (limited to 'gdb/target.c')
-rw-r--r-- | gdb/target.c | 97 |
1 files changed, 63 insertions, 34 deletions
diff --git a/gdb/target.c b/gdb/target.c index 9770b9a..81784da 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -849,6 +849,59 @@ target_xfer_partial_p (void) && target_stack->to_xfer_partial != default_xfer_partial); } +static LONGEST +target_xfer_partial (struct target_ops *ops, + enum target_object object, const char *annex, + void *readbuf, const void *writebuf, + ULONGEST offset, LONGEST len) +{ + LONGEST retval; + + gdb_assert (ops->to_xfer_partial != NULL); + retval = ops->to_xfer_partial (ops, object, annex, readbuf, writebuf, + offset, len); + if (targetdebug) + { + const unsigned char *myaddr = NULL; + + fprintf_unfiltered (gdb_stdlog, + "%s:target_xfer_partial (%d, %s, 0x%lx, 0x%lx, 0x%s, %s) = %s", + ops->to_shortname, + (int) object, + (annex ? annex : "(null)"), + (long) readbuf, (long) writebuf, + paddr_nz (offset), paddr_d (len), paddr_d (retval)); + + if (readbuf) + myaddr = readbuf; + if (writebuf) + myaddr = writebuf; + if (retval > 0 && myaddr != NULL) + { + int i; + + fputs_unfiltered (", bytes =", gdb_stdlog); + for (i = 0; i < retval; i++) + { + if ((((long) &(myaddr[i])) & 0xf) == 0) + { + if (targetdebug < 2 && i > 0) + { + fprintf_unfiltered (gdb_stdlog, " ..."); + break; + } + fprintf_unfiltered (gdb_stdlog, "\n"); + } + + fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff); + } + } + + fputc_unfiltered ('\n', gdb_stdlog); + } + return retval; +} + /* Attempt a transfer all LEN bytes starting at OFFSET between the inferior's KIND:ANNEX space and GDB's READBUF/WRITEBUF buffer. If the transfer succeeds, return zero, otherwize the host ERRNO is @@ -892,8 +945,8 @@ xfer_using_stratum (enum target_object object, const char *annex, target = target_stack; while (1) { - xfered = target->to_xfer_partial (target, object, annex, - readbuf, writebuf, memaddr, len); + xfered = target_xfer_partial (target, object, annex, + readbuf, writebuf, memaddr, len); if (xfered > 0) { /* The partial xfer succeeded, update the counts, check that @@ -1157,9 +1210,8 @@ int target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err) { if (target_xfer_partial_p ()) - return target_stack->to_xfer_partial (target_stack, - TARGET_OBJECT_MEMORY, NULL, - buf, NULL, memaddr, len); + return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL, + buf, NULL, memaddr, len); else return target_xfer_memory_partial (memaddr, buf, len, 0, err); } @@ -1168,9 +1220,8 @@ int target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err) { if (target_xfer_partial_p ()) - return target_stack->to_xfer_partial (target_stack, - TARGET_OBJECT_MEMORY, NULL, - NULL, buf, memaddr, len); + return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL, + NULL, buf, memaddr, len); else return target_xfer_memory_partial (memaddr, buf, len, 1, err); } @@ -1211,8 +1262,8 @@ default_xfer_partial (struct target_ops *ops, enum target_object object, return -1; } else if (ops->beneath != NULL) - return ops->beneath->to_xfer_partial (ops->beneath, object, annex, - readbuf, writebuf, offset, len); + return target_xfer_partial (ops->beneath, object, annex, + readbuf, writebuf, offset, len); else return -1; } @@ -1229,8 +1280,7 @@ target_read_partial (struct target_ops *ops, const char *annex, void *buf, ULONGEST offset, LONGEST len) { - gdb_assert (ops->to_xfer_partial != NULL); - return ops->to_xfer_partial (ops, object, annex, buf, NULL, offset, len); + return target_xfer_partial (ops, object, annex, buf, NULL, offset, len); } LONGEST @@ -1239,8 +1289,7 @@ target_write_partial (struct target_ops *ops, const char *annex, const void *buf, ULONGEST offset, LONGEST len) { - gdb_assert (ops->to_xfer_partial != NULL); - return ops->to_xfer_partial (ops, object, annex, NULL, buf, offset, len); + return target_xfer_partial (ops, object, annex, NULL, buf, offset, len); } /* Wrappers to perform the full transfer. */ @@ -2361,25 +2410,6 @@ debug_to_stop (void) fprintf_unfiltered (gdb_stdlog, "target_stop ()\n"); } -static LONGEST -debug_to_xfer_partial (struct target_ops *ops, enum target_object object, - const char *annex, void *readbuf, const void *writebuf, - ULONGEST offset, LONGEST len) -{ - LONGEST retval; - - retval = debug_target.to_xfer_partial (&debug_target, object, annex, - readbuf, writebuf, offset, len); - - fprintf_unfiltered (gdb_stdlog, - "target_xfer_partial (%d, %s, 0x%lx, 0x%lx, 0x%s, %s) = %s\n", - (int) object, (annex ? annex : "(null)"), - (long) readbuf, (long) writebuf, paddr_nz (offset), - paddr_d (len), paddr_d (retval)); - - return retval; -} - static void debug_to_rcmd (char *command, struct ui_file *outbuf) @@ -2476,7 +2506,6 @@ setup_target_debug (void) current_target.to_thread_alive = debug_to_thread_alive; current_target.to_find_new_threads = debug_to_find_new_threads; current_target.to_stop = debug_to_stop; - current_target.to_xfer_partial = debug_to_xfer_partial; current_target.to_rcmd = debug_to_rcmd; current_target.to_enable_exception_callback = debug_to_enable_exception_callback; current_target.to_get_current_exception_event = debug_to_get_current_exception_event; |