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

861f93
http://sourceware.org/ml/gdb-patches/2012-08/msg00562.html
861f93
Subject: [PATCH] Expand fortran array bounds sizes to LONGEST
861f93
861f93
861f93
--MP_/90J7bck2fqDySEX9JkZtaqL
861f93
Content-Type: text/plain; charset=US-ASCII
861f93
Content-Transfer-Encoding: 7bit
861f93
Content-Disposition: inline
861f93
861f93
Hi,
861f93
861f93
Range bounds for a gdb type can have LONGEST values for low and high
861f93
bounds. Fortran range bounds functions however use only int. The larger
861f93
ranges don't compile by default on gcc, but it is possible to override
861f93
the check in the compiler by using -fno-range-check. As a result, this
861f93
check is necessary so that we don't print junk in case of an overflow.
861f93
861f93
Attached patch does this expansion and also includes a test case that
861f93
verifies that the problem is fixed. I have also verified on x86_64 that
861f93
this patch does not cause any regressions.
861f93
861f93
Regards,
861f93
Siddhesh
861f93
861f93
gdb/ChangeLog:
861f93
861f93
	* f-lang.h (f77_get_upperbound): Return LONGEST.
861f93
	(f77_get_lowerbound): Likewise.
861f93
	* f-typeprint.c (f_type_print_varspec_suffix): Expand
861f93
	UPPER_BOUND and LOWER_BOUND to LONGEST.  Use plongest to format
861f93
	print them.
861f93
	(f_type_print_base): Expand UPPER_BOUND to LONGEST.  Use
861f93
	plongest to format print it.
861f93
	* f-valprint.c (f77_get_lowerbound): Return LONGEST.
861f93
	(f77_get_upperbound): Likewise.
861f93
	(f77_get_dynamic_length_of_aggregate): Expand UPPER_BOUND,
861f93
	LOWER_BOUND to LONGEST.
861f93
	(f77_create_arrayprint_offset_tbl): Likewise.
861f93
861f93
testsuite/ChangeLog:
861f93
861f93
	* gdb.fortran/array-bounds.exp: New test case.
861f93
	* gdb.fortran/array-bounds.f: New test case.
861f93
861f93
--MP_/90J7bck2fqDySEX9JkZtaqL
861f93
Content-Type: text/x-patch
861f93
Content-Transfer-Encoding: 7bit
861f93
Content-Disposition: attachment; filename=f77-bounds.patch
861f93
861f93
Index: gdb-7.5.50.20130118/gdb/f-lang.h
861f93
===================================================================
861f93
--- gdb-7.5.50.20130118.orig/gdb/f-lang.h	2013-01-18 23:39:40.209500968 +0100
861f93
+++ gdb-7.5.50.20130118/gdb/f-lang.h	2013-01-18 23:40:04.010531177 +0100
861f93
@@ -65,9 +65,9 @@ struct common_block
861f93
   struct symbol *contents[1];
861f93
 };
861f93
 
861f93
-extern int f77_get_upperbound (struct type *);
861f93
+extern LONGEST f77_get_upperbound (struct type *);
861f93
 
861f93
-extern int f77_get_lowerbound (struct type *);
861f93
+extern LONGEST f77_get_lowerbound (struct type *);
861f93
 
861f93
 extern void f77_get_dynamic_array_length (struct type *);
861f93
 
861f93
Index: gdb-7.5.50.20130118/gdb/f-typeprint.c
861f93
===================================================================
861f93
--- gdb-7.5.50.20130118.orig/gdb/f-typeprint.c	2013-01-18 23:39:37.564497620 +0100
861f93
+++ gdb-7.5.50.20130118/gdb/f-typeprint.c	2013-01-18 23:39:40.210500970 +0100
861f93
@@ -180,7 +180,7 @@ f_type_print_varspec_suffix (struct type
861f93
 			     int show, int passed_a_ptr, int demangled_args,
861f93
 			     int arrayprint_recurse_level)
