Fixed gdb to print arrays with very high indexes
authorAlok Kumar Sharma <AlokKumar.Sharma@amd.com>
Tue, 4 Feb 2020 01:24:34 +0000 (20:24 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 4 Feb 2020 01:24:34 +0000 (20:24 -0500)
commite409c542cc3cedebf78c7827e976d36955d477bb
treea8231b01637b95ed9efb80cb7155e8241f4c86c1
parent6ec6b3c8abd0378ad6e750570c038b05b6e87703
Fixed gdb to print arrays with very high indexes

In the function f77_print_array_1, the variable 'i' which holds the
index is of datatype 'int', while bounds are of datatype LONGEST. Due to
size of int being smaller than LONGEST, the variable 'i' stores
incorrect values for high indexes (higher than max limit of int).  Due
to this issue in sources, two abnormal behaviors are seen while printing
arrays with high indexes (please check array-bounds-high.f90) For high
indexes with negative sign, gdb prints empty array even if the array has
elements.

    (gdb) p arr
    $1 = ()

For high indexes with positive sign, gdb crashes.  We have now changed
the datatype of 'i' to LONGEST which is same as datatype of bounds.

gdb/ChangeLog:

* f-valprint.c (f77_print_array_1): Changed datatype of index
variable to LONGEST from int to enable it to contain bound
values correctly.

gdb/testsuite/ChangeLog:

* gdb.fortran/array-bounds-high.exp: New file.
* gdb.fortran/array-bounds-high.f90: New file.

Change-Id: Ie2dce9380a249e634e2684b9c90f225e104369b7
gdb/ChangeLog
gdb/f-valprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/array-bounds-high.exp [new file with mode: 0644]
gdb/testsuite/gdb.fortran/array-bounds-high.f90 [new file with mode: 0644]