kvm: Introduce kvm__dump_mem helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov
2015-06-01 16:39:39 +01:00
committed by Will Deacon
parent d1a26cf05d
commit 090f898eae
2 changed files with 20 additions and 0 deletions
+1
View File
@@ -44,6 +44,7 @@ bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction,
*/
void kvm__show_code(struct kvm *self);
void kvm__show_registers(struct kvm *self);
void kvm__dump_mem(struct kvm *self, unsigned long addr, unsigned long size);
extern const char *kvm_exit_reasons[];
+19
View File
@@ -535,3 +535,22 @@ void kvm__show_code(struct kvm *self)
printf("\n");
}
void kvm__dump_mem(struct kvm *self, unsigned long addr, unsigned long size)
{
unsigned char *p;
unsigned long n;
size &= ~7; /* mod 8 */
if (!size)
return;
p = (unsigned char *)guest_flat_to_host(self, addr);
printf("Guest memory dump:\n");
for (n = 0; n < size; n+=8)
printf("0x%08lx: %02x%02x%02x%02x %02x%02x%02x%02x\n",
addr + n, p[n + 0], p[n + 1], p[n + 2], p[n + 3],
p[n + 4], p[n + 5], p[n + 6], p[n + 7]);
}