Blame SOURCES/gdb-rhbz795424-bitpos-25of25.patch

7a6771
http://sourceware.org/ml/gdb-patches/2012-08/msg00562.html
7a6771
Subject: [PATCH] Expand fortran array bounds sizes to LONGEST
7a6771
7a6771
7a6771
--MP_/90J7bck2fqDySEX9JkZtaqL
7a6771
Content-Type: text/plain; charset=US-ASCII
7a6771
Content-Transfer-Encoding: 7bit
7a6771
Content-Disposition: inline
7a6771
7a6771
Hi,
7a6771
7a6771
Range bounds for a gdb type can have LONGEST values for low and high
7a6771
bounds. Fortran range bounds functions however use only int. The larger
7a6771
ranges don't compile by default on gcc, but it is possible to override
7a6771
the check in the compiler by using -fno-range-check. As a result, this
7a6771
check is necessary so that we don't print junk in case of an overflow.
7a6771
7a6771
Attached patch does this expansion and also includes a test case that
7a6771
verifies that the problem is fixed. I have also verified on x86_64 that
7a6771
this patch does not cause any regressions.
7a6771
7a6771
Regards,
7a6771
Siddhesh
7a6771
7a6771
gdb/ChangeLog:
7a6771
7a6771
	* f-lang.h (f77_get_upperbound): Return LONGEST.
7a6771
	(f77_get_lowerbound): Likewise.
7a6771
	* f-typeprint.c (f_type_print_varspec_suffix): Expand
7a6771
	UPPER_BOUND and LOWER_BOUND to LONGEST.  Use plongest to format
7a6771
	print them.
7a6771
	(f_type_print_base): Expand UPPER_BOUND to LONGEST.  Use
7a6771
	plongest to format print it.
7a6771
	* f-valprint.c (f77_get_lowerbound): Return LONGEST.
7a6771
	(f77_get_upperbound): Likewise.
7a6771
	(f77_get_dynamic_length_of_aggregate): Expand UPPER_BOUND,
7a6771
	LOWER_BOUND to LONGEST.
7a6771
	(f77_create_arrayprint_offset_tbl): Likewise.
7a6771
7a6771
testsuite/ChangeLog:
7a6771
7a6771
	* gdb.fortran/array-bounds.exp: New test case.
7a6771
	* gdb.fortran/array-bounds.f: New test case.
7a6771
7a6771
--MP_/90J7bck2fqDySEX9JkZtaqL
7a6771
Content-Type: text/x-patch
7a6771
Content-Transfer-Encoding: 7bit
7a6771
Content-Disposition: attachment; filename=f77-bounds.patch
7a6771
7a6771
Index: gdb-7.11.90.20160907/gdb/f-lang.h
7a6771
===================================================================
7a6771
--- gdb-7.11.90.20160907.orig/gdb/f-lang.h	2016-09-07 21:48:33.308624019 +0200
7a6771
+++ gdb-7.11.90.20160907/gdb/f-lang.h	2016-09-07 21:48:40.967692469 +0200
7a6771
@@ -49,9 +49,9 @@
7a6771
   struct symbol *contents[1];
7a6771
 };
7a6771
 
7a6771
-extern int f77_get_upperbound (struct type *);
7a6771
+extern LONGEST f77_get_upperbound (struct type *);
7a6771
 
7a6771
-extern int f77_get_lowerbound (struct type *);
7a6771
+extern LONGEST f77_get_lowerbound (struct type *);
7a6771
 
7a6771
 extern void f77_get_dynamic_array_length (struct type *);
7a6771
 
7a6771
Index: gdb-7.11.90.20160907/gdb/f-typeprint.c
7a6771
===================================================================
7a6771
--- gdb-7.11.90.20160907.orig/gdb/f-typeprint.c	2016-09-07 21:48:33.309624028 +0200
7a6771
+++ gdb-7.11.90.20160907/gdb/f-typeprint.c	2016-09-07 21:48:40.967692469 +0200
7a6771
@@ -147,7 +147,7 @@
7a6771
 			     int show, int passed_a_ptr, int demangled_args,
7a6771
 			     int arrayprint_recurse_level, int print_rank_only)
7a6771
 {
7a6771
-  int upper_bound, lower_bound;
7a6771
+  LONGEST upper_bound, lower_bound;
7a6771
 
7a6771
   /* No static variables are permitted as an error call may occur during
7a6771
      execution of this function.  */
7a6771
@@ -194,7 +194,7 @@
7a6771
 	{
7a6771
 	  lower_bound = f77_get_lowerbound (type);
7a6771
 	  if (lower_bound != 1)	/* Not the default.  */
7a6771
-	    fprintf_filtered (stream, "%d:", lower_bound);
7a6771
+	    fprintf_filtered (stream, "%s:", plongest (lower_bound));
7a6771
 
7a6771
 	  /* Make sure that, if we have an assumed size array, we
7a6771
 	       print out a warning and print the upperbound as '*'.  */
7a6771
@@ -204,7 +204,7 @@
7a6771
 	  else
7a6771
 	    {
7a6771
 	      upper_bound = f77_get_upperbound (type);
7a6771
-	      fprintf_filtered (stream, "%d", upper_bound);
7a6771
+	      fprintf_filtered (stream, "%s", plongest (upper_bound));
7a6771
 	    }
7a6771
 	}
7a6771
 
7a6771
@@ -276,7 +276,7 @@
7a6771
 f_type_print_base (struct type *type, struct ui_file *stream, int show,
7a6771
 		   int level)
7a6771
 {
7a6771
-  int upper_bound;
7a6771
+  LONGEST upper_bound;
7a6771
   int index;
7a6771
 
7a6771
   QUIT;
7a6771
@@ -358,7 +358,7 @@
7a6771
       else
7a6771
 	{
7a6771
 	  upper_bound = f77_get_upperbound (type);
7a6771
-	  fprintf_filtered (stream, "character*%d", upper_bound);
7a6771
+	  fprintf_filtered (stream, "character*%s", plongest (upper_bound));
7a6771
 	}
7a6771
       break;
7a6771
 
7a6771
Index: gdb-7.11.90.20160907/gdb/f-valprint.c
7a6771
===================================================================
7a6771
--- gdb-7.11.90.20160907.orig/gdb/f-valprint.c	2016-09-07 21:48:33.309624028 +0200
7a6771
+++ gdb-7.11.90.20160907/gdb/f-valprint.c	2016-09-07 21:48:40.967692469 +0200
7a6771
@@ -43,7 +43,7 @@
7a6771
 /* Array which holds offsets to be applied to get a row's elements
7a6771
    for a given array.  Array also holds the size of each subarray.  */
7a6771
 
7a6771
-int
7a6771
+LONGEST
7a6771
 f77_get_lowerbound (struct type *type)
7a6771
 {
7a6771
   if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
7a6771
@@ -52,7 +52,7 @@
7a6771
   return TYPE_ARRAY_LOWER_BOUND_VALUE (type);
7a6771
 }
7a6771
 
7a6771
-int
7a6771
+LONGEST
7a6771
 f77_get_upperbound (struct type *type)
7a6771
 {
7a6771
   if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))