Skip to content

Commit 0e8f7f3

Browse files
ivanivanov884jeffmahoney
authored andcommitted
gdb-rhbz795424-bitpos-25of25.patch
;; Fix `GDB cannot access struct member whose offset is larger than 256MB' ;; (RH BZ 795424). ;;=push http://sourceware.org/ml/gdb-patches/2012-08/msg00562.html --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
1 parent a25d943 commit 0e8f7f3

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

gdb/f-lang.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ struct common_block
4747
struct symbol *contents[1];
4848
};
4949

50-
extern int f77_get_upperbound (struct type *);
50+
extern LONGEST f77_get_upperbound (struct type *);
5151

52-
extern int f77_get_lowerbound (struct type *);
52+
extern LONGEST f77_get_lowerbound (struct type *);
5353

5454
extern void f77_get_dynamic_array_length (struct type *);
5555

gdb/f-typeprint.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
149149
int show, int passed_a_ptr, int demangled_args,
150150
int arrayprint_recurse_level, int print_rank_only)
151151
{
152-
int upper_bound, lower_bound;
152+
LONGEST upper_bound, lower_bound;
153153

154154
/* No static variables are permitted as an error call may occur during
155155
execution of this function. */
@@ -196,7 +196,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
196196
{
197197
lower_bound = f77_get_lowerbound (type);
198198
if (lower_bound != 1) /* Not the default. */
199-
fprintf_filtered (stream, "%d:", lower_bound);
199+
fprintf_filtered (stream, "%s:", plongest (lower_bound));
200200

201201
/* Make sure that, if we have an assumed size array, we
202202
print out a warning and print the upperbound as '*'. */
@@ -206,7 +206,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
206206
else
207207
{
208208
upper_bound = f77_get_upperbound (type);
209-
fprintf_filtered (stream, "%d", upper_bound);
209+
fprintf_filtered (stream, "%s", plongest (upper_bound));
210210
}
211211
}
212212

@@ -278,7 +278,7 @@ void
278278
f_type_print_base (struct type *type, struct ui_file *stream, int show,
279279
int level)
280280
{
281-
int upper_bound;
281+
LONGEST upper_bound;
282282
int index;
283283

284284
QUIT;
@@ -370,7 +370,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
370370
else
371371
{
372372
upper_bound = f77_get_upperbound (type);
373-
fprintf_filtered (stream, "character*%d", upper_bound);
373+
fprintf_filtered (stream, "character*%s", plongest (upper_bound));
374374
}
375375
break;
376376

gdb/f-valprint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ LONGEST f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
4141
/* Array which holds offsets to be applied to get a row's elements
4242
for a given array. Array also holds the size of each subarray. */
4343

44-
int
44+
LONGEST
4545
f77_get_lowerbound (struct type *type)
4646
{
4747
if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
@@ -50,7 +50,7 @@ f77_get_lowerbound (struct type *type)
5050
return TYPE_ARRAY_LOWER_BOUND_VALUE (type);
5151
}
5252

53-
int
53+
LONGEST
5454
f77_get_upperbound (struct type *type)
5555
{
5656
if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))

0 commit comments

Comments
 (0)