aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-05-03 23:27:16 -0400
committerMike Frysinger <vapier@gentoo.org>2021-05-04 08:13:45 -0400
commit5ee0bc23a68fe2a6a7717b31fda1db878b2c9764 (patch)
tree89d9ac8cad39ef7afdf6dfa1d93a5f06b87a440f
parent225bda24db9671e2087fda892f94141625836a40 (diff)
downloadgdb-5ee0bc23a68fe2a6a7717b31fda1db878b2c9764.zip
gdb-5ee0bc23a68fe2a6a7717b31fda1db878b2c9764.tar.gz
gdb-5ee0bc23a68fe2a6a7717b31fda1db878b2c9764.tar.bz2
sim: clean up bfd_vma printing
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.
-rw-r--r--sim/common/ChangeLog7
-rw-r--r--sim/common/cgen-trace.c4
-rw-r--r--sim/common/sim-load.c24
-rw-r--r--sim/cr16/ChangeLog4
-rw-r--r--sim/cr16/interp.c3
-rw-r--r--sim/cris/ChangeLog6
-rw-r--r--sim/cris/sim-if.c16
-rw-r--r--sim/d10v/ChangeLog5
-rw-r--r--sim/d10v/d10v_sim.h1
-rw-r--r--sim/d10v/interp.c3
-rw-r--r--sim/erc32/ChangeLog4
-rw-r--r--sim/erc32/func.c2
-rw-r--r--sim/m32c/ChangeLog4
-rw-r--r--sim/m32c/load.c4
-rw-r--r--sim/rl78/ChangeLog4
-rw-r--r--sim/rl78/load.c18
-rw-r--r--sim/rx/ChangeLog4
-rw-r--r--sim/rx/load.c8
18 files changed, 79 insertions, 42 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 17b711c..7834499 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 0f18c50..649c37a 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 e0aab1e..04681c5 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 654b4e0..ebf601f 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 4615006..8f7fafa 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 1ac455e..49db6ef 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 9914912..edd7885 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 ebe6cd3..bbf97d2 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 a3755bf..64f974f 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 90c171e..86e566a 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 12398af..a6b142a 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 c6dfa19..52428e4 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 e3393c9..df06256 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 156a275..86e774e 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 9d70041..1be5181 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 f89b5e6..c137ba6 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 4d7e93d..21a8ff62 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 b4523e1..b04826f 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;
}