Don't use BFD_VMA_FMT in gdb and sim
authorAlan Modra <amodra@gmail.com>
Thu, 4 Aug 2022 03:18:05 +0000 (12:48 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 5 Aug 2022 22:33:16 +0000 (08:03 +0930)
Like commit b82817674f, this replaces BFD_VMA_FMT "x" in sim/ with
PRIx64 and casts to promote bfd_vma to uint64_t.  The one file using
BFD_VMA_FMT in gdb/ instead now uses hex_string, and a typo in the
warning message is fixed.

gdb/windows-tdep.c
sim/common/cgen-trace.c
sim/common/sim-load.c
sim/cr16/interp.c
sim/cris/sim-if.c
sim/d10v/interp.c
sim/erc32/func.c
sim/m32c/load.c
sim/rl78/load.c
sim/rx/load.c

index a34ac5e5f0a561d3320fddee25669b2531d26971..702af65d4500011d30755350fdb8f70a299571c7 100644 (file)
@@ -1007,10 +1007,11 @@ is_linked_with_cygwin_dll (bfd *abfd)
       || import_table_va >= idata_section_end_va)
     {
       warning (_("\
-%s: import table's virtual address (0x%" BFD_VMA_FMT "x) is outside .idata \
-section's range [0x%" BFD_VMA_FMT "x, 0x%" BFD_VMA_FMT "x[."),
-              bfd_get_filename (abfd), import_table_va, idata_section_va,
-              idata_section_end_va);
+%s: import table's virtual address (%s) is outside .idata \
+section's range [%s, %s]."),
+              bfd_get_filename (abfd), hex_string (import_table_va),
+              hex_string (idata_section_va),
+              hex_string (idata_section_end_va));
       return false;
     }
 
@@ -1057,10 +1058,11 @@ section's range [0x%" BFD_VMA_FMT "x, 0x%" BFD_VMA_FMT "x[."),
       if (name_va < idata_section_va || name_va >= idata_section_end_va)
        {
          warning (_("\
-%s: name's virtual address (0x%" BFD_VMA_FMT "x) is outside .idata section's \
-range [0x%" BFD_VMA_FMT "x, 0x%" BFD_VMA_FMT "x[."),
-                  bfd_get_filename (abfd), name_va, idata_section_va,
-                  idata_section_end_va);
+%s: name's virtual address (%s) is outside .idata section's \
+range [%s, %s]."),
+                  bfd_get_filename (abfd), hex_string (name_va),
+                  hex_string (idata_section_va),
+                  hex_string (idata_section_end_va));
          break;
        }
 
