You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
5.2 KiB

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