Blame SOURCES/gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch

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