Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH/committed] sim: rx: cast bfd_vma when printing
@ 2021-05-01 20:29 Mike Frysinger via Gdb-patches
  2021-05-03 16:20 ` Christian Biesinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-05-01 20:29 UTC (permalink / raw)
  To: gdb-patches

A bit of a hack, but it's what we've been doing so far when printing
bfd_vma's since bfd doesn't provide PRI helper types for us to use.
---
 sim/rx/ChangeLog | 4 ++++
 sim/rx/load.c    | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
index 7541c9d7141b..633ed86780c7 100644
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-01  Mike Frysinger  <vapier@gentoo.org>
+
+	* load.c (rx_load): Cast size to long.
+
 2021-04-26  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (NL_TARGET): Delete.
diff --git a/sim/rx/load.c b/sim/rx/load.c
index a8a473346c67..b4523e12ac75 100644
--- a/sim/rx/load.c
+++ b/sim/rx/load.c
@@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
 	}
       if (bfd_bread (buf, size, prog) != size)
 	{
-	  fprintf (stderr, "Failed to read %lx bytes\n", size);
+	  fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
 	  continue;
 	}
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
  2021-05-01 20:29 [PATCH/committed] sim: rx: cast bfd_vma when printing Mike Frysinger via Gdb-patches
@ 2021-05-03 16:20 ` Christian Biesinger via Gdb-patches
  2021-05-03 20:57   ` Mike Frysinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Biesinger via Gdb-patches @ 2021-05-03 16:20 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Sat, May 1, 2021, 15:29 Mike Frysinger via Gdb-patches <
gdb-patches@sourceware.org> wrote:

> A bit of a hack, but it's what we've been doing so far when printing
> bfd_vma's since bfd doesn't provide PRI helper types for us to use.
> ---
>  sim/rx/ChangeLog | 4 ++++
>  sim/rx/load.c    | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
> index 7541c9d7141b..633ed86780c7 100644
> --- a/sim/rx/ChangeLog
> +++ b/sim/rx/ChangeLog
> @@ -1,3 +1,7 @@
> +2021-05-01  Mike Frysinger  <vapier@gentoo.org>
> +
> +       * load.c (rx_load): Cast size to long.
> +
>  2021-04-26  Mike Frysinger  <vapier@gentoo.org>
>
>         * Makefile.in (NL_TARGET): Delete.
> diff --git a/sim/rx/load.c b/sim/rx/load.c
> index a8a473346c67..b4523e12ac75 100644
> --- a/sim/rx/load.c
> +++ b/sim/rx/load.c
> @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
>         }
>        if (bfd_bread (buf, size, prog) != size)
>         {
> -         fprintf (stderr, "Failed to read %lx bytes\n", size);
> +         fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
>

Wouldn't it be better to use "long long", especially for mingw?

Christian

          continue;
>         }
>
> --
> 2.31.1
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
  2021-05-03 16:20 ` Christian Biesinger via Gdb-patches
@ 2021-05-03 20:57   ` Mike Frysinger via Gdb-patches
  2021-05-03 21:47     ` Christian Biesinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-05-03 20:57 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

