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

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