From nobody Sat Nov 15 22:23:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745986027311184.53884831314144; Tue, 29 Apr 2025 21:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9yiY-0001Mg-H7; Wed, 30 Apr 2025 00:06:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9yi0-00019X-Mi for qemu-devel@nongnu.org; Wed, 30 Apr 2025 00:06:08 -0400 Received: from out28-219.mail.aliyun.com ([115.124.28.219]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9yhy-0005U5-Cg for qemu-devel@nongnu.org; Wed, 30 Apr 2025 00:06:08 -0400 Received: from TC-DZ-03-0020.tc.local(mailfrom:lc00631@tecorigin.com fp:SMTPD_---.cbi39O2_1745985955 cluster:ay29) by smtp.aliyun-inc.com; Wed, 30 Apr 2025 12:05:55 +0800 From: Chao Liu To: pbonzini@redhat.com, peterx@redhat.com, david@redhat.com, philmd@linaro.org Cc: zhangtj@tecorigin.com, zqz00548@tecorigin.com, lc00631@tecorigin.com, qemu-devel@nongnu.org Subject: [PATCH v1 1/1] system: optimizing info mtree printing for monitors Date: Wed, 30 Apr 2025 12:02:23 +0800 Message-ID: <8b29b86a9af84edba54cc53aec017224478312bf.1745894489.git.lc00631@tecorigin.com> X-Mailer: git-send-email 2.47.0.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=115.124.28.219; envelope-from=lc00631@tecorigin.com; helo=out28-219.mail.aliyun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1745986030062019000 Make the hierarchical relationship between nodes clearer by adding characte= rs Signed-off-by: Chao Liu --- system/memory.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/system/memory.c b/system/memory.c index 71434e7ad0..e723928068 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3296,6 +3296,22 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegion= ListHead; int128_sub((size), int128_one())) : 0) #define MTREE_INDENT " " =20 +#define PRINT_MTREE_COL(level) do { \ + if (level =3D=3D 0) { \ + qemu_printf("=E2=94=82 "); \ + } else { \ + qemu_printf("=E2=94=82 "); \ + } \ +} while (0) + +#define PRINT_MTREE_NODE(is_tail) do { \ + if (is_tail) { \ + qemu_printf("=E2=94=94=E2=94=80=E2=94=80 "); \ + } else { \ + qemu_printf("=E2=94=9C=E2=94=80=E2=94=80 "); \ + } \ +} while (0) + static void mtree_expand_owner(const char *label, Object *obj) { DeviceState *dev =3D (DeviceState *) object_dynamic_cast(obj, TYPE_DEV= ICE); @@ -3335,9 +3351,9 @@ static void mtree_print_mr_owner(const MemoryRegion *= mr) static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, hwaddr base, MemoryRegionListHead *alias_print_queue, - bool owner, bool display_disabled) + bool owner, bool display_disabled, bool is_tail) { - MemoryRegionList *new_ml, *ml, *next_ml; + MemoryRegionList *new_ml, *ml, *next_ml, *ml_tail; MemoryRegionListHead submr_print_queue; const MemoryRegion *submr; unsigned int i; @@ -3376,8 +3392,9 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, } if (mr->enabled || display_disabled) { for (i =3D 0; i < level; i++) { - qemu_printf(MTREE_INDENT); + PRINT_MTREE_COL(i); } + PRINT_MTREE_NODE(is_tail); qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx " (prio %d, %s%s): alias %s @%s " HWADDR_FMT_plx "-" HWADDR_FMT_plx "%s", @@ -3398,8 +3415,9 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, } else { if (mr->enabled || display_disabled) { for (i =3D 0; i < level; i++) { - qemu_printf(MTREE_INDENT); + PRINT_MTREE_COL(i); } + PRINT_MTREE_NODE(is_tail); qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx " (prio %d, %s%s): %s%s", cur_start, cur_end, @@ -3434,9 +3452,11 @@ static void mtree_print_mr(const MemoryRegion *mr, u= nsigned int level, } } =20 + ml_tail =3D QTAILQ_LAST(&submr_print_queue); QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { mtree_print_mr(ml->mr, level + 1, cur_start, - alias_print_queue, owner, display_disabled); + alias_print_queue, owner, + display_disabled, ml_tail =3D=3D ml); } =20 QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, mrqueue, next_ml) { @@ -3614,7 +3634,7 @@ static void mtree_print_as(gpointer key, gpointer val= ue, gpointer user_data) struct AddressSpaceInfo *asi =3D user_data; =20 g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL); - mtree_print_mr(mr, 1, 0, asi->ml_head, asi->owner, asi->disabled); + mtree_print_mr(mr, 1, 0, asi->ml_head, asi->owner, asi->disabled, fals= e); qemu_printf("\n"); } =20 @@ -3659,7 +3679,7 @@ static void mtree_info_as(bool dispatch_tree, bool ow= ner, bool disabled) /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { qemu_printf("memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(ml->mr, 1, 0, &ml_head, owner, disabled); + mtree_print_mr(ml->mr, 1, 0, &ml_head, owner, disabled, false); qemu_printf("\n"); } =20 --=20 2.48.1