Commit b371dc594b75d739aa5b6bcf48423b401265dc68
1 parent
2ee4aed8
memsave monitor command
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2288 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
32 additions
and
0 deletions
monitor.c
... | ... | @@ -642,6 +642,36 @@ static void do_print(int count, int format, int size, unsigned int valh, unsigne |
642 | 642 | term_printf("\n"); |
643 | 643 | } |
644 | 644 | |
645 | +static void do_memory_save(unsigned int valh, unsigned int vall, | |
646 | + uint32_t size, const char *filename) | |
647 | +{ | |
648 | + FILE *f; | |
649 | + target_long addr = GET_TLONG(valh, vall); | |
650 | + uint32_t l; | |
651 | + CPUState *env; | |
652 | + uint8_t buf[1024]; | |
653 | + | |
654 | + env = mon_get_cpu(); | |
655 | + if (!env) | |
656 | + return; | |
657 | + | |
658 | + f = fopen(filename, "wb"); | |
659 | + if (!f) { | |
660 | + term_printf("could not open '%s'\n", filename); | |
661 | + return; | |
662 | + } | |
663 | + while (size != 0) { | |
664 | + l = sizeof(buf); | |
665 | + if (l > size) | |
666 | + l = size; | |
667 | + cpu_memory_rw_debug(env, addr, buf, l, 0); | |
668 | + fwrite(buf, 1, l, f); | |
669 | + addr += l; | |
670 | + size -= l; | |
671 | + } | |
672 | + fclose(f); | |
673 | +} | |
674 | + | |
645 | 675 | static void do_sum(uint32_t start, uint32_t size) |
646 | 676 | { |
647 | 677 | uint32_t addr; |
... | ... | @@ -1218,6 +1248,8 @@ static term_cmd_t term_cmds[] = { |
1218 | 1248 | #endif |
1219 | 1249 | { "stopcapture", "i", do_stop_capture, |
1220 | 1250 | "capture index", "stop capture" }, |
1251 | + { "memsave", "lis", do_memory_save, | |
1252 | + "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, | |
1221 | 1253 | { NULL, NULL, }, |
1222 | 1254 | }; |
1223 | 1255 | ... | ... |