From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [RFC PATCH] hw/display: modernise the vga debug code (!!GenAI!!)
Date: Wed, 01 Apr 2026 13:49:43 +0100 [thread overview]
Message-ID: <87fr5eq1zs.fsf@draig.linaro.org> (raw)
In-Reply-To: <a7b05743-c7f4-4626-b11c-ec8200913c33@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Wed, 1 Apr 2026 12:21:02 +0200")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> On 31/3/26 00:28, Alex Bennée wrote:
>> Remove dead code, replace debug prints with trace points.
>> Link:
>> https://patchew.org/QEMU/20260330140656.46FE55969F2@zero.eik.bme.hu/
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>> As an experiment I prompted Gemini with the thread contents and asked
>> it to make the changes. It cost about 9p in inference and I would
>> argue this barely counts as copyrightable as it is a simple
>> transformation of existing patterns.
>> ---
>> hw/display/vga.c | 89 ++++++++---------------------------------
>> hw/display/trace-events | 11 +++++
>> 2 files changed, 27 insertions(+), 73 deletions(-)
>
>
>> @@ -873,9 +824,7 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
>> uint32_t write_mask, bit_mask, set_mask;
>> int plane = 0;
>> -#ifdef DEBUG_VGA_MEM
>> - printf("vga: [0x" HWADDR_FMT_plx "] = 0x%02x\n", addr, val);
>> -#endif
>> + trace_vga_vram_write(addr, val);
>
> OK, ...
>
>> /* convert to VGA memory offset */
>> memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3;
>> addr &= 0x1ffff;
>> @@ -945,9 +894,7 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
>> if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) {
>> if (mask) {
>> s->vram_ptr[(addr << 2) | plane] = val;
>> -#ifdef DEBUG_VGA_MEM
>> - printf("vga: chain4: [0x" HWADDR_FMT_plx "]\n", addr);
>> -#endif
>> + trace_vga_vram_write((addr << 2) | plane, val);
>
> ... but why print the index instead of the address here?
I expect it makes the trace data more closely match the actual access.
As a human I probably would have written:
if (mask) {
size_t idx = (addr << 2) | plane;
s->vram_ptr[idx] = val;
trace_vga_vram_write(idx, val);
...
}
to avoid the double calculation (even though I'm sure the compiler would
have clocked it).
>
>> s->plane_updated |= mask; /* only used to detect font change */
>> memory_region_set_dirty(&s->vram, addr, 1);
>> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-04-01 12:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 14:06 [PATCH] hw/display/vga: Fix debug message BALATON Zoltan
2026-03-30 14:34 ` Alex Bennée
2026-03-30 16:10 ` BALATON Zoltan
2026-03-30 22:28 ` [RFC PATCH] hw/display: modernise the vga debug code (!!GenAI!!) Alex Bennée
2026-04-01 10:21 ` Philippe Mathieu-Daudé
2026-04-01 12:49 ` Alex Bennée [this message]
2026-04-01 19:58 ` BALATON Zoltan
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=87fr5eq1zs.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=kraxel@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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.