index 3df30c5583326427afaf803d83fe778467d109cd..e79e93c7b39ff6488c7ac763a1207f5dc9fb8ac0 100644 (file)
@@ -366,8 +366,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%" BFD_VMA_FMT "x is out of bounds.",
-                       memaddr);
+                       "Address 0x%" PRIx64 " is out of bounds.",
+                       (uint64_t) memaddr);
 }
 
 /* Disassemble using the CGEN opcode table.
index 020165a0dce58045f9a6fa5570b3297e075fb9fa..80fa2ea4f902158561e4622efeafe4562a39ff93 100644 (file)
@@ -121,11 +121,10 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
              if (verbose_p)
                {
                  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"), lma);
+                          "Loading section %s, size 0x%" PRIx64
+                          " %s %" PRIx64 "\n",
+                          bfd_section_name (s), (uint64_t) size,
+                          lma_p ? "lma" : "vma", (uint64_t) lma);
                }
              data_count += size;
              bfd_get_section_contents (result_bfd, s, buffer, 0, size);
@@ -147,8 +146,8 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
   if (verbose_p)
     {
       end_time = time (NULL);
-      xprintf (callback, "Start address %" BFD_VMA_FMT "x\n",
-              bfd_get_start_address (result_bfd));
+      xprintf (callback, "Start address %" PRIx64 "\n",
+              (uint64_t) bfd_get_start_address (result_bfd));
       report_transfer_performance (callback, data_count, start_time, end_time);
     }
 
index 47fb64781bfd891f5720d8b9f79faa975a253b1b..b375dadff5d6d3278b92b28cb6f3a22dfe8eeed6 100644 (file)
@@ -677,8 +677,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%" BFD_VMA_FMT "x\n",
-                  start_address);
+    sim_io_printf (sd, "sim_create_inferior:  PC=0x%" PRIx64 "\n",
+                  (uint64_t) start_address);
 #endif
   {
     SIM_CPU *cpu = STATE_CPU (sd, 0);
index d7c1005fcacccefa3fbbb3ca058d46d5b000b80f..75176d0c020d64cc43b77c4eccb7d7f7abd16db7 100644 (file)
@@ -257,17 +257,18 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write)
 
       if (verbose)
        sim_io_printf (sd,
-                      "Loading segment at 0x%" BFD_VMA_FMT "x, "
-                      "size 0x%" BFD_VMA_FMT "x\n",
-                      lma, phdr[i].p_filesz);
+                      "Loading segment at 0x%" PRIx64 ", "
+                      "size 0x%" PRIx64 "\n",
+                      (uint64_t) lma, (uint64_t) 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%" BFD_VMA_FMT "x, "
-                         "size 0x%" BFD_VMA_FMT "x\n",
-                         STATE_MY_NAME (sd), lma, phdr[i].p_filesz);
+                         "%s: could not read segment at 0x%" PRIx64 ", "
+                         "size 0x%" PRIx64 "\n",
+                         STATE_MY_NAME (sd), (uint64_t) lma,
+                         (uint64_t) phdr[i].p_filesz);
          free (buf);
          return FALSE;
        }
@@ -275,9 +276,10 @@ 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%" BFD_VMA_FMT "x, "
-                         "size 0x%" BFD_VMA_FMT "x\n",
-                         STATE_MY_NAME (sd), lma, phdr[i].p_filesz);
+                         "%s: could not load segment at 0x%" PRIx64 ", "
+                         "size 0x%" PRIx64 "\n",
+                         STATE_MY_NAME (sd), (uint64_t) lma,
+                         (uint64_t) phdr[i].p_filesz);
          free (buf);
          return FALSE;
        }
@@ -573,9 +575,8 @@ 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%" BFD_VMA_FMT "x,"
-                      "0x%" BFD_VMA_FMT "x",
-                      interp_load_addr, interpsiz);
+      sim_do_commandf (sd, "memory region 0x%" PRIx64 ",0x%" PRIx64,
+                      (uint64_t) interp_load_addr, (uint64_t) interpsiz);
 
       /* Now that memory for the interpreter is defined, load it.  */
       if (!cris_load_elf_file (sd, ibfd, cris_write_interp))
