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

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