On 03 May 2021 11:20, Christian Biesinger wrote:
> On Sat, May 1, 2021, 15:29 Mike Frysinger wrote:
> > A bit of a hack, but it's what we've been doing so far when printing
> > bfd_vma's since bfd doesn't provide PRI helper types for us to use.
> >
> > --- a/sim/rx/load.c
> > +++ b/sim/rx/load.c
> > @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
> >         }
> >        if (bfd_bread (buf, size, prog) != size)
> >         {
> > -         fprintf (stderr, "Failed to read %lx bytes\n", size);
> > +         fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
> 
> Wouldn't it be better to use "long long", especially for mingw?

not sure why mingw is special here.  but let's ignore that.

bfd_vma printing is poorly handled in many places in sim when bfd_vma is 64-bit
but the host cpu is 32-bit (i.e. sizeof(long) == 4).  the (long) cast pattern
that i used here for printing is based on those.  i don't think sim is the only
place that does this poorly tbh, it's just what i'm focusing on.

imo picking any type to cast to and copying & pasting that everywhere is a bit
of a losing proposition.  imo we should provide a PRI constant for code to use
as that'll align with other fixed types (e.g. uint64_t).  that makes it obvious
when code is doing it correctly vs the compiler not happening to warn because
the current configuration provides typedefs that align with the hardcoded sizes.
but i don't really have the energy to take on that work.

specifically for the rx_load code, this stuff needs to get deleted entirely and
switched to the existing common/ logic.  which is why i preferred a hacky patch
here rather than diving deeper into the problem.

so you're not wrong, i'm just not investing in code that i know will die :).
-mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
  2021-05-03 20:57   ` Mike Frysinger via Gdb-patches
@ 2021-05-03 21:47     ` Christian Biesinger via Gdb-patches
  2021-05-04  0:47       ` Mike Frysinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Biesinger via Gdb-patches @ 2021-05-03 21:47 UTC (permalink / raw)
  To: Christian Biesinger, gdb-patches

On Mon, May 3, 2021 at 3:57 PM Mike Frysinger <vapier@gentoo.org> wrote:
>
> On 03 May 2021 11:20, Christian Biesinger wrote:
> > On Sat, May 1, 2021, 15:29 Mike Frysinger wrote:
> > > A bit of a hack, but it's what we've been doing so far when printing
> > > bfd_vma's since bfd doesn't provide PRI helper types for us to use.
> > >
> > > --- a/sim/rx/load.c
> > > +++ b/sim/rx/load.c
> > > @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
> > >         }
> > >        if (bfd_bread (buf, size, prog) != size)
> > >         {
> > > -         fprintf (stderr, "Failed to read %lx bytes\n", size);
> > > +         fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
> >
> > Wouldn't it be better to use "long long", especially for mingw?
>
> not sure why mingw is special here.  but let's ignore that.

mingw (and msvc) is special because sizeof(long) is 4, even on a 64-bit system.
https://stackoverflow.com/questions/22344388/size-of-long-int-and-int-in-c-showing-4-bytes

> bfd_vma printing is poorly handled in many places in sim when bfd_vma is 64-bit
> but the host cpu is 32-bit (i.e. sizeof(long) == 4).  the (long) cast pattern
> that i used here for printing is based on those.  i don't think sim is the only
> place that does this poorly tbh, it's just what i'm focusing on.

But if other places already do that, then eh...

Christian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
  2021-05-03 21:47     ` Christian Biesinger via Gdb-patches
@ 2021-05-04  0:47       ` Mike Frysinger via Gdb-patches
  2021-05-04  2:54         ` Mike Frysinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-05-04  0:47 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

