From patchwork Fri Jan 25 12:56:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2044901 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 754953FDD1 for ; Fri, 25 Jan 2013 12:55:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756959Ab3AYMzh (ORCPT ); Fri, 25 Jan 2013 07:55:37 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:47681 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756379Ab3AYMzg (ORCPT ); Fri, 25 Jan 2013 07:55:36 -0500 Received: by mail-pa0-f44.google.com with SMTP id hz11so247587pad.31 for ; Fri, 25 Jan 2013 04:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=Qu4dWXKEf71NeF0GZNfhdE/xkBvRVQRycejijPUfeGM=; b=TJBGdSDP18myB0gUzNbj0fsbak2a3BZVOw8SC4Wqq37Cq+FNepXD1bAH4YwfZu35aV 69mL5hpH9R3jm0wsp6R/vYwo5bkIYtIo2xVTLQmOWRXd4KtwhU9HKXPBOw8UDtaA91H8 DHJdlkUgAyODmn2mm6dI1X0jDbdEENGOndHdINJImzRtCtR5mrWWMknOFj+28azxHqtB +edlc/D0Ar5U3JHZrWcXrNILAuH3Zlu4jOHo6pbj1Em7xwXBLog9zaXj9QFsRNwODXnC 8oW+P9Fk9c6guWIub9rgWUn/qYLq3a5PH4vQlHf0rfCWIHkdGQJTS1XqnDWLji1LUXAU OeMw== X-Received: by 10.66.83.196 with SMTP id s4mr13119329pay.74.1359118535466; Fri, 25 Jan 2013 04:55:35 -0800 (PST) Received: from hj.localdomain ([219.236.95.252]) by mx.google.com with ESMTPS id ai8sm646397pbd.14.2013.01.25.04.55.29 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Jan 2013 04:55:34 -0800 (PST) From: Asias He To: Pekka Enberg Cc: Sasha Levin , Ingo Molnar , Cyrill Gorcunov , kvm@vger.kernel.org Subject: [PATCH] kvm tools: Beautify debug output Date: Fri, 25 Jan 2013 20:56:19 +0800 Message-Id: <1359118579-31667-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.8.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 1. print mem debug info into debugfd instead guest console 2. always print page table info Signed-off-by: Asias He --- tools/kvm/include/kvm/kvm.h | 2 +- tools/kvm/kvm.c | 11 ++++++----- tools/kvm/x86/kvm-cpu.c | 12 +++++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index acb0818..ad53ca7 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -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[]; diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index a6b3c23..cfd30dd 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -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: \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]); } diff --git a/tools/kvm/x86/kvm-cpu.c b/tools/kvm/x86/kvm-cpu.c index b6190ed..5cc4e1e 100644 --- a/tools/kvm/x86/kvm-cpu.c +++ b/tools/kvm/x86/kvm-cpu.c @@ -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",