Don't use BFD_VMA_FMT in gdb and sim

Alan Modra amodra@gmail.com
Fri Aug 5 11:21:40 GMT 2022


On Thu, Aug 04, 2022 at 11:59:25AM -0600, Tom Tromey wrote:
> >>>>> "Alan" == Alan Modra via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Alan> Like commit b82817674f, this replaces BFD_VMA_FMT "x" with PRIx64,
> Alan> and casts to promote bfd_vma to uint64_t.
> 
> Alan> Tested with both 64-bit and 32-bit gdb builds, and 64-bit make check.
> Alan> OK to install?
> 
> Alan> diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
> Alan> index 2516e4ed058..c2823191b42 100644
> Alan> --- a/gdb/windows-tdep.c
> Alan> +++ b/gdb/windows-tdep.c
> Alan> @@ -1011,10 +1011,10 @@ is_linked_with_cygwin_dll (bfd *abfd)
> Alan>        || import_table_va >= idata_section_end_va)
> Alan>      {
> Alan>        warning (_("\
> Alan> -%s: import table's virtual address (0x%" BFD_VMA_FMT "x) is outside .idata \
> Alan> -section's range [0x%" BFD_VMA_FMT "x, 0x%" BFD_VMA_FMT "x[."),
> Alan> -	       bfd_get_filename (abfd), import_table_va, idata_section_va,
> Alan> -	       idata_section_end_va);
> Alan> +%s: import table's virtual address (0x%" PRIx64 ") is outside .idata \
> Alan> +section's range [0x%" PRIx64 ", 0x%" PRIx64 "[."),
> Alan> +	       bfd_get_filename (abfd), (uint64_t) import_table_va,
> Alan> +	       (uint64_t) idata_section_va, (uint64_t) idata_section_end_va);
> 
> For gdb, it's more normal to use %s and 'hex_string (value)'.
> hex_string will add the 0x as well.  It's fine to call it multiple times
> in a single printf.

OK, here's a revision of the gdb/windows-tdep.c changes.  With range
bracket fixed too.  sim/ remains as before.

diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index a34ac5e5f0a..702af65d450 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -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;
 	}
 

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Gdb-patches mailing list