index 5716a10583ea9dfeff1e49703a4c5a967eabbc41..fde96aa70e385669cd504005d7784878f9e55d84 100644 (file)
@@ -1171,8 +1171,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%" BFD_VMA_FMT "x\n",
-                  start_address);
+    sim_io_printf (sd, "sim_create_inferior:  PC=0x%" PRIx64 "\n",
+                  (uint64_t) start_address);
 #endif
   {
     SIM_CPU *cpu = STATE_CPU (sd, 0);
index b4f2b420e345db652ae6a0159e99a807a7d376b9..4d1942065b803e42ce4173560e0e536b61dd140e 100644 (file)
@@ -1060,8 +1060,8 @@ bfd_load (const char *fname)
            section_size = bfd_section_size (section);
 
            if (sis_verbose)
-               printf("\nsection %s at 0x%08" BFD_VMA_FMT "x (0x%lx bytes)",
-                      section_name, section_address, section_size);
+               printf("\nsection %s at 0x%08" PRIx64 " (0x%lx bytes)",
+                      section_name, (uint64_t) section_address, section_size);
 
            /* Text, data or lit */
            if (bfd_section_flags (section) & SEC_LOAD) {
index ce0bddc82d1ceaf51709071a915fefa7d39fa615..9a432d0bf4b1b61be08e28f6d393cbab53e621ae 100644 (file)
@@ -99,8 +99,8 @@ m32c_load (bfd * prog)
 
          base = bfd_section_lma (s);
          if (verbose)
-           fprintf (stderr, "[load a=%08" BFD_VMA_FMT "x s=%08x %s]\n",
-                    base, (int) size, bfd_section_name (s));
+           fprintf (stderr, "[load a=%08" PRIx64 " s=%08x %s]\n",
+                    (uint64_t) 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);
index 2bf5469a62a88a5de1cc470ffbefbd47fae82e77..5c99f2278a1998d9a0f6091cd0ff66e4528d8c3b 100644 (file)
@@ -130,15 +130,15 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
       base = p->p_paddr;
       if (verbose > 1)
        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);
+                "[load segment: lma=%08" PRIx64 " vma=%08" PRIx64 " "
+                "size=%08" PRIx64 "]\n",
+                (uint64_t) base, (uint64_t) p->p_vaddr, (uint64_t) size);
       if (callbacks)
        xprintf (callbacks,
-                "Loading section %s, size %#" BFD_VMA_FMT "x "
-                "lma %08" BFD_VMA_FMT "x vma %08lx\n",
+                "Loading section %s, size %#" PRIx64 " "
+                "lma %08" PRIx64 " vma %08" PRIx64 "\n",
                 find_section_name_by_offset (prog, p->p_offset),
-                size, base, p->p_vaddr);
+                (uint64_t) size, (uint64_t) base, (uint64_t) p->p_vaddr);
 
       buf = xmalloc (size);
 
@@ -151,17 +151,17 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
 
       if (bfd_bread (buf, size, prog) != size)
        {
-         fprintf (stderr, "%s: Failed to read %" BFD_VMA_FMT "x bytes\n",
-                  simname, size);
+         fprintf (stderr, "%s: Failed to read %" PRIx64 " bytes\n",
+                  simname, (uint64_t) size);
          continue;
        }
 
       if (base > 0xeffff || base + size > 0xeffff)
        {
          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);
+                  "%s, Can't load image to RAM/SFR space: 0x%" PRIx64 " "
+                  "- 0x%" PRIx64 "\n",
+                  simname, (uint64_t) base, (uint64_t) (base + size));
          continue;
        }
       if (max_rom < base + size)
index 500babc0d7dd80e3feca97b29bdf6f8f3a433fb2..a0dca3d5b252de05b65afa29a24f37df4352979d 100644 (file)
@@ -130,14 +130,15 @@ rx_load (bfd *prog, host_callback *callback)
       base = p->p_paddr;
       if (verbose > 1)
        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);
+                "[load segment: lma=%08" PRIx64 " vma=%08" PRIx64 " "
+                "size=%08" PRIx64 "]\n",
+                (uint64_t) base, (uint64_t) p->p_vaddr, (uint64_t) size);
       if (callback)
        xprintf (callback,
-                "Loading section %s, size %#lx lma %08lx vma %08lx\n",
+                "Loading section %s, size %#" PRIx64 " lma %08" PRIx64
+                " vma %08" PRIx64 "\n",
                 find_section_name_by_offset (prog, p->p_offset),
-                size, base, p->p_vaddr);
+                (uint64_t) size, (uint64_t) base, (uint64_t) p->p_vaddr);
 
       buf = malloc (size);
       if (buf == NULL)
@@ -154,7 +155,8 @@ rx_load (bfd *prog, host_callback *callback)
        }
       if (bfd_bread (buf, size, prog) != size)
        {
-         fprintf (stderr, "Failed to read %" BFD_VMA_FMT "x bytes\n", size);
+         fprintf (stderr, "Failed to read %" PRIx64 " bytes\n",
+                  (uint64_t) size);
          continue;
        }