From patchwork Wed Dec 21 07:58:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 9482671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D725A60772 for ; Wed, 21 Dec 2016 08:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6CA5280B0 for ; Wed, 21 Dec 2016 08:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8DAA28179; Wed, 21 Dec 2016 08:02:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51C24280B0 for ; Wed, 21 Dec 2016 08:02:27 +0000 (UTC) Received: from localhost ([::1]:55703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJbqz-0007IC-SE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Dec 2016 03:02:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cJboA-0004zQ-Pu for qemu-devel@nongnu.org; Wed, 21 Dec 2016 02:59:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cJbo7-0002ex-Nu for qemu-devel@nongnu.org; Wed, 21 Dec 2016 02:59:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cJbo7-0002eQ-I0 for qemu-devel@nongnu.org; Wed, 21 Dec 2016 02:59:27 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98CC583F3E; Wed, 21 Dec 2016 07:59:26 +0000 (UTC) Received: from pxdev.xzpeter.org (vpn1-7-26.pek2.redhat.com [10.72.7.26]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBL7x5mR008337; Wed, 21 Dec 2016 02:59:23 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 21 Dec 2016 15:58:57 +0800 Message-Id: <1482307137-5106-3-git-send-email-peterx@redhat.com> In-Reply-To: <1482307137-5106-1-git-send-email-peterx@redhat.com> References: <1482307137-5106-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 21 Dec 2016 07:59:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] memory: hmp: dump flat view for 'info mtree' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, marcandre.lureau@gmail.com, peterx@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Dumping flat view will be useful to debug the memory rendering logic, also it'll be much easier with it to know what memory region is handling what address range. Signed-off-by: Peter Xu --- memory.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/memory.c b/memory.c index 5dcc2e1..91341d3 100644 --- a/memory.c +++ b/memory.c @@ -2545,6 +2545,36 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f, } } +static void mtree_print_flatview(fprintf_function p, void *f, + AddressSpace *as) +{ + FlatView *view = address_space_get_flatview(as); + FlatRange *range = &view->ranges[0]; + MemoryRegion *mr; + int n = view->nr; + + if (n <= 0) { + p(f, MTREE_INDENT "No rendered FlatView for " + "address space '%s'\n", as->name); + return; + } + + p(f, MTREE_INDENT "FlatView (address space '%s'):\n", as->name); + + while (n--) { + mr = range->mr; + p(f, MTREE_INDENT MTREE_INDENT TARGET_FMT_plx "-" + TARGET_FMT_plx " (prio %d, %c%c): %s\n", + int128_get64(range->addr.start), + int128_get64(range->addr.start) + MR_SIZE(range->addr.size), + mr->priority, MR_CHAR_RD(mr), MR_CHAR_WR(mr), + memory_region_name(mr)); + range++; + } + + flatview_unref(view); +} + void mtree_info(fprintf_function mon_printf, void *f) { MemoryRegionListHead ml_head; @@ -2556,6 +2586,7 @@ void mtree_info(fprintf_function mon_printf, void *f) QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { mon_printf(f, "address-space: %s\n", as->name); mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head); + mtree_print_flatview(mon_printf, f, as); mon_printf(f, "\n"); }