On 03 May 2021 16:47, Christian Biesinger via Gdb-patches wrote:
> On Mon, May 3, 2021 at 3:57 PM Mike Frysinger wrote:
> > On 03 May 2021 11:20, Christian Biesinger wrote:
> > > On Sat, May 1, 2021, 15:29 Mike Frysinger wrote:
> > > > A bit of a hack, but it's what we've been doing so far when printing
> > > > bfd_vma's since bfd doesn't provide PRI helper types for us to use.
> > > >
> > > > --- a/sim/rx/load.c
> > > > +++ b/sim/rx/load.c
> > > > @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
> > > >         }
> > > >        if (bfd_bread (buf, size, prog) != size)
> > > >         {
> > > > -         fprintf (stderr, "Failed to read %lx bytes\n", size);
> > > > +         fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
> > >
> > > Wouldn't it be better to use "long long", especially for mingw?
> >
> > not sure why mingw is special here.  but let's ignore that.
> 
> mingw (and msvc) is special because sizeof(long) is 4, even on a 64-bit system.
> https://stackoverflow.com/questions/22344388/size-of-long-int-and-int-in-c-showing-4-bytes

we have ILP32 models on mips/n32 [2000], x86_64/x32 [2011], and aarch64 [2016],
so i don't think mingw does anything that unique anymore.

we've long known that long is inappropriate for things that could be 64-bit.
the trouble is when we half implement the suite like just coming up with a
typedef and skimping on printf formats :(.
-mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
  2021-05-04  0:47       ` Mike Frysinger via Gdb-patches
@ 2021-05-04  2:54         ` Mike Frysinger via Gdb-patches
  2021-05-04 12:17           ` [PATCH/committed] sim: clean up bfd_vma printing Mike Frysinger via Gdb-patches
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-05-04  2:54 UTC (permalink / raw)
  To: Christian Biesinger, gdb-patches

On 03 May 2021 20:47, Mike Frysinger via Gdb-patches wrote:
> On 03 May 2021 16:47, Christian Biesinger via Gdb-patches wrote:
> > On Mon, May 3, 2021 at 3:57 PM Mike Frysinger wrote:
> > > On 03 May 2021 11:20, Christian Biesinger wrote:
> > > > On Sat, May 1, 2021, 15:29 Mike Frysinger wrote:
> > > > > A bit of a hack, but it's what we've been doing so far when printing
> > > > > bfd_vma's since bfd doesn't provide PRI helper types for us to use.
> > > > >
> > > > > --- a/sim/rx/load.c
> > > > > +++ b/sim/rx/load.c
> > > > > @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback)
> > > > >         }
> > > > >        if (bfd_bread (buf, size, prog) != size)
> > > > >         {
> > > > > -         fprintf (stderr, "Failed to read %lx bytes\n", size);
> > > > > +         fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
> > > >
> > > > Wouldn't it be better to use "long long", especially for mingw?
> > >
> > > not sure why mingw is special here.  but let's ignore that.
> > 
> > mingw (and msvc) is special because sizeof(long) is 4, even on a 64-bit system.
> > https://stackoverflow.com/questions/22344388/size-of-long-int-and-int-in-c-showing-4-bytes
> 
> we have ILP32 models on mips/n32 [2000], x86_64/x32 [2011], and aarch64 [2016],
> so i don't think mingw does anything that unique anymore.
> 
> we've long known that long is inappropriate for things that could be 64-bit.
> the trouble is when we half implement the suite like just coming up with a
> typedef and skimping on printf formats :(.

looks like i'm just bad at grepping for things i don't know about.  i could
find bad examples, but that's because i knew the form they took.  a patch on
the binutils list points out the format already exists, albeit with a more
verbose name: BFD_VMA_FMT.  so i can clean up the sim code to use that.
-mike

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH/committed] sim: clean up bfd_vma printing
  2021-05-04  2:54         ` Mike Frysinger via Gdb-patches
@ 2021-05-04 12:17           ` Mike Frysinger via Gdb-patches
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger via Gdb-patches @ 2021-05-04 12:17 UTC (permalink / raw)
  To: gdb-patches

A lot of this code predates the bfd_vma format define, so we have a
random mix of casts to known types so we can printf the value.  Use
the BFD_VMA_FMT that now exists to simplify and reliability output
across different build configs.
---
 sim/common/ChangeLog    |  7 +++++++
 sim/common/cgen-trace.c |  4 ++--
 sim/common/sim-load.c   | 24 ++++++------------------
 sim/cr16/ChangeLog      |  4 ++++
 sim/cr16/interp.c       |  3 ++-
 sim/cris/ChangeLog      |  6 ++++++
 sim/cris/sim-if.c       | 16 +++++++++-------
 sim/d10v/ChangeLog      |  5 +++++
 sim/d10v/d10v_sim.h     |  1 -
 sim/d10v/interp.c       |  3 ++-
 sim/erc32/ChangeLog     |  4 ++++
 sim/erc32/func.c        |  2 +-
 sim/m32c/ChangeLog      |  4 ++++
 sim/m32c/load.c         |  4 ++--
 sim/rl78/ChangeLog      |  4 ++++
 sim/rl78/load.c         | 18 ++++++++++++------
 sim/rx/ChangeLog        |  4 ++++
 sim/rx/load.c           |  8 +++++---
 18 files changed, 79 insertions(+), 42 deletions(-)

diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 17b711c965e4..783449941b28 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,10 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* cgen-trace.c (sim_disasm_perror_memory): Use BFD_VMA_FMT and drop
+	cast.
+	* sim-load.c (xprintf_bfd_vma): Delete.
+	(sim_load_file): Delete xprintf_bfd_vma calls.  Use BFD_VMA_FMT.
+
 2021-05-03  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* hw-events.h (hw_event_queue_schedule_tracef): Use format attribute.
diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index 0f18c502c637..649c37a61b1c 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -340,8 +340,8 @@ sim_disasm_perror_memory (int status, bfd_vma memaddr,
     /* Actually, address between memaddr and memaddr + len was
        out of bounds.  */
     info->fprintf_func (info->stream,
-			"Address 0x%x is out of bounds.",
-			(int) memaddr);
+			"Address 0x%" BFD_VMA_FMT "x is out of bounds.",
+			memaddr);
 }
 
 /* Disassemble using the CGEN opcode table.
diff --git a/sim/common/sim-load.c b/sim/common/sim-load.c
index e0aab1e9eb49..04681c524a0c 100644
--- a/sim/common/sim-load.c
+++ b/sim/common/sim-load.c
@@ -38,7 +38,6 @@ static void eprintf (host_callback *, const char *, ...);
 static void xprintf (host_callback *, const char *, ...);
 static void report_transfer_performance
   (host_callback *, unsigned long, time_t, time_t);
-static void xprintf_bfd_vma (host_callback *, bfd_vma);
 
 /* Load program PROG into the simulator using the function DO_LOAD.
    If PROG_BFD is non-NULL, the file has already been opened.
@@ -122,12 +121,12 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
 		lma = bfd_section_vma (s);
 	      if (verbose_p)
 		{
-		  xprintf (callback, "Loading section %s, size 0x%lx %s ",
+		  xprintf (callback,
+			   "Loading section %s, size 0x%lx %s "
+			   "%" BFD_VMA_FMT "x\n",
 			   bfd_section_name (s),
 			   (unsigned long) size,
-			   (lma_p ? "lma" : "vma"));
-		  xprintf_bfd_vma (callback, lma);
-		  xprintf (callback, "\n");
+			   (lma_p ? "lma" : "vma"), lma);
 		}
 	      data_count += size;
 	      bfd_get_section_contents (result_bfd, s, buffer, 0, size);
@@ -149,9 +148,8 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
   if (verbose_p)
     {
       end_time = time (NULL);
-      xprintf (callback, "Start address ");
-      xprintf_bfd_vma (callback, bfd_get_start_address (result_bfd));
-      xprintf (callback, "\n");
+      xprintf (callback, "Start address %" BFD_VMA_FMT "x\n",
+	       bfd_get_start_address (result_bfd));
       report_transfer_performance (callback, data_count, start_time, end_time);
     }
 
@@ -198,13 +196,3 @@ report_transfer_performance (host_callback *callback, unsigned long data_count,
     xprintf (callback, "%ld bits in <1 sec", (data_count * 8));
   xprintf (callback, ".\n");
 }
-
-/* Print a bfd_vma.
-   This is intended to handle the vagaries of 32 vs 64 bits, etc.  */
-
-static void
-xprintf_bfd_vma (host_callback *callback, bfd_vma vma)
-{
-  /* FIXME: for now */
-  xprintf (callback, "0x%lx", (unsigned long) vma);
-}
diff --git a/sim/cr16/ChangeLog b/sim/cr16/ChangeLog
index 654b4e0987ec..ebf601fe9b9d 100644
--- a/sim/cr16/ChangeLog
+++ b/sim/cr16/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* interp.c (sim_create_inferior): Use BFD_VMA_FMT and drop cast.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 46150069a383..8f7fafa715e9 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -672,7 +672,8 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
     start_address = 0x0;
 #ifdef DEBUG
   if (cr16_debug)
-    sim_io_printf (sd, "sim_create_inferior:  PC=0x%lx\n", (long) start_address);
+    sim_io_printf (sd, "sim_create_inferior:  PC=0x%" BFD_VMA_FMT "x\n",
+		   start_address);
 #endif
   {
     SIM_CPU *cpu = STATE_CPU (sd, 0);
diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog
index 1ac455e561bc..49db6ef32b2d 100644
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,3 +1,9 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* sim-if.c (cris_load_elf_file): Use BFD_VMA_FMT
+	(cris_handle_interpreter): Likewise.  Delete phaddr.
+	(sim_open): Use PRIx32.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c
index 9914912b156b..edd7885caf70 100644
--- a/sim/cris/sim-if.c
+++ b/sim/cris/sim-if.c
@@ -257,14 +257,16 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write)
       buf = xmalloc (phdr[i].p_filesz);
 
       if (verbose)
-	sim_io_printf (sd, "Loading segment at 0x%lx, size 0x%lx\n",
+	sim_io_printf (sd,
+		       "Loading segment at 0x%" BFD_VMA_FMT "x, size 0x%lx\n",
 		       lma, phdr[i].p_filesz);
 
       if (bfd_seek (abfd, phdr[i].p_offset, SEEK_SET) != 0
 	  || (bfd_bread (buf, phdr[i].p_filesz, abfd) != phdr[i].p_filesz))
 	{
 	  sim_io_eprintf (sd,
-			  "%s: could not read segment at 0x%lx, size 0x%lx\n",
+			  "%s: could not read segment at 0x%" BFD_VMA_FMT "x, "
+			  "size 0x%lx\n",
 			  STATE_MY_NAME (sd), lma, phdr[i].p_filesz);
 	  free (buf);
 	  return FALSE;
@@ -273,7 +275,8 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write)
       if (do_write (sd, lma, buf, phdr[i].p_filesz) != phdr[i].p_filesz)
 	{
 	  sim_io_eprintf (sd,
-			  "%s: could not load segment at 0x%lx, size 0x%lx\n",
+			  "%s: could not load segment at 0x%" BFD_VMA_FMT "x, "
+			  "size 0x%lx\n",
 			  STATE_MY_NAME (sd), lma, phdr[i].p_filesz);
 	  free (buf);
 	  return FALSE;
@@ -495,7 +498,6 @@ static bfd_boolean
 cris_handle_interpreter (SIM_DESC sd, struct bfd *abfd)
 {
   int i, n_hdrs;
-  bfd_vma phaddr;
   bfd_byte buf[4];
   char *interp = NULL;
   struct bfd *ibfd;
@@ -571,7 +573,7 @@ cris_handle_interpreter (SIM_DESC sd, struct bfd *abfd)
 	 memory area, so we go via a temporary area.  Luckily, the
 	 interpreter is supposed to be small, less than 0x40000
 	 bytes.  */
-      sim_do_commandf (sd, "memory region 0x%lx,0x%lx",
+      sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x,0x%lx",
 		       interp_load_addr, interpsiz);
 
       /* Now that memory for the interpreter is defined, load it.  */
@@ -885,8 +887,8 @@ 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%lx,0x%lx", startmem,
-		     endmem - startmem);
+    sim_do_commandf (sd, "memory region 0x%" PRIx32 "x,0x%" PRIu32 "x",
+		     startmem, endmem - startmem);
 
   /* Allocate simulator I/O managed memory if none specified by user.  */
   if (cris_have_900000xxif)
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index ebe6cd3f1a9f..bbf97d20318b 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* d10v_sim.h (decode_pc): Delete.
+	* interp.c (sim_create_inferior): Use BFD_VMA_FMT.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/d10v/d10v_sim.h b/sim/d10v/d10v_sim.h
index a3755bf3ccb9..64f974f01dbc 100644
--- a/sim/d10v/d10v_sim.h
+++ b/sim/d10v/d10v_sim.h
@@ -444,7 +444,6 @@ while (0)
 
 extern uint8 *dmem_addr (SIM_DESC, SIM_CPU *, uint16 offset);
 extern uint8 *imem_addr (SIM_DESC, SIM_CPU *, uint32);
-extern bfd_vma decode_pc (void);
 
 #define	RB(x)	(*(dmem_addr (sd, cpu, x)))
 #define SB(addr,data)	( RB(addr) = (data & 0xff))
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 90c171eda398..86e566a79fb8 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -1160,7 +1160,8 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
     start_address = 0xffc0 << 2;
 #ifdef DEBUG
   if (d10v_debug)
-    sim_io_printf (sd, "sim_create_inferior:  PC=0x%lx\n", (long) start_address);
+    sim_io_printf (sd, "sim_create_inferior:  PC=0x%" BFD_VMA_FMT "x\n",
+		   start_address);
 #endif
   {
     SIM_CPU *cpu = STATE_CPU (sd, 0);
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog
index 12398af89972..a6b142a6ec28 100644
--- a/sim/erc32/ChangeLog
+++ b/sim/erc32/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* func.c (bfd_load): Use BFD_VMA_FMT.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/erc32/func.c b/sim/erc32/func.c
index c6dfa1927ad4..52428e48350f 100644
--- a/sim/erc32/func.c
+++ b/sim/erc32/func.c
@@ -1056,7 +1056,7 @@ bfd_load (const char *fname)
 	    section_size = bfd_section_size (section);
 
 	    if (sis_verbose)
-		printf("\nsection %s at 0x%08lx (0x%lx bytes)",
+		printf("\nsection %s at 0x%08" BFD_VMA_FMT "x (0x%lx bytes)",
 		       section_name, section_address, section_size);
 
 	    /* Text, data or lit */
diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog
index e3393c9be662..df0625609835 100644
--- a/sim/m32c/ChangeLog
+++ b/sim/m32c/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* load.c (m32c_load): Use BFD_VMA_FMT and drop casts.
+
 2021-05-02  Mike Frysinger  <vapier@gentoo.org>
 
 	* m32c.opc: Include ansidecl.h.
diff --git a/sim/m32c/load.c b/sim/m32c/load.c
index 156a275ad31b..86e774e3abe9 100644
--- a/sim/m32c/load.c
+++ b/sim/m32c/load.c
@@ -97,8 +97,8 @@ m32c_load (bfd * prog)
 
 	  base = bfd_section_lma (s);
 	  if (verbose)
-	    fprintf (stderr, "[load a=%08x s=%08x %s]\n",
-		     (int) base, (int) size, bfd_section_name (s));
+	    fprintf (stderr, "[load a=%08" BFD_VMA_FMT "x s=%08x %s]\n",
+		     base, (int) size, bfd_section_name (s));
 	  buf = (char *) malloc (size);
 	  bfd_get_section_contents (prog, s, buf, 0, size);
 	  mem_put_blk (base, buf, size);
diff --git a/sim/rl78/ChangeLog b/sim/rl78/ChangeLog
index 9d70041b907f..1be5181dc6d1 100644
--- a/sim/rl78/ChangeLog
+++ b/sim/rl78/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* load.c (rl78_load): Use BFD_VMA_FMT and drop casts.
+
 2021-05-01  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/rl78/load.c b/sim/rl78/load.c
index f89b5e69c4be..c137ba6e40e4 100644
--- a/sim/rl78/load.c
+++ b/sim/rl78/load.c
@@ -128,12 +128,15 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
 
       base = p->p_paddr;
       if (verbose > 1)
-	fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n",
-		 (int) base, (int) p->p_vaddr, (int) size);
+	fprintf (stderr,
+		 "[load segment: lma=%08" BFD_VMA_FMT "x vma=%08x "
+		 "size=%08" BFD_VMA_FMT "x]\n",
+		 base, (int) p->p_vaddr, size);
       if (callbacks)
 	xprintf (callbacks,
-	         "Loading section %s, size %#lx lma %08lx vma %08lx\n",
-	         find_section_name_by_offset (prog, p->p_offset),
+		 "Loading section %s, size %#" BFD_VMA_FMT "x "
+		 "lma %08" BFD_VMA_FMT "x vma %08lx\n",
+		 find_section_name_by_offset (prog, p->p_offset),
 		 size, base, p->p_vaddr);
 
       buf = xmalloc (size);
@@ -147,13 +150,16 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
 
       if (bfd_bread (buf, size, prog) != size)
 	{
-	  fprintf (stderr, "%s: Failed to read %lx bytes\n", simname, size);
+	  fprintf (stderr, "%s: Failed to read %" BFD_VMA_FMT "x bytes\n",
+		   simname, size);
 	  continue;
 	}
 
       if (base > 0xeffff || base + size > 0xeffff)
 	{
-	  fprintf (stderr, "%s, Can't load image to RAM/SFR space: 0x%lx - 0x%lx\n",
+	  fprintf (stderr,
+		   "%s, Can't load image to RAM/SFR space: 0x%" BFD_VMA_FMT "x "
+		   "- 0x%" BFD_VMA_FMT "x\n",
 		   simname, base, base+size);
 	  continue;
 	}
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
index 4d7e93dabe92..21a8ff626cf1 100644
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-04  Mike Frysinger  <vapier@gentoo.org>
+
+	* load.c (rx_load): Use BFD_VMA_FMT and drop casts.
+
 2021-05-03  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* trace.c (op_printf): Likewise.
diff --git a/sim/rx/load.c b/sim/rx/load.c
index b4523e12ac75..b04826f55c7f 100644
--- a/sim/rx/load.c
+++ b/sim/rx/load.c
@@ -128,8 +128,10 @@ rx_load (bfd *prog, host_callback *callback)
 
       base = p->p_paddr;
       if (verbose > 1)
-	fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n",
-		 (int) base, (int) p->p_vaddr, (int) size);
+	fprintf (stderr,
+		 "[load segment: lma=%08" BFD_VMA_FMT "x vma=%08x "
+		 "size=%08" BFD_VMA_FMT "x]\n",
+		 base, (int) p->p_vaddr, size);
       if (callback)
 	xprintf (callback,
 	         "Loading section %s, size %#lx lma %08lx vma %08lx\n",
@@ -151,7 +153,7 @@ rx_load (bfd *prog, host_callback *callback)
 	}
       if (bfd_bread (buf, size, prog) != size)
 	{
-	  fprintf (stderr, "Failed to read %lx bytes\n", (long) size);
+	  fprintf (stderr, "Failed to read %" BFD_VMA_FMT "x bytes\n", size);
 	  continue;
 	}
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-04 12:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01 20:29 [PATCH/committed] sim: rx: cast bfd_vma when printing Mike Frysinger via Gdb-patches
2021-05-03 16:20 ` Christian Biesinger via Gdb-patches
2021-05-03 20:57   ` Mike Frysinger via Gdb-patches
2021-05-03 21:47     ` Christian Biesinger via Gdb-patches
2021-05-04  0:47       ` Mike Frysinger via Gdb-patches
2021-05-04  2:54         ` Mike Frysinger via Gdb-patches
2021-05-04 12:17           ` [PATCH/committed] sim: clean up bfd_vma printing Mike Frysinger via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox