362037e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
362037e
From: Kevin Buettner <kevinb@redhat.com>
362037e
Date: Tue, 25 May 2021 17:34:57 -0700
362037e
Subject: gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
362037e
362037e
;; [fortran] Backport Simon Marchi's commit which fixes a 32-bit build
362037e
;; problem in gdb/f-lang.c.
362037e
362037e
gdb: fix format string warnings in f-lang.c
362037e
362037e
I get a bunch of these warnings when compiling for i386 (32-bit):
362037e
362037e
      CXX    f-lang.o
362037e
    /home/simark/src/binutils-gdb/gdb/f-lang.c: In function 'value* fortran_value_subarray(value*, expression*, int*, int, noside)':
362037e
    /home/simark/src/binutils-gdb/gdb/f-lang.c:453:48: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'LONGEST' {aka 'long long int'} [-Werror=format=]
362037e
      453 |        debug_printf ("|   |   |-> Low bound: %ld\n", lb);
362037e
          |                                              ~~^     ~~
362037e
          |                                                |     |
362037e
          |                                                |     LONGEST {aka long long int}
362037e
          |                                                long int
362037e
          |                                              %lld
362037e
362037e
Fix them by using plongest/pulongest.
362037e
362037e
gdb/ChangeLog:
362037e
362037e
	* f-lang.c (fortran_value_subarray): Use plongest/pulongest.
362037e
362037e
Change-Id: I666ead5593653d5a1a3dab2ffdc72942c928c7d2
362037e
362037e
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
362037e
--- a/gdb/f-lang.c
362037e
+++ b/gdb/f-lang.c
362037e
@@ -463,21 +463,21 @@ fortran_value_subarray (struct value *array, struct expression *exp,
362037e
 	      std::string str = type_to_string (dim_type);
362037e
 	      debug_printf ("|   |-> Type: %s\n", str.c_str ());
362037e
 	      debug_printf ("|   |-> Array:\n");
362037e
-	      debug_printf ("|   |   |-> Low bound: %ld\n", lb);
362037e
-	      debug_printf ("|   |   |-> High bound: %ld\n", ub);
362037e
-	      debug_printf ("|   |   |-> Bit stride: %ld\n", sd);
362037e
-	      debug_printf ("|   |   |-> Byte stride: %ld\n", sd / 8);
362037e
-	      debug_printf ("|   |   |-> Type size: %ld\n",
362037e
-			    TYPE_LENGTH (dim_type));
362037e
-	      debug_printf ("|   |   '-> Target type size: %ld\n",
362037e
-			    TYPE_LENGTH (target_type));
362037e
+	      debug_printf ("|   |   |-> Low bound: %s\n", plongest (lb));
362037e
+	      debug_printf ("|   |   |-> High bound: %s\n", plongest (ub));
362037e
+	      debug_printf ("|   |   |-> Bit stride: %s\n", plongest (sd));
362037e
+	      debug_printf ("|   |   |-> Byte stride: %s\n", plongest (sd / 8));
362037e
+	      debug_printf ("|   |   |-> Type size: %s\n",
362037e
+			    pulongest (TYPE_LENGTH (dim_type)));
362037e
+	      debug_printf ("|   |   '-> Target type size: %s\n",
362037e
+			    pulongest (TYPE_LENGTH (target_type)));
362037e
 	      debug_printf ("|   |-> Accessing:\n");
362037e
-	      debug_printf ("|   |   |-> Low bound: %ld\n",
362037e
-			    low);
362037e
-	      debug_printf ("|   |   |-> High bound: %ld\n",
362037e
-			    high);
362037e
-	      debug_printf ("|   |   '-> Element stride: %ld\n",
362037e
-			    stride);
362037e
+	      debug_printf ("|   |   |-> Low bound: %s\n",
362037e
+			    plongest (low));
362037e
+	      debug_printf ("|   |   |-> High bound: %s\n",
362037e
+			    plongest (high));
362037e
+	      debug_printf ("|   |   '-> Element stride: %s\n",
362037e
+			    plongest (stride));
362037e
 	    }
362037e
 
362037e
 	  /* Check the user hasn't asked for something invalid.  */
362037e
@@ -519,13 +519,17 @@ fortran_value_subarray (struct value *array, struct expression *exp,
362037e
 	  if (fortran_array_slicing_debug)
362037e
 	    {
362037e
 	      debug_printf ("|   '-> Results:\n");
362037e
-	      debug_printf ("|       |-> Offset = %ld\n", offset);
362037e
-	      debug_printf ("|       |-> Elements = %ld\n", e_count);
362037e
-	      debug_printf ("|       |-> Low bound = %ld\n", new_low);
362037e
-	      debug_printf ("|       |-> High bound = %ld\n", new_high);
362037e
-	      debug_printf ("|       |-> Byte stride = %ld\n", new_stride);
362037e
-	      debug_printf ("|       |-> Last element = %ld\n", last_elem);
362037e
-	      debug_printf ("|       |-> Remainder = %ld\n", remainder);
362037e
+	      debug_printf ("|       |-> Offset = %s\n", plongest (offset));
362037e
+	      debug_printf ("|       |-> Elements = %s\n", plongest (e_count));
362037e
+	      debug_printf ("|       |-> Low bound = %s\n", plongest (new_low));
362037e
+	      debug_printf ("|       |-> High bound = %s\n",
362037e
+			    plongest (new_high));
362037e
+	      debug_printf ("|       |-> Byte stride = %s\n",
362037e
+			    plongest (new_stride));
362037e
+	      debug_printf ("|       |-> Last element = %s\n",
362037e
+			    plongest (last_elem));
362037e
+	      debug_printf ("|       |-> Remainder = %s\n",
362037e
+			    plongest (remainder));
362037e
 	      debug_printf ("|       '-> Contiguous = %s\n",
362037e
 			    (is_dim_contiguous ? "Yes" : "No"));
362037e
 	    }
362037e
@@ -561,14 +565,16 @@ fortran_value_subarray (struct value *array, struct expression *exp,
362037e
 	      std::string str = type_to_string (dim_type);
362037e
 	      debug_printf ("|   |-> Type: %s\n", str.c_str ());
362037e
 	      debug_printf ("|   |-> Array:\n");
362037e
-	      debug_printf ("|   |   |-> Low bound: %ld\n", lb);
362037e
-	      debug_printf ("|   |   |-> High bound: %ld\n", ub);
362037e
-	      debug_printf ("|   |   |-> Byte stride: %ld\n", sd);
362037e
-	      debug_printf ("|   |   |-> Type size: %ld\n", TYPE_LENGTH (dim_type));
362037e
-	      debug_printf ("|   |   '-> Target type size: %ld\n",
362037e
-			    TYPE_LENGTH (target_type));
362037e
+	      debug_printf ("|   |   |-> Low bound: %s\n", plongest (lb));
362037e
+	      debug_printf ("|   |   |-> High bound: %s\n", plongest (ub));
362037e
+	      debug_printf ("|   |   |-> Byte stride: %s\n", plongest (sd));
362037e
+	      debug_printf ("|   |   |-> Type size: %s\n",
362037e
+			    pulongest (TYPE_LENGTH (dim_type)));
362037e
+	      debug_printf ("|   |   '-> Target type size: %s\n",
362037e
+			    pulongest (TYPE_LENGTH (target_type)));
362037e
 	      debug_printf ("|   '-> Accessing:\n");
362037e
-	      debug_printf ("|       '-> Index: %ld\n", index);
362037e
+	      debug_printf ("|       '-> Index: %s\n",
362037e
+			    plongest (index));
362037e
 	    }
362037e
 
362037e
 	  /* If the array has actual content then check the index is in
362037e
@@ -625,7 +631,8 @@ fortran_value_subarray (struct value *array, struct expression *exp,
362037e
       debug_printf ("'-> Final result:\n");
362037e
       debug_printf ("    |-> Type: %s\n",
362037e
 		    type_to_string (array_slice_type).c_str ());
362037e
-      debug_printf ("    |-> Total offset: %ld\n", total_offset);
362037e
+      debug_printf ("    |-> Total offset: %s\n",
362037e
+		    plongest (total_offset));
362037e
       debug_printf ("    |-> Base address: %s\n",
362037e
 		    core_addr_to_string (value_address (array)));
362037e
       debug_printf ("    '-> Contiguous = %s\n",