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

190f2a
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
190f2a
From: Fedora GDB patches <invalid@email.com>
190f2a
Date: Fri, 27 Oct 2017 21:07:50 +0200
190f2a
Subject: gdb-rhbz795424-bitpos-25of25.patch
190f2a
190f2a
;; Fix `GDB cannot access struct member whose offset is larger than 256MB'
190f2a
;; (RH BZ 795424).
190f2a
;;=push
190f2a
190f2a
http://sourceware.org/ml/gdb-patches/2012-08/msg00562.html
190f2a
190f2a
--MP_/90J7bck2fqDySEX9JkZtaqL
190f2a
Content-Type: text/plain; charset=US-ASCII
190f2a
Content-Transfer-Encoding: 7bit
190f2a
Content-Disposition: inline
190f2a
190f2a
Hi,
190f2a
190f2a
Range bounds for a gdb type can have LONGEST values for low and high
190f2a
bounds. Fortran range bounds functions however use only int. The larger
190f2a
ranges don't compile by default on gcc, but it is possible to override
190f2a
the check in the compiler by using -fno-range-check. As a result, this
190f2a
check is necessary so that we don't print junk in case of an overflow.
190f2a
190f2a
Attached patch does this expansion and also includes a test case that
190f2a
verifies that the problem is fixed. I have also verified on x86_64 that
190f2a
this patch does not cause any regressions.
190f2a
190f2a
Regards,
190f2a
Siddhesh
190f2a
190f2a
gdb/ChangeLog:
190f2a
190f2a
	* f-lang.h (f77_get_upperbound): Return LONGEST.
190f2a
	(f77_get_lowerbound): Likewise.
190f2a
	* f-typeprint.c (f_type_print_varspec_suffix): Expand
190f2a
	UPPER_BOUND and LOWER_BOUND to LONGEST.  Use plongest to format
190f2a
	print them.
190f2a
	(f_type_print_base): Expand UPPER_BOUND to LONGEST.  Use
190f2a
	plongest to format print it.
190f2a
	* f-valprint.c (f77_get_lowerbound): Return LONGEST.
190f2a
	(f77_get_upperbound): Likewise.
190f2a
	(f77_get_dynamic_length_of_aggregate): Expand UPPER_BOUND,
190f2a
	LOWER_BOUND to LONGEST.
190f2a
	(f77_create_arrayprint_offset_tbl): Likewise.
190f2a
190f2a
testsuite/ChangeLog:
190f2a
190f2a
	* gdb.fortran/array-bounds.exp: New test case.
190f2a
	* gdb.fortran/array-bounds.f: New test case.
190f2a
190f2a
--MP_/90J7bck2fqDySEX9JkZtaqL
190f2a
Content-Type: text/x-patch
190f2a
Content-Transfer-Encoding: 7bit
190f2a
Content-Disposition: attachment; filename=f77-bounds.patch
190f2a
190f2a
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
190f2a
--- a/gdb/f-lang.h
190f2a
+++ b/gdb/f-lang.h
190f2a
@@ -47,9 +47,9 @@ struct common_block
190f2a
   struct symbol *contents[1];
190f2a
 };
190f2a
 
190f2a
-extern int f77_get_upperbound (struct type *);
190f2a
+extern LONGEST f77_get_upperbound (struct type *);
190f2a
 
190f2a
-extern int f77_get_lowerbound (struct type *);
190f2a
+extern LONGEST f77_get_lowerbound (struct type *);
190f2a
 
190f2a
 extern void f77_get_dynamic_array_length (struct type *);
190f2a
 
190f2a
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
190f2a
--- a/gdb/f-typeprint.c
190f2a
+++ b/gdb/f-typeprint.c
190f2a
@@ -149,7 +149,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
190f2a
 			     int show, int passed_a_ptr, int demangled_args,
190f2a
 			     int arrayprint_recurse_level, int print_rank_only)
190f2a
 {
190f2a
-  int upper_bound, lower_bound;
190f2a
+  LONGEST upper_bound, lower_bound;
190f2a
 
190f2a
   /* No static variables are permitted as an error call may occur during
190f2a
      execution of this function.  */
190f2a
@@ -196,7 +196,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
190f2a
 	{
190f2a
 	  lower_bound = f77_get_lowerbound (type);
190f2a
 	  if (lower_bound != 1)	/* Not the default.  */
190f2a
-	    fprintf_filtered (stream, "%d:", lower_bound);
190f2a
+	    fprintf_filtered (stream, "%s:", plongest (lower_bound));
190f2a
 
190f2a
 	  /* Make sure that, if we have an assumed size array, we
190f2a
 	       print out a warning and print the upperbound as '*'.  */
190f2a
@@ -206,7 +206,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
190f2a
 	  else
190f2a
 	    {
190f2a
 	      upper_bound = f77_get_upperbound (type);
190f2a
-	      fprintf_filtered (stream, "%d", upper_bound);
190f2a
+	      fprintf_filtered (stream, "%s", plongest (upper_bound));
190f2a
 	    }
190f2a
 	}
190f2a
 
190f2a
@@ -278,7 +278,7 @@ void
190f2a
 f_type_print_base (struct type *type, struct ui_file *stream, int show,
190f2a
 		   int level)
190f2a
 {
190f2a
-  int upper_bound;
190f2a
+  LONGEST upper_bound;
190f2a
   int index;
190f2a
 
190f2a
   QUIT;
190f2a
@@ -370,7 +370,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
190f2a
       else
190f2a
 	{
190f2a
 	  upper_bound = f77_get_upperbound (type);
190f2a
-	  fprintf_filtered (stream, "character*%d", upper_bound);
190f2a
+	  fprintf_filtered (stream, "character*%s", plongest (upper_bound));
190f2a
 	}
190f2a
       break;
190f2a
 
190f2a
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
190f2a
--- a/gdb/f-valprint.c
190f2a
+++ b/gdb/f-valprint.c
190f2a
@@ -41,7 +41,7 @@ LONGEST f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
190f2a
 /* Array which holds offsets to be applied to get a row's elements
190f2a
    for a given array.  Array also holds the size of each subarray.  */
190f2a
 
190f2a
-int
190f2a
+LONGEST
190f2a
 f77_get_lowerbound (struct type *type)
190f2a
 {
190f2a
   if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
190f2a
@@ -50,7 +50,7 @@ f77_get_lowerbound (struct type *type)
190f2a
   return TYPE_ARRAY_LOWER_BOUND_VALUE (type);
190f2a
 }
190f2a
 
190f2a
-int
190f2a
+LONGEST
190f2a
 f77_get_upperbound (struct type *type)
190f2a
 {
190f2a
   if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))