All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Chao Liu <lc00631@tecorigin.com>
Cc: pbonzini@redhat.com,  peterx@redhat.com,  david@redhat.com,
	philmd@linaro.org,  zhangtj@tecorigin.com,
	 zqz00548@tecorigin.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v2 1/1] system: optimizing info mtree printing for monitors
Date: Wed, 30 Apr 2025 16:03:56 +0200	[thread overview]
Message-ID: <874iy5d9v7.fsf@pond.sub.org> (raw)
In-Reply-To: <501e578a4ef28515ccdefcbc82defc04363855ca.1746001489.git.lc00631@tecorigin.com> (Chao Liu's message of "Wed, 30 Apr 2025 16:31:47 +0800")

Chao Liu <lc00631@tecorigin.com> writes:

> Make the hierarchical relationship between nodes clearer by adding characters
>
> e.g.
>
> qemu-system-riscv64 -M virt -monitor stdio -display none
>
> ```
> (qemu) info mtree
> ...
> memory-region: system
> │  ├── 0000000000000000-ffffffffffffffff (prio 0, i/o): system
> │  │   ├── 0000000003000000-000000000300ffff (prio 0, i/o): gpex_ioport_window
> │  │   │   └── 0000000003000000-000000000300ffff (prio 0, i/o): gpex_ioport
> ...
> │  │   └── 0000000400000000-00000007ffffffff (prio 0, i/o): alias ...
> ```

info qtree and info qom-tree could perhaps use similar treatment.

> Signed-off-by: Chao Liu <lc00631@tecorigin.com>
> Reviewed-by: Qingze Zhao <zqz00548@tecorigin.com>
> Reviewed-by: Tingjian Zhang <zhangtj@tecorigin.com>
> ---
>  system/memory.c | 42 ++++++++++++++++++++++++++++++++++++------
>  1 file changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index 71434e7ad0..3a7faeb533 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -3296,6 +3296,27 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
>                             int128_sub((size), int128_one())) : 0)
>  #define MTREE_INDENT "  "
>  
> +enum mtree_node_type {
> +    MTREE_NODE_T_INNER,
> +    MTREE_NODE_T_TAIL,
> +};
> +
> +#define PRINT_MTREE_NODE(node_type) do {  \
> +    if (node_type == MTREE_NODE_T_TAIL) { \
> +        qemu_printf("└── ");              \
> +    } else {                              \
> +        qemu_printf("├── ");              \
> +    }                                     \
> +} while (0)
> +
> +#define PRINT_MTREE_COL(level) do { \
> +    if (level == 0) {               \
> +        qemu_printf("│  ");         \
> +    } else {                        \
> +        qemu_printf("│   ");        \
> +    }                               \
> +} while (0)

Printing non-ASCII Unicode characters encoded in UTF-8 assumes the
monitor / stdout uses UTF-8.  Are we happy with such an assumption?

For what it's worth, such characters are exceedingly rare in C strings
so far.  I found:

    contrib/plugins/lockstep.c:        g_string_printf(out, "Δ too high, we have diverged, previous insns\n");

Intentional.  This is a "plugin for debugging TCG changes" (commit
c81950a2f19).

    hw/uefi/var-service-policy.c:    fprintf(stderr, "    name ´");

This looks like a typo to me.

    tests/tcg/plugins/insn.c:                               " Δ+%"PRId64 " since last match,"

Intentional.  Seems to be a plugin used for testing.

    ui/sdl2.c:            status = " - Press ⌃⌥⇧G to exit grab";
    ui/sdl2.c:            status = " - Press ⌃⌥G to exit grab";

These are #ifndef CONFIG_DARWIN.

None found in QEMU proper.

The common ASCII equivalent to

    │
    ├──

is

    |
    +--

Not as pretty, but quite readable.

[...]



      parent reply	other threads:[~2025-04-30 14:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  8:31 [PATCH v2 0/1] Optimizing the print format of the QEMU monitor 'info mtree' Chao Liu
2025-04-30  8:31 ` [PATCH v2 1/1] system: optimizing info mtree printing for monitors Chao Liu
2025-04-30  8:46   ` Philippe Mathieu-Daudé
2025-04-30 11:33   ` BALATON Zoltan
2025-04-30 14:03   ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874iy5d9v7.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=lc00631@tecorigin.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zhangtj@tecorigin.com \
    --cc=zqz00548@tecorigin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.