mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 12:03:41 +08:00
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.
This commit is contained in:
parent
225bda24db
commit
5ee0bc23a6
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user