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

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