diff options
author | Daniel Jacobowitz <drow@false.org> | 2006-07-12 18:13:45 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2006-07-12 18:13:45 +0000 |
commit | 13547ab600a0929b12f354dc144f1aef37938f30 (patch) | |
tree | 76460826dbe9bbd235dd48cbc8a638b06193c9ec /gdb/avr-tdep.c | |
parent | edfb1a26487b8c8263b434dd07466733ea17ace9 (diff) | |
download | gdb-13547ab600a0929b12f354dc144f1aef37938f30.zip gdb-13547ab600a0929b12f354dc144f1aef37938f30.tar.gz gdb-13547ab600a0929b12f354dc144f1aef37938f30.tar.bz2 |
* target.c (target_read): Stop if target_read_partial returns 0
when some bytes have already been read.
(target_write): Likewise for target_write_partial.
(target_read_partial, target_write_partial): Make static.
(target_read_alloc): New.
* target.h: Doc fixes.
(target_read_partial, target_write_partial): Delete prototypes.
(target_read_alloc): New prototype.
* auxv.c (target_auxv_read): Delete.
(target_auxv_search, fprint_target_auxv): Use target_read_alloc.
* auxv.h (target_auxv_read): Delete prototype.
* avr-tdep.c (avr_io_reg_read_command): Use target_read_alloc.
* ia64-tdep.c (getunwind_table, get_kernel_table): Likewise.
* linux-nat.c (linux_nat_make_corefile_notes): Likewise.
* procfs.c (procfs_make_note_section): Likewise.
* remote.c (remote_xfer_partial): Don't loop here.
* sparc-tdep.c (sparc_fetch_wcookie): Use target_read.
Diffstat (limited to 'gdb/avr-tdep.c')
-rw-r--r-- | gdb/avr-tdep.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 9c6566e..f61e5a0 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1,7 +1,7 @@ /* Target-dependent code for Atmel AVR, for GDB. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005 Free Software Foundation, Inc. + 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -1323,35 +1323,22 @@ static void avr_io_reg_read_command (char *args, int from_tty) { LONGEST bufsiz = 0; - char buf[400]; + gdb_byte *buf; char query[400]; char *p; unsigned int nreg = 0; unsigned int val; int i, j, k, step; - /* Just get the maximum buffer size. */ - bufsiz = target_read_partial (¤t_target, TARGET_OBJECT_AVR, - NULL, NULL, 0, 0); - if (bufsiz < 0) - { - fprintf_unfiltered (gdb_stderr, - _("ERR: info io_registers NOT supported " - "by current target\n")); - return; - } - if (bufsiz > sizeof (buf)) - bufsiz = sizeof (buf); - /* Find out how many io registers the target has. */ - strcpy (query, "avr.io_reg"); - target_read_partial (¤t_target, TARGET_OBJECT_AVR, query, buf, 0, - bufsiz); + bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR, + "avr.io_reg", &buf); - if (strncmp (buf, "", bufsiz) == 0) + if (bufsiz <= 0) { fprintf_unfiltered (gdb_stderr, - _("info io_registers NOT supported by target\n")); + _("ERR: info io_registers NOT supported " + "by current target\n")); return; } @@ -1359,9 +1346,12 @@ avr_io_reg_read_command (char *args, int from_tty) { fprintf_unfiltered (gdb_stderr, _("Error fetching number of io registers\n")); + xfree (buf); return; } + xfree (buf); + reinitialize_more_filter (); printf_unfiltered (_("Target has %u io registers:\n\n"), nreg); @@ -1377,8 +1367,8 @@ avr_io_reg_read_command (char *args, int from_tty) j = nreg - i; /* last block is less than 8 registers */ snprintf (query, sizeof (query) - 1, "avr.io_reg:%x,%x", i, j); - target_read_partial (¤t_target, TARGET_OBJECT_AVR, query, buf, - 0, bufsiz); + bufsiz = target_read_alloc (¤t_target, TARGET_OBJECT_AVR, + query, &buf); p = buf; for (k = i; k < (i + j); k++) @@ -1393,6 +1383,8 @@ avr_io_reg_read_command (char *args, int from_tty) break; } } + + xfree (buf); } } |