diff options
author | Michael Snyder <msnyder@vmware.com> | 2009-08-07 03:19:11 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2009-08-07 03:19:11 +0000 |
commit | 3cb01d40d2c894fc3795f0030ed2cc2010212f62 (patch) | |
tree | d02e322a53495eb3566b0995a4d917ae2c649e85 | |
parent | 5cf3c7d245ad3c2c99d4adcad2e64b7befb93730 (diff) | |
download | binutils-gdb-msnyder-checkpoint-072509-branch.tar.gz |
2009-08-06 Michael Snyder <msnyder@vmware.com>msnyder-checkpoint-072509-branch
* record.c (bfdcore_write): New function, abstracted out
from cmd_record_dump.
(cmd_record_dump): Call bfdcore_write.
(cmd_record_load): Fix setting of record_insn_num.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/record.c | 54 |
2 files changed, 28 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 366afbec431..90d751845a0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2009-08-06 Michael Snyder <msnyder@vmware.com> + * record.c (bfdcore_write): New function, abstracted out + from cmd_record_dump. + (cmd_record_dump): Call bfdcore_write. + (cmd_record_load): Fix setting of record_insn_num. + +2009-08-06 Michael Snyder <msnyder@vmware.com> + * record.c (record_list_release): Finish releasing record list. (cmd_record_load): No longer necessary to null out record list pointers: record_list_release does it. diff --git a/gdb/record.c b/gdb/record.c index 55bbe63f34a..e51fb54e4c3 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -1246,6 +1246,16 @@ cmd_record_fd_cleanups (void *recfdp) #include "elf-bfd.h" +static int +bfdcore_write (bfd *obfd, asection *osec, void *buf, int len, int *offset) +{ + int ret = bfd_set_section_contents (obfd, osec, buf, *offset, len); + + if (ret) + *offset += len; + return ret; +} + static void cmd_record_dump (char *args, int from_tty) { @@ -1338,10 +1348,7 @@ cmd_record_dump (char *args, int from_tty) fprintf_unfiltered (gdb_stdlog, _("\ Writing 4-byte magic cookie RECORD_FILE_MAGIC (0x%08x)\n"), magic); - if (bfd_set_section_contents (obfd, osec, &magic, - bfd_offset, sizeof (magic))) - bfd_offset += sizeof (magic); - else + if (!bfdcore_write (obfd, osec, &magic, sizeof (magic), &bfd_offset)) error (_("Failed to write 'magic' to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); @@ -1352,10 +1359,7 @@ cmd_record_dump (char *args, int from_tty) uint64_t tmpu64; tmpu8 = p->type; - if (bfd_set_section_contents (obfd, osec, &tmpu8, - bfd_offset, sizeof (tmpu8))) - bfd_offset += sizeof (tmpu8); - else + if (!bfdcore_write (obfd, osec, &tmpu8, sizeof (tmpu8), &bfd_offset)) error (_("Failed to write 'type' to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); @@ -1373,20 +1377,14 @@ cmd_record_dump (char *args, int from_tty) *(ULONGEST *) p->u.reg.val, MAX_REGISTER_SIZE); /* FIXME: register num does not need 8 bytes. */ - if (bfd_set_section_contents (obfd, osec, &tmpu64, - bfd_offset, sizeof (tmpu64))) - bfd_offset += sizeof (tmpu64); - else + if (!bfdcore_write (obfd, osec, &tmpu64, + sizeof (tmpu64), &bfd_offset)) error (_("Failed to write regnum to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); /* FIXME: add a len field, and write the smaller value. */ - if (bfd_set_section_contents (obfd, osec, - p->u.reg.val, - bfd_offset, - MAX_REGISTER_SIZE)) - bfd_offset += MAX_REGISTER_SIZE; - else + if (!bfdcore_write (obfd, osec, p->u.reg.val, + MAX_REGISTER_SIZE, &bfd_offset)) error (_("Failed to write regval to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); break; @@ -1400,10 +1398,7 @@ cmd_record_dump (char *args, int from_tty) Writing memory 0x%08x (1 plus 8 plus 8 bytes plus %d bytes)\n"), (unsigned int) p->u.mem.addr, p->u.mem.len); - if (bfd_set_section_contents (obfd, osec, &tmpu64, - bfd_offset, sizeof (tmpu64))) - bfd_offset += sizeof (tmpu64); - else + if (!bfdcore_write (obfd, osec, &tmpu64, sizeof (tmpu64), &bfd_offset)) error (_("Failed to write memaddr to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); @@ -1412,19 +1407,12 @@ cmd_record_dump (char *args, int from_tty) tmpu64 = bswap_64 (tmpu64); /* FIXME: len does not need 8 bytes. */ - if (bfd_set_section_contents (obfd, osec, &tmpu64, - bfd_offset, sizeof (tmpu64))) - bfd_offset += sizeof (tmpu64); - else + if (!bfdcore_write (obfd, osec, &tmpu64, sizeof (tmpu64), &bfd_offset)) error (_("Failed to write memlen to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); - if (bfd_set_section_contents (obfd, osec, - p->u.mem.val, - bfd_offset, - p->u.mem.len)) - bfd_offset += p->u.mem.len; - else + if (!bfdcore_write (obfd, osec, p->u.mem.val, + p->u.mem.len, &bfd_offset)) error (_("Failed to write memval to %s (%s)"), recfilename, bfd_errmsg (bfd_get_error ())); break; @@ -1648,7 +1636,7 @@ cmd_record_load (char *args, int from_tty) record_arch_list_head->prev = rec; /* Update record_insn_num and record_insn_max_num. */ - record_insn_num += insn_number; + record_insn_num = insn_number; if (record_insn_num > record_insn_max_num) { record_insn_max_num = record_insn_num; |