GNU Binutils with patches for OS216
Revision | 3cb01d40d2c894fc3795f0030ed2cc2010212f62 (tree) |
---|---|
Zeit | 2009-08-07 12:19:11 |
Autor | Michael Snyder <msnyder@vmwa...> |
Commiter | Michael Snyder |
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.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2009-08-06 Michael Snyder <msnyder@vmware.com> |
2 | 2 | |
3 | + * record.c (bfdcore_write): New function, abstracted out | |
4 | + from cmd_record_dump. | |
5 | + (cmd_record_dump): Call bfdcore_write. | |
6 | + (cmd_record_load): Fix setting of record_insn_num. | |
7 | + | |
8 | +2009-08-06 Michael Snyder <msnyder@vmware.com> | |
9 | + | |
3 | 10 | * record.c (record_list_release): Finish releasing record list. |
4 | 11 | (cmd_record_load): No longer necessary to null out |
5 | 12 | record list pointers: record_list_release does it. |
@@ -1246,6 +1246,16 @@ cmd_record_fd_cleanups (void *recfdp) | ||
1246 | 1246 | |
1247 | 1247 | #include "elf-bfd.h" |
1248 | 1248 | |
1249 | +static int | |
1250 | +bfdcore_write (bfd *obfd, asection *osec, void *buf, int len, int *offset) | |
1251 | +{ | |
1252 | + int ret = bfd_set_section_contents (obfd, osec, buf, *offset, len); | |
1253 | + | |
1254 | + if (ret) | |
1255 | + *offset += len; | |
1256 | + return ret; | |
1257 | +} | |
1258 | + | |
1249 | 1259 | static void |
1250 | 1260 | cmd_record_dump (char *args, int from_tty) |
1251 | 1261 | { |
@@ -1338,10 +1348,7 @@ cmd_record_dump (char *args, int from_tty) | ||
1338 | 1348 | fprintf_unfiltered (gdb_stdlog, _("\ |
1339 | 1349 | Writing 4-byte magic cookie RECORD_FILE_MAGIC (0x%08x)\n"), |
1340 | 1350 | magic); |
1341 | - if (bfd_set_section_contents (obfd, osec, &magic, | |
1342 | - bfd_offset, sizeof (magic))) | |
1343 | - bfd_offset += sizeof (magic); | |
1344 | - else | |
1351 | + if (!bfdcore_write (obfd, osec, &magic, sizeof (magic), &bfd_offset)) | |
1345 | 1352 | error (_("Failed to write 'magic' to %s (%s)"), |
1346 | 1353 | recfilename, bfd_errmsg (bfd_get_error ())); |
1347 | 1354 |
@@ -1352,10 +1359,7 @@ cmd_record_dump (char *args, int from_tty) | ||
1352 | 1359 | uint64_t tmpu64; |
1353 | 1360 | |
1354 | 1361 | tmpu8 = p->type; |
1355 | - if (bfd_set_section_contents (obfd, osec, &tmpu8, | |
1356 | - bfd_offset, sizeof (tmpu8))) | |
1357 | - bfd_offset += sizeof (tmpu8); | |
1358 | - else | |
1362 | + if (!bfdcore_write (obfd, osec, &tmpu8, sizeof (tmpu8), &bfd_offset)) | |
1359 | 1363 | error (_("Failed to write 'type' to %s (%s)"), |
1360 | 1364 | recfilename, bfd_errmsg (bfd_get_error ())); |
1361 | 1365 |
@@ -1373,20 +1377,14 @@ cmd_record_dump (char *args, int from_tty) | ||
1373 | 1377 | *(ULONGEST *) p->u.reg.val, |
1374 | 1378 | MAX_REGISTER_SIZE); |
1375 | 1379 | /* FIXME: register num does not need 8 bytes. */ |
1376 | - if (bfd_set_section_contents (obfd, osec, &tmpu64, | |
1377 | - bfd_offset, sizeof (tmpu64))) | |
1378 | - bfd_offset += sizeof (tmpu64); | |
1379 | - else | |
1380 | + if (!bfdcore_write (obfd, osec, &tmpu64, | |
1381 | + sizeof (tmpu64), &bfd_offset)) | |
1380 | 1382 | error (_("Failed to write regnum to %s (%s)"), |
1381 | 1383 | recfilename, bfd_errmsg (bfd_get_error ())); |
1382 | 1384 | |
1383 | 1385 | /* FIXME: add a len field, and write the smaller value. */ |
1384 | - if (bfd_set_section_contents (obfd, osec, | |
1385 | - p->u.reg.val, | |
1386 | - bfd_offset, | |
1387 | - MAX_REGISTER_SIZE)) | |
1388 | - bfd_offset += MAX_REGISTER_SIZE; | |
1389 | - else | |
1386 | + if (!bfdcore_write (obfd, osec, p->u.reg.val, | |
1387 | + MAX_REGISTER_SIZE, &bfd_offset)) | |
1390 | 1388 | error (_("Failed to write regval to %s (%s)"), |
1391 | 1389 | recfilename, bfd_errmsg (bfd_get_error ())); |
1392 | 1390 | break; |
@@ -1400,10 +1398,7 @@ cmd_record_dump (char *args, int from_tty) | ||
1400 | 1398 | Writing memory 0x%08x (1 plus 8 plus 8 bytes plus %d bytes)\n"), |
1401 | 1399 | (unsigned int) p->u.mem.addr, |
1402 | 1400 | p->u.mem.len); |
1403 | - if (bfd_set_section_contents (obfd, osec, &tmpu64, | |
1404 | - bfd_offset, sizeof (tmpu64))) | |
1405 | - bfd_offset += sizeof (tmpu64); | |
1406 | - else | |
1401 | + if (!bfdcore_write (obfd, osec, &tmpu64, sizeof (tmpu64), &bfd_offset)) | |
1407 | 1402 | error (_("Failed to write memaddr to %s (%s)"), |
1408 | 1403 | recfilename, bfd_errmsg (bfd_get_error ())); |
1409 | 1404 |
@@ -1412,19 +1407,12 @@ cmd_record_dump (char *args, int from_tty) | ||
1412 | 1407 | tmpu64 = bswap_64 (tmpu64); |
1413 | 1408 | |
1414 | 1409 | /* FIXME: len does not need 8 bytes. */ |
1415 | - if (bfd_set_section_contents (obfd, osec, &tmpu64, | |
1416 | - bfd_offset, sizeof (tmpu64))) | |
1417 | - bfd_offset += sizeof (tmpu64); | |
1418 | - else | |
1410 | + if (!bfdcore_write (obfd, osec, &tmpu64, sizeof (tmpu64), &bfd_offset)) | |
1419 | 1411 | error (_("Failed to write memlen to %s (%s)"), |
1420 | 1412 | recfilename, bfd_errmsg (bfd_get_error ())); |
1421 | 1413 | |
1422 | - if (bfd_set_section_contents (obfd, osec, | |
1423 | - p->u.mem.val, | |
1424 | - bfd_offset, | |
1425 | - p->u.mem.len)) | |
1426 | - bfd_offset += p->u.mem.len; | |
1427 | - else | |
1414 | + if (!bfdcore_write (obfd, osec, p->u.mem.val, | |
1415 | + p->u.mem.len, &bfd_offset)) | |
1428 | 1416 | error (_("Failed to write memval to %s (%s)"), |
1429 | 1417 | recfilename, bfd_errmsg (bfd_get_error ())); |
1430 | 1418 | break; |
@@ -1648,7 +1636,7 @@ cmd_record_load (char *args, int from_tty) | ||
1648 | 1636 | record_arch_list_head->prev = rec; |
1649 | 1637 | |
1650 | 1638 | /* Update record_insn_num and record_insn_max_num. */ |
1651 | - record_insn_num += insn_number; | |
1639 | + record_insn_num = insn_number; | |
1652 | 1640 | if (record_insn_num > record_insn_max_num) |
1653 | 1641 | { |
1654 | 1642 | record_insn_max_num = record_insn_num; |