sim cris: Correct PRIu32 to PRIx32
authorHans-Peter Nilsson <hp@axis.com>
Mon, 14 Feb 2022 22:50:18 +0000 (23:50 +0100)
committerHans-Peter Nilsson <hp@bitrange.com>
Mon, 14 Feb 2022 22:50:18 +0000 (23:50 +0100)
In 5ee0bc23a68f "sim: clean up bfd_vma printing" there was
an additional introduction of PRIx32 and PRIu32 but just in
sim/cris/sim-if.c.  One type of bug was fixed in commit
d16ce6e4d581 "sim: cris: fix memory setup typos" but one
remained; the PRIu32 usage is wrong, as hex output is
desired; note the 0x prefix.

Without this fix, you'll see output like:
 memory map 0:0x4000..0x5fff (8192 bytes) overlaps 0:0x0..0x16383 (91012 bytes)
 program stopped with signal 6 (Aborted).
for some C programs, like some of the ones in the sim/cris/c
testsuite from where the example is taken (freopen2.c).

The bug behavior was with memory allocation.  With an
attempt to allocate memory using the brk syscall such that
the room up to the next 8192-byte "page boundary" wasn't
sufficient, the simulator memory allocation machinery horked
on a consistency error when trying to allocate a memory
block to raise the "end of the data segment": there was
already memory allocated at that address.

Unfortunately, none of the programs in sim/cris/asm exposed
this bug at the time, but an assembler test-case is
committed after this fix.

sim/cris:
* sim-if.c (sim_open): Correct PRIu32 to PRIx32.

sim/cris/sim-if.c

index 602db9aebf4b36a5f72a80df8c7b41e4149fbe78..63deb467bc075d6a958216b1c94c0512b2fc4f4b 100644 (file)
@@ -887,7 +887,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
 
   /* Allocate core managed memory if none specified by user.  */
   if (sim_core_read_buffer (sd, NULL, read_map, &c, startmem, 1) == 0)
-    sim_do_commandf (sd, "memory region 0x%" PRIx32 ",0x%" PRIu32,
+    sim_do_commandf (sd, "memory region 0x%" PRIx32 ",0x%" PRIx32,
                     startmem, endmem - startmem);
 
   /* Allocate simulator I/O managed memory if none specified by user.  */