monitor: Correctly display virtual addresses while dumping memory

While reworking the address format width in commit 6ad593a75a we
introduce a bug, leading to addresses being displayed with too many
zeroes:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000000000000000000000000000000000000000000000000000: 0x00000000
  (qemu) x/x 0xfff00000
  00000000000000000000000000000000000000000000000000000000fff00000: 0x60000000

  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: 0x00000000

Correct the format width to restore the previous behavior:

  $ qemu-system-ppc -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  00000000: 0x00000000

  $ qemu-system-ppc64 -monitor stdio -S
  QEMU 10.2.90 monitor - type 'help' for more information
  (qemu) x/x 0
  0000000000000000: 0x00000000

Fixes: 6ad593a75a ("monitor/hmp: Use plain uint64_t @addr argument in memory_dump()")
Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20260323095020.66658-1-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé
2026-03-23 10:44:07 +01:00
parent fa4a759fc1
commit 083072dba0

View File

@@ -537,7 +537,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
uint8_t buf[16];
uint64_t v;
CPUState *cs = mon_get_cpu(mon);
const unsigned int addr_width = is_physical ? 8 : (target_long_bits() * 2);
const unsigned int addr_width = is_physical ? 8 : (target_long_bits() / 4);
const bool big_endian = target_big_endian();
if (!cs && (format == 'i' || !is_physical)) {