memzap

replay memory writes
git clone git://git.2f30.org/memzap
Log | Files | Refs | README | LICENSE

commit c9552cead65bebac9467eb348ac95ba573624edf
parent 06aef97ceacf6506da8fc66e51735ad09cc88556
Author: sin <sin@2f30.org>
Date:   Sun,  3 Mar 2013 15:56:43 +0000

memzap: Write out a test.mdiff

Diffstat:
Mmemzap.c | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/memzap.c b/memzap.c @@ -10,11 +10,13 @@ main(int argc, char *argv[]) struct mem_region *mr_old, *mr_new; struct mem_tree *mt_old; struct mem_region_diff *rdiff; + struct mdiff_hdr hdr; int stat; pid_t pid; unsigned char *buf, *buf_new; char *addr; size_t len; + int fd; if (argc != 4) { fprintf(stderr, "usage: %s <program> <address> <len>\n", *argv); @@ -61,6 +63,11 @@ main(int argc, char *argv[]) if (!WIFSTOPPED(stat)) goto out_mmap; + fd = create_mdiff("test.mdiff"); + memset(&hdr, 0, sizeof(hdr)); + strncpy(hdr.magic, "MDIFF", 5); + hdr.blksize = BLKSIZE; + mdiff_start_diff(fd); do { readmem(pid, buf, addr, len); @@ -76,7 +83,7 @@ main(int argc, char *argv[]) if (!WIFSTOPPED(stat)) { free_mem_region(mr_old); free_mem_tree(mt_old); - goto out_mmap; + break; } readmem(pid, buf_new, addr, len); @@ -87,7 +94,8 @@ main(int argc, char *argv[]) rdiff = diff_mem_region(mt_old, mr_new); if (rdiff->nmrdiffs) { apply_diff(mr_old, rdiff); - dump_mem_region_diff(rdiff); + mdiff_append_rdiff(fd, rdiff); + hdr.nregions++; } free_mem_region(mr_old); @@ -96,6 +104,8 @@ main(int argc, char *argv[]) free_mem_region_diff(rdiff); } while(1); + mdiff_insert_hdr(fd, &hdr); + close_mdiff(fd); out_mmap: unmap_buf(buf, len); unmap_buf(buf_new, len);