861f93
 {
861f93
-  int upper_bound, lower_bound;
861f93
+  LONGEST upper_bound, lower_bound;
861f93
 
861f93
   /* No static variables are permitted as an error call may occur during
861f93
      execution of this function.  */
861f93
@@ -210,7 +210,7 @@ f_type_print_varspec_suffix (struct type
861f93
 
861f93
       lower_bound = f77_get_lowerbound (type);
861f93
       if (lower_bound != 1)	/* Not the default.  */
861f93
-	fprintf_filtered (stream, "%d:", lower_bound);
861f93
+	fprintf_filtered (stream, "%s:", plongest (lower_bound));
861f93
 
861f93
       /* Make sure that, if we have an assumed size array, we
861f93
          print out a warning and print the upperbound as '*'.  */
861f93
@@ -220,7 +220,7 @@ f_type_print_varspec_suffix (struct type
861f93
       else
861f93
 	{
861f93
 	  upper_bound = f77_get_upperbound (type);
861f93
-	  fprintf_filtered (stream, "%d", upper_bound);
861f93
+	  fprintf_filtered (stream, "%s", plongest (upper_bound));
861f93
 	}
861f93
 
861f93
       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
861f93
@@ -288,7 +288,7 @@ void
861f93
 f_type_print_base (struct type *type, struct ui_file *stream, int show,
861f93
 		   int level)
861f93
 {
861f93
-  int upper_bound;
861f93
+  LONGEST upper_bound;
861f93
   int index;
861f93
 
861f93
   QUIT;
861f93
@@ -370,7 +370,7 @@ f_type_print_base (struct type *type, st
861f93
       else
861f93
 	{
861f93
 	  upper_bound = f77_get_upperbound (type);
861f93
-	  fprintf_filtered (stream, "character*%d", upper_bound);
861f93
+	  fprintf_filtered (stream, "character*%s", plongest (upper_bound));
861f93
 	}
861f93
       break;
861f93
 
861f93
Index: gdb-7.5.50.20130118/gdb/f-valprint.c
861f93
===================================================================
861f93
--- gdb-7.5.50.20130118.orig/gdb/f-valprint.c	2013-01-18 23:39:37.564497620 +0100
861f93
+++ gdb-7.5.50.20130118/gdb/f-valprint.c	2013-01-18 23:39:40.210500970 +0100
861f93
@@ -57,7 +57,7 @@ LONGEST f77_array_offset_tbl[MAX_FORTRAN
861f93
 
861f93
 #define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
861f93
 
861f93
-int
861f93
+LONGEST
861f93
 f77_get_lowerbound (struct type *type)
861f93
 {
861f93
   f_object_address_data_valid_or_error (type);
861f93
@@ -68,7 +68,7 @@ f77_get_lowerbound (struct type *type)
861f93
   return TYPE_ARRAY_LOWER_BOUND_VALUE (type);
861f93
 }
861f93
 
861f93
-int
861f93
+LONGEST
861f93
 f77_get_upperbound (struct type *type)
861f93
 {
861f93
   f_object_address_data_valid_or_error (type);
861f93
@@ -92,8 +92,8 @@ f77_get_upperbound (struct type *type)
861f93
 static void
861f93
 f77_get_dynamic_length_of_aggregate (struct type *type)
861f93
 {
861f93
-  int upper_bound = -1;
861f93
-  int lower_bound = 1;
861f93
+  LONGEST upper_bound = -1;
861f93
+  LONGEST lower_bound = 1;
861f93
 
861f93
   /* Recursively go all the way down into a possibly multi-dimensional
861f93
      F77 array and get the bounds.  For simple arrays, this is pretty
861f93
@@ -128,7 +128,7 @@ f77_create_arrayprint_offset_tbl (struct
861f93
   struct type *tmp_type;
861f93
   LONGEST eltlen;
861f93
   int ndimen = 1;
861f93
-  int upper, lower;
861f93
+  LONGEST upper, lower;
861f93
 
861f93
   tmp_type = type;
861f93