kvm tools: Beautify debug output

1. print mem debug info into debugfd instead guest console
2. always print page table info

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Asias He
2013-01-25 20:56:19 +08:00
committed by Will Deacon
parent 76857a39f6
commit b2cf1e9f5f
3 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *ker
/*
* Debugging
*/
void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size);
void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size, int debug_fd);
extern const char *kvm_exit_reasons[];
+6 -5
View File
@@ -444,7 +444,7 @@ int kvm_timer__exit(struct kvm *kvm)
}
firmware_exit(kvm_timer__exit);
void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size)
void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size, int debug_fd)
{
unsigned char *p;
unsigned long n;
@@ -456,10 +456,11 @@ void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size)
p = guest_flat_to_host(kvm, addr);
for (n = 0; n < size; n += 8) {
if (!host_ptr_in_ram(kvm, p + n))
break;
printf(" 0x%08lx: %02x %02x %02x %02x %02x %02x %02x %02x\n",
if (!host_ptr_in_ram(kvm, p + n)) {
dprintf(debug_fd, " 0x%08lx: <unknown>\n", addr + n);
continue;
}
dprintf(debug_fd, " 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]);
}
+9 -3
View File
@@ -364,7 +364,8 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu)
dprintf(debug_fd, "\n Stack:\n");
dprintf(debug_fd, " ------\n");
kvm__dump_mem(vcpu->kvm, vcpu->regs.rsp, 32);
dprintf(debug_fd, " rsp: [<%016lx>] \n", (unsigned long) vcpu->regs.rsp);
kvm__dump_mem(vcpu->kvm, vcpu->regs.rsp, 32, debug_fd);
}
void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
@@ -374,8 +375,12 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
u64 *pte3;
u64 *pte4;
if (!is_in_protected_mode(vcpu))
if (!is_in_protected_mode(vcpu)) {
dprintf(debug_fd, "\n Page Tables:\n");
dprintf(debug_fd, " ------\n");
dprintf(debug_fd, " Not in protected mode\n");
return;
}
if (ioctl(vcpu->vcpu_fd, KVM_GET_SREGS, &vcpu->sregs) < 0)
die("KVM_GET_SREGS failed");
@@ -396,7 +401,8 @@ void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
if (!host_ptr_in_ram(vcpu->kvm, pte1))
return;
dprintf(debug_fd, "Page Tables:\n");
dprintf(debug_fd, "\n Page Tables:\n");
dprintf(debug_fd, " ------\n");
if (*pte2 & (1 << 7))
dprintf(debug_fd, " pte4: %016llx pte3: %016llx"
" pte2: %016llx\n",