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